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 #27440. fixes #19784, #22599, #26202.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28828 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2014-07-09 17:28:17 +00:00
parent 5a43586db1
commit 2dfccee78f
7 changed files with 379 additions and 9 deletions

View File

@ -1811,7 +1811,8 @@ div.action-links {
}
#plugin-information-title {
padding: 0 20px 0 76px;
margin-left: 56px; /* avoid collisions with the close icon */
padding: 0 20px;
font-size: 22px;
font-weight: 600;
line-height: 56px;
@ -1824,6 +1825,79 @@ div.action-links {
white-space: nowrap;
}
#plugin-information-title.with-banner {
margin-left: 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;
right: 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%;
}
}
#plugin-information-tabs {
padding: 0 16px;
position: absolute;
@ -1834,6 +1908,17 @@ div.action-links {
z-index: 1;
}
#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;
}
}
#plugin-information-tabs a {
position: relative;
float: right;
@ -1871,6 +1956,16 @@ div.action-links {
right: 0;
}
#plugin-information-content.with-banner {
top:249px;
}
@media only screen and (max-width: 800px) {
#plugin-information-content.with-banner {
top:99px;
}
}
#section-holder {
margin: 0;
padding: 10px 26px;
@ -1887,6 +1982,7 @@ div.action-links {
}
#plugin-information .fyi {
display: block;
background: #f3f3f3;
border-right: 1px solid #ddd;
color: #666;
@ -1927,6 +2023,49 @@ div.action-links {
margin: 0 0 10px;
}
#plugin-information .counter-label {
float: right;
margin-left: 5px;
}
#plugin-information .counter-back {
height: 17px;
width: 92px;
background-color: #ececec;
float: right;
}
#plugin-information .counter-bar {
height: 17px;
background-color: #fddb5a;
float: right;
}
#plugin-information .counter-count {
margin-right: 5px;
}
#plugin-information .fyi ul.contributors {
margin-top: 10px;
}
#plugin-information .fyi ul.contributors li {
display: inline-block;
margin-left: 8px;
vertical-align: middle;
}
#plugin-information .fyi ul.contributors li {
display: inline-block;
margin-left: 8px;
vertical-align: middle;
}
#plugin-information .fyi ul.contributors li img {
vertical-align: middle;
margin-left: 4px;
}
#plugin-information-footer {
padding: 15px 16px;
position: absolute;
@ -2053,11 +2192,22 @@ body.import-php .tb-close-icon,
body.plugins-php .tb-close-icon,
body.update-core-php .tb-close-icon,
body.index-php .tb-close-icon {
background: rgba( 255, 255, 255, .5);
color: #444;
line-height: 48px;
width: 48px;
height: 48px;
}
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;
}
body.plugin-install-php .tb-close-icon:before,
body.import-php .tb-close-icon:before,
body.plugins-php .tb-close-icon:before,

View File

