Created
May 20, 2014 18:01
-
-
Save aaemnnosttv/67a03302c51f09a5f669 to your computer and use it in GitHub Desktop.
Soft Disable All WP Plugins
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 | |
/** | |
* Plugin Name: Soft disable all WP plugins | |
* Author: Evan Mattson (@aaemnnosttv) | |
* Description: Allows all plugins to be softly disabled and re-enabled using a single constant. | |
* Version: 1.0 | |
* | |
* Usage: Install this under mu-plugins/, and define('SOFT_DISABLE_PLUGINS', true) to soft disable all plugins. | |
* Delete/comment-out the constant definition or set to false to restore all plugins to their previous active states. | |
* | |
* For WordPress 3.0 and above | |
*/ | |
if ( !defined('SOFT_DISABLE_PLUGINS') ) | |
define('SOFT_DISABLE_PLUGINS', false); | |
if ( SOFT_DISABLE_PLUGINS ) | |
{ | |
add_filter('pre_option_active_plugins' , '__return_empty_array' , 9999); | |
// This next filter prevents the active_plugins setting from being updated (wiped out) while we have them all disabled. | |
// update_option will not update an option if the new value === old value. | |
add_filter('pre_update_option_active_plugins' , '__return_empty_array' , 9999); | |
} |
Hello and thanks for sharing.
One ting puzzles me: would that be a useful plugin to convert an existing single WP site into a multi-site installation? They recommend to close all plugins for that purpose - which is a bummer because of several settings getting lost I guess - but I'm not sure if keeping those settings in the database would ruin the multi-site conversion... Perhaps you have an idea? Cheers.
This code isn't designed to work with multisite, but it could be used for that purpose I suppose. It does not however affect network-enabled plugins for a site already running as a multisite.
Thank you for this, it is much appreciated...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!!