Last active
December 11, 2015 14:48
-
-
Save tillkruss/4616592 to your computer and use it in GitHub Desktop.
Force disable WordPress developer plugins in production environments. Depended on WP_STAGE constant. Use as MU plugin.
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: Disable Developer Plugins | |
Description: Force disables developer plugins in production environments. | |
*/ | |
$dev_plugins = array( | |
'debug-bar/debug-bar.php', | |
'debug-bar-cron/debug-bar-cron.php', | |
'debug-bar-extender/debug-bar-extender.php', | |
'developer/developer.php', | |
'log-deprecated-notices/log-deprecated-notices.php', | |
'rewrite-rules-inspector/rewrite-rules-inspector.php' | |
); | |
$active_plugins = (array) get_option( 'active_plugins', array() ); | |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); | |
foreach ( $active_plugins as $plugin ) { | |
if ( WP_STAGE === 'production' && in_array( $plugin, $dev_plugins ) ) { | |
deactivate_plugins( $plugin, false, is_network_admin() ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment