mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 02:34:38 +00:00
Deactivate plugins during plugin update. Props DD32. see #6262
git-svn-id: https://develop.svn.wordpress.org/trunk@7465 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -31,7 +31,7 @@ function get_plugin_data( $plugin_file ) {
|
||||
return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version);
|
||||
}
|
||||
|
||||
function get_plugins() {
|
||||
function get_plugins($plugin_folder = '') {
|
||||
global $wp_plugins;
|
||||
|
||||
if ( isset( $wp_plugins ) ) {
|
||||
@@ -40,6 +40,8 @@ function get_plugins() {
|
||||
|
||||
$wp_plugins = array ();
|
||||
$plugin_root = ABSPATH . PLUGINDIR;
|
||||
if( !empty($plugin_folder) )
|
||||
$plugin_root .= $plugin_folder;
|
||||
|
||||
// Files in wp-content/plugins directory
|
||||
$plugins_dir = @ opendir( $plugin_root);
|
||||
@@ -86,6 +88,10 @@ function get_plugins() {
|
||||
return $wp_plugins;
|
||||
}
|
||||
|
||||
function is_plugin_active($plugin){
|
||||
return in_array($plugin, get_option('active_plugins'));
|
||||
}
|
||||
|
||||
function activate_plugin($plugin, $redirect = '') {
|
||||
$current = get_option('active_plugins');
|
||||
$plugin = trim($plugin);
|
||||
@@ -109,7 +115,7 @@ function activate_plugin($plugin, $redirect = '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
function deactivate_plugins($plugins) {
|
||||
function deactivate_plugins($plugins, $silent= false) {
|
||||
$current = get_option('active_plugins');
|
||||
|
||||
if ( !is_array($plugins) )
|
||||
@@ -121,7 +127,8 @@ function deactivate_plugins($plugins) {
|
||||
continue;
|
||||
if ( ( $key = array_search( $plugin, $current) ) !== false )
|
||||
array_splice($current, $key, 1 ); // Fixed Array-fu!
|
||||
do_action('deactivate_' . trim( $plugin ));
|
||||
if ( ! $silent )
|
||||
do_action('deactivate_' . trim( $plugin ));
|
||||
}
|
||||
|
||||
update_option('active_plugins', $current);
|
||||
|
||||
Reference in New Issue
Block a user