rest_post_dispatch
Filters the REST API response.
Allows modification of the response before returning.
Использование
add_filter( 'rest_post_dispatch', 'wp_kama_rest_post_dispatch_filter', 10, 3 ); /** * Function for `rest_post_dispatch` filter-hook. * * @param WP_HTTP_Response $result Result to send to the client. Usually a `WP_REST_Response`. * @param WP_REST_Server $server Server instance. * @param WP_REST_Request $request Request used to generate the response. * * @return WP_HTTP_Response */ function wp_kama_rest_post_dispatch_filter( $result, $server, $request ){ // filter... return $result; }
- $result(WP_HTTP_Response)
- Result to send to the client. Usually a WP_REST_Response.
- $server(WP_REST_Server)
- Server instance.
- $request(WP_REST_Request)
- Request used to generate the response.
Список изменений
С версии 4.4.0 | Введена. |
С версии 4.5.0 | Applied to embedded responses. |
Где вызывается хук
rest_post_dispatch
rest_post_dispatch
rest_post_dispatch
rest_post_dispatch
wp-includes/rest-api/class-wp-rest-server.php 462
$result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $request );
wp-includes/rest-api.php 2961
$response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $server, $request );
wp-includes/rest-api/class-wp-rest-server.php 823
$response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $this, $request );
wp-includes/rest-api/class-wp-rest-server.php 1857
$result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $single_request );
Где используется хук в WordPress
wp-includes/rest-api.php 253
add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 );
wp-includes/rest-api.php 254
add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 );