rest_route_data

Filters the publicly-visible data for routes.

Description

apply_filters( 'rest_route_data', (array) $available, (array) $routes ); 

This data is exposed on indexes and can be used by clients or developers to investigate the site and find out how to use it. It acts as a form of self-documentation.

Parameters (2)

0. $available (array)
Map of route to route data.
1. $routes (array)
Internal route data as an associative array.

Usage

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

Defined (1)

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

/wp-includes/rest-api/class-wp-rest-server.php  
  1. return apply_filters( 'rest_route_data', $available, $routes );