Make WordPress Core


Ignore:
Timestamp:
11/09/2021 01:57:48 AM (3 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-posts-controller.php

    r51964 r52068  
    3939     */
    4040    protected $password_check_passed = array();
     41
     42    /**
     43     * Whether the controller supports batching.
     44     *
     45     * @since 5.9.0
     46     * @var array
     47     */
     48    protected $allow_batch = array( 'v1' => true );
    4149
    4250    /**
     
    8189                    'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
    8290                ),
    83                 'schema' => array( $this, 'get_public_item_schema' ),
     91                'allow_batch' => $this->allow_batch,
     92                'schema'      => array( $this, 'get_public_item_schema' ),
    8493            )
    8594        );
     
    99108            '/' . $this->rest_base . '/(?P<id>[\d]+)',
    100109            array(
    101                 'args'   => array(
     110                'args'        => array(
    102111                    'id' => array(
    103112                        'description' => __( 'Unique identifier for the post.' ),
     
    129138                    ),
    130139                ),
    131                 'schema' => array( $this, 'get_public_item_schema' ),
     140                'allow_batch' => $this->allow_batch,
     141                'schema'      => array( $this, 'get_public_item_schema' ),
    132142            )
    133143        );
Note: See TracChangeset for help on using the changeset viewer.