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
367            *
368            * @since 4.4.0
369            *
370            * @param bool             $served  Whether the request has already been served.
371            *                                           Default false.
372            * @param WP_HTTP_Response $result  Result to send to the client. Usually a WP_REST_Response.
373            * @param WP_REST_Request  $request Request used to generate the response.
374            * @param WP_REST_Server   $this    Server instance.
375            */
376           $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
377
378           if ( ! $served ) {
379                if ( 'HEAD' === $request->get_method() ) {
380                     return null;
381                }
382
383                // Embed links inside the request.
384                $result = $this->response_to_data( $result, isset( $_GET['_embed'] ) );
385