lukasbesch / bedrock-plugin-disabler
Disable certain plugins in non-production environments using PHP constants.
Installs: 45 229
Dependents: 1
Suggesters: 0
Security: 0
Stars: 51
Watchers: 4
Forks: 6
Open Issues: 0
Type:wordpress-muplugin
Requires
- php: >=5.6
- composer/installers: ^1.4|^2.0
Requires (Dev)
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2025-01-06 16:32:30 UTC
README
Define an array of plugins that deactivate automatically in certain environments (e.g. caching plugins in development).
Inspired by this blog post by Kamil Grzegorczyk.
Uses a fork of the DisablePlugins
class written by Mark Jaquith.
Installation
This plugin is designed to work with Bedrock based sites, and will not work with a Standard WordPress installation.
$ composer require lukasbesch/bedrock-plugin-disabler
It will be installed as a wordpress-muplugin
.
If you try to activate it as a regular plugin, the plugin will deactivate itself with a notice.
Manual Installation (not recommended)
Download the latest release and place it in your web/app/mu-plugins
folder.
Usage
Define the constant DISABLED_PLUGINS
with an array of the plugins main files you want to deactivate in your preferred environment configuration, for example config/environments/development.php
:
Config::define('DISABLED_PLUGINS', [ 'autoptimize/autoptimize.php', 'updraftplus/updraftplus.php', 'wp-super-cache/wp-cache.php', 'w3-total-cache/w3-total-cache.php', ]);
If you have an older Bedrock installation (< 1.9.0) you have to define the constant using the regular define()
function:
if (! defined('DISABLED_PLUGINS') define('DISABLED_PLUGINS', [ 'autoptimize/autoptimize.php', ]); }
PHP 5.6+ can store arrays in constants, but you can also provide serialized data:
Config::define('DISABLED_PLUGINS', serialize([ 'autoptimize/autoptimize.php', ]));