#17805 closed defect (bug) (wontfix)
"Child of a child" Theme: Convert include(functions.php) to include_once().
Reported by: | 5ubliminal | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2 |
Component: | Themes | Keywords: | has-patch |
Focuses: | Cc: |
Description
After some trickery, I managed to get child of a child themes working. Unfortunately bumped into a problem.
The wp-settings.php include(functions.php) breaks the whole thing as, in the first "child", you need to manually include the parent's functions.php when you use the "child of child" (2nd child).
I added a patch, seriously needs your attention or better child of child theme support, recursive location or master parent and reverse order functions.php inclusion.
Thanks.
Attachments (1)
Change History (15)
#2
@
14 years ago
- Keywords close added
We don't support child of child themes.
You can do this on your own. Additional trickery will require including one of the parent function.php calls manually. I don't see what a conversion to include_once has to do with it.
include_once is slower. I don't see a reason for the patch.
#3
@
14 years ago
I can understand what you're doing in the patch (you can't include()
the file in wp-settings.php and then include()
it again in the 2nd child theme. So kudos to figuring out how to fix it.
At the same time, I agree 100% with Nacin. We don't support child of child themes (grandchild themes) for several valid reasons already hashed out at-length elsewhere. Vote to close.
#4
@
14 years ago
If you guys say so, but not everyone agrees:
http://arin.me/blog/php-require-vs-include-vs-require_once-vs-include_once-performance-test
PS: I'll do some tests.
#5
@
14 years ago
- Keywords close removed
On my setup (Windows 7 x64, PHP 5.3.6, Apach 2.2+ VC9):
- include_once = 0.023 - 0.025
- include = 0.024 - 0.026
170 get_included_files() before I reach this line.
Not really the holly grail of performance in my opinion considering it's just one lousy call.
#6
@
14 years ago
Regardless of justification for performance reasons, you've yet to justify it for functional reasons.
There would be three functions.php files in this case -- grandchild, child, and parent.
Core, presumably, would believe that the grandchild is STYLESHEETPATH, and the child is TEMPLATEPATH. You've then hooked in and did final checks for parent templates in the various hierarchy trees, if I had to guess.
At that point, your grandchild theme should know it needs to include the grandparent functions.php. No extra juggling required.
#7
@
14 years ago
You can not include the parent as it's already include with include(). The inclusion is done before the include ends and PHP does not track it.
I know this error and it's how it should be. PHP marks a file as included at the end of the call. But there are three themes involved:
- Root
- Parent
- Child
Without include_once() Parent can not be activated. You can just use the Original and last Child. Do some tests. Including a file with include once in the same include breaks: Double declaration. No going around.
#8
@
14 years ago
Root, Parent, and Child. Which one is stylesheet, which one is template, which one is neither, and how are you loading the third one?
#9
@
14 years ago
Root is THEME. Fully featured theme I bought.
Parent is a brutal modification. Remove sidebars, added others, changed stylesheets, some hooks inside functions.php but rather empty.
Child is another modification, this time of the Parent. It has its own extra hooks in functions.php and build on the parent. It's designed for one site only.. Each of these stylesheets use @include to pull the closest parent's.
Each child will be a blog. Special design for a VERY blog. But as the Parent is the Root changed drastically, I need them all. The child relies on the parent's changes while the parent depends on the root to exist.
#11
@
14 years ago
STYLESHEETPATH is Parent or Child. TEMPLATEPATH is Root or Parent. So Parent/Child and Root/Parent combinations. But they include each other. Child includes Parent, Parent includes Root... and this is where it breaks. If Child went directly for Root, it will lose the Parent vital modifications, if it goes for Parent, the Parent has to load Root.
But if I use the Parent theme, WordPress includes Root.
Parent includes Root, WordPress includes Root when using Parent as theme. This is the breaking point.
#12
@
14 years ago
You should be able to properly detect this already, without any help from WordPress.
In your Parent theme, you need to include Root, but *only* when the parent theme is being used as a child theme.
if ( STYLESHEETPATH == dirname( __FILE__ ) )
in the parent theme's functions.php. If that returns true, it's being used as a child theme. False, being used as a parent theme.
Can also do: if ( get_stylesheet() == 'parent_theme_name' )
-- serves the same purpose.
Point is, you can do all of these checks. You don't need to blindly include files. WordPress doesn't need to change for what you're trying to do.
#13
@
14 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Severity changed from major to normal
- Status changed from new to closed
The patch.