rest_namespace_index
Filter HookDescription
Filters the REST API namespace index data. This typically is just the route data for the namespace, but you can add any data you'd like here.Hook Information
File Location |
wp-includes/rest-api/class-wp-rest-server.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1555 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_REST_Response
|
$response
|
Response data. |
WP_REST_Request
|
$request
|
Request data. The namespace is passed as the 'namespace' parameter. |
Usage Examples
Basic Usage
<?php
// Hook into rest_namespace_index
add_filter('rest_namespace_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:1555
- How this hook is used in WordPress core
<?php
1550 * @since 4.4.0
1551 *
1552 * @param WP_REST_Response $response Response data.
1553 * @param WP_REST_Request $request Request data. The namespace is passed as the 'namespace' parameter.
1554 */
1555 return apply_filters( 'rest_namespace_index', $response, $request );
1556 }
1557
1558 /**
1559 * Retrieves the publicly-visible data for routes.
1560 *
PHP Documentation
<?php
/**
* Filters the REST API namespace index data.
*
* This typically is just the route data for the namespace, but you can
* add any data you'd like here.
*
* @since 4.4.0
*
* @param WP_REST_Response $response Response data.
* @param WP_REST_Request $request Request data. The namespace is passed as the 'namespace' parameter.
*/
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.