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:
parent
e254c02be5
commit
c9d23006db
|
@ -1187,7 +1187,8 @@ a.rsswidget {
|
|||
padding-left: 6px;
|
||||
}
|
||||
|
||||
#dashboard_php_nag.php-insecure .dashicons-warning {
|
||||
#dashboard_php_nag.php-no-security-updates .dashicons-warning,
|
||||
#dashboard_php_nag.php-version-lower-than-future-minimum .dashicons-warning {
|
||||
color: #d63638;
|
||||
}
|
||||
|
||||
|
@ -1199,14 +1200,15 @@ a.rsswidget {
|
|||
margin: 12px 0;
|
||||
}
|
||||
|
||||
#dashboard_php_nag h3 {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#dashboard_php_nag .button .dashicons-external {
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
.bigger-bolder-text {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* =Media Queries
|
||||
-------------------------------------------------------------- */
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1186,7 +1186,8 @@ a.rsswidget {
|
|||
padding-right: 6px;
|
||||
}
|
||||
|
||||
#dashboard_php_nag.php-insecure .dashicons-warning {
|
||||
#dashboard_php_nag.php-no-security-updates .dashicons-warning,
|
||||
#dashboard_php_nag.php-version-lower-than-future-minimum .dashicons-warning {
|
||||
color: #d63638;
|
||||
}
|
||||
|
||||
|
@ -1198,14 +1199,15 @@ a.rsswidget {
|
|||
margin: 12px 0;
|
||||
}
|
||||
|
||||
#dashboard_php_nag h3 {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#dashboard_php_nag .button .dashicons-external {
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
.bigger-bolder-text {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* =Media Queries
|
||||
-------------------------------------------------------------- */
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -741,7 +741,7 @@ class WP_Site_Health {
|
|||
'<p>%s</p>',
|
||||
sprintf(
|
||||
/* 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’s performance. The minimum recommended version of PHP is %s.' ),
|
||||
__( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site’s performance. The minimum recommended version of PHP is %s.' ),
|
||||
$response ? $response['recommended_version'] : ''
|
||||
)
|
||||
),
|
||||
|
@ -764,7 +764,7 @@ class WP_Site_Health {
|
|||
if ( $response['is_supported'] ) {
|
||||
$result['label'] = sprintf(
|
||||
/* translators: %s: The server PHP version. */
|
||||
__( 'Your site is running an older version of PHP (%s)' ),
|
||||
__( 'Your site is running on an older version of PHP (%s)' ),
|
||||
PHP_VERSION
|
||||
);
|
||||
$result['status'] = 'recommended';
|
||||
|
@ -772,11 +772,28 @@ class WP_Site_Health {
|
|||
return $result;
|
||||
}
|
||||
|
||||
// The PHP version is still receiving security fixes, but is lower than
|
||||
// the expected minimum version that will be required by WordPress in the near future.
|
||||
if ( $response['is_secure'] && $response['is_lower_than_future_minimum'] ) {
|
||||
// The `is_secure` array key name doesn't actually imply this is a secure version of PHP. It only means it receives security updates.
|
||||
|
||||
$result['label'] = sprintf(
|
||||
/* translators: %s: The server PHP version. */
|
||||
__( 'Your site is running on an outdated version of PHP (%s), which soon will not be supported by WordPress.' ),
|
||||
PHP_VERSION
|
||||
);
|
||||
|
||||
$result['status'] = 'critical';
|
||||
$result['badge']['label'] = __( 'Requirements' );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// The PHP version is only receiving security fixes.
|
||||
if ( $response['is_secure'] ) {
|
||||
$result['label'] = sprintf(
|
||||
/* translators: %s: The server PHP version. */
|
||||
__( 'Your site is running an older version of PHP (%s), which should be updated' ),
|
||||
__( 'Your site is running on an older version of PHP (%s), which should be updated' ),
|
||||
PHP_VERSION
|
||||
);
|
||||
$result['status'] = 'recommended';
|
||||
|
@ -784,13 +801,25 @@ class WP_Site_Health {
|
|||
return $result;
|
||||
}
|
||||
|
||||
// Anything no longer secure must be updated.
|
||||
$result['label'] = sprintf(
|
||||
// No more security updates for the PHP version, and lower than the expected minimum version required by WordPress.
|
||||
if ( $response['is_lower_than_future_minimum'] ) {
|
||||
$message = sprintf(
|
||||
/* translators: %s: The server PHP version. */
|
||||
__( 'Your site is running an outdated version of PHP (%s), which requires an update' ),
|
||||
__( '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.' ),
|
||||
PHP_VERSION
|
||||
);
|
||||
} else {
|
||||
// No more security updates for the PHP version, must be updated.
|
||||
$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
|
||||
);
|
||||
}
|
||||
|
||||
$result['label'] = $message;
|
||||
$result['status'] = 'critical';
|
||||
|
||||
$result['badge']['label'] = __( 'Security' );
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -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();
|
||||
|
||||
/* 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,15 +39,20 @@ 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' )
|
||||
) {
|
||||
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' );
|
||||
|
||||
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.
|
||||
if ( current_user_can( 'view_site_health_checks' ) && ! is_network_admin() ) {
|
||||
|
@ -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 an insecure version of PHP (%s), which should be updated.' ),
|
||||
__( '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 {
|
||||
$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 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 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 {
|
||||
$message = sprintf(
|
||||
/* translators: %s: The server PHP version. */
|
||||
__( '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’s performance.' ); ?>
|
||||
<?php
|
||||
if ( ! empty( $response['recommended_version'] ) ) {
|
||||
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’s performance. The minimum recommended version of PHP is %s.' ),
|
||||
$response ? $response['recommended_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;
|
||||
|
|
|
@ -1585,7 +1585,8 @@ function wp_check_php_version() {
|
|||
* 'recommended_version' - string - The PHP version recommended by WordPress.
|
||||
* 'is_supported' - boolean - Whether the PHP version is actively supported.
|
||||
* 'is_secure' - boolean - Whether the PHP version receives security updates.
|
||||
* 'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress.
|
||||
* 'is_acceptable' - boolean - Whether the PHP version is still acceptable or warnings
|
||||
* should be shown and an update recommended.
|
||||
*/
|
||||
$response = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
|
@ -1613,5 +1614,15 @@ function wp_check_php_version() {
|
|||
$response['is_acceptable'] = (bool) apply_filters( 'wp_is_php_version_acceptable', true, $version );
|
||||
}
|
||||
|
||||
$response['is_lower_than_future_minimum'] = false;
|
||||
|
||||
// The minimum supported PHP version will be updated to 7.2. Check if the current version is lower.
|
||||
if ( version_compare( $version, '7.2', '<' ) ) {
|
||||
$response['is_lower_than_future_minimum'] = true;
|
||||
|
||||
// Force showing of warnings.
|
||||
$response['is_acceptable'] = false;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.1-alpha-54168';
|
||||
$wp_version = '6.1-alpha-54169';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue