rest_index
Filter HookDescription
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.Hook Information
File Location |
wp-includes/rest-api/class-wp-rest-server.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1421 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_REST_Response
|
$response
|
Response data. |
WP_REST_Request
|
$request
|
Request data. |
Usage Examples
Basic Usage
<?php
// Hook into rest_index
add_filter('rest_index', 'my_custom_filter', 10, 2);
function my_custom_filter($response, $request) {
// Your custom filtering logic here
return $response;
}
Source Code Context
wp-includes/rest-api/class-wp-rest-server.php:1421
- How this hook is used in WordPress core
<?php
1416 * @since 6.0.0 Added `$request` parameter.
1417 *
1418 * @param WP_REST_Response $response Response data.
1419 * @param WP_REST_Request $request Request data.
1420 */
1421 return apply_filters( 'rest_index', $response, $request );
1422 }
1423
1424 /**
1425 * Adds a link to the active theme for users who have proper permissions.
1426 *
PHP Documentation
<?php
/**
* 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.
*
* @since 4.4.0
* @since 6.0.0 Added `$request` parameter.
*
* @param WP_REST_Response $response Response data.
* @param WP_REST_Request $request Request data.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/rest-api/class-wp-rest-server.php
Related Hooks
Related hooks will be displayed here in future updates.