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

WordPress Trac noreply at wordpress.org
Wed Aug 31 18:21:38 UTC 2016


#18302: Improve child theme file inheritance by introducing a function to locate a
file URI
---------------------------------------------+--------------------------
 Reporter:  johnbillion                      |       Owner:  johnbillion
     Type:  enhancement                      |      Status:  accepted
 Priority:  high                             |   Milestone:  4.7
Component:  Themes                           |     Version:
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch commit has-unit-tests  |     Focuses:  template
---------------------------------------------+--------------------------
Changes (by johnbillion):

 * keywords:  has-patch needs-unit-tests early => has-patch commit has-unit-
     tests
 * status:  reviewing => accepted


Comment:

 [attachment:18302.diff] (yay for messed up attachment numbering) is my
 latest incarnation of this. I would very much like to commit this to core
 this week in order to gauge feedback. Summary:

 * `get_theme_file_uri()` function to return the URL to a file in either
 the child or parent theme as relevant.
 * `get_parent_theme_file_uri()` function to return the URL to a file in
 the parent theme.
 * `get_theme_file()` function to return the path to a file in either the
 child or parent theme as relevant.
 * `get_parent_theme_file()` function to return the path to a file in the
 parent theme.
 * The `$file` parameter is optional in all four functions.
 * Unit tests for all the things.

 Some notes:

 * `get_()` has been added as a prefix to the function names as per
 feedback.
 * `wp_()` could also be added as a further prefix, but this makes the
 function names very long. I'm -1 on this.

 One remaining question:

 * Should the `get_theme_file()` and `get_parent_theme_file()` functions be
 named `get_theme_file_path()` and `get_parent_theme_file_path()`?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/18302#comment:94>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list