Skip to content

Commit

Permalink
Improve compatiblity with WordPress 5.9 (#36372)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey authored Nov 11, 2021
1 parent ccd8f80 commit ab7e8aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions lib/class-wp-rest-menu-items-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
* @see WP_REST_Posts_Controller
*/
class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {

/**
* Constructor.
* Whether the controller supports batching.
*
* @param string $post_type Post type.
* @since 5.9.0
* @var array
*/
public function __construct( $post_type ) {
parent::__construct( $post_type );
$this->namespace = 'wp/v2';
}
protected $allow_batch = array( 'v1' => true );

/**
* Overrides the route registration to support "allow_batch".
Expand All @@ -44,7 +43,7 @@ public function register_routes() {
'permission_callback' => array( $this, 'create_item_permissions_check' ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
),
'allow_batch' => array( 'v1' => true ),
'allow_batch' => $this->allow_batch,
'schema' => array( $this, 'get_public_item_schema' ),
)
);
Expand Down Expand Up @@ -93,7 +92,7 @@ public function register_routes() {
),
),
),
'allow_batch' => array( 'v1' => true ),
'allow_batch' => $this->allow_batch,
'schema' => array( $this, 'get_public_item_schema' ),
)
);
Expand Down
15 changes: 7 additions & 8 deletions lib/class-wp-rest-menus-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
class WP_REST_Menus_Controller extends WP_REST_Terms_Controller {

/**
* Constructor.
* Whether the controller supports batching.
*
* @param string $taxonomy Taxonomy key.
* @since 5.9.0
* @var array
*/
public function __construct( $taxonomy ) {
parent::__construct( $taxonomy );
$this->namespace = 'wp/v2';
}
protected $allow_batch = array( 'v1' => true );

/**
* Overrides the route registration to support "allow_batch".
Expand All @@ -47,7 +45,8 @@ public function register_routes() {
'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' ),
)
);

Expand Down Expand Up @@ -87,7 +86,7 @@ public function register_routes() {
),
),
),
'allow_batch' => array( 'v1' => true ),
'allow_batch' => $this->allow_batch,
'schema' => array( $this, 'get_public_item_schema' ),
)
);
Expand Down

0 comments on commit ab7e8aa

Please sign in to comment.