Skip to content

Commit

Permalink
Move WP_REST_Block_Navigation_Areas_Controller from Gutenberg to Core. (
Browse files Browse the repository at this point in the history
#36374)

* Move WP_REST_Block_Navigation_Areas_Controller from Gutenberg to Core.
We have to use /wp/v2 namespace.

* Move WP_REST_Block_Navigation_Areas_Controller from Gutenberg to Core.
We have to use /wp/v2 namespace.

* Enable batching.
  • Loading branch information
anton-vlasenko committed Nov 11, 2021
1 parent ab7e8aa commit 137a02b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/class-wp-rest-block-navigation-areas-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class WP_REST_Block_Navigation_Areas_Controller extends WP_REST_Controller {
* Constructor.
*/
public function __construct() {
$this->namespace = '__experimental';
$this->namespace = 'wp/v2';
$this->rest_base = 'block-navigation-areas';
}

Expand All @@ -37,7 +37,8 @@ public function register_routes() {
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => $this->get_collection_params(),
),
'schema' => array( $this, 'get_public_item_schema' ),
'schema' => array( $this, 'get_public_item_schema' ),
'allow_batch' => array( 'v1' => true ),
)
);

Expand Down
2 changes: 1 addition & 1 deletion lib/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function gutenberg_get_navigation_areas_paths_to_preload() {
$areas = get_option( 'fse_navigation_areas', array() );
$active_areas = array_intersect_key( $areas, gutenberg_get_navigation_areas() );
$paths = array(
'/__experimental/block-navigation-areas?context=edit',
'/wp/v2/block-navigation-areas?context=edit',
);
foreach ( $active_areas as $post_id ) {
if ( 0 !== $post_id ) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const defaultEntities = [
{
name: 'navigationArea',
kind: 'root',
baseURL: '/__experimental/block-navigation-areas',
baseURL: '/wp/v2/block-navigation-areas',
baseURLParams: { context: 'edit' },
plural: 'navigationAreas',
label: __( 'Navigation Area' ),
Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe( 'saveEditedEntityRecord', () => {
{
kind: 'root',
name: 'navigationArea',
baseURL: '/__experimental/block-navigation-areas',
baseURL: '/wp/v2/block-navigation-areas',
},
];
const select = {
Expand Down Expand Up @@ -160,7 +160,7 @@ describe( 'saveEditedEntityRecord', () => {
{
kind: 'root',
name: 'navigationArea',
baseURL: '/__experimental/block-navigation-areas',
baseURL: '/wp/v2/block-navigation-areas',
key: 'area',
},
];
Expand Down

0 comments on commit 137a02b

Please sign in to comment.