From 6a74b306daec263a295407be51355c37755d3243 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 29 Jul 2017 20:35:45 +0000 Subject: [PATCH] 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 --- wp-admin/includes/template.php | 21 +++++++++++---------- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 32cdc0214e..8385c90670 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -2094,14 +2094,15 @@ function _local_storage_notice() { * @param array $args { * Optional. Array of star ratings arguments. * - * @type int $rating The rating to display, expressed in either a 0.5 rating increment, - * or percentage. Default 0. - * @type string $type Format that the $rating is in. Valid values are 'rating' (default), - * or, 'percent'. Default 'rating'. - * @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 - * of echoing it. Default true. + * @type int|float $rating The rating to display, expressed in either a 0.5 rating increment, + * or percentage. Default 0. + * @type string $type Format that the $rating is in. Valid values are 'rating' (default), + * or, 'percent'. Default 'rating'. + * @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 + * of echoing it. Default true. * } + * @return string Star rating HTML. */ function wp_star_rating( $args = array() ) { $defaults = array( @@ -2112,11 +2113,11 @@ function wp_star_rating( $args = array() ) { ); $r = wp_parse_args( $args, $defaults ); - // Non-english decimal places when the $rating is coming from a string - $rating = str_replace( ',', '.', $r['rating'] ); + // Non-English decimal places when the $rating is coming from a string + $rating = (float) str_replace( ',', '.', $r['rating'] ); // Convert Percentage to star rating, 0..5 in .5 increments - if ( 'percent' == $r['type'] ) { + if ( 'percent' === $r['type'] ) { $rating = round( $rating / 10, 0 ) / 2; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 25c2ba4104..a25d5523c4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.