Last active
March 19, 2024 19:09
-
-
Save subharanjanm/4272d25a446fb2ca12a549a4a5662633 to your computer and use it in GitHub Desktop.
Deactivate certain plugins in the development/staging environment of WP Engine
This file contains 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 | |
/* | |
Plugin Name: Deactivate Certain Plugins - WPEngine Staging | |
Plugin URI: https://gist.github.com/subharanjanm/4272d25a446fb2ca12a549a4a5662633 | |
Description: Deactivate certain plugins in the development/staging environment of WP Engine. | |
Version: 1.0 | |
Author: Subharanjan | |
Author URI: https://gist.github.com/subharanjanm/4272d25a446fb2ca12a549a4a5662633 | |
License: GPLv2 | |
*/ | |
/** | |
* Deactivate some plugins in the development/staging 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/decativated 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 server environment variable `IS_WPE_SNAPSHOT`. | |
* Also, you can use the variables like `HTTP_HOST` or `SERVER_NAME` to | |
* check for development/staging environment. | |
*/ | |
if ( getenv( 'IS_WPE_SNAPSHOT' ) == 1 ) { | |
$plugins = array( | |
'coschedule-by-todaymade/tm-scheduler.php', | |
'google-analyticator/google-analyticator.php', | |
'hubspot-tracking-code/hubspot-tracking-code.php', | |
); | |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
deactivate_plugins( $plugins ); | |
} |
I forked this into a version that will disable plugins based upon the site's domain.
eg:
website.com = Active plugins.
website.stagingserver.com = Disabled plugins
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the complete list of WPEngine server environment variables.