rest_index хук-фильтр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.

Использование

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.

Список изменений

С версии 4.4.0 Введена.
С версии 6.0.0 Added $request parameter.

Где вызывается хук

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

Где используется хук в WordPress

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