rest_request_from_url

Filters the request generated from a URL.

Description

apply_filters( 'rest_request_from_url', (WP_REST_Request|false) $request, (string) $url ); 

Parameters (2)

0. $request (WP_REST_Request|false)
Generated request object, or false if URL could not be parsed.
1. $url (string)
URL the request was generated from.

Usage

To run the hook, copy the example below.
  1. $request = apply_filters( 'rest_request_from_url', $request, $url ); 
  2.  
  3. if ( !empty( $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_request_from_url callback 
  2. function filter_rest_request_from_url( $request, $url ) { 
  3. // make filter magic happen here... 
  4. return $request
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'rest_request_from_url', 'filter_rest_request_from_url', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'rest_request_from_url', 'filter_rest_request_from_url', 10, 2 ); 

Defined (1)

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

/wp-includes/rest-api/class-wp-rest-request.php  
  1. return apply_filters( 'rest_request_from_url', $request, $url );