Make WordPress Core


Ignore:
Timestamp:
04/19/2022 02:38:16 PM (2 years ago)
Author:
gziolo
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r53152 r53217  
    28692869    if ( 200 === $response->status ) {
    28702870        $server = rest_get_server();
     2871        /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
     2872        $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $server, $request );
    28712873        $embed  = $request->has_param( '_embed' ) ? rest_parse_embed_param( $request['_embed'] ) : false;
    28722874        $data   = (array) $server->response_to_data( $response, $embed );
    28732875
    28742876        if ( 'OPTIONS' === $method ) {
    2875             $response = rest_send_allow_header( $response, $server, $request );
    2876 
    28772877            $memo[ $method ][ $path ] = array(
    28782878                'body'    => $data,
Note: See TracChangeset for help on using the changeset viewer.