-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Patterns: add a custom taxonomy for user created patterns #53163
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
94d2e52
Add custom patterns taxonomy
glendaviesnz d7c1065
Update pull request number
glendaviesnz 28d1fcf
Drop custom from the taxonomy name
glendaviesnz 7d2eae1
Flag as taxonomy as builtin
glendaviesnz 907e04a
Remove UI for now and only expose via rest
glendaviesnz d662766
Linting fixes
glendaviesnz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* Overrides Core's wp-includes/block-patterns.php to add new wp_patterns taxonomy for WP 6.4. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Adds a new taxonomy for organizing user created patterns. | ||
* | ||
* Note: This should be removed when the minimum required WP version is >= 6.4. | ||
* | ||
* @see https://github.com/WordPress/gutenberg/pull/53163 | ||
* | ||
* @return void | ||
*/ | ||
function gutenberg_register_taxonomy_patterns() { | ||
$labels = array( | ||
'name' => _x( 'Pattern Categories', 'taxonomy general name' ), | ||
'singular_name' => _x( 'Pattern Category', 'taxonomy singular name' ), | ||
); | ||
$args = array( | ||
'hierarchical' => false, | ||
'labels' => $labels, | ||
'show_ui' => true, | ||
'show_in_menu' => false, | ||
'show_in_nav_menus' => false, | ||
'show_admin_column' => true, | ||
'query_var' => true, | ||
'show_in_rest' => true, | ||
'_builtin' => true, | ||
'rewrite' => array( 'slug' => 'wp_pattern_category' ), | ||
); | ||
register_taxonomy( 'wp_pattern_category', array( 'wp_block' ), $args ); | ||
} | ||
add_action( 'init', 'gutenberg_register_taxonomy_patterns' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
show_ui
tofalse
; the post type has no admin menu, which will do nothing.query_var
,rewrite
,public
) will need to be adjusted.That would give us pretty much the same argument shape as
wp_template_part_area
- https://github.com/WordPress/wordpress-develop/blob/8cd99074624a8c4b589f31c7b2a8092f4fe5c79e/src/wp-includes/taxonomy.php#L207-L224There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference with patterns is if we set show_ui false and make it not public users won't be able to see/update the terms in the
/wp-admin/edit.php?post_type=wp_block
interface, eg.Not sure how critical that is 🤔 What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
PostTaxonomies
component only checks forshow_ui
, not the other arguments.Considering that the new taxonomy does very little without remaining work from #53164. I think it's okay to hide UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, have removed the UI for now at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Glen!