Allow extensions to customize the template name in the 'Add template' screen #60283
Labels
[Feature] Extensibility
The ability to extend blocks or the editing experience
[Feature] Template Editing Mode
Related to the template editor available in the Block Editor
[Status] In Progress
Tracking issues with work in progress
[Type] Enhancement
A suggestion for improvement.
[Type] New API
New API to be used by plugin developers or package users.
Description
When creating a new template, Custom Post Type taxonomies are displayed with not very user-friendly titles. Ie:
Recipe (recipe_cat)
.That's not ideal because:
Category (recipe_cat)
means the Recipes by Category template.Currently, the values which are used are the
singular_name
label and the taxonomy slug:gutenberg/packages/edit-site/src/components/add-new-template/utils.js
Lines 372 to 377 in 39500f6
However, that doesn't give enough flexibility to 3rd-party plugins because
singular_name
is used in other parts of the UI so it can't be adapted to the context of the Site Editor.A real-life example
While the Recipe example I showed above is quite simple, there are other plugins which might add more templates, like WooCommerce:
(Sidenote: currently WooCommerce doesn't show these templates in the 'Add template' screen, but we would like to: woocommerce/woocommerce#42532)
Suggested solutions
I would like to propose some possible solutions that, I believe, would help improve this part of the UI:
register_taxonomy()
WordPress function intended to be used to name the templates in the admin. In the Product Category case, that could beProduct Category Archives
. If a plugin registers a taxonomy without specifying that value, thesingular_name
could be used as a fallback.singular_name
would automatically become more use friendly. In the WC example, I'm thinking that there could be aProduct
orWooCommerce
header where all product-related templates could be grouped. Ideally that would require no work by plugins.Step-by-step reproduction instructions
Category (recipe_cat)
.Expected result:
As a user, I don't need to know that Recipe Categories uses the
recipe_cat
slug internally. Ideally, those buttons should show up a user-friendly name like:Recipe Category Archives
orRecipes by Category
.Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: