Make WordPress Core

Changeset 43006


Ignore:
Timestamp:
04/26/2018 02:30:24 PM (6 years ago)
Author:
flixos90
Message:

General: Implement editorial, design and accessibility feedback for the PHP version nag.

The updated version of the nag is shorter, more on point and less aggressive than the previous one. It integrates better with the other dashboard widgets and fixes several accessibility concerns. A yellow warning color is used when the current PHP version is outdated, a red error color is used when it is also insecure.

Props afercia, birgire, danieltj, flixos90, johnjamesjacoby, karmatosed, Luciano Croce, nerrad, pento, schlessera, SergeyBiryukov, sonjaleix.

Fixes #41191.

Location:
trunk/src/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/dashboard.css

    r42832 r43006  
    11181118
    11191119/* PHP Nag */
    1120 #dashboard_php_nag h2.hndle {
    1121     border-left: 4px solid #dc3232;
     1120#dashboard_php_nag .dashicons-warning {
     1121    color: #ffb900;
     1122    padding-right: 6px;
     1123}
     1124
     1125#dashboard_php_nag.php-insecure .dashicons-warning {
     1126    color: #df3232;
     1127}
     1128
     1129#dashboard_php_nag p {
     1130    margin: 12px 0;
    11221131}
    11231132
     
    11261135}
    11271136
    1128 #dashboard_php_nag .button.button-hero {
    1129     display: block;
    1130     text-align: center;
     1137#dashboard_php_nag .button .dashicons-external {
     1138    line-height: 25px;
    11311139}
    11321140
  • trunk/src/wp-admin/includes/dashboard.php

    r42891 r43006  
    3636    }
    3737
    38     // PHP Version
     38    // PHP Version.
    3939    $response = wp_check_php_version();
    40     if ( $response && ! $response['is_acceptable'] && current_user_can( 'upgrade_php' ) ) {
    41         $title = $response['is_secure'] ? __( 'Your site could be much faster!' ) : __( 'Your site could be much faster and more secure!' );
    42         wp_add_dashboard_widget( 'dashboard_php_nag', $title, 'wp_dashboard_php_nag' );
     40    if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'upgrade_php' ) ) {
     41        add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
     42        wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
    4343    }
    4444
     
    16191619    }
    16201620
    1621     $information_url = _x( 'https://wordpress.org/support/upgrade-php/', 'localized PHP upgrade information page' );
    1622 
    1623     if ( ! $response['is_secure'] ) {
    1624         $msg = __( 'WordPress has detected that your site is running on an insecure version of PHP, which is why we’re showing you this notice.' );
     1621    if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
     1622        $msg = __( 'WordPress has detected that your site is running on an insecure version of PHP.' );
    16251623    } else {
    1626         $msg = __( 'WordPress has detected that your site is running on an outdated version of PHP, which is why we’re showing you this notice.' );
     1624        $msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
    16271625    }
    16281626
     
    16301628    <p><?php echo $msg; ?></p>
    16311629
    1632     <h3><?php _e( 'What is PHP and why should I care?' ); ?></h3>
    1633     <p><?php _e( 'PHP is the programming language that WordPress is built on. Newer versions of PHP are both faster and more secure, so upgrading is better for your site, and better for the people who are building WordPress.' ); ?></p>
    1634     <p><?php _e( 'If you want to know exactly how PHP works and why it is important, continue reading.' ); ?></p>
    1635 
    1636     <h3><?php _e( 'How can I upgrade my PHP version?' ); ?></h3>
    1637     <p><?php _e( 'The button below will take you to a page with more details on what PHP is, how to upgrade your PHP version, and what to do if it turns out you can&#8217;t.' ); ?></p>
    1638     <p>
    1639         <a class="button button-primary button-hero" href="<?php echo esc_url( $information_url ); ?>"><?php _e( 'Show me how to upgrade my PHP' ); ?></a>
     1630    <h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
     1631    <p><?php _e( 'PHP is the programming language we use to build and maintain WordPress. Newer versions of PHP are both faster and more secure, so updating will have a positive effect on your site’s performance.' ); ?></p>
     1632
     1633    <p class="button-container">
     1634        <?php
     1635            printf(
     1636                '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
     1637                esc_url( _x( 'https://wordpress.org/support/upgrade-php/', 'localized PHP upgrade information page' ) ),
     1638                __( 'Learn more about updating PHP' ),
     1639                /* translators: accessibility text */
     1640                __( '(opens in a new tab)' )
     1641            );
     1642        ?>
    16401643    </p>
    1641 
    1642     <p><?php _e( 'Upgrading usually takes only a few minutes and should be safe if you follow the provided instructions.' ); ?></p>
    16431644    <?php
    16441645}
    16451646
    16461647/**
     1648 * Adds an additional class to the PHP nag if the current version is insecure.
     1649 *
     1650 * @since 5.0.0
     1651 *
     1652 * @param array $classes Metabox classes.
     1653 * @return array Modified metabox classes.
     1654 */
     1655function dashboard_php_nag_class( $classes ) {
     1656    $response = wp_check_php_version();
     1657
     1658    if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
     1659        $classes[] = 'php-insecure';
     1660    }
     1661
     1662    return $classes;
     1663}
     1664
     1665/**
    16471666 * Checks if the user needs to upgrade PHP.
    16481667 *
    16491668 * @since 5.0.0
    16501669 *
    1651  * @return array Array of PHP version data.
     1670 * @return array|false $response Array of PHP version data. False on failure.
    16521671 */
    16531672function wp_check_php_version() {
     
    16661685        $response = wp_remote_get( $url );
    16671686
    1668         if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
     1687        if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
    16691688            return false;
    16701689        }
     
    16721691        /**
    16731692         * Response should be an array with:
    1674          *  'recommended_version' - string - The PHP version recommended by WordPress
    1675          *  'is_supported' - boolean - Whether the PHP version is actively supported
    1676          *  'is_secure' - boolean - Whether the PHP version receives security updates
    1677          *  'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress
     1693         *  'recommended_version' - string - The PHP version recommended by WordPress.
     1694         *  'is_supported' - boolean - Whether the PHP version is actively supported.
     1695         *  'is_secure' - boolean - Whether the PHP version receives security updates.
     1696         *  'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress.
    16781697         */
    16791698        $response = json_decode( wp_remote_retrieve_body( $response ), true );
  • trunk/src/wp-admin/includes/template.php

    r42974 r43006  
    11411141                        echo '</button>';
    11421142                    }
    1143                     echo "<h2 class='hndle'><span>{$box['title']}</span></h2>\n";
     1143                    echo '<h2 class="hndle">';
     1144                    if ( 'dashboard_php_nag' === $box['id'] ) {
     1145                        echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
     1146                        echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
     1147                    }
     1148                    echo "<span>{$box['title']}</span>";
     1149                    echo "</h2>\n";
    11441150                    echo '<div class="inside">' . "\n";
    11451151                    call_user_func( $box['callback'], $object, $box );
     
    21672173<!DOCTYPE html>
    21682174<!--[if IE 8]>
    2169 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" 
     2175<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>"
    21702176                                                                    <?php
    21712177                                                                    /**
     
    21792185<![endif]-->
    21802186<!--[if !(IE 8) ]><!-->
    2181 <html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" 
     2187<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>"
    21822188                                                                <?php
    21832189                                                                /** This action is documented in wp-admin/includes/template.php */
Note: See TracChangeset for help on using the changeset viewer.