<!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>[29040] trunk/src/wp-admin: Improvements to the plugin information modal:</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/29040">29040</a></dd>
<dt>Author</dt> <dd>helen</dd>
<dt>Date</dt> <dd>2014-07-09 17:27:22 +0000 (Wed, 09 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Improvements to the plugin information modal:

* Show the banner image when available.
* Show contributors and ratings breakdown in the FYI box.
* Show reviews in a tab.

props stephdau, tellyworth, paulwilde, michalzuber. see <a href="http://core.trac.wordpress.org/ticket/27440">#27440</a>. fixes <a href="http://core.trac.wordpress.org/ticket/19784">#19784</a>, <a href="http://core.trac.wordpress.org/ticket/22599">#22599</a>, <a href="http://core.trac.wordpress.org/ticket/26202">#26202</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsscommoncss">trunk/src/wp-admin/css/common.css</a></li>
<li><a href="#trunksrcwpadminincludesplugininstallphp">trunk/src/wp-admin/includes/plugin-install.php</a></li>
<li><a href="#trunksrcwpadminjsplugininstalljs">trunk/src/wp-admin/js/plugin-install.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsscommoncss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/css/common.css (29039 => 29040)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/css/common.css        2014-07-09 16:03:17 UTC (rev 29039)
+++ trunk/src/wp-admin/css/common.css   2014-07-09 17:27:22 UTC (rev 29040)
</span><span class="lines">@@ -1811,7 +1811,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #plugin-information-title {
</span><del>-       padding: 0 76px 0 20px;
</del><ins>+        margin-right: 56px; /* avoid collisions with the close icon */
+       padding: 0 20px;
</ins><span class="cx">   font-size: 22px;
</span><span class="cx">  font-weight: 600;
</span><span class="cx">  line-height: 56px;
</span><span class="lines">@@ -1824,6 +1825,79 @@
</span><span class="cx">  white-space: nowrap;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#plugin-information-title.with-banner {
+       margin-right: 0;
+       height: 250px;
+       bottom: 250px;
+       background-size: 100% auto;
+}
+
+@media only screen and (max-width: 800px) {
+       #plugin-information-title.with-banner {
+               height: 100px;
+               bottom: 100px;
+       }
+}
+
+#plugin-information-title h2 {
+       font-family: "Helvetica Neue", sans-serif;
+       padding:0;
+       margin: 0;
+       max-width: 760px;
+}
+
+#plugin-information-title.with-banner h2 {
+       font-size: 30px;
+       line-height: 50px;
+       font-weight: bold;
+       max-width: 760px;
+       position: absolute;
+       left: 20px;
+       top: 145px;
+       padding: 0 15px;
+       margin: 0;
+       color: #fff;
+       background: rgba( 30, 30, 30, 0.9 );
+       text-shadow: 0 1px 3px rgba( 0, 0, 0, 0.4 );
+       -webkit-box-shadow: 0 0 30px rgba( 255, 255, 255, 0.1 );
+       -moz-box-shadow: 0 0 30px rgba( 255, 255, 255, 0.1 );
+       box-shadow: 0 0 30px rgba( 255, 255, 255, 0.1 );
+       -webkit-border-radius: 8px;
+       border-radius: 8px;
+}
+
+@media only screen and (max-width: 800px) {
+       #plugin-information-title.with-banner h2 {
+               top: 12px;
+               font-size: 20px;
+               line-height: 40px;
+       }
+}
+
+#plugin-information-title div.vignette {
+       display: none;
+}
+
+#plugin-information-title.with-banner div.vignette {
+       display: block;
+       top: 0;
+       height: 215px;
+       width: 830px;
+       margin: 0 -20px;
+       background: transparent;
+       -webkit-box-shadow: inset 0 0 50px 4px rgba( 0, 0, 0, 0.2 ), inset 0 -1px 0 rgba( 0, 0, 0, 0.1 );
+       -moz-box-shadow: inset 0 0 50px 4px rgba( 0, 0, 0, 0.2 ), inset 0 -1px 0 rgba( 0, 0, 0, 0.1 );
+       box-shadow: inset 0 0 50px 4px rgba( 0, 0, 0, 0.2 ), inset 0 -1px 0 rgba( 0, 0, 0, 0.1 );
+}
+
+@media only screen and (max-width: 800px) {
+       #plugin-information-title.with-banner div.vignette {
+               height: 65px;
+               bottom: 65px;
+               width: 800%;
+       }
+}
+
</ins><span class="cx"> #plugin-information-tabs {
</span><span class="cx">  padding: 0 16px;
</span><span class="cx">  position: absolute;
</span><span class="lines">@@ -1834,6 +1908,17 @@
</span><span class="cx">  z-index: 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#plugin-information-tabs.with-banner {
+       top: 215px;
+       background: rgba( 255, 255, 255, 0.85 );
+}
+
+@media only screen and (max-width: 800px) {
+       #plugin-information-tabs.with-banner {
+               top: 65px;
+       }
+}
+
</ins><span class="cx"> #plugin-information-tabs a {
</span><span class="cx">  position: relative;
</span><span class="cx">  float: left;
</span><span class="lines">@@ -1871,6 +1956,16 @@
</span><span class="cx">  left: 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#plugin-information-content.with-banner {
+       top:249px;
+}
+
+@media only screen and (max-width: 800px) {
+       #plugin-information-content.with-banner {
+               top:99px;
+       }
+}
+
</ins><span class="cx"> #section-holder {
</span><span class="cx">  margin: 0;
</span><span class="cx">  padding: 10px 26px;
</span><span class="lines">@@ -1887,6 +1982,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #plugin-information .fyi {
</span><ins>+       display: block;
</ins><span class="cx">   background: #f3f3f3;
</span><span class="cx">  border-left: 1px solid #ddd;
</span><span class="cx">  color: #666;
</span><span class="lines">@@ -1927,6 +2023,49 @@
</span><span class="cx">  margin: 0 0 10px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#plugin-information .counter-label {
+       float: left;
+       margin-right: 5px;
+}
+
+#plugin-information .counter-back {
+       height: 17px;
+       width: 92px;
+       background-color: #ececec;
+       float: left;
+}
+
+#plugin-information .counter-bar {
+       height: 17px;
+       background-color: #fddb5a;
+       float: left;
+}
+
+#plugin-information .counter-count {
+       margin-left: 5px;
+}
+
+#plugin-information .fyi ul.contributors {
+       margin-top: 10px;
+}
+
+#plugin-information .fyi ul.contributors li {
+       display: inline-block;
+       margin-right: 8px;
+       vertical-align: middle;
+}
+
+#plugin-information .fyi ul.contributors li {
+       display: inline-block;
+       margin-right: 8px;
+       vertical-align: middle;
+}
+
+#plugin-information .fyi ul.contributors li img {
+       vertical-align: middle;
+       margin-right: 4px;
+}
+
</ins><span class="cx"> #plugin-information-footer {
</span><span class="cx">  padding: 15px 16px;
</span><span class="cx">  position: absolute;
</span><span class="lines">@@ -2053,11 +2192,22 @@
</span><span class="cx"> body.plugins-php .tb-close-icon,
</span><span class="cx"> body.update-core-php .tb-close-icon,
</span><span class="cx"> body.index-php .tb-close-icon {
</span><ins>+       background: rgba( 255, 255, 255, .5);
+       color: #444;
</ins><span class="cx">   line-height: 48px;
</span><span class="cx">  width: 48px;
</span><span class="cx">  height: 48px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+body.plugin-install-php .tb-close-icon:hover,
+body.import-php .tb-close-icon:hover,
+body.plugins-php .tb-close-icon:hover,
+body.update-core-php .tb-close-icon:hover,
+body.index-php .tb-close-icon:hover {
+       background: #0074a2;
+       color: #fff;
+}
+
</ins><span class="cx"> body.plugin-install-php .tb-close-icon:before,
</span><span class="cx"> body.import-php .tb-close-icon:before,
</span><span class="cx"> body.plugins-php .tb-close-icon:before,
</span></span></pre></div>
<a id="trunksrcwpadminincludesplugininstallphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/plugin-install.php (29039 => 29040)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/plugin-install.php   2014-07-09 16:03:17 UTC (rev 29039)
+++ trunk/src/wp-admin/includes/plugin-install.php      2014-07-09 17:27:22 UTC (rev 29040)
</span><span class="lines">@@ -311,7 +311,7 @@
</span><span class="cx"> function install_plugin_information() {
</span><span class="cx">  global $tab;
</span><span class="cx"> 
</span><del>-       $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl() ) );
</del><ins>+        $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl(), 'fields' => array( 'banners' => true, 'reviews' => true ) ) );
</ins><span class="cx"> 
</span><span class="cx">  if ( is_wp_error( $api ) )
</span><span class="cx">          wp_die( $api );
</span><span class="lines">@@ -331,6 +331,7 @@
</span><span class="cx">          'faq'          => _x('FAQ',          'Plugin installer section title'),
</span><span class="cx">          'screenshots'  => _x('Screenshots',  'Plugin installer section title'),
</span><span class="cx">          'changelog'    => _x('Changelog',    'Plugin installer section title'),
</span><ins>+               'reviews'      => _x('Reviews',      'Plugin installer section title'),
</ins><span class="cx">           'other_notes'  => _x('Other Notes',  'Plugin installer section title')
</span><span class="cx">  );
</span><span class="cx"> 
</span><span class="lines">@@ -354,10 +355,32 @@
</span><span class="cx"> 
</span><span class="cx">  iframe_header( __('Plugin Install') );
</span><span class="cx"> 
</span><del>-       echo "<div id='{$_tab}-title'>{$api->name}</div>";
-       echo "<div id='{$_tab}-tabs'>\n";
</del><ins>+        $_with_banner = '';
</ins><span class="cx"> 
</span><ins>+       if ( !empty( $api->banners ) && ( !empty( $api->banners['low'] ) || !empty( $api->banners['high'] ) ) ) {
+               $_with_banner = 'with-banner';
+               $low  = ( !empty( $api->banners['low'] ) ) ? $api->banners['low'] : $api->banners['high'];
+               $high = ( !empty( $api->banners['high'] ) ) ? $api->banners['high'] : $api->banners['low'];
+               ?>
+               <style type="text/css">
+                       #plugin-information-title.with-banner {
+                               background-image: url(<?php echo $low ?>);
+                       }
+                       @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
+                               #plugin-information-title.with-banner {
+                                       background-image: url(<?php echo $high ?>});
+                               }
+                       }
+               </style>
+               <?php
+       }
+
+       echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>";
+       echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n";
+
</ins><span class="cx">   foreach ( (array)$api->sections as $section_name => $content ) {
</span><ins>+               if ( 'reviews' == $section_name && ( empty( $api->ratings ) || 0 == array_sum( (array) $api->ratings ) ) )
+                       continue;
</ins><span class="cx"> 
</span><span class="cx">          if ( isset( $plugins_section_titles[ $section_name ] ) )
</span><span class="cx">                  $title = $plugins_section_titles[ $section_name ];
</span><span class="lines">@@ -374,7 +397,7 @@
</span><span class="cx">  echo "</div>\n";
</span><span class="cx"> 
</span><span class="cx">  ?>
</span><del>-       <div id="<?php echo $_tab; ?>-content">
</del><ins>+        <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
</ins><span class="cx">   <div class="fyi">
</span><span class="cx">          <ul>
</span><span class="cx"> <?php if ( ! empty( $api->version ) ) : ?>
</span><span class="lines">@@ -394,6 +417,8 @@
</span><span class="cx">                  <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page &#187;') ?></a></li>
</span><span class="cx"> <?php endif; if ( ! empty( $api->homepage ) ) : ?>
</span><span class="cx">                  <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;') ?></a></li>
</span><ins>+<?php endif;if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) : ?>
+                       <li><a target="_blank" href="<?php echo $api->donate_link ?>"><?php _e('Donate to this plugin &#187;') ?></a></li>
</ins><span class="cx"> <?php endif; ?>
</span><span class="cx">          </ul>
</span><span class="cx">          <?php if ( ! empty( $api->rating ) ) : ?>
</span><span class="lines">@@ -401,6 +426,46 @@
</span><span class="cx">          <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
</span><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><ins>+               <?php
+               if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) {
+                       foreach( $api->ratings as $key=>$ratecount ) {
+                               // avoid div-by-zero
+                               $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
+                               ?>
+                               <div class="counter-container">
+                                       <a href="./plugin-install.php?tab=plugin-information&plugin=<?php echo $api->slug; ?>&section=reviews"
+                                          title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>" -->
+                                               <span class="counter-label" style="float:left; margin-right:5px;"><?php echo $key; ?> stars</span>
+                                               <span class="counter-back" style="height:17px;width:92px;background-color:#ececec;float:left;">
+                                                       <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;height:17px;background-color:#fddb5a;float:left;"></span>
+                                               </span>
+                                       </a>
+                                       <span class="counter-count" style="margin-left:5px;"><?php echo $ratecount; ?></span>
+                               </div>
+                       <?php
+                       }
+               }
+               if ( ! empty( $api->contributors ) ) : ?>
+                       <h3><?php _e('Contributors') ?></h3>
+                       <ul class="contributors">
+                               <?php
+                               foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) {
+                                       if ( empty( $contrib_username ) && empty( $contrib_profile ) )
+                                               continue;
+                                       if ( empty( $contrib_username ) )
+                                               $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile );
+                                       $contrib_username = sanitize_user( $contrib_username );
+                                       if ( empty( $contrib_profile ) )
+                                               echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' />{$contrib_username}</li>";
+                                       else
+                                               echo "<li><a href='{$contrib_profile}' target='_blank'><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' />{$contrib_username}</a></li>";
+                               }
+                               ?>
+                       </ul>
+                       <?php if ( ! empty( $api->donate_link ) ) : ?>
+                               <a target="_blank" href="<?php echo $api->donate_link ?>"><?php _e('Donate to this plugin &#187;') ?></a>
+                       <?php endif; ?>
+               <?php endif; ?>
</ins><span class="cx">   </div>
</span><span class="cx">  <div id="section-holder" class="wrap">
</span><span class="cx">  <?php
</span></span></pre></div>
<a id="trunksrcwpadminjsplugininstalljs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/js/plugin-install.js (29039 => 29040)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/js/plugin-install.js  2014-07-09 16:03:17 UTC (rev 29039)
+++ trunk/src/wp-admin/js/plugin-install.js     2014-07-09 17:27:22 UTC (rev 29040)
</span><span class="lines">@@ -53,6 +53,11 @@
</span><span class="cx">          //Flip the tab
</span><span class="cx">          $( '#plugin-information-tabs a.current' ).removeClass( 'current' );
</span><span class="cx">          $( this ).addClass( 'current' );
</span><ins>+               //Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top.
+               if ( 'description' != $( this ).attr( 'name' ) && $( 'body').width() < 830 )
+                       $( '#plugin-information-content div.fyi' ).hide();
+               else
+                       $( '#plugin-information-content div.fyi' ).show();
</ins><span class="cx">           //Flip the content.
</span><span class="cx">          $( '#section-holder div.section' ).hide(); //Hide 'em all
</span><span class="cx">          $( '#section-' + tab ).show();
</span></span></pre>
</div>
</div>

</body>
</html>