Skip to content

Commit

Permalink
Remove pattern directory categories endpoint (WordPress#51340)
Browse files Browse the repository at this point in the history
* Remove pattern directories endpoint

* fix init
  • Loading branch information
ntsekouras authored and sethrubenstein committed Jul 13, 2023
1 parent 88eb948 commit bf3e84b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 176 deletions.
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.
}

}

0 comments on commit bf3e84b

Please sign in to comment.