wppaste
WordPress

apply_filters( 'site_status_tests', array[] $tests )

Since
5.2.0, 5.6.0
Filters which site status tests are run on a site.

Description

The site health is determined by a set of tests based on best practices from both the WordPress Hosting Team and web standards in general.

Some sites may not have the same requirements, for example the automatic update checks may be handled by a host, and are therefore disabled in core.
Or maybe you want to introduce a new test, is caching enabled/disabled/stale for example.

Tests may be added either as direct, or asynchronous ones. Any test that may require some time to complete should run asynchronously, to avoid extended loading periods within wp-admin.

Compatibility

WordPress
since 5.6.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$testsarray[]
{ An associative array of direct and asynchronous tests.
@type array[] $direct { An array of direct tests.
@type array ...$identifier { $identifier should be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests.
@type string $label The friendly label to identify the test.
@type callable $test The callback function that runs the test and returns its result.
@type bool $skip_cron Whether to skip this test when running as cron.
} } @type array[] $async { An array of asynchronous tests.
@type array ...$identifier { $identifier should be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests.
@type string $label The friendly label to identify the test.
@type string $test An admin-ajax.php action to be called to perform the test, or if $has_rest is true, a URL to a REST API endpoint to perform the test.
@type bool $has_rest Whether the $test property points to a REST API endpoint.
@type bool $skip_cron Whether to skip this test when running as cron.
@type callable $async_direct_test A manner of directly calling the test marked as asynchronous, as the scheduled event can not authenticate, and endpoints may require authentication.
} } }
  • $directarray[]

    An array of direct tests.
    • ...$identifierarray

      $identifier should be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests.
      • $labelstring

        The friendly label to identify the test.
      • $testcallable

        The callback function that runs the test and returns its result.
      • $skip_cronbool

        Whether to skip this test when running as cron. } } @type array[] $async { An array of asynchronous tests.
      • ...$identifierarray

        $identifier should be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests.
        • $labelstring

          The friendly label to identify the test.
        • $teststring

          An admin-ajax.php action to be called to perform the test, or if $has_rest is true, a URL to a REST API endpoint to perform the test.
        • $has_restbool

          Whether the $test property points to a REST API endpoint.
        • $skip_cronbool

          Whether to skip this test when running as cron.
        • $async_direct_testcallable

          A manner of directly calling the test marked as asynchronous, as the scheduled event can not authenticate, and endpoints may require authentication. }

Where this hook fires · 1

  • wp-admin/includes/class-wp-site-health.php:2885WP_Site_Health::get_tests()

Source code

		 *                                               as the scheduled event can not authenticate, and endpoints		 *                                               may require authentication.		 *         }		 *     }		 * }		 */		$tests = apply_filters( 'site_status_tests', $tests ); 		// Ensure that the filtered tests contain the required array keys.		$tests = array_merge(			array(				'direct' => array(),				'async'  => array(),

Changelog

Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.6.0
Added the async_direct_test array key for asynchronous tests.
Added the skip_cron array key for all tests.from the docblock
5.2.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.