rest_api_loaded

Loads the REST API.

Description

rest_api_loaded(); 

Usage

  1. if ( !function_exists( 'rest_api_loaded' ) ) { 
  2. require_once ABSPATH . WPINC . '/rest-api.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = rest_api_loaded(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/rest-api.php  
  1. function rest_api_loaded() { 
  2. if ( empty( $GLOBALS[wp]->query_vars['rest_route'] ) ) { 
  3. return; 
  4.  
  5. /** 
  6. * Whether this is a REST Request. 
  7. * @since 4.4.0 
  8. * @var bool 
  9. */ 
  10. define( 'REST_REQUEST', true ); 
  11.  
  12. // Initialize the server. 
  13. $server = rest_get_server(); 
  14.  
  15. // Fire off the request. 
  16. $route = untrailingslashit( $GLOBALS[wp]->query_vars['rest_route'] ); 
  17. if ( empty( $route ) ) { 
  18. $route = '/'; 
  19. $server->serve_request( $route ); 
  20.  
  21. // We're done. 
  22. die();