WP_REST_Site_Health_Controller::register_routes()publicWP 5.6.0

Registers API routes.

Method of the class: WP_REST_Site_Health_Controller{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_REST_Site_Health_Controller = new WP_REST_Site_Health_Controller();
$WP_REST_Site_Health_Controller->register_routes();

Notes

Changelog

Since 5.6.0 Introduced.
Since 6.1.0 Adds page-cache async test.

WP_REST_Site_Health_Controller::register_routes() code WP 6.4.3

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(
			array(
				'methods'             => 'GET',
				'callback'            => array( $this, 'test_https_status' ),
				'permission_callback' => function () {
					return $this->validate_request_permission( 'https_status' );
				},
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		sprintf(
			'/%s/%s',
			$this->rest_base,
			'dotorg-communication'
		),
		array(
			array(
				'methods'             => 'GET',
				'callback'            => array( $this, 'test_dotorg_communication' ),
				'permission_callback' => function () {
					return $this->validate_request_permission( 'dotorg_communication' );
				},
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		sprintf(
			'/%s/%s',
			$this->rest_base,
			'authorization-header'
		),
		array(
			array(
				'methods'             => 'GET',
				'callback'            => array( $this, 'test_authorization_header' ),
				'permission_callback' => function () {
					return $this->validate_request_permission( 'authorization_header' );
				},
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		sprintf(
			'/%s',
			'directory-sizes'
		),
		array(
			'methods'             => 'GET',
			'callback'            => array( $this, 'get_directory_sizes' ),
			'permission_callback' => function () {
				return $this->validate_request_permission( 'directory_sizes' ) && ! is_multisite();
			},
		)
	);

	register_rest_route(
		$this->namespace,
		sprintf(
			'/%s/%s',
			$this->rest_base,
			'page-cache'
		),
		array(
			array(
				'methods'             => 'GET',
				'callback'            => array( $this, 'test_page_cache' ),
				'permission_callback' => function () {
					return $this->validate_request_permission( 'page_cache' );
				},
			),
		)
	);
}