Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_pre_serve_request

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
482            *
483            * @since 4.4.0
484            *
485            * @param bool             $served  Whether the request has already been served.
486            *                                           Default false.
487            * @param WP_HTTP_Response $result  Result to send to the client. Usually a `WP_REST_Response`.
488            * @param WP_REST_Request  $request Request used to generate the response.
489            * @param WP_REST_Server   $this    Server instance.
490            */
491           $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
492
493           if ( ! $served ) {
494                if ( 'HEAD' === $request->get_method() ) {
495                     return null;
496                }
497
498                // Embed links inside the request.
499                $embed  = isset( $_GET['_embed'] ) ? rest_parse_embed_param( $_GET['_embed'] ) : false;
500                $result = $this->response_to_data( $result, $embed );