Make WordPress Core

Ticket #26170: 26170.diff

File 26170.diff, 7.5 KB (added by dd32, 11 years ago)
  • src/wp-admin/css/color-schemes/_admin.scss

     
    392392        border-color: transparent;
    393393        background: $menu-highlight-background;
    394394}
     395
     396.star-rating .star {
     397        color: $highlight-color;
     398}
     399.star-rating .star-half:before {
     400        /* Temporary until half-icon added */
     401        color: lighten( $highlight-color, 25% );
     402}
     403 No newline at end of file
  • src/wp-admin/css/wp-admin.css

     
    77147714        float: left;
    77157715}
    77167716
    7717 .theme-details .star-holder {
    7718         margin: 14px 0;
     7717.theme-details .star-rating {
     7718        margin: 7px 0;
    77197719        float: right;
    77207720}
    77217721
     
    93419341        display: block;
    93429342}
    93439343
    9344 /* Star ratings */
    9345 div.star-holder {
    9346         position: relative;
    9347         height: 17px;
    9348         width: 100px;
    9349         background: url('../images/stars.png?ver=20121108') repeat-x bottom left;
     9344/* Star Ratings */
     9345.star-rating {
     9346        white-space: nowrap;
    93509347}
    9351 
    9352 div.star-holder .star-rating {
    9353         background: url('../images/stars.png?ver=20121108') repeat-x top left;
    9354         height: 17px;
    9355         float: left;
     9348.star-rating .star {
     9349        display: inline-block;
     9350        width: 25px;
     9351        height: 25px;
     9352        -webkit-font-smoothing: antialiased;
     9353        font-size: 25px;
     9354        line-height: 1;
     9355        font-family: 'dashicons';
     9356        text-decoration: inherit;
     9357        font-weight: normal;
     9358        font-style: normal;
     9359        vertical-align: top;
     9360        -moz-transition: color .1s ease-in 0;
     9361        -webkit-transition: color .1s ease-in 0;
     9362        text-align: center;
     9363       
     9364        color: #0074a2;
    93569365}
     9366.star-rating .star-full:before {
     9367        content:'\f155';
     9368}
     9369.star-rating .star-half:before {
     9370        /* TODO: Need a half-star, colour temporary until that happens. */
     9371        color: #5FC5EE;
     9372        content:'\f155';
     9373}
     9374.star-rating .star-empty:before {
     9375        content:'\f154';
     9376}
    93579377
    93589378div.action-links {
    93599379        font-weight: normal;
     
    1072510745                background-size: 11px 11px;
    1072610746        }
    1072710747
    10728         div.star-holder {
    10729                 background: url('../images/stars-2x.png?ver=20121108') repeat-x bottom left;
    10730                 background-size: 21px 37px;
    10731         }
    10732 
    10733         div.star-holder .star-rating {
    10734                 background: url('../images/stars-2x.png?ver=20121108') repeat-x top left;
    10735                 background-size: 21px 37px;
    10736         }
    10737 
    1073810748        .wp-full-overlay .collapse-sidebar-arrow {
    1073910749                background-image: url('../images/arrows-2x.png');
    1074010750                background-size: 15px 123px;
  • src/wp-admin/includes/class-wp-plugin-install-list-table.php

     
    270270                        </td>
    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>
    278276                </tr>
  • src/wp-admin/includes/class-wp-theme-install-list-table.php

     
    341341                                <img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" />
    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>
    349347                                        <?php echo wp_kses( $theme->version, $themes_allowedtags ); ?>
  • src/wp-admin/includes/plugin-install.php

     
    413413                </ul>
    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; ?>
    421419        </div>
  • src/wp-admin/includes/template.php

     
    19661966        </div>
    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 with
     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 arguement.
     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        $full_stars = floor( $rating );
     2002        $half_stars = ceil( $rating - $full_stars );
     2003        $empty_stars = 5 - $full_stars - $half_stars;
     2004
     2005        if ( $number ) {
     2006                /* translators: 1: The rating, 2: The number of ratings */
     2007                $title = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $number );
     2008                $title = sprintf( $title, number_format_i18n( $rating, 1 ), number_format_i18n( $number ) );
     2009        } else {
     2010                $title = number_format_i18n( $rating, 1 );
     2011        }
     2012
     2013        echo '<div class="star-rating" title="' . esc_attr( $title ) . '">';
     2014        echo str_repeat( '<div class="star star-full"></div>', $full_stars );
     2015        echo str_repeat( '<div class="star star-half"></div>', $half_stars );
     2016        echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);
     2017        echo '</div>';
     2018}
     2019 No newline at end of file