Make WordPress Core

Changeset 26380


Ignore:
Timestamp:
11/26/2013 02:24:25 AM (11 years ago)
Author:
dd32
Message:

Replace the Star ratings in the dashboard with dashicons ratings.
This also moves the ratings to only displaying full, half, or empty stars (ie. 3.0, 3.5, 4.0, no 3.7 ratings - which are rounded).
Fixes #26170

Location:
trunk/src/wp-admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/color-schemes/_admin.scss

    r26311 r26380  
    393393    background: $menu-highlight-background;
    394394}
     395
     396.star-rating .star {
     397    color: $highlight-color;
     398}
  • trunk/src/wp-admin/css/wp-admin.css

    r26379 r26380  
    77157715}
    77167716
    7717 .theme-details .star-holder {
    7718     margin: 14px 0;
     7717.theme-details .star-rating {
     7718    margin: 7px 0;
    77197719    float: right;
    77207720}
     
    93429342}
    93439343
    9344 /* Star ratings */
     9344/* Star Ratings - Back-compat for pre-3.8 */
    93459345div.star-holder {
    93469346    position: relative;
     
    93549354    height: 17px;
    93559355    float: left;
     9356}
     9357
     9358/* Star Ratings */
     9359.star-rating {
     9360    white-space: nowrap;
     9361}
     9362.star-rating .star {
     9363    display: inline-block;
     9364    width: 25px;
     9365    height: 25px;
     9366    -webkit-font-smoothing: antialiased;
     9367    font-size: 25px;
     9368    line-height: 1;
     9369    font-family: 'dashicons';
     9370    text-decoration: inherit;
     9371    font-weight: normal;
     9372    font-style: normal;
     9373    vertical-align: top;
     9374    -moz-transition: color .1s ease-in 0;
     9375    -webkit-transition: color .1s ease-in 0;
     9376    text-align: center;
     9377    color: #0074a2;
     9378}
     9379
     9380.star-rating .star-full:before {
     9381    content:'\f155';
     9382}
     9383
     9384.star-rating .star-half:before {
     9385    content:'\f459';
     9386}
     9387
     9388.star-rating .star-empty:before {
     9389    content:'\f154';
    93569390}
    93579391
     
    1072610760    }
    1072710761
     10762    /* Back-compat for pre-3.8 */
    1072810763    div.star-holder {
    1072910764        background: url('../images/stars-2x.png?ver=20121108') repeat-x bottom left;
     
    1073110766    }
    1073210767
     10768    /* Back-compat for pre-3.8 */
    1073310769    div.star-holder .star-rating {
    1073410770        background: url('../images/stars-2x.png?ver=20121108') repeat-x top left;
  • trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php

    r25630 r26380  
    271271            <td class="vers column-version"<?php echo $style['version']; ?>><?php echo $version; ?></td>
    272272            <td class="vers column-rating"<?php echo $style['rating']; ?>>
    273                 <div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings'] ), number_format_i18n( $plugin['num_ratings'] ) ) ?>">
    274                     <div class="star star-rating" style="width: <?php echo esc_attr( str_replace( ',', '.', $plugin['rating'] ) ); ?>px"></div>
    275                 </div>
     273                <?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?>
    276274            </td>
    277275            <td class="desc column-description"<?php echo $style['description']; ?>><?php echo $description, $author; ?></td>
  • trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php

    r26317 r26380  
    342342            <?php endif; ?>
    343343            <div class="theme-details">
    344                 <div class="star-holder" title="<?php echo esc_attr( $num_ratings ); ?>">
    345                     <div class="star-rating" style="width:<?php echo esc_attr( intval( $theme->rating ) . 'px' ); ?>;"></div>
    346                 </div>
     344                <?php wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings ) ); ?>
    347345                <div class="theme-version">
    348346                    <strong><?php _e('Version:') ?> </strong>
  • trunk/src/wp-admin/includes/plugin-install.php

    r25956 r26380  
    414414        <?php if ( ! empty($api->rating) ) : ?>
    415415        <h2><?php _e('Average Rating') ?></h2>
    416         <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?>">
    417             <div class="star star-rating" style="width: <?php echo esc_attr( str_replace( ',', '.', $api->rating ) ); ?>px"></div>
    418         </div>
     416        <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
    419417        <small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small>
    420418        <?php endif; ?>
  • trunk/src/wp-admin/includes/template.php

    r26247 r26380  
    19671967    <?php
    19681968}
     1969
     1970/**
     1971 * Output a HTML element with a star rating for a given rating.
     1972 *
     1973 * Outputs a HTML element with the star rating exposed on a 0..5 scale in
     1974 * half star increments (ie. 1, 1.5, 2 stars). Optionally, if specified, the
     1975 * number of ratings may also be displayed by passing the $number parameter.
     1976 *
     1977 * @since 3.8.0
     1978 * @param array $args {
     1979 *     @type int    $rating The Rating to display, Expressed in a 0.5 rating increment, or a percentage.
     1980 *     @type string $type   The format that the $rating is in. Valid values are 'rating' (default), or, 'percent'.
     1981 *     @type int    $number The number of ratings which makes up this rating.
     1982 * }
     1983 */
     1984function wp_star_rating( $args = array() ) {
     1985    $defaults = array(
     1986        'rating' => 0,
     1987        'type' => 'rating',
     1988        'number' => 0,
     1989    );
     1990    $r = wp_parse_args( $args, $defaults );
     1991    extract( $r, EXTR_SKIP );
     1992
     1993    // Non-english decimal places when the $rating is coming from a string
     1994    $rating = str_replace( ',', '.', $rating );
     1995
     1996    // Convert Percentage to star rating, 0..5 in .5 increments
     1997    if ( 'percent' == $type ) {
     1998        $rating = round( $rating / 10, 0 ) / 2;
     1999    }
     2000
     2001    // Calculate the number of each type of star needed
     2002    $full_stars = floor( $rating );
     2003    $half_stars = ceil( $rating - $full_stars );
     2004    $empty_stars = 5 - $full_stars - $half_stars;
     2005
     2006    if ( $number ) {
     2007        /* translators: 1: The rating, 2: The number of ratings */
     2008        $title = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $number );
     2009        $title = sprintf( $title, number_format_i18n( $rating, 1 ), number_format_i18n( $number ) );
     2010    } else {
     2011        /* translators: 1: The rating */
     2012        $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
     2013    }
     2014
     2015    echo '<div class="star-rating" title="' . esc_attr( $title ) . '">';
     2016    echo str_repeat( '<div class="star star-full"></div>', $full_stars );
     2017    echo str_repeat( '<div class="star star-half"></div>', $half_stars );
     2018    echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);
     2019    echo '</div>';
     2020}
Note: See TracChangeset for help on using the changeset viewer.