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:
@@ -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 »') ?></a></li>
|
||||
<?php endif; if ( ! empty( $api->homepage ) ) : ?>
|
||||
<li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage »') ?></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 »') ?></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; ?>§ion=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 »') ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div id="section-holder" class="wrap">
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user