WordPress.org

Make WordPress Core

Timestamp:
09/08/2016 10:53:57 PM (5 years ago)
Author:
johnbillion
Message:

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

Location:
trunk/tests/phpunit/data/theme-file-parent
Files:
2 added

Note: See TracChangeset for help on using the changeset viewer.