[wp-trac] [WordPress Trac] #18302: Improve child theme file inheritance by introducing `theme_url()` to locate a file URI

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 5 21:43:06 UTC 2012


#18302: Improve child theme file inheritance by introducing `theme_url()` to locate
a file URI
-------------------------------------------------+-------------------------
 Reporter:  johnbillion                          |       Owner:  westi
     Type:  enhancement                          |      Status:  reviewing
 Priority:  normal                               |   Milestone:  3.5
Component:  Template                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch westi-likes needs-unit-    |
  tests                                          |
-------------------------------------------------+-------------------------

Comment (by Otto42):

 Suggestion: Naming confusion abounds around there. Why not go whole hog
 and rethink the naming, deprecating old confusing naming along with it.

 Straw man Proposal:

 `function theme_url($path='', $theme='')` : Gets the URL to a specified
 file ($path) in the current theme, accounting for existence of the file in
 the child/parent situation (child if exists, parent if not). If the $theme
 is specified via the slug (or `__FILE__`), then the child/parent is not
 accounted for, using the specified theme directly.

 `function child_theme_url($path='')` : same, but only accounts for child,
 false if no file exists. Essentially a shortcut to theme_url with the
 child theme specified as the $theme.

 `function parent_theme_url($path='')` : same but only accounts for parent.
 Essentially a shortcut to theme_url with the parent theme specified as the
 $theme.

 Like-named functions: theme_file, child_theme_file, parent_theme_file: Do
 the same as above but return full path to the file, suitable for including
 or whatever.

 Is there anything else that is ever needed at this low of a level? We have
 many things like locate_template and such, and those might be able to be
 simplified greatly using something along these lines.

 Naming is dealer's choice, I'm thinking about overall functionality here
 to simplify the whole system.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18302#comment:38>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list