rest_pre_echo_response
Filters the REST API response.
Allows modification of the response data after inserting embedded data (if any) and before echoing the response data.
Usage
add_filter( 'rest_pre_echo_response', 'wp_kama_rest_pre_echo_response_filter', 10, 3 ); /** * Function for `rest_pre_echo_response` filter-hook. * * @param array $result Response data to send to the client. * @param WP_REST_Server $server Server instance. * @param WP_REST_Request $request Request used to generate the response. * * @return array */ function wp_kama_rest_pre_echo_response_filter( $result, $server, $request ){ // filter... return $result; }
- $result(array)
- Response data to send to the client.
- $server(WP_REST_Server)
- Server instance.
- $request(WP_REST_Request)
- Request used to generate the response.
Changelog
Since 4.8.1 | Introduced. |
Where the hook is called
rest_pre_echo_response
wp-includes/rest-api/class-wp-rest-server.php 538
$result = apply_filters( 'rest_pre_echo_response', $result, $this, $request );