-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Full Site Editing]: Expand the templates that can be added - custom taxonomies, specific term, specific category and tag #41875
Conversation
Size Change: +684 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
Nice, everything seems to be working as expected for me :) tax.mp4The names / descriptions of the templates are a bit tricky to grok sometimes, but I appreciate we're somewhat restricted there. Things get a bit strange if you have taxonomy terms with the same name, attached to different post types. For example I have:
If I create templates for Post->Uncategorized and Product->Uncategorized I see this in the templates list: I have no idea which is which. Could we include the post type in the description? (Definitely open to other ideas). This would help with the template menu as well, where it's not super-obvious what is the difference between "Category" and "Single taxonomy: Category": |
Hm.. that's interesting indeed. First I have to note that the taxonomies are not in a 1:1 relation with post types, so it doesn't help to show any linked post type as a hint. The real problem here is that some taxonomies like
I'm wondering how we can differentiate these if we can't rely on the labels.. 🤔 Something unique is the taxonomy slug, but not sure it will be much helpful. |
This is where the mosaic view would be useful, because you'd be able to tell the difference visually. Still, we do probably need to have some unique identifiers in the label / description.
That's true, but each taxonomy has a list of associated post types(?), so perhaps we could attach that list to the description somehow? Otherwise it does seem like the slug is the only unique thing we can rely on 😓 |
feb9902
to
b315644
Compare
@ntsekouras and I had a pairing session today and discussed ideas to manage complexity around this feature, especially in the broader context of expanding the Template Editor's capabilities (#37407). For now, I pushed some straightforward refactorings as well as some minor changes to the config model:
These changes should cause no change in behaviour. See: compare/b3156445d..82997c9 I have a bunch of ideas brewing — some of them mutually contradictory — about how to improve the implementation, but they shouldn't hold this PR back. As far as I am concerned, this is good to go, but some fresh testing would be welcome! |
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.
LGTM, and I can approve Nik's work. Nik or someone else can approve my follow-up changes. :)
// TODO: check if we can reuse the message and the translators message...(?) | ||
// This refers to `where %1$s is the singular name of a post type and %2$s...`part. |
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.
Highly debatable, but I think we could keep the description as is, just because it's clearer to understand the idea if we are focused on the CPT case, but it becomes a bit too abstract if we try to generalise (e.g. "where %1$s is the singular name of a concrete WordPress entity […]").
// TODO: check if we can reuse the message and the translators message...(?) | |
// This refers to `where %1$s is the singular name of a post type and %2$s...`part. |
exclude: entityForSuggestions.postsToExclude, | ||
per_page: search ? 20 : 10, | ||
}; | ||
function useDebouncedInput() { |
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 am a bit biased, and my goal with the refactoring with useDebouncedInput
and useSearchSuggestions
was to rewrite in a way that doesn't need comments to be easy to understand. So: is it succeeding? Or should these hooks be described?
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 it can be addressed as part of: #41875 (comment) as well. Personally I know exactly what it does, so I might not be the best candidate to judge as well.
setShowCustomTemplateModal( true ); | ||
setEntityForSuggestions( _entityForSuggestions ); | ||
}; | ||
// TODO: find better names for many new vars :) |
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.
The TODO
is acknowledged, and we will address it in the context of #41875 (comment).
packages/edit-site/src/components/add-new-template/new-template.js
Outdated
Show resolved
Hide resolved
I would approve Miguels changes, but I can't since it's my own PR 😄 . I will merge this and we can do some quick follow ups for renaming some vars or some refactoring, if we see fit, and the main thing would be to address the case where taxonomies use the same labels with |
bfa6a6d
to
b93b1fb
Compare
…taxonomies, specific term, specific category and tag
Isolate all template-computing logic in a macro hook (useMarkPersistent)
Also rename and move some other variables for clarity.
…e.js Co-authored-by: Miguel Fonseca <[email protected]>
b93b1fb
to
d5beea6
Compare
What?
Part of: #37407
This PR expands the templates that can be added by handling custom taxonomies and specific terms of any public taxonomy, including
category
andtag
.How?
It uses the same design for custom post types that is already merged.
taxonomy-$taxonomy_slug
and we have available terms that don't have a specific template created, it will show a modal with two options to create either of them. You can search through the available terms to create a specific template for it.taxonomy-$taxonomy_slug
and we don't have available terms that don't have a specific template created, clicking the menu item will just create thetaxonomy-$taxonomy_slug
.taxonomy-$taxonomy_slug
and we have available terms that don't have a specific template created, it will show the UI for searching the available terms.taxonomy-$taxonomy_slug
and we don't have available terms that don't have a specific template created, the menu item will not be added.This also applies for
category
andtag
with different slugs though(technical detail).Testing Instructions
Screenshots or screencast
Screen.Recording.2022-06-22.at.4.18.26.PM.mov