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

Full Site Editing: De-emphasise inactive templates in template navigation UI #26264

Closed
jameskoster opened this issue Oct 19, 2020 · 3 comments
Closed
Labels
[Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later

Comments

@jameskoster
Copy link
Contributor

If there are inactive, non-general ($custom) templates at a site, they should be moved to an "inactive" section in the new template navigation UI.

As an example, if the Page, Single, and Singular templates were all present (and assuming no other CPTs are registered), the Singular template would never be resolved to display content. De-emphasising the template by moving it to an "inactive" section does two things:

  1. Cleans up the UI - there can be many templates, anything we can do to streamline the navigation experience is a win
  2. Reduces the risk of user confusion by editing a template that isn't actually in use, this is particularly important considering the significant overlap of some of the base templates

The Inactive section should appear towards the bottom of the panel, just above the "Manage all templates" menu item:

1

Note: The template descriptions are still WIP :)

@Copons
Copy link
Contributor

Copons commented Oct 19, 2020

This seems extremely hard to develop, as I think it entails knowing everything about the site.

It's hard to wrap my head around the template hierarchy, so I'll try to explain with an example based upon this ever helpful image:
WP Template Hierarchy

Please let me know if I'm looking at this from the wrong angle, which is very very likely!


We want to check if any given template available on a site is inactive, which means that no content (page, post, etc.) uses it, either because it's "overridden" by a more specific template, or because the content has a $custom template assigned.

Let's start with index, which is most likely available on all sites:

  • Is there an archive template? No, this site doesn't provide one, so index might be used for archives.
    • Is there an author template? No, we might still use index
      • Is there an author-$id? Yes! There is an author-123 template, that I use for myself!
      • What about the other authors? This site only has one author (me), so we're good to go.
        This means that index won't be used for the authors, at least as long as the site has only one author, so we need to keep scanning to see if it's used elsewhere.
    • Is there a category template? No.
      • Is there a category-$id template? No, for any categories.
        • Is there a category-$slug template? Yes, 2: category-foo and category-bar.
          Though the site has 3 categories: Foo, Bar, and Baz.
          Foo and Bar will use their own specific template, while Baz will fall back all the way to index.
          We have confirmed that index is indeed an active template. ✅

Now we can proceed to singular!

  • (Just kidding, we won't 😄 )

My point is that we don't really have any data about the "status" of a template.
We only know if it's active when a content uses it, but I don't think there's a way to know if a template is inactive, unless we had data about all content (pages, posts, custom post types, attachments, authors, etc.) readily available to scan.

@mtias mtias added the [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later label Oct 19, 2020
@mtias
Copy link
Member

mtias commented Oct 19, 2020

I think there are ways in which we could handle some inactive templates but from the opposite end — i.e. if there is a category-123 template but no 123 category. In any case, I think this should be considered lower priority in general.

@jameskoster
Copy link
Contributor Author

A rudimentary version of this has been merged so I'm going to close this. We can revisit later as required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later
Projects
None yet
Development

No branches or pull requests

4 participants