From 80c409458f84f7b25146da8a07f01fe2d60e7739 Mon Sep 17 00:00:00 2001 From: azaozz Date: Tue, 29 Jul 2008 23:10:12 +0000 Subject: [PATCH] Include only valid plugins. Props guillep2k, fixes #6871 git-svn-id: http://svn.automattic.com/wordpress/trunk@8495 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/plugin.php | 5 +++++ wp-admin/plugins.php | 6 ++++-- wp-settings.php | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index ac8f3b53e2..48f26ce516 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -304,14 +304,19 @@ function validate_active_plugins() { return; } + //Invalid is any plugin that is deactivated due to error. + $invalid = array(); + // If a plugin file does not exist, remove it from the list of active // plugins. foreach ( $check_plugins as $check_plugin ) { $result = validate_plugin($check_plugin); if ( is_wp_error( $result ) ) { + $invalid[$check_plugin] = $result; deactivate_plugins( $check_plugin, true); } } + return $invalid; } function validate_plugin($plugin) { diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 883d88bffe..a24e88aed8 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -165,8 +165,10 @@ wp_enqueue_script('admin-forms'); $title = __('Manage Plugins'); require_once('admin-header.php'); -validate_active_plugins(); - +$invalid = validate_active_plugins(); +if( !empty($invalid) ) + foreach($invalid as $plugin_file => $error) + echo '

' . sprintf(__('The plugin %s has been deactivated due to "%s".'), $plugin_file, $error->get_error_message()) . '

'; ?> diff --git a/wp-settings.php b/wp-settings.php index 3fc4f5168a..b1d7cd6a23 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -421,7 +421,7 @@ if ( get_option('active_plugins') ) { $current_plugins = get_option('active_plugins'); if ( is_array($current_plugins) ) { foreach ($current_plugins as $plugin) { - if ('' != $plugin && file_exists(WP_PLUGIN_DIR . '/' . $plugin)) + if ( '' != $plugin && ! validate_file($plugin) && file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) include_once(WP_PLUGIN_DIR . '/' . $plugin); } }