Opened 8 months ago
Last modified 7 months ago
#22273 new enhancement
Parent/child page template inheritance should be more consistent
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Themes | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | knut@… |
Description
When page templates in sub-directories was introduced in 3.4, we also inadvertantly introduced some scenarios where page template inheritance from parent to child themes gets wonky.
After some testing on trunk (r22290), I came up with some interesting findings in what I like to call Battle of the page template inheritance:
Relationship: Parent:Child
Same filename, same Template Name:
- root:root = Child wins
- root:sub = Parent wins
- sub:sub = Child wins
- sub:root = Parent wins
Different filename, same Template Name:
- root:root = Parent wins
- root:sub = Parent wins
- sub:sub = Parent wins
- sub:root = Parent wins
Same filename, different Template Name:
- root:root = Child wins
- root:sub = Both available
- sub:sub = Child wins
- sub:root = Both available
In #22269, @duck_ made light of get_page_templates() making use of array_flip() which effectively gives preference to Parent templates in some situations. I think it's worth looking at whether we can't allow get_page_templates() to properly respect inheritance, regardless of sub or root path.
The other interesting tidbit of course is that in the third set, we see the Child can override the parent file of the same filename, even if the Template Name is different, which I take is expected, but odd in terms of inheritance.