rest_exposed_cors_headers
Filter HookDescription
Filters the list of response headers that are exposed to REST API CORS requests.Hook Information
File Location |
wp-includes/rest-api/class-wp-rest-server.php
View on GitHub
|
Hook Type | Filter |
Line Number | 406 |
Hook Parameters
Type | Name | Description |
---|---|---|
string[]
|
$expose_headers
|
The list of response headers to expose. |
WP_REST_Request
|
$request
|
The request in context. |
Usage Examples
Basic Usage
<?php
// Hook into rest_exposed_cors_headers
add_filter('rest_exposed_cors_headers', 'my_custom_filter', 10, 2);
function my_custom_filter($expose_headers, $request) {
// Your custom filtering logic here
return $expose_headers;
}
Source Code Context
wp-includes/rest-api/class-wp-rest-server.php:406
- How this hook is used in WordPress core
<?php
401 * @since 6.3.0 The `$request` parameter was added.
402 *
403 * @param string[] $expose_headers The list of response headers to expose.
404 * @param WP_REST_Request $request The request in context.
405 */
406 $expose_headers = apply_filters( 'rest_exposed_cors_headers', $expose_headers, $request );
407
408 $this->send_header( 'Access-Control-Expose-Headers', implode( ', ', $expose_headers ) );
409
410 $allow_headers = array(
411 'Authorization',
PHP Documentation
<?php
/**
* Filters the list of response headers that are exposed to REST API CORS requests.
*
* @since 5.5.0
* @since 6.3.0 The `$request` parameter was added.
*
* @param string[] $expose_headers The list of response headers to expose.
* @param WP_REST_Request $request The request in context.
*/
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.