One of the chief difficulties in separating functionality and style is that there is no longer a nice “package” to present to a client. When handing off the custom theme there needs to be some detailed explanation about required plugins and installation, and setup of these plugins is a time consuming and onerous task.
With TGM Plugin activation not only is there no need to have to remember which plugins are required and/ or suggested but they are very easy to install.
To quote form the documentation:
TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference pre-packaged plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
Using TGM Plugin Activation
In order to use it you only need to include the class within a theme.
Now at first glance this doesn’t seem terribly different than WordPress’ own Must Use Plugins but there are some important differences. The most obvious one is that the plugin remains visible in the plugin panel and can be deactivated if need be. It is installed and updated in the same manner as other plugins.
TGM is pretty easy to use. Simply download it, include it in your theme files and require it using
require_once dirname( __FILE__ ) . '/inc/class-tgm-plugin-activation.php'; this assumes you have it in a directory called inc and are calling it from functions.php in your theme.
It comes with an example.php file which explains quite clearly what to do in each scenario.
Not only does it require and install plugins that are packaged with the theme but it can also install them from a private repository or directly from the WordPress Plugin repository.
As long as a plugin with the required name, slug and version (if applicable) is present in the plugins directory no message will be displayed. Otherwise there is either and unobtrusive message that can be dismissed:
Or a more insistant message that requires plugin installation and activation. It can also be configured be a bit more insistant still with no option to dismiss.
This library does lots to solve the difficulties of separating functionality and style in WordPress custom themes. It makes life easier for those who need to deliver a packaged product without a disclaimer of “Some assembly required.”