diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index fdc3034755..4304881b16 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -466,22 +466,6 @@ class WP_REST_Server { $code = $result->get_status(); $this->set_status( $code ); - /** - * Filters whether the REST API request has already been served. - * - * Allow sending the request manually - by returning true, the API result - * 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 $server Server instance. - */ - $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); - /** * Filters whether to send nocache headers on a REST API request. * @@ -504,6 +488,22 @@ class WP_REST_Server { } } + /** + * Filters whether the REST API request has already been served. + * + * Allow sending the request manually - by returning true, the API result + * 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 $server Server instance. + */ + $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); + if ( ! $served ) { if ( 'HEAD' === $request->get_method() ) { return null;