Make WordPress Core

Ticket #56199: 56199-dashboard-widget.diff

File 56199-dashboard-widget.diff, 7.4 KB (added by azaozz, 2 years ago)
  • src/wp-admin/css/dashboard.css

     
    11861186        padding-right: 6px;
    11871187}
    11881188
    1189 #dashboard_php_nag.php-insecure .dashicons-warning {
     1189#dashboard_php_nag.php-insecure .dashicons-warning,
     1190#dashboard_php_nag.php-version-lower-than-future-minimum .dashicons-warning {
    11901191        color: #d63638;
    11911192}
    11921193
     
    11981199        margin: 12px 0;
    11991200}
    12001201
    1201 #dashboard_php_nag h3 {
    1202         font-weight: 600;
    1203 }
    1204 
    12051202#dashboard_php_nag .button .dashicons-external {
    12061203        line-height: 25px;
    12071204}
    12081205
     1206.bigger-bolder-text {
     1207        font-weight: 600;
     1208        font-size: 14px;
     1209}
     1210
    12091211/* =Media Queries
    12101212-------------------------------------------------------------- */
    12111213
  • src/wp-admin/includes/dashboard.php

     
    2020function wp_dashboard_setup() {
    2121        global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
    2222
    23         $wp_dashboard_control_callbacks = array();
    24         $screen                         = get_current_screen();
     23        $screen = get_current_screen();
    2524
    2625        /* Register Widgets and Controls */
     26        $wp_dashboard_control_callbacks = array();
    2727
    28         $response = wp_check_browser_version();
     28        // Browser version
     29        $check_browser = wp_check_browser_version();
    2930
    30         if ( $response && $response['upgrade'] ) {
     31        if ( $check_browser && $check_browser['upgrade'] ) {
    3132                add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
    3233
    33                 if ( $response['insecure'] ) {
     34                if ( $check_browser['insecure'] ) {
    3435                        wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
    3536                } else {
    3637                        wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
     
    3839        }
    3940
    4041        // PHP Version.
    41         $response = wp_check_php_version();
     42        $check_php = wp_check_php_version();
    4243
    43         if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable']
    44                 && current_user_can( 'update_php' )
    45         ) {
    46                 add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
     44        if ( $check_php && current_user_can( 'update_php' ) ) {
     45                // If "not acceptable" the widget will be shown.
     46                if ( isset( $check_php['is_acceptable'] ) && ! $check_php['is_acceptable'] ) {
     47                        add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
    4748
    48                 wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' );
     49                        if ( $check_php['is_lower_than_future_minimum'] ) {
     50                                wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
     51                        } else {
     52                                wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' );
     53                        }
     54                }
    4955        }
    5056
    5157        // Site Health.
     
    18251831        }
    18261832
    18271833        if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
    1828                 $msg = sprintf(
     1834                if ( $response['is_lower_than_future_minimum'] ) {
     1835                        $message = sprintf(
     1836                                /* translators: %s: The server PHP version. */
     1837                                __( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates and soon will not be supported by WordPress. Ensure that PHP is updated on your server as soon as possible. Otherwise you will not be able to upgrade WordPress.' ),
     1838                                PHP_VERSION
     1839                        );
     1840                } else {
     1841                        $message = sprintf(
     1842                                /* translators: %s: The server PHP version. */
     1843                                __( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates. It should be updated.' ),
     1844                                PHP_VERSION
     1845                        );
     1846                }
     1847        } elseif ( $response['is_lower_than_future_minimum'] ) {
     1848                $message = sprintf(
    18291849                        /* translators: %s: The server PHP version. */
    1830                         __( 'Your site is running an insecure version of PHP (%s), which should be updated.' ),
     1850                        __( 'Your site is running on an outdated version of PHP (%s), which soon will not be supported by WordPress. Ensure that PHP is updated on your server as soon as possible. Otherwise you will not be able to upgrade WordPress.' ),
    18311851                        PHP_VERSION
    18321852                );
    18331853        } else {
    1834                 $msg = sprintf(
     1854                $message = sprintf(
    18351855                        /* translators: %s: The server PHP version. */
    1836                         __( 'Your site is running an outdated version of PHP (%s), which should be updated.' ),
     1856                        __( 'Your site is running on an outdated version of PHP (%s), which should be updated.' ),
    18371857                        PHP_VERSION
    18381858                );
    18391859        }
    18401860        ?>
    1841         <p><?php echo $msg; ?></p>
     1861        <p class="bigger-bolder-text"><?php echo $message; ?></p>
    18421862
    1843         <h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
     1863        <p><?php _e( 'What is PHP and how does it affect my site?' ); ?></p>
    18441864        <p>
     1865                <?php _e( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site&#8217;s performance.' ); ?>
    18451866                <?php
    1846                 printf(
    1847                         /* translators: %s: The minimum recommended PHP version. */
    1848                         __( 'PHP is the programming language used to build and maintain WordPress. Newer versions of PHP are created with increased performance in mind, so you may see a positive effect on your site&#8217;s performance. The minimum recommended version of PHP is %s.' ),
    1849                         $response ? $response['recommended_version'] : ''
    1850                 );
     1867                if ( ! empty( $response['recommended_version'] ) ) {
     1868                        printf(
     1869                                /* translators: %s: The minimum recommended PHP version. */
     1870                                __( 'The minimum recommended version of PHP is %s.' ),
     1871                                $response['recommended_version']
     1872                        );
     1873                }
    18511874                ?>
    18521875        </p>
    18531876
     
    18791902function dashboard_php_nag_class( $classes ) {
    18801903        $response = wp_check_php_version();
    18811904
    1882         if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
     1905        if ( ! $response ) {
     1906                return $classes;
     1907        }
     1908
     1909        if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
    18831910                $classes[] = 'php-insecure';
     1911        } elseif ( $response['is_lower_than_future_minimum'] ) {
     1912                $classes[] = 'php-version-lower-than-future-minimum';
    18841913        }
    18851914
    18861915        return $classes;
  • src/wp-admin/includes/misc.php

     
    15501550                 *  'recommended_version' - string - The PHP version recommended by WordPress.
    15511551                 *  'is_supported' - boolean - Whether the PHP version is actively supported.
    15521552                 *  'is_secure' - boolean - Whether the PHP version receives security updates.
    1553                  *  'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress.
     1553                 *  'is_acceptable' - boolean - Whether the PHP version is still acceptable or warnings
     1554                 *                              should be shown and an update recommended.
    15541555                 */
    15551556                $response = json_decode( wp_remote_retrieve_body( $response ), true );
    15561557
     
    15781579                $response['is_acceptable'] = (bool) apply_filters( 'wp_is_php_version_acceptable', true, $version );
    15791580        }
    15801581
     1582        $response['is_lower_than_future_minimum'] = false;
     1583
     1584        // The minimum supported PHP version will be updated to 7.2. Check if the current version is lower.
     1585        if ( version_compare( $version, '7.2', '<' ) ) {
     1586                $response['is_lower_than_future_minimum'] = true;
     1587
     1588                // Force showing of warnings.
     1589                $response['is_acceptable'] = false;
     1590        }
     1591
    15811592        return $response;
    15821593}