-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Introduce 'template_name' label to custom post types and custom taxonomies #6344
Introduce 'template_name' label to custom post types and custom taxonomies #6344
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
7fe9450
to
16f1d8d
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Thanks for the PR! Can you create a trac ticket for this and link this PR? |
Thanks for taking a look, @ntsekouras! The track ticket was already created: https://core.trac.wordpress.org/ticket/60881. It's linked from the PR description. 🙂 |
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.
Alright this looks good to me 👍
16f1d8d
to
999985e
Compare
Thanks for the review, @audrasjb! I rebased this PR with the latest |
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.
I think this will cause a regression for custom taxonomies.
Currently the singular name is used by default, so it's clear the taxonomy the template is for the human label, ie the one shown in the admin.
After these chanages (and some might be upstream) the label will become Tags (taxonomy_slug)
which is much more difficult to interpret as a user.
I think the default should be Singular Name Archives
so the human name remains in the site editor. The logic for defining the default label would probably need to be in get_taxonomy_labels
instead.
Co-authored-by: Peter Wilson <[email protected]>
ffb78b9
to
4f06e99
Compare
Thanks for the review, @peterwilsoncc! I updated the PR based on your feedback. If the custom post type and the custom taxonomies don't include a |
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.
I've added a few more notes inline.
While adding the labels, do you think it's worth adding one for post type archives too?
At the moment the archive is always shown as Archive: [CPT]
but if WP is to allow for Single item: [CPT]
to be customized it seems inconsistent not to allow the archive to be renamed too.
Let me know if this was discussed on the upstream ticket.
This is the mini-plugin I was using for testing this change:
add_action( 'init', function() {
register_post_type( 'pwcc_test_type', [
'labels' => [
'name' => 'Test CPTs',
'singular_name' => 'Test CPT',
'template_name' => 'Template Name Test CPT',
],
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
] );
register_taxonomy( 'pwcc_test_taxonomy', 'pwcc_test_type', [
'label' => 'Test Taxonomy',
'labels' => [
'name' => 'Test Taxonomies',
'singular_name' => 'Test Taxonomy',
'template_name' => 'Template Name Test Taxonomy',
],
'show_in_rest' => true,
] );
} );
Thanks again for the review, @peterwilsoncc, feedback should be addressed.
You mean adding a |
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.
This look good to me, thank you!
Testing notes:
✅ Setting the template_name
displays the string in the add new template screen
✅ Setting labels without the template name displays the singular name
✅ Setting neither $label
or $labels
displays the object slug to differentiate
✅ Setting singular $label
without $labels
displays the $label
in the default string
Once again, thanks for the review, @peterwilsoncc! I don't have merge/commit access to the WordPress repo, so please let me know if there is anything else I can do from my end. 🙏 |
Trac ticket: https://core.trac.wordpress.org/ticket/60881
This PR is a follow-up of WordPress/gutenberg#60367 to:
template_name
label when registering post types and taxonomies.Testing steps
template_name
to the post type and taxonomy:This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.