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

Patterns: add a custom taxonomy for user created patterns #53163

Merged
merged 6 commits into from
Aug 17, 2023

Conversation

glendaviesnz
Copy link
Contributor

@glendaviesnz glendaviesnz commented Jul 31, 2023

What?

Adds a custom taxonomy to allow users to organize the synced and unsynced patterns that they create.

Why?

Currently there is no way for users to classify their own patterns.
This would be step one to implement #53164 - see further discussion there.

How?

Adds a standard WP custom taxonomy called wp_pattern_custom_category.

Currently this just adds the base taxonomy. The post and site editor UI to make use of the UI will be added in follow-up PRs if this approach of using a custom taxonomy is accepted.

Testing Instructions

  • Go to /wp-admin/edit.php?post_type=wp_block and add a new pattern
  • Make sure the Category option appears in the right settings panel and that you can add new categories

Screenshots or screencast

categories.mp4

@glendaviesnz glendaviesnz added [Type] Enhancement A suggestion for improvement. [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced labels Jul 31, 2023
@glendaviesnz glendaviesnz self-assigned this Jul 31, 2023
@github-actions
Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/compat/wordpress-6.4/block-patterns.php
❔ lib/load.php

@github-actions
Copy link

Flaky tests detected in cc8887b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5710416307
📝 Reported issues:

Copy link
Member

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

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

I am not sure this is needed in core. Where will this functionality to used in core? Why would we not just use post meta?

@Mamaduka
Copy link
Member

@spacedmonkey, see #53164.

@glendaviesnz
Copy link
Contributor Author

glendaviesnz commented Aug 10, 2023

Sorry @spacedmonkey, I should have included the link to the overview issue in the PR description. Let me know if you still have concerns after reading that.

@glendaviesnz
Copy link
Contributor Author

@spacedmonkey are you able to confirm if you are happy with this or not after reading the background issue?

@glendaviesnz
Copy link
Contributor Author

@Mamaduka it looks like @spacedmonkey is away until September and it would be good to move this forward. There was agreement over on the issue that this is the right way forward for this, so do you think it is ok to override the blocker on this PR?

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

@glendaviesnz, that sounds good to me 👍

Comment on lines 22 to 32
$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' ),
Copy link
Member

Choose a reason for hiding this comment

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

  • We can set show_ui to false; the post type has no admin menu, which will do nothing.
  • REST API will mainly consume the taxonomy, so it's not publicly queriable. Related arguments (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-L224

Copy link
Contributor Author

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.

Screenshot 2023-08-17 at 4 48 05 PM

Not sure how critical that is 🤔 What do you think?

Copy link
Member

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 for show_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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you, Glen!

@Mamaduka Mamaduka dismissed spacedmonkey’s stale review August 17, 2023 05:16

Feedback was provided

@glendaviesnz glendaviesnz merged commit 4da51a1 into trunk Aug 17, 2023
50 checks passed
@glendaviesnz glendaviesnz deleted the add/patterns-custom-taxonomy branch August 17, 2023 06:07
@github-actions github-actions bot added this to the Gutenberg 16.6 milestone Aug 17, 2023
@mikachan mikachan added the Needs PHP backport Needs PHP backport to Core label Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced Needs User Documentation Needs new user documentation [Type] Enhancement A suggestion for improvement.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants