rest_api_loaded() WordPress Function
The rest_api_loaded() function is a WordPress function that is called when the REST API is loaded. This function is used to initialize the REST API.
rest_api_loaded() #
Loads the REST API.
Source
File: wp-includes/rest-api.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();
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |