Created
May 3, 2014 20:47
-
-
Save ginsterbusch/725903f2f3b0ef36f63e to your computer and use it in GitHub Desktop.
Function to disable plugins in WordPress
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 | |
/** | |
* Direct update of the stored active plugins (in wp_options table) | |
* @see http://perishablepress.com/quickly-disable-or-enable-all-wordpress-plugins-via-the-database/ | |
* | |
* @author Fabian Wolf (@link http://usability-idealist.de/) | |
*/ | |
function disable_plugin() { | |
$active_plugins = get_option( 'active_plugins', array() ); | |
/*echo '<pre>'.print_r( array( 'active_plugins' => $active_plugins, 'plugin_basename' => plugin_basename(__FILE__) ) , true).'</pre>'; | |
exit;*/ | |
if( in_array( plugin_basename(__FILE__), $active_plugins ) != false ) { | |
$update_active_plugins = array(); | |
for( $n = 0; $n < sizeof( $active_plugins ); $n++ ) { | |
if( plugin_basename(__FILE__) != $active_plugins[ $n ] ) { | |
$update_active_plugins[] = $active_plugins[ $n ]; | |
} | |
} | |
//print_r( $update_active_plugins ); | |
//exit; | |
update_option( 'active_plugins', $update_active_plugins ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment