Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_pre_echo_response

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
508                 * Allows modification of the response data after inserting
509                 * embedded data (if any) and before echoing the response data.
510                 *
511                 * @since 4.8.1
512                 *
513                 * @param array            $result  Response data to send to the client.
514                 * @param WP_REST_Server   $server  Server instance.
515                 * @param WP_REST_Request  $request Request used to generate the response.
516                 */
517                $result = apply_filters( 'rest_pre_echo_response', $result, $this, $request );
518
519                // The 204 response shouldn't have a body.
520                if ( 204 === $code || null === $result ) {
521                     return null;
522                }
523
524                $result = wp_json_encode( $result, $this->get_json_encode_options( $request ) );
525
526                $json_error_message = $this->get_json_last_error();