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