How to Disable Tests in the WordPress Site Health Check Tool

Depending on your server setup, there may be tests in the new WordPress Site Health tool that are not relevant to your site and will never pass. Here is how to disable individual tests so you can get back to 💯

WordPress 5.2 was released yesterday and it introduced a new Site Health Tool in the admin to help site owners with common configuration issues that might cause problems for their site.

These tests were carefully selected based on the recommended configuration for the majority of site owners. However, there are certain situations where the default tests, or tests that have been added by a plugin, may not be relevant to your setup.

Some examples include:

  • Disabling automatic updates because you keep your entire site under version control.
  • Intentionally keeping one or more disabled plugins installed for temporary activation.
  • Running PHP 7.2, which is secure and actively maintained, but your host hasn’t made PHP 7.3 available yet.

In these cases, it would be helpful to exclude those tests, but still allow the other tests to run so you’ll be aware of any issues with your site. This is especially helpful for people who have clients that might get concerned when viewing this page and seeing a “failing” test.

Note: I do not encourage you to disable tests unless you have a valid reason for doing so. If a tests shows a Critical Issue or Recommended Improvement, and you don’t understand why, I encourage you to ask for help on the support forums, or from your hosting provider.

Site Health Tool Manager Plugin

The easiest option is to use a plugin I made called Site Health Tool Manager. It adds a very basic settings screen that allows you to uncheck individual tests that you don’t want to run.

The Site Health Tool Manager settings screen

I have a couple more features I’d like to add to the plugin, such as limiting Site Health Tool access to only certain users, but it’s intentionally pretty simple.

The nice thing about this plugin method is that it will also identify any tests registered by other plugins and allow you to disable those as well.

Filtering the Tests Directly

If you’d prefer not to add the plugin—for example if you don’t want to allow the tests to be turned back on—you can do it directly using a tiny bit of code in an MU Plugin or in functions.php in your theme.

This is done through the site_status_tests filter, which is fired on the return from WP_Site_Health::get_tests().

Here is an example that removes the PHP version test:

function prefix_remove_php_test( $tests ) {
	unset( $tests['direct']['php_version'] );
	return $tests;
}
add_filter( 'site_status_tests', 'prefix_remove_php_test' );Code language: PHP (php)

Note that $tests is a multi-dimensional array. It consists of $tests['direct'] and $tests['async']. The direct tests are run in PHP before the Site Health Status screen is loaded, and the async tests are fired via AJAX calls after the page loads.

You’ll need to check the response from WP_Site_Health::get_tests() or view the function in /wp-admin/includes/class-wp-site-health.php directly to figure out which group the test you want to remove resides in, and what its key is.

8 Comments

  1. Thank you, Mr. Earnhardt. I had pesky “critical” errors. No longer.
    I inserted in my functions.php:
    function prefix_remove_rest_availability( $tests ) {
    unset( $tests['direct']['rest_availability'] );
    return $tests;
    }
    add_filter( 'site_status_tests', 'prefix_remove_rest_availability' );

    function prefix_remove_loopback_requests( $tests ) {
    unset( $tests['async']['loopback_requests'] );
    return $tests;
    }
    add_filter( 'site_status_tests', 'prefix_remove_loopback_requests' );

  2. I’m back 🙂

    Apologies, forgot to mention it last time. Great article, Mr. Earnhardt!

    The noted snippet (code) has been extremely useful to us. We incorporated his snippet using the plugin, Code Snippets, a long time ago.

    Since the release of WP 5.6.2, however, vast improvements have been made to WP’s Site Health Tool which has eliminated our need to use it. Have others experienced the same ?

    Cheers!

Comments are closed.