mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-25 02:27:50 +01:00
Plugins: In wp_star_rating()
, use explicit type casting for $rating
to avoid a "non-numeric value encountered" warning in PHP 7.1.
Clarify in the function DocBlock that `$rating` can be a float. Props afragen. Fixes #41484. Built from https://develop.svn.wordpress.org/trunk@41184 git-svn-id: http://core.svn.wordpress.org/trunk@41024 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
66a3b24b72
commit
6a74b306da
@ -2094,14 +2094,15 @@ function _local_storage_notice() {
|
|||||||
* @param array $args {
|
* @param array $args {
|
||||||
* Optional. Array of star ratings arguments.
|
* Optional. Array of star ratings arguments.
|
||||||
*
|
*
|
||||||
* @type int $rating The rating to display, expressed in either a 0.5 rating increment,
|
* @type int|float $rating The rating to display, expressed in either a 0.5 rating increment,
|
||||||
* or percentage. Default 0.
|
* or percentage. Default 0.
|
||||||
* @type string $type Format that the $rating is in. Valid values are 'rating' (default),
|
* @type string $type Format that the $rating is in. Valid values are 'rating' (default),
|
||||||
* or, 'percent'. Default 'rating'.
|
* or, 'percent'. Default 'rating'.
|
||||||
* @type int $number The number of ratings that makes up this rating. Default 0.
|
* @type int $number The number of ratings that makes up this rating. Default 0.
|
||||||
* @type bool $echo Whether to echo the generated markup. False to return the markup instead
|
* @type bool $echo Whether to echo the generated markup. False to return the markup instead
|
||||||
* of echoing it. Default true.
|
* of echoing it. Default true.
|
||||||
* }
|
* }
|
||||||
|
* @return string Star rating HTML.
|
||||||
*/
|
*/
|
||||||
function wp_star_rating( $args = array() ) {
|
function wp_star_rating( $args = array() ) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
@ -2112,11 +2113,11 @@ function wp_star_rating( $args = array() ) {
|
|||||||
);
|
);
|
||||||
$r = wp_parse_args( $args, $defaults );
|
$r = wp_parse_args( $args, $defaults );
|
||||||
|
|
||||||
// Non-english decimal places when the $rating is coming from a string
|
// Non-English decimal places when the $rating is coming from a string
|
||||||
$rating = str_replace( ',', '.', $r['rating'] );
|
$rating = (float) str_replace( ',', '.', $r['rating'] );
|
||||||
|
|
||||||
// Convert Percentage to star rating, 0..5 in .5 increments
|
// Convert Percentage to star rating, 0..5 in .5 increments
|
||||||
if ( 'percent' == $r['type'] ) {
|
if ( 'percent' === $r['type'] ) {
|
||||||
$rating = round( $rating / 10, 0 ) / 2;
|
$rating = round( $rating / 10, 0 ) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.9-alpha-41183';
|
$wp_version = '4.9-alpha-41184';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user