rest_do_request

Do a REST request.

Description

(WP_REST_Response) rest_do_request( (WP_REST_Request|string) $request ); 

Used primarily to route internal requests through WP_REST_Server.

Returns (WP_REST_Response)

REST response.

Parameters (1)

0. $request (WP_REST_Request|string)
The request.

Usage

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

Defined (1)

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

/wp-includes/rest-api.php  
  1. function rest_do_request( $request ) { 
  2. $request = rest_ensure_request( $request ); 
  3. return rest_get_server()->dispatch( $request );