If you develop a plugin that is introducing additional post types, you mostly need to add templates, css, images, functions etc. to the WordPress system.
Basically, you would put these into the plugin’s directory. But when it comes to customization for your clients, where to put those modified templates, functions or assets? You don’t want alter your plugin files or additions to your plugin folder as it won’t be able to update the plugin, safely.
Next place is the theme’s directory. Put some filter or action hooks into the theme’s functions.php, append CSS to the theme’s CSS or custom.css and load some additional files into the theme’s directory. But this will fail if you need to update the theme or – even worse – the client clicks on „update theme“ on his own. On many themes out there, all your changes will be lost! Hopefully, you have already backed up your latest changes…
One thing helps against this issue: Get your plugin-specific modifications into the theme’s core itself. But your plugin’s name has to be WooCommerce or bbPress to be integrated into a wide set of themes!
As you will see, I go one step further than WooCommerce:
Over the past 2 years facing these problems, I developed another concept:
With this concept you can create separate plugins that act like „Child Themes“ for your plugin
- Your plugin stays untouched
- The theme stays untouched
- Modifications can be deliverd separately as an additional plugin
- Different pluggable layouts/themes can be delivered for your plugin
- Theme-dependent modifications can still be put into a subfolder in the theme
- Don’t confuse your plugin’s users by telling them something about filter and action hooks in your templates
- Make your plugin HTML easily modifiable in a Child Theme manner (like WooCommerce does in /shop/) by overriding your templates
Right before writing this blog post, I found a post from 4 years ago by Automattic’s Ian Dunn on WordPress.org/ideas asking if it wouldn’t be great to have a concept of „Child Plugins“ – here we go, now!
I’ve put my code on GitHub as two installable plugins (parent and child) – contributions and feedback are extremely welcome!
My first question for you: How to name those Child plugins? „Plugin Theme“, „Plugin Layout“, „Plugin Design“, or just „Child Plugin“? I personally prefer „Plugin Theme“ which shows its proximity to „WordPress Theme“, but it may somehow be confusing.
What’s your opinion about it? Please tell me, right now!