@ -1811,7 +1811,8 @@ div.action-links {
}
#plugin-information-title {
padding: 0 76px 0 20px;
margin-right: 56px; /* avoid collisions with the close icon */
padding: 0 20px;
font-size: 22px;
font-weight: 600;
line-height: 56px;
@ -1824,6 +1825,79 @@ div.action-links {
white-space: nowrap;
}
#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%;
}
}
#plugin-information-tabs {
padding: 0 16px;
position: absolute;
@ -1834,6 +1908,17 @@ div.action-links {
z-index: 1;
}
#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;
}
}
#plugin-information-tabs a {
position: relative;
float: left;
@ -1871,6 +1956,16 @@ div.action-links {
left: 0;
}
#plugin-information-content.with-banner {
top:249px;
}
@media only screen and (max-width: 800px) {
#plugin-information-content.with-banner {
top:99px;
}
}
#section-holder {
margin: 0;
padding: 10px 26px;
@ -1887,6 +1982,7 @@ div.action-links {
}
#plugin-information .fyi {
display: block;
background: #f3f3f3;
border-left: 1px solid #ddd;
color: #666;
@ -1927,6 +2023,49 @@ div.action-links {
margin: 0 0 10px;
}
#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;
}
#plugin-information-footer {
padding: 15px 16px;
position: absolute;
@ -2053,11 +2192,22 @@ body.import-php .tb-close-icon,
body.plugins-php .tb-close-icon,
body.update-core-php .tb-close-icon,
body.index-php .tb-close-icon {
background: rgba( 255, 255, 255, .5);
color: #444;
line-height: 48px;
width: 48px;
height: 48px;
}
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;
}
body.plugin-install-php .tb-close-icon:before,
body.import-php .tb-close-icon:before,
body.plugins-php .tb-close-icon:before,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -311,7 +311,7 @@ function install_plugin_install_status($api, $loop = false) {
function install_plugin_information() {
global $tab;
$api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl() ) );
$api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl(), 'fields' => array( 'banners' => true, 'reviews' => true ) ) );
if ( is_wp_error( $api ) )
wp_die( $api );
@ -331,6 +331,7 @@ function install_plugin_information() {
'faq' => _x('FAQ', 'Plugin installer section title'),
'screenshots' => _x('Screenshots', 'Plugin installer section title'),
'changelog' => _x('Changelog', 'Plugin installer section title'),
'reviews' => _x('Reviews', 'Plugin installer section title'),
'other_notes' => _x('Other Notes', 'Plugin installer section title')
);
@ -354,10 +355,32 @@ function install_plugin_information() {
iframe_header( __('Plugin Install') );
echo "<div id='{$_tab}-title'>{$api->name}</div>";
echo "<div id='{$_tab}-tabs'>\n";
$_with_banner = '';
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";
foreach ( (array)$api->sections as $section_name => $content ) {
if ( 'reviews' == $section_name && ( empty( $api->ratings ) || 0 == array_sum( (array) $api->ratings ) ) )
continue;
if ( isset( $plugins_section_titles[ $section_name ] ) )
$title = $plugins_section_titles[ $section_name ];
@ -374,7 +397,7 @@ function install_plugin_information() {
echo "</div>\n";
?>
<div id="<?php echo $_tab; ?>-content">
<div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
<div class="fyi">
<ul>
<?php if ( ! empty( $api->version ) ) : ?>
@ -394,6 +417,8 @@ function install_plugin_information() {
<li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page &#187;') ?></a></li>
<?php endif; if ( ! empty( $api->homepage ) ) : ?>
<li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;') ?></a></li>
<?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>
<?php endif; ?>
</ul>
<?php if ( ! empty( $api->rating ) ) : ?>
@ -401,6 +426,46 @@ function install_plugin_information() {
<?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; ?>
<?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; ?>
</div>
<div id="section-holder" class="wrap">
<?php

View File

@ -53,6 +53,11 @@ jQuery( document ).ready( function( $ ) {
//Flip the tab
$( '#plugin-information-tabs a.current' ).removeClass( 'current' );
$( this ).addClass( 'current' );
//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();
//Flip the content.
$( '#section-holder div.section' ).hide(); //Hide 'em all
$( '#section-' + tab ).show();

View File

@ -1 +1 @@
var tb_position;jQuery(document).ready(function(a){tb_position=function(){var b=a("#TB_window"),c=a(window).width(),d=a(window).height()-(c>850?60:20),e=c>850?830:c-20;return b.size()&&(b.width(e).height(d),a("#TB_iframeContent").width(e).height(d),b.css({"margin-left":"-"+parseInt(e/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&b.css({top:(c>850?30:10)+"px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+e+"&height="+d))})},a(window).resize(function(){tb_position()}),a(".plugins").on("click","a.thickbox",function(){return tb_click.call(this),a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"}),a("#TB_ajaxWindowTitle").html("<strong>"+plugininstallL10n.plugin_information+"</strong>&nbsp;"+a(this).attr("title")),!1}),a("#plugin-information-tabs a").click(function(b){var c=a(this).attr("name");b.preventDefault(),a("#plugin-information-tabs a.current").removeClass("current"),a(this).addClass("current"),a("#section-holder div.section").hide(),a("#section-"+c).show()}),a("a.install-now").click(function(){return confirm(plugininstallL10n.ays)})});
var tb_position;jQuery(document).ready(function(a){tb_position=function(){var b=a("#TB_window"),c=a(window).width(),d=a(window).height()-(c>850?60:20),e=c>850?830:c-20;return b.size()&&(b.width(e).height(d),a("#TB_iframeContent").width(e).height(d),b.css({"margin-left":"-"+parseInt(e/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&b.css({top:(c>850?30:10)+"px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+e+"&height="+d))})},a(window).resize(function(){tb_position()}),a(".plugins").on("click","a.thickbox",function(){return tb_click.call(this),a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"}),a("#TB_ajaxWindowTitle").html("<strong>"+plugininstallL10n.plugin_information+"</strong>&nbsp;"+a(this).attr("title")),!1}),a("#plugin-information-tabs a").click(function(b){var c=a(this).attr("name");b.preventDefault(),a("#plugin-information-tabs a.current").removeClass("current"),a(this).addClass("current"),"description"!=a(this).attr("name")&&a("body").width()<830?a("#plugin-information-content div.fyi").hide():a("#plugin-information-content div.fyi").show(),a("#section-holder div.section").hide(),a("#section-"+c).show()}),a("a.install-now").click(function(){return confirm(plugininstallL10n.ays)})});