<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[26380] trunk/src/wp-admin: Replace the Star ratings in the dashboard with dashicons ratings.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/26380">26380</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2013-11-26 02:24:25 +0000 (Tue, 26 Nov 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 <a href="http://core.trac.wordpress.org/ticket/26170">#26170</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsscolorschemes_adminscss">trunk/src/wp-admin/css/color-schemes/_admin.scss</a></li>
<li><a href="#trunksrcwpadmincsswpadmincss">trunk/src/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunksrcwpadminincludesclasswpplugininstalllisttablephp">trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpthemeinstalllisttablephp">trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesplugininstallphp">trunk/src/wp-admin/includes/plugin-install.php</a></li>
<li><a href="#trunksrcwpadminincludestemplatephp">trunk/src/wp-admin/includes/template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsscolorschemes_adminscss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/css/color-schemes/_admin.scss (26379 => 26380)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/css/color-schemes/_admin.scss 2013-11-26 02:04:15 UTC (rev 26379)
+++ trunk/src/wp-admin/css/color-schemes/_admin.scss    2013-11-26 02:24:25 UTC (rev 26380)
</span><span class="lines">@@ -392,3 +392,7 @@
</span><span class="cx">  border-color: transparent;
</span><span class="cx">  background: $menu-highlight-background;
</span><span class="cx"> }
</span><ins>+
+.star-rating .star {
+       color: $highlight-color;
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/css/wp-admin.css (26379 => 26380)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/css/wp-admin.css      2013-11-26 02:04:15 UTC (rev 26379)
+++ trunk/src/wp-admin/css/wp-admin.css 2013-11-26 02:24:25 UTC (rev 26380)
</span><span class="lines">@@ -7714,8 +7714,8 @@
</span><span class="cx">  float: left;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.theme-details .star-holder {
-       margin: 14px 0;
</del><ins>+.theme-details .star-rating {
+       margin: 7px 0;
</ins><span class="cx">   float: right;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -9341,7 +9341,7 @@
</span><span class="cx">  display: block;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-/* Star ratings */
</del><ins>+/* Star Ratings - Back-compat for pre-3.8 */
</ins><span class="cx"> div.star-holder {
</span><span class="cx">  position: relative;
</span><span class="cx">  height: 17px;
</span><span class="lines">@@ -9355,6 +9355,40 @@
</span><span class="cx">  float: left;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* 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';
+}
+
</ins><span class="cx"> div.action-links {
</span><span class="cx">  font-weight: normal;
</span><span class="cx">  margin: 6px 0 0;
</span><span class="lines">@@ -10725,11 +10759,13 @@
</span><span class="cx">          background-size: 11px 11px;
</span><span class="cx">  }
</span><span class="cx"> 
</span><ins>+       /* Back-compat for pre-3.8 */
</ins><span class="cx">   div.star-holder {
</span><span class="cx">          background: url('../images/stars-2x.png?ver=20121108') repeat-x bottom left;
</span><span class="cx">          background-size: 21px 37px;
</span><span class="cx">  }
</span><span class="cx"> 
</span><ins>+       /* Back-compat for pre-3.8 */
</ins><span class="cx">   div.star-holder .star-rating {
</span><span class="cx">          background: url('../images/stars-2x.png?ver=20121108') repeat-x top left;
</span><span class="cx">          background-size: 21px 37px;
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpplugininstalllisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php (26379 => 26380)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php       2013-11-26 02:04:15 UTC (rev 26379)
+++ trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php  2013-11-26 02:24:25 UTC (rev 26380)
</span><span class="lines">@@ -270,9 +270,7 @@
</span><span class="cx">                  </td>
</span><span class="cx">                  <td class="vers column-version"<?php echo $style['version']; ?>><?php echo $version; ?></td>
</span><span class="cx">                  <td class="vers column-rating"<?php echo $style['rating']; ?>>
</span><del>-                               <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>
</del><ins>+                                <?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?>
</ins><span class="cx">                   </td>
</span><span class="cx">                  <td class="desc column-description"<?php echo $style['description']; ?>><?php echo $description, $author; ?></td>
</span><span class="cx">          </tr>
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpthemeinstalllisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php (26379 => 26380)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php        2013-11-26 02:04:15 UTC (rev 26379)
+++ trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php   2013-11-26 02:24:25 UTC (rev 26380)
</span><span class="lines">@@ -341,9 +341,7 @@
</span><span class="cx">                          <img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" />
</span><span class="cx">                  <?php endif; ?>
</span><span class="cx">                  <div class="theme-details">
</span><del>-                               <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>
</del><ins>+                                <?php wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings ) ); ?>
</ins><span class="cx">                           <div class="theme-version">
</span><span class="cx">                                  <strong><?php _e('Version:') ?> </strong>
</span><span class="cx">                                  <?php echo wp_kses( $theme->version, $themes_allowedtags ); ?>
</span></span></pre></div>
<a id="trunksrcwpadminincludesplugininstallphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/plugin-install.php (26379 => 26380)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/plugin-install.php   2013-11-26 02:04:15 UTC (rev 26379)
+++ trunk/src/wp-admin/includes/plugin-install.php      2013-11-26 02:24:25 UTC (rev 26380)
</span><span class="lines">@@ -413,9 +413,7 @@
</span><span class="cx">          </ul>
</span><span class="cx">          <?php if ( ! empty($api->rating) ) : ?>
</span><span class="cx">          <h2><?php _e('Average Rating') ?></h2>
</span><del>-               <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>
</del><ins>+                <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
</ins><span class="cx">           <small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small>
</span><span class="cx">          <?php endif; ?>
</span><span class="cx">  </div>
</span></span></pre></div>
<a id="trunksrcwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/template.php (26379 => 26380)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/template.php 2013-11-26 02:04:15 UTC (rev 26379)
+++ trunk/src/wp-admin/includes/template.php    2013-11-26 02:24:25 UTC (rev 26380)
</span><span class="lines">@@ -1966,3 +1966,55 @@
</span><span class="cx">  </div>
</span><span class="cx">  <?php
</span><span class="cx"> }
</span><ins>+
+/**
+ * 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>';
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>