mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +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:
@@ -39,6 +39,14 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
*/
|
||||
protected $password_check_passed = array();
|
||||
|
||||
/**
|
||||
* Whether the controller supports batching.
|
||||
*
|
||||
* @since 5.9.0
|
||||
* @var array
|
||||
*/
|
||||
protected $allow_batch = array( 'v1' => true );
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -80,7 +88,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
'permission_callback' => array( $this, 'create_item_permissions_check' ),
|
||||
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
'allow_batch' => $this->allow_batch,
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -98,7 +107,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<id>[\d]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the post.' ),
|
||||
'type' => 'integer',
|
||||
@@ -128,7 +137,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
),
|
||||
),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
'allow_batch' => $this->allow_batch,
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user