Created
April 5, 2017 13:18
-
-
Save duanecilliers/e0cefea19ff29f986bd1311b0bfb0d31 to your computer and use it in GitHub Desktop.
Deactivates plugins based on WP_ENV constant. Intended for use as an mu-plugin.
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 | |
/** | |
* Deactivate plugins based environment (WP_ENV) | |
* | |
* Used to deactivate plugins only needed in specific environments, caching and security for example. | |
* | |
* @package Duanec\DeactivatePlugins | |
*/ | |
namespace Duanec\DeactivatePlugins; | |
function deactivate( $file ) { | |
if ( is_plugin_active( $file ) ) { | |
deactivate_plugins( $file ); | |
} | |
} | |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
switch ( WP_ENV ) { | |
case 'development': | |
deactivate( 'w3-total-cache/w3-total-cache.php' ); | |
deactivate( 'ithemes-security-pro/ithemes-security-pro.php' ); | |
break; | |
case 'staging': | |
deactivate( 'w3-total-cache/w3-total-cache.php' ); | |
break; | |
case 'production': | |
default: | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment