The Plugin Manager is designed to enforce the activation and deactivation of specific plugins based on the environment in which your WordPress site is running. It allows you to specify:
- Plugins to activate per environment.
- Plugins to deactivate per environment.
-
Add the plugin to your mu-plugins directory. Get it here.
- Create a file named
env-plugin-manager.php
.
- Create a file named
-
Ensure Plugin Files Exist:
- Verify that all plugins specified in the activation and deactivation arrays are installed in the
wp-content/plugins/
directory. - Remove the example plugins from the arrays
$plugins_to_activate
and$plugins_to_deactivate
- Verify that all plugins specified in the activation and deactivation arrays are installed in the
- Define
WP_ENV
: Must be defined inwp-config.php
or via server environment variables. - Possible Values:
'local'
,'staging'
,'production'
Edit the $plugins_to_activate
array in the plugin-manager.php
file:
$plugins_to_activate = array(
'local' => array(
'query-monitor/query-monitor.php',
'debug-bar/debug-bar.php',
),
'staging' => array(
'maintenance-mode/maintenance-mode.php',
),
'production' => array(
'cache-plugin/cache-plugin.php',
'seo-plugin/seo-plugin.php',
),
);
Edit the $plugins_to_deactivate
array:
$plugins_to_deactivate = array(
'local' => array(
'cache-plugin/cache-plugin.php', // Disable caching on local
),
'staging' => array(
'seo-plugin/seo-plugin.php', // Disable SEO plugin on staging
),
'production' => array(
'query-monitor/query-monitor.php', // Disable development plugins on production
),
);
For WordPress Multisite installations, the plugin manages network-activated plugins:
- Function:
manage_network_plugins( $plugins )
- Hook:
site_option_active_sitewide_plugins
- Format: Paths should be relative to the
wp-content/plugins/
directory. This will also work with Bedrock based sites, etc. - Example:
'plugin-folder/plugin-main-file.php'
- Ensure Correct Paths: Incorrect paths will prevent the plugin from being activated or deactivated as intended.
- Changes must be made directly in the
plugin-manager.php
file. - This plugin has no dependencies. Ensure there is a very very valid reason you will not allow specific plugins to be activated/deactivated before using this plugin.
- Missing plugins will be skipped silently. (so copy this plugin and load it up with your settings. You can then deploy it across all of your websites).
- Administrators cannot override the activation/deactivation settings via the WordPress admin interface. Any manual changes will be reset on the next page load.
This plugin is released under the GNU General Public License v2 or later.
Support: None. You're on your own.