Ticket #6871: 6871.diff
| File 6871.diff, 2.0 KB (added by , 18 years ago) |
|---|
-
wp-admin/includes/plugin.php
175 175 update_option('active_plugins', array()); 176 176 return; 177 177 } 178 179 //Invalid is any plugins which are deactivated due to error. 180 $invalid = array(); 178 181 179 182 // If a plugin file does not exist, remove it from the list of active 180 183 // plugins. 181 184 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); 189 189 } 190 190 } 191 192 return $invalid; 191 193 } 192 194 193 195 function validate_plugin($plugin) { 194 196 if ( validate_file($plugin) ) 195 197 return new WP_Error('plugin_invalid', __('Invalid plugin.')); 198 196 199 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) 197 200 return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); 198 201 202 $plugins = get_plugins(); 203 if ( ! isset($plugins[ $plugin ]) ) 204 return new WP_Error('plugin_not_proper', __('Invalid plugin.')); 205 199 206 return 0; 200 207 } 201 208 -
wp-admin/plugins.php
39 39 $title = __('Manage Plugins'); 40 40 require_once('admin-header.php'); 41 41 42 validate_active_plugins(); 42 $invalid = validate_active_plugins(); 43 if( ! 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>' 43 46 44 47 ?> 45 48