Site Health: Introduce the WP_Site_Health::is_development_environment() method.

This allows Site Health tests to check if the current environment type is set to `development` or `local`.

Use the new method:
* In HTTPS tests, instead of a hardcoded check for `localhost`.
* In `WP_DEBUG` and `WP_DEBUG_DISPLAY` tests, to set the status to `recommended` instead of `critical`.

Props dkotter, Clorith, DavidAnderson, joyously, knutsp, afragen, SergeyBiryukov.
Fixes #47058.
Built from https://develop.svn.wordpress.org/trunk@49237


git-svn-id: http://core.svn.wordpress.org/trunk@48999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-10-20 16:23:07 +00:00
parent 173b9aa122
commit 35681b0e9a
2 changed files with 22 additions and 5 deletions

View File

@ -106,8 +106,8 @@ class WP_Site_Health {
if ( 'site-health' === $screen->id && ! isset( $_GET['tab'] ) ) {
$tests = WP_Site_Health::get_tests();
// Don't run https test on localhost.
if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) {
// Don't run https test on development environments.
if ( $this->is_development_environment() ) {
unset( $tests['direct']['https_status'] );
}
@ -1465,6 +1465,11 @@ class WP_Site_Health {
$result['status'] = 'critical';
// On development environments, set the status to recommended.
if ( $this->is_development_environment() ) {
$result['status'] = 'recommended';
}
$result['description'] .= sprintf(
'<p>%s</p>',
sprintf(
@ -2531,8 +2536,8 @@ class WP_Site_Health {
'critical' => 0,
);
// Don't run https test on localhost.
if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) {
// Don't run https test on development environments.
if ( $this->is_development_environment() ) {
unset( $tests['direct']['https_status'] );
}
@ -2615,4 +2620,16 @@ class WP_Site_Health {
set_transient( 'health-check-site-status-result', wp_json_encode( $site_status ) );
}
/**
* Checks if the current environment type is set to 'development' or 'local'.
*
* @since 5.6.0
*
* @return bool True if it is a development environment, false if not.
*/
public function is_development_environment() {
return in_array( wp_get_environment_type(), array( 'development', 'local' ), true );
}
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-49236';
$wp_version = '5.6-alpha-49237';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.