site_status_tests WordPress Filter Hook

The site_status_tests hook is called during the WordPress bootstrap process. It is used to test whether a site is able to connect to the WordPress database and whether the current theme is compatible with the installed version of WordPress.

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

Add or modify 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.


Top ↑

Parameters

$tests

(array[])An associative array of direct and asynchronous tests.

  • 'direct'
    (array[]) An array of direct tests.
    • '...$identifier'
      (array) $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.
      • 'label'
        (string) The friendly label to identify the test.
      • 'test'
        (callable) The callback function that runs the test and returns its result.
      • 'skip_cron'
        (bool) Whether to skip this test when running as cron. }
    • 'async'
      (array[]) An array of asynchronous tests.
      • '...$identifier'
        (array) $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.
        • 'label'
          (string) The friendly label to identify the test.
        • 'test'
          (string) 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_rest'
          (bool) Whether the $test property points to a REST API endpoint.
        • 'skip_cron'
          (bool) Whether to skip this test when running as cron.
        • 'async_direct_test'
          (callable) A manner of directly calling the test marked as asynchronous, as the scheduled event can not authenticate, and endpoints may require authentication. }


Top ↑

Source

File: wp-admin/includes/class-wp-site-health.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.6.0Added the async_direct_test array key for asynchronous tests. Added the skip_cron array key for all tests.
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.