rest_index │ filter-hook │ WP 4.4.0

Filters the REST API root index data.

This contains the data describing the API. This includes information about supported authentication schemes, supported namespaces, routes available on the API, and a small amount of data about the site.

Usage

add_filter( 'rest_index', 'wp_kama_rest_index_filter', 10, 2 );

/**
 * Function for `rest_index` filter-hook.
 * 
 * @param WP_REST_Response $response Response data.
 * @param WP_REST_Request  $request  Request data.
 *
 * @return WP_REST_Response
 */
function wp_kama_rest_index_filter( $response, $request ){
	// filter...
	return $response;
}
$response(WP_REST_Response)
Response data.
$request(WP_REST_Request)
Request data.

Changelog

Since 4.4.0 Introduced.
Since 6.0.0 Added $request parameter.

Where the hook is called

WP_REST_Server::get_index()
rest_index
wp-includes/rest-api/class-wp-rest-server.php 1442
return apply_filters( 'rest_index', $response, $request );

Where the hook is used in WordPress

wp-includes/rest-api.php 257
add_filter( 'rest_index', 'rest_add_application_passwords_to_index' );