Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update patterns REST controllers namespace to stable #40252

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WP_REST_Block_Pattern_Categories_Controller extends WP_REST_Controller {
* @since 6.0.0
*/
public function __construct() {
$this->namespace = '__experimental';
$this->namespace = 'wp/v2';
$this->rest_base = 'block-patterns/categories';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
* Constructor.
*/
public function __construct() {
$this->namespace = '__experimental';
$this->namespace = 'wp/v2';
$this->rest_base = 'block-patterns/patterns';
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,14 @@ export const __experimentalGetCurrentThemeGlobalStylesVariations = () => async (

export const getBlockPatterns = () => async ( { dispatch } ) => {
const patterns = await apiFetch( {
path: '/__experimental/block-patterns/patterns',
path: '/wp/v2/block-patterns/patterns',
} );
dispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );
};

export const getBlockPatternCategories = () => async ( { dispatch } ) => {
const categories = await apiFetch( {
path: '/__experimental/block-patterns/categories',
path: '/wp/v2/block-patterns/categories',
} );
dispatch( { type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES', categories } );
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function wpTearDownAfterClass() {
public function test_register_routes() {
$routes = rest_get_server()->get_routes();
$this->assertArrayHasKey(
'/__experimental/block-patterns/categories',
'/wp/v2/block-patterns/categories',
$routes,
'The categories route does not exist'
);
Expand All @@ -61,7 +61,7 @@ public function test_get_items() {
$expected_names = array( 'test', 'query' );
$expected_fields = array( 'name', 'label' );

$request = new WP_REST_Request( 'GET', '/__experimental/block-patterns/categories' );
$request = new WP_REST_Request( 'GET', '/wp/v2/block-patterns/categories' );
$request['_fields'] = 'name,label';
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
Expand Down
4 changes: 2 additions & 2 deletions phpunit/class-wp-rest-block-patterns-controller-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function wpTearDownAfterClass() {
public function test_register_routes() {
$routes = rest_get_server()->get_routes();
$this->assertArrayHasKey(
'/__experimental/block-patterns/patterns',
'/wp/v2/block-patterns/patterns',
$routes,
'The patterns route does not exist'
);
Expand All @@ -77,7 +77,7 @@ public function test_get_items() {
$expected_names = array( 'test/one', 'test/two' );
$expected_fields = array( 'name', 'content' );

$request = new WP_REST_Request( 'GET', '/__experimental/block-patterns/patterns' );
$request = new WP_REST_Request( 'GET', '/wp/v2/block-patterns/patterns' );
$request['_fields'] = 'name,content';
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
Expand Down