My Theme defines its own actions and filters so that it can be extended by third-parties without having to fork or modify the Theme’s core code.
I already have a few plugins specific to my Theme, that I’m installing in the usual way in wp-content/plugins
and activating through the Admin panel.
However, for ease of use, I would like to bundle a few plugins directly into my Theme itself, for example in my_theme/plugins
, without having to require the user to move the plugins he wants to install to the WordPress plugin directory (thus breaking the Theme’s update capabilities, etc.).
Have you seen any Theme or Plugin that does that in an elegant way? What are best practices to doing that?
In particular, a few questions come to mind if I were to implement such a system:
- Is there a way to easily configure a custom plugin directory into WordPress, in addition to
wp-content/plugins
? - If I were to simply implement my own naive plugin activation system, what steps should I take? Do I just need to set up a basic admin panel listing, store a list of activated “custom plugins” and just include the corresponding PHP files on Theme init?
Thanks for your help!
EDIT: Related to, but different from, Are drop-in plugins a product of design and Add Plugins to WordPress Theme: in the present case, plugins don’t make sense without the Theme (they extend it) and they’re written by the same person/company.
See Add multiple plugin directories for one way to do this.
In an earlier project I did something similar, but I used a dedicated theme options page for my theme plugins.
Looking back ⦠I wouldnât do that again. Plugin updates are a too complicated, separated version control setups too. The client wasnât always sure where to look at when we were talking about plugins.
And sooner or later you may want to re-use a plugin from theme 1 for theme 2 â you end up copying files back and forth ⦠far from ideal.
You can bundle multiple (single file) plugins in one directory inside the regular plugin directory. In your theme you can use
is_plugin_active()
to check your requirements.TL;DR: Keep plugins and theme separate. You donât save any work by mixing both.
There’s another kid on the block in this regard that’s an addon for themes. It allows you create dependencies in a theme and handles guiding people through installation of the plugins you define in a nice way. The plugins don’t even have to be in the WP repo.
Check it out: http://tgmpluginactivation.com/
Ok, I’ve actually found (in yet another question) that the Carrington Theme includes bundled plugins. I’m still unsure however if this is done in the best possible way: https://wordpress.stackexchange.com/a/27533/4826