[wp-trac] [WordPress Trac] #22273: Parent/child page template inheritance should be more consistent

WordPress Trac noreply at wordpress.org
Wed Oct 24 18:39:49 UTC 2012


#22273: Parent/child page template inheritance should be more consistent
-----------------------------+-------------------------
 Reporter:  DrewAPicture     |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Themes
  Version:                   |   Severity:  normal
 Keywords:                   |
-----------------------------+-------------------------
 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 [http://core.trac.wordpress.org/ticket/22269#comment:1 #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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22273>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list