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

Built from https://develop.svn.wordpress.org/trunk@26380


git-svn-id: http://core.svn.wordpress.org/trunk@26280 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2013-11-26 02:25:21 +00:00
parent 43ef093ce1
commit 89dfee993d
15 changed files with 151 additions and 20 deletions

View File

@ -392,3 +392,7 @@ div#moby6-toggle a:before {
border-color: transparent;
background: $menu-highlight-background;
}
.star-rating .star {
color: $highlight-color;
}

View File

@ -258,3 +258,6 @@ div#moby6-toggle a:before {
.moby6-open div#moby6-toggle a {
border-color: transparent;
background: #096484; }
.star-rating .star {
color: #096484; }

File diff suppressed because one or more lines are too long

View File

@ -259,6 +259,9 @@ div#moby6-toggle a:before {
border-color: transparent;
background: #888888; }
.star-rating .star {
color: #04a4cc; }
/* temporary fix for admin-bar hover color */
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar > #wp-toolbar > #wp-admin-bar-root-default li:hover span.ab-label, #wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary li.hover span.ab-label, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #333333; }

File diff suppressed because one or more lines are too long

View File

@ -258,3 +258,6 @@ div#moby6-toggle a:before {
.moby6-open div#moby6-toggle a {
border-color: transparent;
background: #e14d43; }
.star-rating .star {
color: #e14d43; }

File diff suppressed because one or more lines are too long

View File

@ -7714,8 +7714,8 @@ body.full-overlay-active {
float: right;
}
.theme-details .star-holder {
margin: 14px 0;
.theme-details .star-rating {
margin: 7px 0;
float: left;
}
@ -9341,7 +9341,7 @@ body.menu-max-depth-11 { min-width: 1280px !important; }
display: block;
}
/* Star ratings */
/* Star Ratings - Back-compat for pre-3.8 */
div.star-holder {
position: relative;
height: 17px;
@ -9355,6 +9355,40 @@ div.star-holder .star-rating {
float: right;
}
/* Star Ratings */
.star-rating {
white-space: nowrap;
}
.star-rating .star {
display: inline-block;
width: 25px;
height: 25px;
-webkit-font-smoothing: antialiased;
font-size: 25px;
line-height: 1;
font-family: 'dashicons';
text-decoration: inherit;
font-weight: normal;
font-style: normal;
vertical-align: top;
-moz-transition: color .1s ease-in 0;
-webkit-transition: color .1s ease-in 0;
text-align: center;
color: #0074a2;
}
.star-rating .star-full:before {
content:'\f155';
}
.star-rating .star-half:before {
content:'\f459';
}
.star-rating .star-empty:before {
content:'\f154';
}
div.action-links {
font-weight: normal;
margin: 6px 0 0;
@ -10725,11 +10759,13 @@ li#wp-admin-bar-toggle-button {
background-size: 11px 11px;
}
/* Back-compat for pre-3.8 */
div.star-holder {
background: url('../images/stars-2x.png?ver=20121108') repeat-x bottom right;
background-size: 21px 37px;
}
/* Back-compat for pre-3.8 */
div.star-holder .star-rating {
background: url('../images/stars-2x.png?ver=20121108') repeat-x top right;
background-size: 21px 37px;

File diff suppressed because one or more lines are too long

View File

@ -7714,8 +7714,8 @@ body.full-overlay-active {
float: left;
}
.theme-details .star-holder {
margin: 14px 0;
.theme-details .star-rating {
margin: 7px 0;
float: right;
}
@ -9341,7 +9341,7 @@ body.menu-max-depth-11 { min-width: 1280px !important; }
display: block;
}
/* Star ratings */
/* Star Ratings - Back-compat for pre-3.8 */
div.star-holder {
position: relative;
height: 17px;
@ -9355,6 +9355,40 @@ div.star-holder .star-rating {
float: left;
}
/* Star Ratings */
.star-rating {
white-space: nowrap;
}
.star-rating .star {
display: inline-block;
width: 25px;
height: 25px;
-webkit-font-smoothing: antialiased;
font-size: 25px;
line-height: 1;
font-family: 'dashicons';
text-decoration: inherit;
font-weight: normal;
font-style: normal;
vertical-align: top;
-moz-transition: color .1s ease-in 0;
-webkit-transition: color .1s ease-in 0;
text-align: center;
color: #0074a2;
}
.star-rating .star-full:before {
content:'\f155';
}
.star-rating .star-half:before {
content:'\f459';
}
.star-rating .star-empty:before {
content:'\f154';
}
div.action-links {
font-weight: normal;
margin: 6px 0 0;
@ -10725,11 +10759,13 @@ li#wp-admin-bar-toggle-button {
background-size: 11px 11px;
}
/* Back-compat for pre-3.8 */
div.star-holder {
background: url('../images/stars-2x.png?ver=20121108') repeat-x bottom left;
background-size: 21px 37px;
}
/* Back-compat for pre-3.8 */
div.star-holder .star-rating {
background: url('../images/stars-2x.png?ver=20121108') repeat-x top left;
background-size: 21px 37px;

File diff suppressed because one or more lines are too long

View File

@ -270,9 +270,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
</td>
<td class="vers column-version"<?php echo $style['version']; ?>><?php echo $version; ?></td>
<td class="vers column-rating"<?php echo $style['rating']; ?>>
<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'] ) ) ?>">
<div class="star star-rating" style="width: <?php echo esc_attr( str_replace( ',', '.', $plugin['rating'] ) ); ?>px"></div>
</div>
<?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?>
</td>
<td class="desc column-description"<?php echo $style['description']; ?>><?php echo $description, $author; ?></td>
</tr>

View File

@ -341,9 +341,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
<img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" />
<?php endif; ?>
<div class="theme-details">
<div class="star-holder" title="<?php echo esc_attr( $num_ratings ); ?>">
<div class="star-rating" style="width:<?php echo esc_attr( intval( $theme->rating ) . 'px' ); ?>;"></div>
</div>
<?php wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings ) ); ?>
<div class="theme-version">
<strong><?php _e('Version:') ?> </strong>
<?php echo wp_kses( $theme->version, $themes_allowedtags ); ?>

View File

@ -413,9 +413,7 @@ function install_plugin_information() {
</ul>
<?php if ( ! empty($api->rating) ) : ?>
<h2><?php _e('Average Rating') ?></h2>
<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)); ?>">
<div class="star star-rating" style="width: <?php echo esc_attr( str_replace( ',', '.', $api->rating ) ); ?>px"></div>
</div>
<?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
<small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small>
<?php endif; ?>
</div>

View File

@ -1966,3 +1966,55 @@ function _local_storage_notice() {
</div>
<?php
}
/**
* Output a HTML element with a star rating for a given rating.
*
* Outputs a HTML element with the star rating exposed on a 0..5 scale in
* half star increments (ie. 1, 1.5, 2 stars). Optionally, if specified, the
* number of ratings may also be displayed by passing the $number parameter.
*
* @since 3.8.0
* @param array $args {
* @type int $rating The Rating to display, Expressed in a 0.5 rating increment, or a percentage.
* @type string $type The format that the $rating is in. Valid values are 'rating' (default), or, 'percent'.
* @type int $number The number of ratings which makes up this rating.
* }
*/
function wp_star_rating( $args = array() ) {
$defaults = array(
'rating' => 0,
'type' => 'rating',
'number' => 0,
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
// Non-english decimal places when the $rating is coming from a string
$rating = str_replace( ',', '.', $rating );
// Convert Percentage to star rating, 0..5 in .5 increments
if ( 'percent' == $type ) {
$rating = round( $rating / 10, 0 ) / 2;
}
// Calculate the number of each type of star needed
$full_stars = floor( $rating );
$half_stars = ceil( $rating - $full_stars );
$empty_stars = 5 - $full_stars - $half_stars;
if ( $number ) {
/* translators: 1: The rating, 2: The number of ratings */
$title = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $number );
$title = sprintf( $title, number_format_i18n( $rating, 1 ), number_format_i18n( $number ) );
} else {
/* translators: 1: The rating */
$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
}
echo '<div class="star-rating" title="' . esc_attr( $title ) . '">';
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>';
}