Disable specified WordPress plugins in your development environment. Useful for plugins that either make network calls you don't want when working (eg, auto-posting to Facebook), or for plugins that rely on services only available in production (eg, Varnish).
<?php
/**
* Disable specified plugins in development environment.
*
* This is a "Must-Use" plugin. Code here is loaded automatically before regular plugins load.
* This is the only place from which regular plugins can be disabled programatically.
*
* Place this code in a file in WP_CONTENT_DIR/mu-plugins or specify a custom location
* by setting the WPMU_PLUGIN_URL and WPMU_PLUGIN_DIR constants in wp-config.php.
*
* This code depends on a server environment variable of WP_ENV, which I set
* to "development" or "production" in each particular server/environment.
*/
/* Disable specified plugins in development environment */
if (empty($_SERVER['WP_ENV']) || $_SERVER['WP_ENV'] != 'production') {
$plugins = array(
'add-link-to-facebook/add-link-to-facebook.php',
'varnish-http-purge/varnish-http-purge.php',
);
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
deactivate_plugins($plugins);
}