From 24219160f12aec0452df9970597043a70c4a047c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 10 Oct 2015 06:43:24 +0000 Subject: [PATCH] Add `echo` parameter for `wp_star_rating()`. See #34080. Built from https://develop.svn.wordpress.org/trunk@35005 git-svn-id: http://core.svn.wordpress.org/trunk@34970 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template-functions.php | 25 +++++++++++++++++------- wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/wp-admin/includes/template-functions.php b/wp-admin/includes/template-functions.php index 81e8534c6c..0918bfd86c 100644 --- a/wp-admin/includes/template-functions.php +++ b/wp-admin/includes/template-functions.php @@ -1984,6 +1984,8 @@ function _local_storage_notice() { * number of ratings may also be displayed by passing the $number parameter. * * @since 3.8.0 + * @since 4.4.0 Introduced the `echo` parameter. + * * @param array $args { * Optional. Array of star ratings arguments. * @@ -1992,13 +1994,16 @@ function _local_storage_notice() { * @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. * } */ function wp_star_rating( $args = array() ) { $defaults = array( 'rating' => 0, - 'type' => 'rating', + 'type' => 'rating', 'number' => 0, + 'echo' => true, ); $r = wp_parse_args( $args, $defaults ); @@ -2024,12 +2029,18 @@ function wp_star_rating( $args = array() ) { $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) ); } - echo '
'; - echo '' . $title . ''; - echo str_repeat( '
', $full_stars ); - echo str_repeat( '
', $half_stars ); - echo str_repeat( '
', $empty_stars); - echo '
'; + $output = '
'; + $output .= '' . $title . ''; + $output .= str_repeat( '
', $full_stars ); + $output .= str_repeat( '
', $half_stars ); + $output .= str_repeat( '
', $empty_stars ); + $output .= '
'; + + if ( $r['echo'] ) { + echo $output; + } + + return $output; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 4085cc80fa..ab0d7c9429 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-35004'; +$wp_version = '4.4-alpha-35005'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.