WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 3 times in this file.
| Line | Code |
|---|---|
| 453 | * Allows modification of the response before returning. |
| 454 | * |
| 455 | * @since 4.4.0 |
| 456 | * @since 4.5.0 Applied to embedded responses. |
| 457 | * |
| 458 | * @param WP_HTTP_Response $result Result to send to the client. Usually a `WP_REST_Response`. |
| 459 | * @param WP_REST_Server $server Server instance. |
| 460 | * @param WP_REST_Request $request Request used to generate the response. |
| 461 | */ |
| 462 | $result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $request ); |
| 463 | |
| 464 | // Wrap the response in an envelope if asked for. |
| 465 | if ( isset( $_GET['_envelope'] ) ) { |
| 466 | $embed = isset( $_GET['_embed'] ) ? rest_parse_embed_param( $_GET['_embed'] ) : false; |
| 467 | $result = $this->envelope_response( $result, $embed ); |
| 468 | } |
| 469 | |
| 470 | // Send extra data from response objects. |
| 471 | $headers = $result->get_headers(); |
| Line | Code |
| 752 | $matched = $this->match_request_to_handler( $request ); |
| 753 | if ( ! is_wp_error( $matched ) && isset( $matched[1]['args']['per_page']['maximum'] ) ) { |
| 754 | $request['per_page'] = (int) $matched[1]['args']['per_page']['maximum']; |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | $response = $this->dispatch( $request ); |
| 759 | |
| 760 | /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
| 761 | $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $this, $request ); |
| 762 | |
| 763 | $this->embed_cache[ $item['href'] ] = $this->response_to_data( $response, false ); |
| 764 | } |
| 765 | |
| 766 | $embeds[] = $this->embed_cache[ $item['href'] ]; |
| 767 | } |
| 768 | |
| 769 | // Determine if any real links were found. |
| 770 | $has_links = count( array_filter( $embeds ) ); |
| Line | Code |
| 1786 | array( 'status' => 500 ) |
| 1787 | ); |
| 1788 | } |
| 1789 | |
| 1790 | $result = $this->respond_to_request( $single_request, $route, $handler, $error ); |
| 1791 | } |
| 1792 | } |
| 1793 | |
| 1794 | /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
| 1795 | $result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $single_request ); |
| 1796 | |
| 1797 | $responses[] = $this->envelope_response( $result, false )->get_data(); |
| 1798 | } |
| 1799 | |
| 1800 | return new WP_REST_Response( array( 'responses' => $responses ), WP_Http::MULTI_STATUS ); |
| 1801 | } |
| 1802 | |
| 1803 | /** |
| 1804 | * Sends an HTTP status code. |