Please note: the following is “experimental”, although it has been tested and seems to be working, it was tested only briefly. This post is more to share the idea and see if I can’t get feedback to improve or reformat the idea. I am sure there is a good chance something like this has been implemented out there somewhere.
Since creating my own WordPress framework for personal and business use I have been constantly considering theme options. What is necessary, what is not and what my be limiting in terms of future development. I have always come to the same conclusion. That is, to go minimal on the framework theme options, limiting it to the basics that would be useful no matter the theme you create from the framework. Things like SEO, Analytics inserts etc.
This left me with a question. What if certain theme options make sense when developing future themes from the framework?
Let me back up a minute it is important that I note I am talking about a framework from which I create themes via Child Theme. Basically this means I create a theme which uses the framework as a template but without actually touching the framework theme files. See this post on ThemeShaper for further information.
Ok so back to the question, how do I keep the framework options minimal and allow the addition of new theme options to the existing options through the child theme?
This morning after some work I believe I stumbled on a solution. Have a look at the files below starting with the framework theme options page here. Pay close attention to the following lines…
$childoptions = apply_filters('childtheme_options_test', $childoptions);
$options = wp_parse_args( $childoptions, $options);
This is condensed version of the options setup for example purposes only, for further info on this please see this post.
// Create theme options
$options = array (
array( "name" => "General",
"type" => "heading"),
array( "type" => "open"),
array( "name" => "Logo",
"desc" => "Enter the full path to your custom logo here.",
"id" => $shortname."_logo",
"std"; => " ",
"type" => "text", ),
array( "type" => "close"),
);
$childoptions = apply_filters('childtheme_options_test', $childoptions);
$options = wp_parse_args( $childoptions, $options);
Now you will see in the child theme functions file where I was able to add a filter, basically adding new options to the theme without modifying the framework.
function child_options_test() {
$shortname = "etm";
$options = array (
array( "name" => "Test",
"type" => "heading"),
array( "type" => "open" ),
array( "name" => "Test",
"desc" => "Enter custom text here.",
"id" => $shortname."_logo",
"std"; => " ",
"type" => "text", ),
array( "type" => "close"),
);
return $options;
}
add_filter('childtheme_options_test', 'child_options_test');
Finally I would hook the output of this new option to the theme framework in the desired place via a new child theme function.
Before you implement this I will say, I do not recommend it without doing your own testing. I have tested it and it seems to work as planned, however this post was not meant to be a tutorial. What I am looking for here is some feedback on the implementation to see if it has merit or if there is a smarter way to go about this.
Please feel free to comment below or contact me with your thoughts on this implementation.
This was a cool trick. I had a different way to define theme options but after playing around I saw this actually worked great. I have extra child theme options.
One thing that I think will not work is trying to put multiple options (extra options) for existing ones and at different places. will need to do more research on placements.
Nice, I would love to hear what you discover. I have changed up how my base theme handles options quite a bit since I posted this and have been experimenting with hooks and such that allow me to add theme options to my child themes. Also I have tried to eliminate anything but the basics(universal options) from my base theme options allowing me to keep it simple only adding options if absolutely necessary and entirely through the child theme. I will more than likely release a theme in the future with this new handling but for now it’s mostly used on personal projects and in testing. I do feel like there is a way that you could manipulate options that are already in place if you found a need for doing this. It would of course have to be built into the framework that way. Let me know what you figure out and thanks for the comment!
Thanks for the post on this. I just put some work into creating a Thematic child theme with 3 default options for a adding a logo, selecting stylesheets, and google analytics. I also built it to be easily expandable for additional options. Free free to check out the code and use it:
http://wordpresstheming.com/2009/10/thematic-theme-options-panel/
Hello
This is a great way to define options in a theme.
I wanted to know if it is possible to create child themes of existing child themes. What I meant was that I’m already using a theme which is a child theme. I wanted to make some changes to the child theme and instead of modifying the child theme files I thought it would be better if I create a child theme of an existing child theme. Is this possible as it does not seem to be working for me.
Thanks in advance.
Pali Madra
Hi Pali – Thanks for the comment. You pose an interesting question here, one I’ve had to think about before replying and have a feeling I still will not give the greatest answer.
For starters I would have a look at these two discussions http://www.wptavern.com/forum/themes-templates/464-grand-child-themes.html and http://ptahdunbar.com/wordpress/on-using-wordpress-theme-frameworks/.
In my personal opinion I am not sure that I see it being necessary nor would I look to attempt it if it is in fact possible. It seems to me that most child themes are built with the idea that code modification is minimal and the majority of the child theme concentrates on design accomplished via css. The heavy lifting is accomplished by the core/parent theme, thus the only reason that a child theme might need to be upgraded is if there was a major change in the parent theme. For instance themename-hook-header gets the axe, said child theme happens to hook into themename-hook-header and on upgrade of the parent theme there are problems. That doesn’t take into account that the theme framework author would more than likely deprecate the function thus making it available for some time there after. (Ideally all of this would be well documented and easy to follow.)
That aside, let’s say at this point the original child theme author decides to upgrade the child theme to account for the parent theme change, it would more than likely be very minimal and something you could take care of in a matter of minutes without actually needing to undergo a full upgrade of the child theme as well.
I’m rambling here but hopefully that makes some sense. I think the idea here is to protect the parent theme from core modification, leaving the child theme to allow you to do what you would like with it. Ultimately if the original parent theme was well planned and upgrades are well documented then any absolutely necessary upgrades to the child theme should be minimal and easy to maintain without having to undergo a full upgrade.
I suppose that if the original base child theme was some extreme modification of the parent theme, then there might be reason for concern but even then I am not sure.
Hopefully that helps in your decision, definitely read the two linked posts as well and let me know what you decide to do.
Hi Jeremy. Thanks for posting the thoughtful reply to Pali’s question. I would agree with the remarks in the Tavern. Once you get two child themes deep, you’re then making modifications of modifications? Seems very complicated and indirect.
Exactly, it seems like it would start a perpetual cycle. Let’s say Grandchild themes are possible – Parent theme get’s upgraded with something major so the original child theme get’s upgraded leading to the possibility that the grandchild theme now needs an upgrade so where do you stop? It would be my opinion that the child theme should be the end point. If you were looking at modifying the child theme css file only, I suppose that you could do so by adding a new style sheet and hooking that into the head. As long as you set the order correctly you could potentially modify the child theme without actually modifying the child theme, if that makes sense.
Jeremy,
Thank you for replying to comment. The community of WordPress thrives on participation from people like you. I want to assure you the comments you have made are not rambling in fact they are interesting and I have read your comment thrice!
I have gone through the links and some of the people specially those of Green Shady. After going through the content provided by you I have understood the concept of Frameworks and Child Themes better.
I also agree that creating “grand child” themes would be like taking the concept too far and implementing child themes would be complex and it is unlikely that it would be a smooth process.
Therefore I have decided for the particular project to go in for modifying the child theme. Actually it is a child theme developed by StudioPress. I will keep you posted on how it goes.
Please advise if you think it is not the correct decision.
Thanks once again. You have one more fan now.
Pali Madra
Pali -
You are welcome, I enjoy getting into discussions like this. For starters anything by StudioPress is obviously an extremely solid theme to start with, plus you know that it’s going to come with good documentation and history of changes whenever an upgrade is performed. It doesn’t hurt to know that it is also a solid company behind the theme that I don’t see disappearing anytime in the near future. That aside I would be interested to hear their thoughts on recommended course of action for modification given that it looks like they will be porting all of their themes to the Genesis Framework as child themes.
Have you attempted to start a discussion on this in the support forum, or even tried reaching out to one of the developers via Twitter to ask opinions? All parties involved in the StudioPress company are top notch when it comes to WordPress knowledge so like I said, I would definitely be interested to hear their recommendations.
Don’t hesitate to drop by and leave updates on this thread, find me on Twitter or even email me if you would like. I took interest in the child theme concept when frameworks like Thematic and Hybrid came to be and started promoting the idea. Since then I have more or less developed my own adaptation of a framework that works best for my development style but of course I am still very interested to see how others work with frameworks and child themes so please feel free to come by for discussion as you work through this project.
Look forward to you coming back around in the future and thanks again for starting this conversation.
Excellent post, very rare topic, even a year later.
I have this working perfectly on a new theme for WordPress 3.0.
Cheers!
Brian -
Thank for leaving a comment, glad you found the post useful and good to hear it’s still working in 3.0! It depends somewhat on how the parent theme creates options in the first place I suppose, none the less I know this works with a few of them out there.
Jeremy