[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
Thu Sep 8 22:53:58 UTC 2016
#18302: Improve child theme file inheritance by introducing a function to locate a
file URI
---------------------------------------------+--------------------------
Reporter: johnbillion | Owner: johnbillion
Type: enhancement | Status: closed
Priority: high | Milestone: 4.7
Component: Themes | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch commit has-unit-tests | Focuses: template
---------------------------------------------+--------------------------
Changes (by johnbillion):
* status: accepted => closed
* resolution: => fixed
Comment:
In [changeset:"38578"]:
{{{
#!CommitTicketReference repository="" revision="38578"
Themes: Improve child theme file inheritance by introducing functions for
locating and fetching the URL or path to files within child and parent
themes.
The most useful function this introduces is `get_theme_file_uri()`, which
returns the URL to the specified file in the child theme if it exists, and
falls back to the URL to the specified file in the parent theme. This
allows parent themes to reference files (including enqueuing CSS and
JavaScript files) that can be overridden by the child theme simply by
existing.
This change also introduces `get_theme_file_path()`, which is the file
path equivalent of `get_theme_file_uri()`.
Finally, `get_parent_theme_file_uri()` and `get_parent_theme_file_path()`
are also introduced, which allow a theme to specifically reference a file
URL or file path in the parent theme. These can be used as replacements
for `get_template_directory_uri()` and `get_template_directory()`
respectively, for consistency.
Props johnbillion, georgestephanis, gma992.
Fixes #18302
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/18302#comment:97>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list