Created
July 4, 2017 03:52
-
-
Save johanoloflindberg/4533992aa0f33c67de5c3e150dc19e31 to your computer and use it in GitHub Desktop.
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment