Disable Plugins Based on Environment
Bedrock supports defining an environment with the
WP_ENV environment variable. A typical setup for a project could contain several different environments:
developmentfor local development
stagingfor a staging environment
productionfor the live/production environment
In some cases, you may want to enforce certain plugins to be deactivated on one or more of your environments.
The Bedrock Plugin Disabler mu-plugin package by @luke can be used to configure a list of disabled plugins in your Bedrock environment configs located in
Install the mu-plugin with Composer:
composer require lukasbesch/bedrock-plugin-disabler
This package requires defining a
DISABLED_PLUGINS constant with an array of plugin filenames to be disabled.
Disabling plugins on local development
The most common use-case is disabling caching plugins on local development. We'll cover disabling WP Rocket and WP Super Cache in the following example.
config/environments/development.php and add the
Config::define('DISABLED_PLUGINS', [ 'wp-rocket/wp-rocket.php', 'wp-super-cache/wp-cache.php', ]);
Help us continue to build and maintain our open source projects. We’re a small team of independent developers and every little bit helps.Sponsor Roots on GitHub