rest_pre_serve_request

The WordPress Core rest pre serve request hook.

Description

add_filter( 'rest_pre_serve_request', (string) $oembed_rest_pre_serve_request, (int) $int, (int) $int ); 

Parameters (3)

0. $oembed_rest_pre_serve_request (string) => '_oembed_rest_pre_serve_request'
The oembed rest pre serve request.
1. $int (int) => 10
The int.
2. $int (int) => 4
The int.

Usage

To run the hook, copy the example below.
  1. $oembed_rest_pre_serve_request = apply_filters( 'rest_pre_serve_request', $oembed_rest_pre_serve_request, $int, $int ); 
  2.  
  3. if ( !empty( $oembed_rest_pre_serve_request ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the rest_pre_serve_request callback 
  2. function filter_rest_pre_serve_request( $oembed_rest_pre_serve_request, $int, $int ) { 
  3. // make filter magic happen here... 
  4. return $oembed_rest_pre_serve_request
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'rest_pre_serve_request', 'filter_rest_pre_serve_request', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'rest_pre_serve_request', 'filter_rest_pre_serve_request', 10, 3 ); 

Defined (3)

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

/wp-includes/default-filters.php  
  1. add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); 
/wp-includes/rest-api/class-wp-rest-server.php  
  1. $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); 
/wp-includes/rest-api.php  
  1. add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );