rest_url

Filters the REST URL.

Description

apply_filters( 'rest_url', (string) $url, (string) $path, (int) $blog_id, (string) $scheme ); 

Use this filter to adjust the url returned by the get_rest_url() function.

Parameters (4)

0. $url (string)
REST URL.
1. $path (string)
REST route.
2. $blog_id (int)
The blog id.
3. $scheme (string)
Sanitization scheme.

Usage

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

Defined (1)

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

/wp-includes/rest-api.php  
  1. return apply_filters( 'rest_url', $url, $path, $blog_id, $scheme );