Make WordPress Core

Ticket #27440: 27440.1.diff

File 27440.1.diff, 33.7 KB (added by michalzuber, 11 years ago)

Reuse defined var tab in if condition. Replaced preventDefault with return false to be similiard to the other anchor click functions.

  • src/wp-admin/css/common.css

     
    18331833        background-size: 100% auto;
    18341834}
    18351835
    1836 @media only screen and (max-width: 800px) {
    1837         #plugin-information-title.with-banner {
    1838                 height: 100px;
    1839                 bottom: 100px;
    1840         }
    1841 }
    1842 
    18431836#plugin-information-title h2 {
    18441837        font-family: "Helvetica Neue", sans-serif;
    18451838        padding:0;
     
    18661859        border-radius: 8px;
    18671860}
    18681861
    1869 @media only screen and (max-width: 800px) {
    1870         #plugin-information-title.with-banner h2 {
    1871                 top: 12px;
    1872                 font-size: 20px;
    1873                 line-height: 40px;
    1874         }
    1875 }
    1876 
    18771862#plugin-information-title div.vignette {
    18781863        display: none;
    18791864}
     
    18891874        box-shadow: inset 0 0 50px 4px rgba( 0, 0, 0, 0.2 ), inset 0 -1px 0 rgba( 0, 0, 0, 0.1 );
    18901875}
    18911876
    1892 @media only screen and (max-width: 800px) {
    1893         #plugin-information-title.with-banner div.vignette {
    1894                 height: 65px;
    1895                 bottom: 65px;
    1896                 width: 800%;
    1897         }
    1898 }
    1899 
    19001877#plugin-information-tabs {
    19011878        padding: 0 16px;
    19021879        position: absolute;
     
    19121889        background: rgba( 255, 255, 255, 0.85 );
    19131890}
    19141891
    1915 @media only screen and (max-width: 800px) {
    1916         #plugin-information-tabs.with-banner {
    1917                 top: 65px;
    1918         }
    1919 }
    1920 
    19211892#plugin-information-tabs a {
    19221893        position: relative;
    19231894        float: left;
     
    19591930        top:249px;
    19601931}
    19611932
    1962 @media only screen and (max-width: 800px) {
    1963         #plugin-information-content.with-banner {
    1964                 top:99px;
    1965         }
    1966 }
    1967 
    19681933#section-holder {
    19691934        margin: 0;
    19701935        padding: 10px 26px;
     
    21162081        font-size: 13px;
    21172082}
    21182083
    2119 @media screen and ( max-width: 782px ) {
     2084@media screen and ( max-width: 771px ) {
     2085        #plugin-information-title.with-banner {
     2086                height: 100px;
     2087                bottom: 100px;
     2088        }
     2089
     2090        #plugin-information-title.with-banner h2 {
     2091                top: 12px;
     2092                font-size: 20px;
     2093                line-height: 40px;
     2094        }
     2095
     2096        #plugin-information-title.with-banner div.vignette {
     2097                height: 65px;
     2098                bottom: 65px;
     2099                width: 800%;
     2100        }
     2101
     2102        #plugin-information-tabs.with-banner {
     2103                top: 65px;
     2104        }
     2105
     2106        #plugin-information-content.with-banner {
     2107                top:99px;
     2108        }
     2109
    21202110        #plugin-information-content {
    21212111                overflow: auto;
    21222112                bottom: 58px;
  • src/wp-admin/includes/plugin-install.php

     
    2626 * @param array|object $args Optional. Arguments to serialize for the Plugin Info API.
    2727 * @return object plugins_api response object on success, WP_Error on failure.
    2828 */
    29 function plugins_api($action, $args = null) {
     29function plugins_api( $action, $args = null ) {
    3030
    31         if ( is_array($args) )
    32                 $args = (object)$args;
     31        if ( is_array( $args ) ) {
     32                $args = (object) $args;
     33        }
    3334
    34         if ( !isset($args->per_page) )
     35        if ( ! isset( $args->per_page ) ) {
    3536                $args->per_page = 24;
     37        }
    3638
    3739        /**
    3840         * Override the Plugin Install API arguments.
     
    7880                        $request = wp_remote_post( $http_url, $args );
    7981                }
    8082
    81                 if ( is_wp_error($request) ) {
    82                         $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() );
     83                if ( is_wp_error( $request ) ) {
     84                        $res = new WP_Error( 'plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() );
    8385                } else {
    8486                        $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
    8587                        if ( ! is_object( $res ) && ! is_array( $res ) )
    86                                 $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) );
     88                                $res = new WP_Error( 'plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) );
    8789                }
    88         } elseif ( !is_wp_error($res) ) {
     90        } elseif ( ! is_wp_error( $res ) ) {
    8991                $res->external = true;
    9092        }
    9193
     
    110112 * @return array
    111113 */
    112114function install_popular_tags( $args = array() ) {
    113         $key = md5(serialize($args));
    114         if ( false !== ($tags = get_site_transient('poptags_' . $key) ) )
     115        $key = md5( serialize( $args ) );
     116        if ( false !== ( $tags = get_site_transient( 'poptags_' . $key ) ) )
    115117                return $tags;
    116118
    117         $tags = plugins_api('hot_tags', $args);
     119        $tags = plugins_api( 'hot_tags', $args );
    118120
    119         if ( is_wp_error($tags) )
     121        if ( is_wp_error( $tags ) )
    120122                return $tags;
    121123
    122124        set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS );
     
    128130        ?>
    129131        <p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format via <a href="%2$s">this page</a>.' ), 'https://wordpress.org/plugins/', self_admin_url( 'plugin-install.php?tab=upload' ) ); ?></p>
    130132
    131         <h4><?php _e('Search') ?></h4>
     133        <h4><?php _e( 'Search' ); ?></h4>
    132134        <?php install_search_form( false ); ?>
    133135
    134         <h4><?php _e('Popular tags') ?></h4>
    135         <p class="install-help"><?php _e('You may also browse based on the most popular tags in the Plugin Directory:') ?></p>
     136        <h4><?php _e( 'Popular tags' ); ?></h4>
     137        <p class="install-help"><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ); ?></p>
    136138        <?php
    137139
    138140        $api_tags = install_popular_tags();
    139141
    140142        echo '<p class="popular-tags">';
    141         if ( is_wp_error($api_tags) ) {
     143        if ( is_wp_error( $api_tags ) ) {
    142144                echo $api_tags->get_error_message();
    143145        } else {
    144146                //Set up the tags in a way which can be interpreted by wp_generate_tag_cloud()
    145147                $tags = array();
    146                 foreach ( (array)$api_tags as $tag )
     148                foreach ( (array) $api_tags as $tag ) {
    147149                        $tags[ $tag['name'] ] = (object) array(
    148                                                                         'link' => esc_url( self_admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ),
    149                                                                         'name' => $tag['name'],
    150                                                                         'id' => sanitize_title_with_dashes($tag['name']),
    151                                                                         'count' => $tag['count'] );
    152                 echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins') ) );
     150                                'link' => esc_url( self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) ) ),
     151                                'name' => $tag['name'],
     152                                'id' => sanitize_title_with_dashes( $tag['name'] ),
     153                                'count' => $tag['count']
     154                        );
     155                }
     156                echo wp_generate_tag_cloud( $tags, array( 'single_text' => __( '%s plugin' ), 'multiple_text' => __( '%s plugins' ) ) );
    153157        }
    154158        echo '</p><br class="clear" />';
    155159}
    156 add_action('install_plugins_dashboard', 'install_dashboard');
     160add_action( 'install_plugins_dashboard', 'install_dashboard' );
    157161
    158162/**
    159163 * Display search form for searching plugins.
     
    161165 * @since 2.7.0
    162166 */
    163167function install_search_form( $type_selector = true ) {
    164         $type = isset($_REQUEST['type']) ? wp_unslash( $_REQUEST['type'] ) : 'term';
    165         $term = isset($_REQUEST['s']) ? wp_unslash( $_REQUEST['s'] ) : '';
     168        $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
     169        $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
    166170
    167         ?><form id="search-plugins" method="get" action="">
     171        ?>
     172        <form id="search-plugins" method="get" action="">
    168173                <input type="hidden" name="tab" value="search" />
    169                 <?php if ( $type_selector ) : ?>
     174                <?php if ( $type_selector ) { ?>
    170175                <select name="type" id="typeselector">
    171                         <option value="term"<?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
    172                         <option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option>
    173                         <option value="tag"<?php selected('tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>
     176                        <option value="term"<?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>
     177                        <option value="author"<?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>
     178                        <option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option>
    174179                </select>
    175                 <?php endif; ?>
    176                 <input type="search" name="s" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
    177                 <label class="screen-reader-text" for="plugin-search-input"><?php _e('Search Plugins'); ?></label>
     180                <?php } ?>
     181                <input type="search" name="s" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" />
     182                <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?></label>
    178183                <?php submit_button( __( 'Search Plugins' ), 'button', 'plugin-search-input', false ); ?>
    179         </form><?php
     184        </form>
     185        <?php
    180186}
    181187
    182188/**
     
    187193 */
    188194function install_plugins_upload( $page = 1 ) {
    189195?>
    190         <h4><?php _e('Install a plugin in .zip format'); ?></h4>
    191         <p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.'); ?></p>
    192         <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-plugin'); ?>">
    193                 <?php wp_nonce_field( 'plugin-upload'); ?>
    194                 <label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label>
     196        <h4><?php _e( 'Install a plugin in .zip format' ); ?></h4>
     197        <p class="install-help"><?php _e( 'If you have a plugin in a .zip format, you may install it by uploading it here.' ); ?></p>
     198        <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url( 'update.php?action=upload-plugin' ); ?>">
     199                <?php wp_nonce_field( 'plugin-upload' ); ?>
     200                <label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label>
    195201                <input type="file" id="pluginzip" name="pluginzip" />
    196202                <?php submit_button( __( 'Install Now' ), 'button', 'install-plugin-submit', false ); ?>
    197203        </form>
    198204<?php
    199205}
    200 add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
     206add_action( 'install_plugins_upload', 'install_plugins_upload', 10, 1 );
    201207
    202208/**
    203209 * Show a username form for the favorites page
     
    227233function display_plugins_table() {
    228234        global $wp_list_table;
    229235
    230         if ( current_filter() == 'install_plugins_favorites' && empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) )
    231                         return;
     236        if ( current_filter() === 'install_plugins_favorites' && empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) {
     237                return;
     238        }
    232239
    233240        $wp_list_table->display();
    234241}
     
    244251 *
    245252 * @since 3.0.0
    246253 */
    247 function install_plugin_install_status($api, $loop = false) {
    248         // this function is called recursively, $loop prevents further loops.
    249         if ( is_array($api) )
     254function install_plugin_install_status( $api, $loop = false ) {
     255        // This function is called recursively, $loop prevents further loops.
     256        if ( is_array( $api ) ) {
    250257                $api = (object) $api;
     258        }
    251259
    252         //Default to a "new" plugin
     260        // Default to a "new" plugin
    253261        $status = 'install';
    254262        $url = false;
    255263
    256         //Check to see if this plugin is known to be installed, and has an update awaiting it.
    257         $update_plugins = get_site_transient('update_plugins');
     264        // Check to see if this plugin is known to be installed, and has an update awaiting it.
     265        $update_plugins = get_site_transient( 'update_plugins' );
    258266        if ( isset( $update_plugins->response ) ) {
    259                 foreach ( (array)$update_plugins->response as $file => $plugin ) {
     267                foreach ( (array) $update_plugins->response as $file => $plugin ) {
    260268                        if ( $plugin->slug === $api->slug ) {
    261269                                $status = 'update_available';
    262270                                $update_file = $file;
    263271                                $version = $plugin->new_version;
    264                                 if ( current_user_can('update_plugins') )
    265                                         $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file);
     272                                if ( current_user_can( 'update_plugins' ) ) {
     273                                        $url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $update_file ), 'upgrade-plugin_' . $update_file );
     274                                }
    266275                                break;
    267276                        }
    268277                }
    269278        }
    270279
    271         if ( 'install' == $status ) {
     280        if ( 'install' === $status ) {
    272281                if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
    273                         $installed_plugin = get_plugins('/' . $api->slug);
    274                         if ( empty($installed_plugin) ) {
    275                                 if ( current_user_can('install_plugins') )
    276                                         $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
     282                        $installed_plugin = get_plugins( '/' . $api->slug );
     283                        if ( empty( $installed_plugin ) ) {
     284                                if ( current_user_can( 'install_plugins' ) )
     285                                        $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug );
    277286                        } else {
    278287                                $key = array_keys( $installed_plugin );
    279                                 $key = array_shift( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
    280                                 if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
     288                                $key = array_shift( $key ); // Use the first plugin regardless of the name. Could have issues for multiple-plugins in one directory if they share different version numbers.
     289                                if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) {
    281290                                        $status = 'latest_installed';
    282                                 } elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
     291                                } elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<' ) ) {
    283292                                        $status = 'newer_installed';
    284293                                        $version = $installed_plugin[ $key ]['Version'];
    285294                                } else {
    286                                         //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
     295                                        // If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh.
    287296                                        if ( ! $loop ) {
    288                                                 delete_site_transient('update_plugins');
     297                                                delete_site_transient( 'update_plugins' );
    289298                                                wp_update_plugins();
    290                                                 return install_plugin_install_status($api, true);
     299                                                return install_plugin_install_status( $api, true );
    291300                                        }
    292301                                }
    293302                        }
    294303                } else {
    295                         // "install" & no directory with that slug
    296                         if ( current_user_can('install_plugins') )
    297                                 $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
     304                        // "install" and no directory with that slug.
     305                        if ( current_user_can( 'install_plugins' ) ) {
     306                                $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug );
     307                        }
    298308                }
    299309        }
    300         if ( isset($_GET['from']) )
     310        if ( isset( $_GET['from'] ) )
    301311                $url .= '&amp;from=' . urlencode( wp_unslash( $_GET['from'] ) );
    302312
    303         return compact('status', 'url', 'version');
     313        return compact( 'status', 'url', 'version' );
    304314}
    305315
    306316/**
     
    311321function install_plugin_information() {
    312322        global $tab;
    313323
    314         $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl(), 'fields' => array( 'banners' => true, 'reviews' => true ) ) );
     324        $api = plugins_api( 'plugin_information', array(
     325                'slug' => wp_unslash( $_REQUEST['plugin'] ),
     326                'is_ssl' => is_ssl(),
     327                'fields' => array( 'banners' => true, 'reviews' => true )
     328        ) );
    315329
    316         if ( is_wp_error( $api ) )
     330        if ( is_wp_error( $api ) ) {
    317331                wp_die( $api );
     332        }
    318333
    319334        $plugins_allowedtags = array(
    320335                'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ),
     
    326341        );
    327342
    328343        $plugins_section_titles = array(
    329                 'description'  => _x('Description',  'Plugin installer section title'),
    330                 'installation' => _x('Installation', 'Plugin installer section title'),
    331                 'faq'          => _x('FAQ',          'Plugin installer section title'),
    332                 'screenshots'  => _x('Screenshots',  'Plugin installer section title'),
    333                 'changelog'    => _x('Changelog',    'Plugin installer section title'),
    334                 'reviews'      => _x('Reviews',      'Plugin installer section title'),
    335                 'other_notes'  => _x('Other Notes',  'Plugin installer section title')
     344                'description'  => _x( 'Description',  'Plugin installer section title' ),
     345                'installation' => _x( 'Installation', 'Plugin installer section title' ),
     346                'faq'          => _x( 'FAQ',          'Plugin installer section title' ),
     347                'screenshots'  => _x( 'Screenshots',  'Plugin installer section title' ),
     348                'changelog'    => _x( 'Changelog',    'Plugin installer section title' ),
     349                'reviews'      => _x( 'Reviews',      'Plugin installer section title' ),
     350                'other_notes'  => _x( 'Other Notes',  'Plugin installer section title' )
    336351        );
    337352
    338         //Sanitize HTML
    339         foreach ( (array)$api->sections as $section_name => $content ) {
    340                 $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
     353        // Sanitize HTML
     354        foreach ( (array) $api->sections as $section_name => $content ) {
     355                $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags );
    341356        }
    342357
    343358        foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
    344                 if ( isset( $api->$key ) )
     359                if ( isset( $api->$key ) ) {
    345360                        $api->$key = wp_kses( $api->$key, $plugins_allowedtags );
     361                }
    346362        }
    347363
    348364        $_tab = esc_attr( $tab );
    349365
    350         $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.
     366        $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
    351367        if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
    352368                $section_titles = array_keys( (array) $api->sections );
    353369                $section = array_shift( $section_titles );
    354370        }
    355371
    356         iframe_header( __('Plugin Install') );
     372        iframe_header( __( 'Plugin Install' ) );
    357373
    358374        $_with_banner = '';
    359375
    360         if ( !empty( $api->banners ) && ( !empty( $api->banners['low'] ) || !empty( $api->banners['high'] ) ) ) {
     376        if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) {
    361377                $_with_banner = 'with-banner';
    362                 $low  = ( !empty( $api->banners['low'] ) ) ? $api->banners['low'] : $api->banners['high'];
    363                 $high = ( !empty( $api->banners['high'] ) ) ? $api->banners['high'] : $api->banners['low'];
     378                $low  = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low'];
     379                $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high'];
    364380                ?>
    365381                <style type="text/css">
    366382                        #plugin-information-title.with-banner {
    367                                 background-image: url(<?php echo $low ?>);
     383                                background-image: url( <?php echo $low; ?> );
    368384                        }
    369                         @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
     385                        @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) {
    370386                                #plugin-information-title.with-banner {
    371                                         background-image: url(<?php echo $high ?>});
     387                                        background-image: url( <?php echo $high; ?> );
    372388                                }
    373389                        }
    374390                </style>
     
    378394        echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>";
    379395        echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n";
    380396
    381         foreach ( (array)$api->sections as $section_name => $content ) {
    382                 if ( 'reviews' == $section_name && ( empty( $api->ratings ) || 0 == array_sum( (array) $api->ratings ) ) )
     397        foreach ( (array) $api->sections as $section_name => $content ) {
     398                if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) {
    383399                        continue;
     400                }
    384401
    385                 if ( isset( $plugins_section_titles[ $section_name ] ) )
     402                if ( isset( $plugins_section_titles[ $section_name ] ) ) {
    386403                        $title = $plugins_section_titles[ $section_name ];
    387                 else
     404                } else {
    388405                        $title = ucwords( str_replace( '_', ' ', $section_name ) );
     406                }
    389407
    390                 $class = ( $section_name == $section ) ? ' class="current"' : '';
     408                $class = ( $section_name === $section ) ? ' class="current"' : '';
    391409                $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
    392410                $href = esc_url( $href );
    393411                $san_section = esc_attr( $section_name );
     
    400418        <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
    401419        <div class="fyi">
    402420                <ul>
    403 <?php if ( ! empty( $api->version ) ) : ?>
    404                         <li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li>
    405 <?php endif; if ( ! empty( $api->author ) ) : ?>
    406                         <li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li>
    407 <?php endif; if ( ! empty( $api->last_updated ) ) : ?>
    408                         <li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
    409                                                         printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
    410 <?php endif; if ( ! empty( $api->requires ) ) : ?>
    411                         <li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li>
    412 <?php endif; if ( ! empty( $api->tested ) ) : ?>
    413                         <li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li>
    414 <?php endif; if ( ! empty( $api->downloaded ) ) : ?>
    415                         <li><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li>
    416 <?php endif; if ( ! empty( $api->slug ) && empty( $api->external ) ) : ?>
    417                         <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page &#187;') ?></a></li>
    418 <?php endif; if ( ! empty( $api->homepage ) ) : ?>
    419                         <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;') ?></a></li>
    420 <?php endif;if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) : ?>
    421                         <li><a target="_blank" href="<?php echo $api->donate_link ?>"><?php _e('Donate to this plugin &#187;') ?></a></li>
    422 <?php endif; ?>
     421                <?php if ( ! empty( $api->version ) ) { ?>
     422                        <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li>
     423                <?php } if ( ! empty( $api->author ) ) { ?>
     424                        <li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li>
     425                <?php } if ( ! empty( $api->last_updated ) ) { ?>
     426                        <li><strong><?php _e( 'Last Updated:' ); ?></strong> <span title="<?php echo $api->last_updated; ?>">
     427                                <?php printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); ?>
     428                        </span></li>
     429                <?php } if ( ! empty( $api->requires ) ) { ?>
     430                        <li><strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php printf( __( '%s or higher' ), $api->requires ); ?></li>
     431                <?php } if ( ! empty( $api->tested ) ) { ?>
     432                        <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
     433                <?php } if ( ! empty( $api->downloaded ) ) { ?>
     434                        <li><strong><?php _e( 'Downloaded:' ); ?></strong> <?php printf( _n( '%s time', '%s times', $api->downloaded ), number_format_i18n( $api->downloaded ) ); ?></li>
     435                <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
     436                        <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
     437                <?php } if ( ! empty( $api->homepage ) ) { ?>
     438                        <li><a target="_blank" href="<?php echo $api->homepage; ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a></li>
     439                <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
     440                        <li><a target="_blank" href="<?php echo $api->donate_link ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a></li>
     441                <?php } ?>
    423442                </ul>
    424                 <?php if ( ! empty( $api->rating ) ) : ?>
    425                 <h3><?php _e('Average Rating') ?></h3>
     443                <?php if ( ! empty( $api->rating ) ) { ?>
     444                <h3><?php _e( 'Average Rating' ); ?></h3>
    426445                <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
    427                 <small><?php printf( _n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings) ); ?></small>
    428                 <?php endif; ?>
    429                 <?php
     446                <small><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></small>
     447                <?php }
     448
    430449                if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) {
    431                         foreach( $api->ratings as $key=>$ratecount ) {
     450                        foreach( $api->ratings as $key => $ratecount ) {
    432451                                // avoid div-by-zero
    433452                                $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
    434453                                ?>
    435454                                <div class="counter-container">
    436455                                        <a href="./plugin-install.php?tab=plugin-information&plugin=<?php echo $api->slug; ?>&section=reviews"
    437                                            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 ) ); ?>" -->
    438                                                 <span class="counter-label" style="float:left; margin-right:5px;"><?php echo $key; ?> stars</span>
    439                                                 <span class="counter-back" style="height:17px;width:92px;background-color:#ececec;float:left;">
    440                                                         <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;height:17px;background-color:#fddb5a;float:left;"></span>
     456                                           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 ) ); ?>">
     457                                                <span class="counter-label"><?php echo $key; ?> stars</span>
     458                                                <span class="counter-back">
     459                                                        <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
    441460                                                </span>
    442461                                        </a>
    443                                         <span class="counter-count" style="margin-left:5px;"><?php echo $ratecount; ?></span>
     462                                        <span class="counter-count"><?php echo $ratecount; ?></span>
    444463                                </div>
    445                         <?php
     464                                <?php
    446465                        }
    447466                }
    448                 if ( ! empty( $api->contributors ) ) : ?>
    449                         <h3><?php _e('Contributors') ?></h3>
     467                if ( ! empty( $api->contributors ) ) { ?>
     468                        <h3><?php _e( 'Contributors' ); ?></h3>
    450469                        <ul class="contributors">
    451470                                <?php
    452471                                foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) {
    453                                         if ( empty( $contrib_username ) && empty( $contrib_profile ) )
     472                                        if ( empty( $contrib_username ) && empty( $contrib_profile ) ) {
    454473                                                continue;
    455                                         if ( empty( $contrib_username ) )
     474                                        }
     475                                        if ( empty( $contrib_username ) ) {
    456476                                                $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile );
     477                                        }
    457478                                        $contrib_username = sanitize_user( $contrib_username );
    458                                         if ( empty( $contrib_profile ) )
     479                                        if ( empty( $contrib_profile ) ) {
    459480                                                echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' />{$contrib_username}</li>";
    460                                         else
     481                                        } else {
    461482                                                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>";
     483                                        }
    462484                                }
    463485                                ?>
    464486                        </ul>
    465                         <?php if ( ! empty( $api->donate_link ) ) : ?>
    466                                 <a target="_blank" href="<?php echo $api->donate_link ?>"><?php _e('Donate to this plugin &#187;') ?></a>
    467                         <?php endif; ?>
    468                 <?php endif; ?>
     487                        <?php if ( ! empty( $api->donate_link ) ) { ?>
     488                                <a target="_blank" href="<?php echo $api->donate_link; ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a>
     489                        <?php } ?>
     490                <?php } ?>
    469491        </div>
    470492        <div id="section-holder" class="wrap">
    471493        <?php
    472                 if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) )
     494                if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
    473495                        echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
    474 
    475                 else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) )
     496                } else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
    476497                        echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>';
     498                }
    477499
    478                 foreach ( (array)$api->sections as $section_name => $content ) {
    479 
     500                foreach ( (array) $api->sections as $section_name => $content ) {
    480501                        $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
    481502                        $content = links_add_target( $content, '_blank' );
    482503
    483504                        $san_section = esc_attr( $section_name );
    484505
    485                         $display = ( $section_name == $section ) ? 'block' : 'none';
     506                        $display = ( $section_name === $section ) ? 'block' : 'none';
    486507
    487508                        echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
    488509                        echo $content;
     
    491512        echo "</div>\n";
    492513        echo "</div>\n";
    493514        echo "<div id='$tab-footer'>\n";
    494         if ( ! empty( $api->download_link ) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) {
    495                 $status = install_plugin_install_status($api);
     515        if ( ! empty( $api->download_link ) && ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) {
     516                $status = install_plugin_install_status( $api );
    496517                switch ( $status['status'] ) {
    497518                        case 'install':
    498                                 if ( $status['url'] )
    499                                         echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';
     519                                if ( $status['url'] ) {
     520                                        echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>';
     521                                }
    500522                                break;
    501523                        case 'update_available':
    502                                 if ( $status['url'] )
    503                                         echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>';
     524                                if ( $status['url'] ) {
     525                                        echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>';
     526                                }
    504527                                break;
    505528                        case 'newer_installed':
    506                                 echo '<a class="button button-primary right disabled">' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';
     529                                echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed'), $status['version'] ) . '</a>';
    507530                                break;
    508531                        case 'latest_installed':
    509                                 echo '<a class="button button-primary right disabled">' . __('Latest Version Installed') . '</a>';
     532                                echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>';
    510533                                break;
    511534                }
    512535        }
  • src/wp-admin/js/plugin-install.js

     
    66        tb_position = function() {
    77                var tbWindow = $( '#TB_window' ),
    88                        width = $( window ).width(),
    9                         H = $( window ).height() - ( ( 850 < width ) ? 60 : 20 ),
    10                         W = ( 850 < width ) ? 830 : width - 20;
     9                        H = $( window ).height() - ( ( 792 < width ) ? 60 : 20 ),
     10                        W = ( 792 < width ) ? 772 : width - 20;
    1111
    1212                if ( tbWindow.size() ) {
    1313                        tbWindow.width( W ).height( H );
     
    1717                        });
    1818                        if ( typeof document.body.style.maxWidth !== 'undefined' ) {
    1919                                tbWindow.css({
    20                                         'top': ( ( 850 < width ) ? 30 : 10 ) + 'px',
     20                                        'top': ( ( 792 < width ) ? 30 : 10 ) + 'px',
    2121                                        'margin-top': '0'
    2222                                });
    2323                        }
     
    3030                        }
    3131                        href = href.replace( /&width=[0-9]+/g, '' );
    3232                        href = href.replace( /&height=[0-9]+/g, '' );
    33                         $(this).attr( 'href', href + '&width=' + W + '&height=' + ( H ) );
     33                        $( this ).attr( 'href', href + '&width=' + W + '&height=' + ( H ) );
    3434                });
    3535        };
    3636
     
    3838                tb_position();
    3939        });
    4040
    41         $('.plugins').on( 'click', 'a.thickbox', function() {
     41        $( '.plugins' ).on( 'click', 'a.thickbox', function() {
    4242                tb_click.call(this);
    4343
    44                 $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
    45                 $('#TB_ajaxWindowTitle').html('<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).attr('title') );
     44                $( '#TB_title' ).css( {'background-color':'#222','color':'#cfcfcf'} );
     45                $( '#TB_ajaxWindowTitle' ).html( '<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $( this ).attr( 'title' ) );
    4646                return false;
    4747        });
    4848
    49         /* Plugin install related JS*/
    50         $( '#plugin-information-tabs a' ).click( function( event ) {
     49        /* Plugin install related JS */
     50        $( '#plugin-information-tabs a' ).click( function() {
    5151                var tab = $( this ).attr( 'name' );
    52                 event.preventDefault();
    53                 //Flip the tab
     52                // Flip the tab
    5453                $( '#plugin-information-tabs a.current' ).removeClass( 'current' );
    5554                $( this ).addClass( 'current' );
    56                 //Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top.
    57                 if ( 'description' != $( this ).attr( 'name' ) && $( 'body').width() < 830 )
    58                         $( '#plugin-information-content div.fyi' ).hide();
    59                 else
    60                         $( '#plugin-information-content div.fyi' ).show();
    61                 //Flip the content.
    62                 $( '#section-holder div.section' ).hide(); //Hide 'em all
     55                // Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top.
     56                if ( 'description' !== tab && $( window ).width() < 772 ) {
     57                        $( '#plugin-information-content' ).find( '.fyi' ).hide();
     58                } else {
     59                        $( '#plugin-information-content' ).find( '.fyi' ).show();
     60                }
     61                // Flip the content.
     62                $( '#section-holder div.section' ).hide(); // Hide 'em all.
    6363                $( '#section-' + tab ).show();
     64                return false;
    6465        });
    6566
    6667        $( 'a.install-now' ).click( function() {