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/class-wp-rest-server.php

    r51962 r52068  
    14041404        );
    14051405
     1406        $allow_batch = false;
     1407
    14061408        if ( isset( $this->route_options[ $route ] ) ) {
    14071409            $options = $this->route_options[ $route ];
     
    14101412                $data['namespace'] = $options['namespace'];
    14111413            }
     1414
     1415            $allow_batch = isset( $options['allow_batch'] ) ? $options['allow_batch'] : false;
    14121416
    14131417            if ( isset( $options['schema'] ) && 'help' === $context ) {
     
    14301434                'methods' => array_keys( $callback['methods'] ),
    14311435            );
     1436
     1437            $callback_batch = isset( $callback['allow_batch'] ) ? $callback['allow_batch'] : $allow_batch;
     1438
     1439            if ( $callback_batch ) {
     1440                $endpoint_data['allow_batch'] = $callback_batch;
     1441            }
    14321442
    14331443            if ( isset( $callback['args'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.