-
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
Update: Use wp_theme taxonomy for wp_global_styles cpt. #31436
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,13 +84,13 @@ function gutenberg_register_template_post_type() { | |
* Registers block editor 'wp_theme' taxonomy. | ||
*/ | ||
function gutenberg_register_wp_theme_taxonomy() { | ||
if ( ! gutenberg_supports_block_templates() ) { | ||
if ( ! gutenberg_supports_block_templates() && ! WP_Theme_JSON_Resolver::theme_has_support() ) { | ||
return; | ||
} | ||
|
||
register_taxonomy( | ||
'wp_theme', | ||
array( 'wp_template', 'wp_template_part' ), | ||
array( 'wp_template', 'wp_template_part', 'wp_global_styles' ), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There may be themes that have theme.json but aren't block-based themes and vice-versa, so we need to make sure that this relationship works as expected in those scenarios (a few lines above this there's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch I updated the condition used to register the taxonomy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it ok to register all of this or should we only register the individual pieces per each feature?
cc @vindl There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we are not registering wp_global_styles or wp_template we are registering wp_theme taxonomy and saying the taxonomy can be used on wp_global_styles, wp_template and wp_template_part block types. I think there is no issue in registering a taxonomy and saying it can be used in a CPT that is not yet available. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At #35427 we're probably making changes to when we register the user CPT. I've checked the logic for |
||
array( | ||
'public' => false, | ||
'hierarchical' => false, | ||
|
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.
Braindump: the result of removing this is that the CPT name will inherit the title's, which is "Custom Styles", so we end up with CPTs with names (and guids) such as
custom-styles
,custom-styles-2
,custom-styles-3
, etc. Wondering if we could retain this or even havecustom-styles-<theme>
as a name.Not that it matters much for our use as we'll have the taxonomy. However, I wonder what happens if/when we reach the last
guid
number. Does it start over from 0? At that point, is it ok that there are two CPTs withcustom-styles-2
names? Those sort of situations.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.
Yes, I guess we can keep the existing name, I updated the code.