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

6.4 Backport: Add a taxonomy for user pattern categories #5234

Closed
Closed
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
21 changes: 21 additions & 0 deletions src/wp-includes/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,27 @@ function create_initial_taxonomies() {
'show_in_rest' => false,
)
);

register_taxonomy(
'wp_pattern_category',
array( 'wp_block' ),
array(
'public' => true,
'publicly_queryable' => false,
'hierarchical' => false,
'labels' => array(
'name' => _x( 'Pattern Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Pattern Category', 'taxonomy singular name' ),
),
'query_var' => false,
'rewrite' => false,
'show_ui' => true,
'_builtin' => true,
'show_in_nav_menus' => false,
'show_in_rest' => true,
'show_admin_column' => true,
)
);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/tests/rest-api/rest-schema-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public function test_expected_routes_in_schema() {
'/wp-site-health/v1/tests/authorization-header',
'/wp-site-health/v1/tests/page-cache',
'/wp-site-health/v1/directory-sizes',
'/wp/v2/wp_pattern_category',
'/wp/v2/wp_pattern_category/(?P<id>[\d]+)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to run this test suite locally for some reason, but the earlier CI failures pointed to these lines being missing so I added them in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, still failing. Does anything need to be updated on the REST API side to support this taxonomy?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will take a look

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all that was added in the plugin to make it work https://github.com/WordPress/gutenberg/pull/53163/files

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I run this branch locally going to /wp-admin/edit-tags.php?taxonomy=wp_pattern_category shows the taxonomy and allows you to edit it, but that is not via REST I guess

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran all the unit tests locally and this regenerated the fixtures file - so hopefully pushing this fixes it.

);

$this->assertSameSets( $expected_routes, $routes );
Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/tests/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public function test_get_link_taxonomies() {
$this->assertSame( array( 'link_category' ), get_object_taxonomies( 'link' ) );
}

public function test_get_block_taxonomies() {
$this->assertSame( array( 'wp_pattern_category' ), get_object_taxonomies( 'wp_block' ) );
}

/**
* @ticket 5417
*/
Expand Down Expand Up @@ -119,6 +123,7 @@ public function test_taxonomy_exists_known() {
$this->assertTrue( taxonomy_exists( 'category' ) );
$this->assertTrue( taxonomy_exists( 'post_tag' ) );
$this->assertTrue( taxonomy_exists( 'link_category' ) );
$this->assertTrue( taxonomy_exists( 'wp_pattern_category' ) );
}

public function test_taxonomy_exists_unknown() {
Expand Down
Loading