From d2e9cf1f81ae6b52ce66f088223bc0976b9ffb4f Mon Sep 17 00:00:00 2001 From: gziolo Date: Tue, 19 Apr 2022 14:40:09 +0000 Subject: [PATCH] REST API: Respect _fields query arg in preloaded requests Ensures that preloaded request can include a `_fields` query param that asks that only selected response fields are returned. Props jsnajdr, timothyblynjacobs. Fixes #55213. See #55567. Built from https://develop.svn.wordpress.org/trunk@53217 git-svn-id: http://core.svn.wordpress.org/trunk@52806 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 941aa25f12..13666c0dfc 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -2868,12 +2868,12 @@ function rest_preload_api_request( $memo, $path ) { $response = rest_do_request( $request ); if ( 200 === $response->status ) { $server = rest_get_server(); + /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ + $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $server, $request ); $embed = $request->has_param( '_embed' ) ? rest_parse_embed_param( $request['_embed'] ) : false; $data = (array) $server->response_to_data( $response, $embed ); if ( 'OPTIONS' === $method ) { - $response = rest_send_allow_header( $response, $server, $request ); - $memo[ $method ][ $path ] = array( 'body' => $data, 'headers' => $response->headers, diff --git a/wp-includes/version.php b/wp-includes/version.php index dd0d29c5bf..57b40480c4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-beta1-53216'; +$wp_version = '6.0-beta1-53217'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.