mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-07 14:14:36 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@53217 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user