Skip to content
Bedrock
v1.23.2

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:

  • development for local development
  • staging for a staging environment
  • production for 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 config/environments/.

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.

Open config/environments/development.php and add the DISABLED_PLUGINS constant:

Config::define('DISABLED_PLUGINS', [
    'wp-rocket/wp-rocket.php',
    'wp-super-cache/wp-cache.php',
]);

Contributors

Last updated

Support Roots

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