WP_REST_Site_Health_Controller
- Since
- 5.6.0
- Source
wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php:17
Core class for interacting with Site Health tests.
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).
Hooks and filters fired · 1
Every hook that fires from inside WP_REST_Site_Health_Controller, in the order it appears in the class, grouped by the method that fires it.
Properties · 1
$site_healthWP_Site_Healthprivate- An instance of the site health class.
Methods · 12
- __construct()Site Health controller constructor.
- register_routes()Registers API routes.
- validate_request_permission()Validates if the current user can request this REST endpoint.
- test_background_updates()Checks if background updates work as expected.
- test_dotorg_communication()Checks that the site can reach the WordPress.org API.
- test_loopback_requests()Checks that loopbacks can be performed.
- test_https_status()Checks that the site's frontend can be accessed over HTTPS.
- test_authorization_header()Checks that the authorization header is valid.
- test_page_cache()Checks that full page cache is active.
- get_directory_sizes()Gets the current directory sizes for this install.
- load_admin_textdomain()Loads the admin textdomain for Site Health tests.
- get_item_schema()Gets the schema for each site health test.
Source code
class WP_REST_Site_Health_Controller extends WP_REST_Controller { /** * An instance of the site health class. * * @since 5.6.0 * * @var WP_Site_Health */ private $site_health; /** * Site Health controller constructor. * * @since 5.6.0 * * @param WP_Site_Health $site_health An instance of the site health class. */ public function __construct( $site_health ) { $this->namespace = 'wp-site-health/v1'; $this->rest_base = 'tests'; $this->site_health = $site_health; } /** * Registers API routes. * * @since 5.6.0 * @since 6.1.0 Adds page-cache async test. * * @see register_rest_route() */ public function register_routes() { register_rest_route( $this->namespace, sprintf( '/%s/%s', $this->rest_base, 'background-updates' ), array( array( 'methods' => 'GET', 'callback' => array( $this, 'test_background_updates' ), 'permission_callback' => function () { return $this->validate_request_permission( 'background_updates' ); }, ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, sprintf( '/%s/%s', $this->rest_base, 'loopback-requests' ), array( array( 'methods' => 'GET', 'callback' => array( $this, 'test_loopback_requests' ), 'permission_callback' => function () { return $this->validate_request_permission( 'loopback_requests' ); }, ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, sprintf( '/%s/%s', $this->rest_base, 'https-status' ), array(Changelog
Introduced in 5.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php, 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.