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

Remove pattern directory categories endpoint #51340

Merged
merged 2 commits into from
Jun 12, 2023
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
10 changes: 10 additions & 0 deletions lib/compat/wordpress-6.2/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,13 @@ function filter_block_pattern_response( $response, $raw_pattern ) {
return $response;
}
add_filter( 'rest_prepare_block_pattern', 'filter_block_pattern_response', 10, 2 );


/**
* Registers the block pattern directory.
*/
function gutenberg_register_rest_pattern_directory() {
$pattern_directory_controller = new Gutenberg_REST_Pattern_Directory_Controller_6_2();
$pattern_directory_controller->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_rest_pattern_directory' );

This file was deleted.

9 changes: 0 additions & 9 deletions lib/compat/wordpress-6.3/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
* @package gutenberg
*/

/**
* Registers the block pattern directory.
*/
function gutenberg_register_rest_pattern_directory() {
$pattern_directory_controller = new Gutenberg_REST_Pattern_Directory_Controller_6_3();
$pattern_directory_controller->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_rest_pattern_directory' );

/**
* Updates `wp_template` and `wp_template_part` post types to use
* Gutenberg's REST controllers
Expand Down
1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-global-styles-controller-6-2.php';

// WordPress 6.3 compat.
require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-pattern-directory-controller-6-3.php';
require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php';
require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-global-styles-controller-6-3.php';
require_once __DIR__ . '/compat/wordpress-6.3/rest-api.php';
Expand Down
34 changes: 1 addition & 33 deletions phpunit/class-wp-rest-pattern-directory-controller-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function wpSetUpBeforeClass( $factory ) {

self::$http_request_urls = array();

static::$controller = new Gutenberg_REST_Pattern_Directory_Controller_6_3();
static::$controller = new Gutenberg_REST_Pattern_Directory_Controller_6_2();
}

public static function wpTearDownAfterClass() {
Expand All @@ -78,39 +78,8 @@ public function test_register_routes() {
$routes = rest_get_server()->get_routes();

$this->assertArrayHasKey( '/wp/v2/pattern-directory/patterns', $routes );
$this->assertArrayHasKey( '/wp/v2/pattern-directory/categories', $routes );
}

/**
* @covers WP_REST_Pattern_Directory_Controller::prepare_pattern_category_for_response
*
* @since 6.2.0
*/
public function test_prepare_pattern_category_for_response() {
$raw_categories = array(
(object) array(
'id' => 3,
'name' => 'Columns',
'slug' => 'columns',
'description' => 'A description',
),
);

$prepared_category = static::$controller->prepare_response_for_collection(
static::$controller->prepare_pattern_category_for_response( $raw_categories[0], new WP_REST_Request() )
);

$this->assertSame(
array(
'id' => 3,
'name' => 'Columns',
'slug' => 'columns',
),
$prepared_category
);
}


/**
* Tests if the provided query args are passed through to the wp.org API.
*
Expand Down Expand Up @@ -317,5 +286,4 @@ public function test_delete_item() {
public function test_get_item_schema() {
// The controller's schema is hardcoded, so tests would not be meaningful.
}

}