From c664315b0138e39029bf52ee2cf1b337892dfc7e Mon Sep 17 00:00:00 2001 From: markjaquith Date: Thu, 24 Sep 2009 04:15:37 +0000 Subject: [PATCH] Active plugin filter, plugin deactivation array_splice() protection. props apeatling. fixes #10839 git-svn-id: http://svn.automattic.com/wordpress/trunk@11966 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/plugin.php | 11 ++++++++--- wp-settings.php | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 4dc0baac6..45dff3301 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -272,7 +272,7 @@ function get_plugins($plugin_folder = '') { * @return bool True, if in the active plugins list. False, not in the list. */ function is_plugin_active($plugin) { - return in_array($plugin, get_option('active_plugins')); + return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ); } /** @@ -347,7 +347,12 @@ function deactivate_plugins($plugins, $silent= false) { continue; if ( ! $silent ) do_action( 'deactivate_plugin', trim( $plugin ) ); - array_splice($current, array_search( $plugin, $current), 1 ); // Fixed Array-fu! + + $key = array_search( $plugin, (array) $current ); + + if ( false !== $key ) + array_splice( $current, $key, 1 ); + //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. if ( ! $silent ) { do_action( 'deactivate_' . trim( $plugin ) ); @@ -484,7 +489,7 @@ function delete_plugins($plugins, $redirect = '' ) { } function validate_active_plugins() { - $check_plugins = get_option('active_plugins'); + $check_plugins = apply_filters( 'active_plugins', get_option('active_plugins') ); // Sanity check. If the active plugin list is not an array, make it an // empty array. diff --git a/wp-settings.php b/wp-settings.php index 099d7e0e3..095e8a89d 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -552,7 +552,7 @@ if ( get_option('hack_file') ) { require(ABSPATH . 'my-hacks.php'); } -$current_plugins = get_option('active_plugins'); +$current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); if ( is_array($current_plugins) && !defined('WP_INSTALLING') ) { foreach ( $current_plugins as $plugin ) { // check the $plugin filename