As I develop a new theme, I want to package plugins with my theme. Normally, plugins are installed under wp-content/plugins – but if you are distributing your theme, you need a clean, WordPress-familiar way of distributing the corresponding plugins as well (especially the plugins your theme depends upon).
Turns out that Thomas Griffin has created a nice class here: https://github.com/thomasgriffin/TGM-Plugin-Activation
Do the following:
- Dump the plugins you wish to package with your theme somewhere inside of your theme folder hierarchy (for me, it was something like mytheme/plugins/plugin1.zip).
- Add the class file from Griffin to your theme. Remember to ‘require_once’ on the file from your functions.php file.
- Take a look at Griffin’s example.php file, copy over the WordPress action hook and function implementation to your theme to your functions.php file. Tweak the plugin references to the plugins you just dumped in your theme (step #1).
Voila! When the child theme developer activates the theme and moves around the Administration area, there will be a message at the top of every page reminding them to install and activate the plugins that you specified. Looks something like this: