Ticket #6871: 6871.diff

File 6871.diff, 2.0 kB (added by DD32, 4 months ago)
  • wp-admin/includes/plugin.php

    old new  
    175175                update_option('active_plugins', array()); 
    176176                return; 
    177177        } 
     178         
     179        //Invalid is any plugins which are deactivated due to error. 
     180        $invalid = array(); 
    178181 
    179182        // If a plugin file does not exist, remove it from the list of active 
    180183        // plugins. 
    181184        foreach ( $check_plugins as $check_plugin ) { 
    182                 if ( !file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin) ) { 
    183                         $current = get_option('active_plugins'); 
    184                         $key = array_search($check_plugin, $current); 
    185                         if ( false !== $key && NULL !== $key ) { 
    186                                 unset($current[$key]); 
    187                                 update_option('active_plugins', $current); 
    188                         } 
     185                $result = validate_plugin($check_plugin); 
     186                if ( is_wp_error( $result ) ) { 
     187                        $invalid[ $check_plugin ] = $result; 
     188                        deactivate_plugins( $check_plugin, true); 
    189189                } 
    190190        } 
     191 
     192        return $invalid; 
    191193} 
    192194 
    193195function validate_plugin($plugin) { 
    194196        if ( validate_file($plugin) ) 
    195197                return new WP_Error('plugin_invalid', __('Invalid plugin.')); 
     198 
    196199        if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) 
    197200                return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); 
    198201 
     202        $plugins = get_plugins(); 
     203        if ( ! isset($plugins[ $plugin ]) ) 
     204                return new WP_Error('plugin_not_proper', __('Invalid plugin.')); 
     205 
    199206        return 0; 
    200207} 
    201208 
  • wp-admin/plugins.php

    old new  
    3939$title = __('Manage Plugins'); 
    4040require_once('admin-header.php'); 
    4141 
    42 validate_active_plugins(); 
     42$invalid = validate_active_plugins(); 
     43if( ! empty($invalid) ) 
     44        foreach($invalid as $plugin_file => $error) 
     45                echo '<div id="message" class="updated fade"><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>' 
    4346 
    4447?> 
    4548