Site health:

- Add a check to `wp_check_php_version()` whether the current PHP version is lower than the next (desired) minimum version.
- Set the next desired minimum PHP version to 7.2.
- Use that check to update the warnings in the `wp_dashboard_php_nag()` widget, and on the Site Health screen.

Props Clorith, SergeyBiryukov, ironprogrammer, azaozz.
See #56199.
Built from https://develop.svn.wordpress.org/trunk@54169


git-svn-id: http://core.svn.wordpress.org/trunk@53728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz
2022-09-14 22:19:14 +00:00
parent e254c02be5
commit c9d23006db
8 changed files with 123 additions and 48 deletions

View File

@@ -20,17 +20,18 @@
function wp_dashboard_setup() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
$screen = get_current_screen();
/* Register Widgets and Controls */
$wp_dashboard_control_callbacks = array();
$response = wp_check_browser_version();
// Browser version
$check_browser = wp_check_browser_version();
if ( $response && $response['upgrade'] ) {
if ( $check_browser && $check_browser['upgrade'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
if ( $response['insecure'] ) {
if ( $check_browser['insecure'] ) {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
} else {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
@@ -38,14 +39,19 @@ function wp_dashboard_setup() {
}
// PHP Version.
$response = wp_check_php_version();
$check_php = wp_check_php_version();
if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable']
&& current_user_can( 'update_php' )
) {
add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
if ( $check_php && current_user_can( 'update_php' ) ) {
// If "not acceptable" the widget will be shown.
if ( isset( $check_php['is_acceptable'] ) && ! $check_php['is_acceptable'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' );
if ( $check_php['is_lower_than_future_minimum'] ) {
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
} else {
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' );
}
}
}
// Site Health.
@@ -1825,29 +1831,48 @@ function wp_dashboard_php_nag() {
}
if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$msg = sprintf(
// The `is_secure` array key name doesn't actually imply this is a secure version of PHP. It only means it receives security updates.
if ( $response['is_lower_than_future_minimum'] ) {
$message = sprintf(
/* translators: %s: The server PHP version. */
__( '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.' ),
PHP_VERSION
);
} else {
$message = sprintf(
/* translators: %s: The server PHP version. */
__( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates. It should be updated.' ),
PHP_VERSION
);
}
} elseif ( $response['is_lower_than_future_minimum'] ) {
$message = sprintf(
/* translators: %s: The server PHP version. */
__( 'Your site is running an insecure version of PHP (%s), which should be updated.' ),
__( '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.' ),
PHP_VERSION
);
} else {
$msg = sprintf(
$message = sprintf(
/* translators: %s: The server PHP version. */
__( 'Your site is running an outdated version of PHP (%s), which should be updated.' ),
__( 'Your site is running on an outdated version of PHP (%s), which should be updated.' ),
PHP_VERSION
);
}
?>
<p><?php echo $msg; ?></p>
<p class="bigger-bolder-text"><?php echo $message; ?></p>
<h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
<p><?php _e( 'What is PHP and how does it affect my site?' ); ?></p>
<p>
<?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.' ); ?>
<?php
printf(
/* translators: %s: The minimum recommended PHP version. */
__( '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.' ),
$response ? $response['recommended_version'] : ''
);
if ( ! empty( $response['recommended_version'] ) ) {
printf(
/* translators: %s: The minimum recommended PHP version. */
__( 'The minimum recommended version of PHP is %s.' ),
$response['recommended_version']
);
}
?>
</p>
@@ -1879,8 +1904,14 @@ function wp_dashboard_php_nag() {
function dashboard_php_nag_class( $classes ) {
$response = wp_check_php_version();
if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$classes[] = 'php-insecure';
if ( ! $response ) {
return $classes;
}
if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$classes[] = 'php-no-security-updates';
} elseif ( $response['is_lower_than_future_minimum'] ) {
$classes[] = 'php-version-lower-than-future-minimum';
}
return $classes;