diff --git a/src/wp-admin/css/dashboard.css b/src/wp-admin/css/dashboard.css index f64cc92422..0353da78c1 100644 --- a/src/wp-admin/css/dashboard.css +++ b/src/wp-admin/css/dashboard.css @@ -1116,6 +1116,20 @@ a.rsswidget { font-size: 16px; } +/* PHP Nag */ +#dashboard_php_nag h2.hndle { + border-left: 4px solid #dc3232; +} + +#dashboard_php_nag h3 { + font-weight: 600; +} + +#dashboard_php_nag .button.button-hero { + display: block; + text-align: center; +} + /* =Media Queries -------------------------------------------------------------- */ diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 08d80baa88..fb7068ff11 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -35,6 +35,13 @@ function wp_dashboard_setup() { } } + // PHP Version + $response = wp_check_php_version(); + if ( $response && ! $response['is_acceptable'] && current_user_can( 'upgrade_php' ) ) { + $title = $response['is_secure'] ? __( 'Your site could be much faster!' ) : __( 'Your site could be much faster and more secure!' ); + wp_add_dashboard_widget( 'dashboard_php_nag', $title, 'wp_dashboard_php_nag' ); + } + // Right Now if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); @@ -178,8 +185,10 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ $location = 'side'; } + $high_priority_widgets = array( 'dashboard_browser_nag', 'dashboard_php_nag' ); + $priority = 'core'; - if ( 'dashboard_browser_nag' === $widget_id ) { + if ( in_array( $widget_id, $high_priority_widgets, true ) ) { $priority = 'high'; } @@ -1599,6 +1608,91 @@ function wp_check_browser_version() { return $response; } +/** + * Displays the PHP upgrade nag. + * + * @since 5.0.0 + */ +function wp_dashboard_php_nag() { + $response = wp_check_php_version(); + + if ( ! $response ) { + return; + } + + $information_url = _x( 'https://wordpress.org/support/upgrade-php/', 'localized PHP upgrade information page' ); + + $msg = __( 'Hi, it’s your friends at WordPress here.' ); + if ( ! $response['is_secure'] ) { + $msg .= ' ' . __( 'We noticed that your site is running on an insecure version of PHP, which is why we’re showing you this notice.' ); + } else { + $msg .= ' ' . __( 'We noticed that your site is running on an outdated version of PHP, which is why we’re showing you this notice.' ); + } + + ?> +

+ +

+

+

+ +

+

+

+ +

+ +

+

+

+ array( 'administrator' ), 'update_languages' => array( 'administrator' ), 'deactivate_plugins' => array( 'administrator' ), + 'upgrade_php' => array( 'administrator' ), 'edit_categories' => array( 'administrator', 'editor' ), 'delete_categories' => array( 'administrator', 'editor' ), @@ -267,6 +268,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { 'install_languages' => array(), 'update_languages' => array(), 'deactivate_plugins' => array(), + 'upgrade_php' => array(), 'customize' => array( 'administrator' ), 'delete_site' => array( 'administrator' ),