WordPress.org

Make WordPress Core

Changeset 35005


Ignore:
Timestamp:
10/10/2015 06:42:19 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Add echo parameter for wp_star_rating().

See #34080.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/template-functions.php

    r34952 r35005  
    19851985 *
    19861986 * @since 3.8.0
     1987 * @since 4.4.0 Introduced the `echo` parameter.
     1988 *
    19871989 * @param array $args {
    19881990 *     Optional. Array of star ratings arguments.
     
    19931995 *                          or, 'percent'. Default 'rating'.
    19941996 *     @type int    $number The number of ratings that makes up this rating. Default 0.
     1997 *     @type bool   $echo   Whether to echo the generated markup. False to return the markup instead
     1998 *                          of echoing it. Default true.
    19951999 * }
    19962000 */
     
    19982002    $defaults = array(
    19992003        'rating' => 0,
    2000         'type' => 'rating',
     2004        'type'   => 'rating',
    20012005        'number' => 0,
     2006        'echo'   => true,
    20022007    );
    20032008    $r = wp_parse_args( $args, $defaults );
     
    20252030    }
    20262031
    2027     echo '<div class="star-rating" title="' . esc_attr( $title ) . '">';
    2028     echo '<span class="screen-reader-text">' . $title . '</span>';
    2029     echo str_repeat( '<div class="star star-full"></div>', $full_stars );
    2030     echo str_repeat( '<div class="star star-half"></div>', $half_stars );
    2031     echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);
    2032     echo '</div>';
     2032    $output = '<div class="star-rating" title="' . esc_attr( $title ) . '">';
     2033    $output .= '<span class="screen-reader-text">' . $title . '</span>';
     2034    $output .= str_repeat( '<div class="star star-full"></div>', $full_stars );
     2035    $output .= str_repeat( '<div class="star star-half"></div>', $half_stars );
     2036    $output .= str_repeat( '<div class="star star-empty"></div>', $empty_stars );
     2037    $output .= '</div>';
     2038
     2039    if ( $r['echo'] ) {
     2040        echo $output;
     2041    }
     2042
     2043    return $output;
    20332044}
    20342045
Note: See TracChangeset for help on using the changeset viewer.