rest_exposed_cors_headers
Filters the list of response headers that are exposed to REST API CORS requests.
Использование
add_filter( 'rest_exposed_cors_headers', 'wp_kama_rest_exposed_cors_headers_filter', 10, 2 ); /** * Function for `rest_exposed_cors_headers` filter-hook. * * @param string[] $expose_headers The list of response headers to expose. * @param WP_REST_Request $request The request in context. * * @return string[] */ function wp_kama_rest_exposed_cors_headers_filter( $expose_headers, $request ){ // filter... return $expose_headers; }
- $expose_headers(string[])
- The list of response headers to expose.
- $request(WP_REST_Request)
- The request in context.
Список изменений
С версии 5.5.0 | Введена. |
С версии 6.3.0 | The $request parameter was added. |
Где вызывается хук
rest_exposed_cors_headers
wp-includes/rest-api/class-wp-rest-server.php 406
$expose_headers = apply_filters( 'rest_exposed_cors_headers', $expose_headers, $request );