Registers wp_guideline_type taxonomy#77156
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Before landing this, I'd like to align on direction. I don't think the taxonomy is quite ready to wire in yet. As things stand, But that tradeoff was built around "one document per site." Introducing
The current PR doesn't commit to either, and nothing in the REST controller actually reads from the taxonomy. Two questions for the Guidelines team:
I think @swissspidy's angle is worth revisiting here. The community instinct that classification belongs in taxonomies is pointing at a real architectural limit, and this PR is the moment it starts to show. Happy to help sketch a direction or open a design issue once we agree. |
Thanks for flagging this @gziolo
We do have planned task is to relax the singleton constraint for non-content guideline types. The scope is:
I believe that either we can:
Do you have recommendations on this? |
|
Adding a couple more core examples where taxonomies enable classification or coexistence of multiple posts inside a single CPT:
With a hierarchical taxonomy, the organization could fall out naturally: One post per leaf term, with the parent chain encoding both the document kind and its internal category. The categories currently stored as post meta become child terms of
Yes, we could embed that for the |
| foreach ( self::VALID_TYPES as $type ) { | ||
| if ( ! term_exists( $type, self::TAXONOMY ) ) { | ||
| wp_insert_term( $type, self::TAXONOMY, array( 'slug' => $type ) ); | ||
| } |
There was a problem hiding this comment.
term_exists() issues a SELECT per term on every init call. With four terms this adds four queries per page load site-wide when the experiment is enabled. This compounds on high-traffic sites.
Is there a way to make it a one-time seeding operation, instead of per-request?
There was a problem hiding this comment.
Thanks for flagging this, Wasif. I have tried to do one-time operation of seeding in 7abff2c. Happy to seek advice on having a better way.
|
Two suggestions to simplify and sidestep the seeding question: 1. Use 2. Trim the registration to match core peers (
register_taxonomy(
self::TAXONOMY,
self::POST_TYPE,
array(
'public' => false,
'publicly_queryable' => false,
'hierarchical' => false,
'labels' => array(
'name' => __( 'Guideline Types', 'gutenberg' ),
'singular_name' => __( 'Guideline Type', 'gutenberg' ),
),
'query_var' => false,
'rewrite' => false,
'show_ui' => false,
'show_in_nav_menus' => false,
'show_in_rest' => true,
'default_term' => array(
'name' => 'content',
'slug' => 'content',
),
)
); |
7abff2c to
a6db81e
Compare
|
@copilot resolve the merge conflicts in this pull request |
a6db81e to
c2afd74
Compare
What?
Follow-up to #77147
Registers a
wp_guideline_typetaxonomy on the guidelines CPT, following thewp_template+wp_themepattern from core. Usesdefault_termto seedcontentas the default type.Why?
As discussed in the Guidelines announcement comments, the CPT is evolving to support different document types beyond site-wide editorial guidelines. A taxonomy cleanly separates these types within the same CPT, enabling REST-based discovery and filtering — the same approach core uses with
wp_templateandwp_theme.How?
TAXONOMYconstant toGutenberg_Content_Guidelines_Post_Typeregister_taxonomy()inside the existingregister()method, right afterregister_post_type()default_termto auto-create and assign thecontentterm (handled by core, no per-request queries)show_in_rest = true, registration trimmed to match core peers (wp_theme,wp_pattern_category)No changes to the REST controller, singleton behavior, or client-side code.
Testing Instructions
Setup
npm run wp-env startTaxonomy verification
http://localhost:8888/wp-json/wp/v2/wp_guideline_type— should return one term:contenthttp://localhost:8888/wp-json/wp/v2/taxonomies/wp_guideline_type— should return the taxonomy definition attached to the guidelines CPTRegression
Testing Instructions for Keyboard
No special case for keyboard required.
Screenshots or screencast
No visual changes expected.
Use of AI Tools
Claude Code used for planning, review feedback implementation, and PR description updates.