Make WordPress Core


Ignore:
Timestamp:
11/09/2021 01:57:48 AM (5 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Add batch support for posts and terms controllers.

This also exposes the value of allow_batch in OPTIONS requests to a route.

A future commit will add batch support to more resources.

Props spacedmonkey, chrisvanpatten.
See #53063.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r51964 r52068  
    4848         */
    4949        protected $total_terms;
     50
     51        /**
     52         * Whether the controller supports batching.
     53         *
     54         * @since 5.9.0
     55         * @var array
     56         */
     57        protected $allow_batch = array( 'v1' => true );
    5058
    5159        /**
     
    9098                                        'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
    9199                                ),
    92                                 'schema' => array( $this, 'get_public_item_schema' ),
     100                                'allow_batch' => $this->allow_batch,
     101                                'schema'      => array( $this, 'get_public_item_schema' ),
    93102                        )
    94103                );
     
    98107                        '/' . $this->rest_base . '/(?P<id>[\d]+)',
    99108                        array(
    100                                 'args'   => array(
     109                                'args'        => array(
    101110                                        'id' => array(
    102111                                                'description' => __( 'Unique identifier for the term.' ),
     
    130139                                        ),
    131140                                ),
    132                                 'schema' => array( $this, 'get_public_item_schema' ),
     141                                'allow_batch' => $this->allow_batch,
     142                                'schema'      => array( $this, 'get_public_item_schema' ),
    133143                        )
    134144                );
Note: See TracChangeset for help on using the changeset viewer.