Content Types: Add Duplicate action to taxonomy management#77853
Conversation
|
Size Change: +33 kB (+0.42%) Total Size: 7.91 MB 📦 View Changed
ℹ️ View Unchanged
|
Adds a "Duplicate" action to the taxonomies DataView that opens a modal prefilled with the source taxonomy's plural/singular labels and a suffixed key, then creates an inactive copy carrying the same config and object_type associations. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
7494d95 to
806656d
Compare
|
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. |
|
Flaky tests detected in bb3b6e7. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25325187282
|
ntsekouras
left a comment
There was a problem hiding this comment.
I'm pretty sure we will revisit/refine this action and there might be more nuances to it. I remember duplicate post action having lots of nuances and not sure what's similar with this one too.
That said, it's definitely okay to have this for now as it helps with testing the features way easier.
| }; | ||
|
|
||
| function buildCopySlug( slug: string ): string { | ||
| const suffix = '_copy'; |
There was a problem hiding this comment.
I think this is the main issue of this PR. Adding a hardcoded suffix will create invalid forms on subsequent duplicates of a taxonomy (duplicate two times, assuming the user kept the generated slug).
There was a problem hiding this comment.
Good point. Resolved this in bb3b6e7 by appending an incremental number. As a result, when duplicating we get:
- 'test' -> 'test2'
- 'test3' -> 'test4'
- 'test9' -> 'test10'
- 'test99' -> 'test100'
There was a problem hiding this comment.
It's fine for now, mostly because I believe we'll end up 'internally' prefixing the slug to ensure uniqueness. The reason we'll probably need that is because users could create taxonomies/post types with an available slug and later on a plugin or theme could have the same slug.
For the record though the only foolproof logic for this step would be to check registered/inactive taxonomy slugs.
There was a problem hiding this comment.
It's quite an edge case, but yep, added a follow-up item in #77600.
|
|
||
| function buildCopySlug( slug: string ): string { | ||
| const suffix = '_copy'; | ||
| const base = slug.slice( 0, SLUG_MAX_LENGTH - suffix.length ); |
There was a problem hiding this comment.
The case of slug being trimmed (if it was max-length before) is also a small nuance that's worth thinking for follow ups.
There was a problem hiding this comment.
Resolved as part of bb3b6e7 - we're trimming to make space for the appended number.
Yep, that's a good point. I'd suggest keeping it for now (as it also facilitates testing) but keeping an eye on it as we move forward. |
ntsekouras
left a comment
There was a problem hiding this comment.
Let's get this in and iterate, thanks!
What?
Adds a "Duplicate" action to the taxonomy management screen.
Why?
When a user wants a new taxonomy that is similar to an existing one, today, they have to recreate every option from scratch. Duplicating is the obvious shortcut.
How?
Adding a new action that opens a modal for adding details and then duplicates the taxonomy based on the passed data.
Testing Instructions
<original> (Copy)<original-slug>_copy(truncated if needed)Testing Instructions for Keyboard
Screenshots or screencast
Use of AI Tools
Opus 4.7