mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@52068 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1403,6 +1403,8 @@ class WP_REST_Server {
|
||||
'endpoints' => array(),
|
||||
);
|
||||
|
||||
$allow_batch = false;
|
||||
|
||||
if ( isset( $this->route_options[ $route ] ) ) {
|
||||
$options = $this->route_options[ $route ];
|
||||
|
||||
@@ -1410,6 +1412,8 @@ class WP_REST_Server {
|
||||
$data['namespace'] = $options['namespace'];
|
||||
}
|
||||
|
||||
$allow_batch = isset( $options['allow_batch'] ) ? $options['allow_batch'] : false;
|
||||
|
||||
if ( isset( $options['schema'] ) && 'help' === $context ) {
|
||||
$data['schema'] = call_user_func( $options['schema'] );
|
||||
}
|
||||
@@ -1430,6 +1434,12 @@ class WP_REST_Server {
|
||||
'methods' => array_keys( $callback['methods'] ),
|
||||
);
|
||||
|
||||
$callback_batch = isset( $callback['allow_batch'] ) ? $callback['allow_batch'] : $allow_batch;
|
||||
|
||||
if ( $callback_batch ) {
|
||||
$endpoint_data['allow_batch'] = $callback_batch;
|
||||
}
|
||||
|
||||
if ( isset( $callback['args'] ) ) {
|
||||
$endpoint_data['args'] = array();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user