rest_envelope_response

Filters the enveloped form of a response.

Description

apply_filters( 'rest_envelope_response', (array) $envelope, (WP_REST_Response) $response ); 

Parameters (2)

0. $envelope (array)
Envelope data.
1. $response (WP_REST_Response)
Original response data.

Usage

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

Defined (1)

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

/wp-includes/rest-api/class-wp-rest-server.php  
  1. $envelope = apply_filters( 'rest_envelope_response', $envelope, $response );