Skip to content

Instantly share code, notes, and snippets.

@tillkruss
Last active December 11, 2015 14:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tillkruss/4616592 to your computer and use it in GitHub Desktop.
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.
<?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