woocommerce_rest_api_cached_headers
Filter the list of response header names to cache.
Usage
add_filter( 'woocommerce_rest_api_cached_headers', 'wp_kama_woocommerce_rest_api_cached_headers_filter', 10, 6 );
/**
* Function for `woocommerce_rest_api_cached_headers` filter-hook.
*
* @param array $cached_header_names Candidate list of header names to cache.
* @param array $all_header_names All header names available in the response.
* @param WP_REST_Request $request The request object.
* @param WP_REST_Response $response The response object.
* @param string|null $endpoint_id Optional friendly identifier for the endpoint.
* @param object $controller The controller instance.
*
* @return array
*/
function wp_kama_woocommerce_rest_api_cached_headers_filter( $cached_header_names, $all_header_names, $request, $response, $endpoint_id, $controller ){
// filter...
return $cached_header_names;
}
- $cached_header_names(array)
- Candidate list of header names to cache.
- $all_header_names(array)
- All header names available in the response.
- $request(WP_REST_Request)
- The request object.
- $response(WP_REST_Response)
- The response object.
- $endpoint_id(string|null)
- Optional friendly identifier for the endpoint.
- $controller(object)
- The controller instance.
Changelog
| Since 10.5.0 | Introduced. |
Where the hook is called
woocommerce_rest_api_cached_headers
woocommerce/src/Internal/Traits/RestApiCache.php 832-840
$filtered_header_names = apply_filters( 'woocommerce_rest_api_cached_headers', $cached_header_names, $all_header_names, $request, $response, $endpoint_id, $this );