WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/15/2016 04:36:07 PM (3 years ago)
Author:
obenland
Message:

Update/Install: Shiny Updates v2.

Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.

Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin-install.php

    r37488 r37714  
    541541
    542542    ?>
    543     <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
     543<div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
    544544    <div class="fyi">
    545545        <ul>
    546         <?php if ( ! empty( $api->version ) ) { ?>
    547             <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li>
    548         <?php } if ( ! empty( $api->author ) ) { ?>
    549             <li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li>
    550         <?php } if ( ! empty( $api->last_updated ) ) { ?>
    551             <li><strong><?php _e( 'Last Updated:' ); ?></strong>
    552                 <?php printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); ?>
    553             </li>
    554         <?php } if ( ! empty( $api->requires ) ) { ?>
    555             <li><strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php printf( __( '%s or higher' ), $api->requires ); ?></li>
    556         <?php } if ( ! empty( $api->tested ) ) { ?>
    557             <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
    558         <?php } if ( ! empty( $api->active_installs ) ) { ?>
    559             <li><strong><?php _e( 'Active Installs:' ); ?></strong> <?php
    560                 if ( $api->active_installs >= 1000000 ) {
    561                     _ex( '1+ Million', 'Active plugin installs' );
    562                 } else {
    563                     echo number_format_i18n( $api->active_installs ) . '+';
    564                 }
    565             ?></li>
    566         <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
    567             <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
    568         <?php } if ( ! empty( $api->homepage ) ) { ?>
    569             <li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a></li>
    570         <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
    571             <li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a></li>
    572         <?php } ?>
     546            <?php if ( ! empty( $api->version ) ) { ?>
     547                <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li>
     548            <?php } if ( ! empty( $api->author ) ) { ?>
     549                <li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li>
     550            <?php } if ( ! empty( $api->last_updated ) ) { ?>
     551                <li><strong><?php _e( 'Last Updated:' ); ?></strong>
     552                    <?php
     553                    /* translators: %s: Time since the last update */
     554                    printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) );
     555                    ?>
     556                </li>
     557            <?php } if ( ! empty( $api->requires ) ) { ?>
     558                <li>
     559                    <strong><?php _e( 'Requires WordPress Version:' ); ?></strong>
     560                    <?php
     561                    /* translators: %s: WordPress version */
     562                    printf( __( '%s or higher' ), $api->requires );
     563                    ?>
     564                </li>
     565            <?php } if ( ! empty( $api->tested ) ) { ?>
     566                <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
     567            <?php } if ( ! empty( $api->active_installs ) ) { ?>
     568                <li><strong><?php _e( 'Active Installs:' ); ?></strong> <?php
     569                    if ( $api->active_installs >= 1000000 ) {
     570                        _ex( '1+ Million', 'Active plugin installs' );
     571                    } else {
     572                        echo number_format_i18n( $api->active_installs ) . '+';
     573                    }
     574                    ?></li>
     575            <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
     576                <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
     577            <?php } if ( ! empty( $api->homepage ) ) { ?>
     578                <li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a></li>
     579            <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
     580                <li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a></li>
     581            <?php } ?>
    573582        </ul>
    574583        <?php if ( ! empty( $api->rating ) ) { ?>
    575         <h3><?php _e( 'Average Rating' ); ?></h3>
    576         <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
    577         <p aria-hidden="true" class="fyi-description"><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></p>
     584            <h3><?php _e( 'Average Rating' ); ?></h3>
     585            <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
     586            <p aria-hidden="true" class="fyi-description"><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></p>
    578587        <?php }
    579588
     
    592601                ?>
    593602                <div class="counter-container">
    594                     <span class="counter-label"><a href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
    595                         target="_blank" aria-label="<?php echo $aria_label; ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span>
    596                     <span class="counter-back">
    597                         <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
    598                     </span>
     603                        <span class="counter-label"><a href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
     604                                                       target="_blank" aria-label="<?php echo $aria_label; ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span>
     605                        <span class="counter-back">
     606                            <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
     607                        </span>
    599608                    <span class="counter-count" aria-hidden="true"><?php echo number_format_i18n( $ratecount ); ?></span>
    600609                </div>
     
    629638    <div id="section-holder" class="wrap">
    630639    <?php
    631         if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
    632             echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.' ) . '</p></div>';
    633         } elseif ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
    634             echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.' ) . '</p></div>';
    635         }
    636 
    637         foreach ( (array) $api->sections as $section_name => $content ) {
    638             $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
    639             $content = links_add_target( $content, '_blank' );
    640 
    641             $san_section = esc_attr( $section_name );
    642 
    643             $display = ( $section_name === $section ) ? 'block' : 'none';
    644 
    645             echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
    646             echo $content;
    647             echo "\t</div>\n";
    648         }
     640    if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
     641        echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.' ) . '</p></div>';
     642    } elseif ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
     643        echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.' ) . '</p></div>';
     644    }
     645
     646    foreach ( (array) $api->sections as $section_name => $content ) {
     647        $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
     648        $content = links_add_target( $content, '_blank' );
     649
     650        $san_section = esc_attr( $section_name );
     651
     652        $display = ( $section_name === $section ) ? 'block' : 'none';
     653
     654        echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
     655        echo $content;
     656        echo "\t</div>\n";
     657    }
    649658    echo "</div>\n";
    650659    echo "</div>\n";
     
    656665            case 'install':
    657666                if ( $status['url'] ) {
    658                     echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>';
     667                    echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_install_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>';
    659668                }
    660669                break;
     
    665674                break;
    666675            case 'newer_installed':
     676                /* translators: %s: Plugin version */
    667677                echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed'), $status['version'] ) . '</a>';
    668678                break;
Note: See TracChangeset for help on using the changeset viewer.