WordPress at a glance
function is not described

rest_api_loaded() WP 4.4.0

Loads the REST API.

  • Global. WP. $wp Current WordPress environment instance.

No Hooks.

Return

Nothing (null).

Usage

rest_api_loaded();

Code of rest api loaded: wp-includes/rest-api.php VER 5.1.1

<?php
function rest_api_loaded() {
	if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
		return;
	}

	/**
	 * Whether this is a REST Request.
	 *
	 * @since 4.4.0
	 * @var bool
	 */
	define( 'REST_REQUEST', true );

	// Initialize the server.
	$server = rest_get_server();

	// Fire off the request.
	$route = untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] );
	if ( empty( $route ) ) {
		$route = '/';
	}
	$server->serve_request( $route );

	// We're done.
	die();
}