#36091 closed feature request (invalid)
Resolve location of files in template and stylesheet directories
Reported by: | screamingdev | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Themes | Keywords: | needs-patch reporter-feedback |
Focuses: | template | Cc: |
Description
Templates files are located in parent themes and can be extended by the child-theme. Unfortunately not all files can be extended or extending parent themes is a pain.
Imagine the functions.php is including multiple files but you want to replace some. Today you need to copy the functions.php and replace the original file with your own one in the child-theme.
The next theme-update might break your theme. Due to changes in the newer parent-theme/function.php that your child-theme/functions.php doesn't have the theme won't work as expected.
For better inheritance parent and child-themes can use the new get_theme_direcotry( $file )
function. It looks up if the required file is given in the child-theme. If so, then this one will be returned. Otherwise it gives you the desired path pointing to the parent-theme.
Attachments (1)
Change History (5)
#1
@
9 years ago
- Keywords needs-patch reporter-feedback added
- Version trunk deleted
Related: #18302.
@screamingdev Welcome to WordPress Trac. Can you provide a usage example of your patch in action please? It would be good to see what problem this solves. Also it looks like your patch is in reverse (the proposed get_theme_directory()
function is being deleted instead of added).
#2
@
9 years ago
For better inheritance parent and child-themes can use the new
get_theme_direcotry( $file )
function. It looks up if the required file is given in the child-theme. If so, then this one will be returned. Otherwise it gives you the desired path pointing to the parent-theme.
How is that different from locate_template()?
#3
@
9 years ago
- Resolution set to invalid
- Status changed from new to closed
Gosh, it acutally is almost like locate_template. You are right @SergeyBiryukov .
Here is a case @johnbillion :
- Parent-Theme has plenty of files.
- Child-Theme inherits only the ones it likes.
Problem:
- Usually the parent themes would use
get_template_directory()
- This causes that the ones from child themes won't be loaded automatically.
- Inheritance is broken
Solution:
- Parent themes use another function to resolve files.
Now that I see that there is locate_template
it is quite obvious that themes could already have better inheritance for child-themes. I guess someone just have to use it :/
I have to blog about this and spread the words. Sorry for this issue.
Patch-file for this functionality