mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Include only valid plugins. Props guillep2k, fixes #6871
git-svn-id: http://svn.automattic.com/wordpress/trunk@8495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7add050b10
commit
80c409458f
@ -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) {
|
||||
|
@ -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 '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to <em>"%s"</em>.'), $plugin_file, $error->get_error_message()) . '</p></div>';
|
||||
?>
|
||||
|
||||
<?php if ( isset($_GET['error']) ) : ?>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user