wphooks.info - rest_pre_serve_request

rest_pre_serve_request

(trunk - 5.1-alpha-44286)

The hook occurs in the following file:

wp-includes/rest-api/class-wp-rest-server.php:
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
		 * will not be sent to the client.
		 *
		 * @since 4.4.0
		 *
		 * @param bool             $served  Whether the request has already been served.
		 *                                           Default false.
		 * @param WP_HTTP_Response $result  Result to send to the client. Usually a WP_REST_Response.
		 * @param WP_REST_Request  $request Request used to generate the response.
		 * @param WP_REST_Server   $this    Server instance.
		 */
		$served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );

		if ( ! $served ) {
			if ( 'HEAD' === $request->get_method() ) {
				return null;
			}

			// Embed links inside the request.
			$result = $this->response_to_data( $result, isset( $_GET['_embed'] ) );