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 2 times in this file.
Line | Code |
---|---|
335 | * Allows modification of the response before returning. |
336 | * |
337 | * @since 4.4.0 |
338 | * @since 4.5.0 Applied to embedded responses. |
339 | * |
340 | * @param WP_HTTP_Response $result Result to send to the client. Usually a WP_REST_Response. |
341 | * @param WP_REST_Server $this Server instance. |
342 | * @param WP_REST_Request $request Request used to generate the response. |
343 | */ |
344 | $result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $request ); |
345 |
|
346 | // Wrap the response in an envelope if asked for. |
347 | if ( isset( $_GET['_envelope'] ) ) { |
348 | $result = $this->envelope_response( $result, isset( $_GET['_embed'] ) ); |
349 | } |
350 |
|
351 | // Send extra data from response objects. |
352 | $headers = $result->get_headers(); |
353 | $this->send_headers( $headers ); |
Line | Code |
577 |
|
578 | // Embedded resources get passed context=embed. |
579 | if ( empty( $request['context'] ) ) { |
580 | $request['context'] = 'embed'; |
581 | } |
582 |
|
583 | $response = $this->dispatch( $request ); |
584 |
|
585 | /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
586 | $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $this, $request ); |
587 |
|
588 | $embeds[] = $this->response_to_data( $response, false ); |
589 | } |
590 |
|
591 | // Determine if any real links were found. |
592 | $has_links = count( array_filter( $embeds ) ); |
593 |
|
594 | if ( $has_links ) { |
595 | $embedded[ $rel ] = $embeds; |