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
This commit is contained in:
Sergey Biryukov 2015-10-10 06:43:24 +00:00
parent c6bffb6264
commit 24219160f1
2 changed files with 19 additions and 8 deletions

View File

@ -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 '<div class="star-rating" title="' . esc_attr( $title ) . '">';
echo '<span class="screen-reader-text">' . $title . '</span>';
echo str_repeat( '<div class="star star-full"></div>', $full_stars );
echo str_repeat( '<div class="star star-half"></div>', $half_stars );
echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);
echo '</div>';
$output = '<div class="star-rating" title="' . esc_attr( $title ) . '">';
$output .= '<span class="screen-reader-text">' . $title . '</span>';
$output .= str_repeat( '<div class="star star-full"></div>', $full_stars );
$output .= str_repeat( '<div class="star star-half"></div>', $half_stars );
$output .= str_repeat( '<div class="star star-empty"></div>', $empty_stars );
$output .= '</div>';
if ( $r['echo'] ) {
echo $output;
}
return $output;
}
/**

View File

@ -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.