wppaste
WordPress

apply_filters( 'rest_pre_serve_request', bool $served, WP_HTTP_Response $result, WP_REST_Request $request, WP_REST_Server $server )

Since
4.4.0
Filters whether the REST API request has already been served.

Description

Allow sending the request manually - by returning true, the API result will not be sent to the client.

Parameters

$servedbool
Whether the request has already been served.
Default false.
$resultWP_HTTP_Response
Result to send to the client. Usually a WP_REST_Response.
$requestWP_REST_Request
Request used to generate the response.
$serverWP_REST_Server
Server instance.

Fired at · 1

  • wp-includes/rest-api/class-wp-rest-server.php:521WP_REST_Server::serve_request()

Source

		 * @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   $server  Server instance.		 */		$served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); 		if ( ! $served ) {			if ( 'HEAD' === $request->get_method() ) {				return null;			}

History

Introduced in 4.4.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.