Ticket #9838: 9838.diff
| File 9838.diff, 6.4 KB (added by , 17 years ago) |
|---|
-
wp-admin/plugins.php
11 11 12 12 if ( isset($_POST['clear-recent-list']) ) 13 13 $action = 'clear-recent-list'; 14 elseif ( isset($_REQUEST['action']) )14 elseif ( !empty($_REQUEST['action']) ) 15 15 $action = $_REQUEST['action']; 16 elseif ( !empty($_REQUEST['action2']) ) 17 $action = $_REQUEST['action2']; 16 18 else 17 19 $action = false; 18 20 … … 36 38 switch ( $action ) { 37 39 case 'activate': 38 40 check_admin_referer('activate-plugin_' . $plugin); 41 39 42 $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin); 40 43 if ( is_wp_error( $result ) ) 41 44 wp_die($result); 45 42 46 $recent = (array)get_option('recently_activated'); 43 47 if ( isset($recent[ $plugin ]) ) { 44 48 unset($recent[ $plugin ]); 45 49 update_option('recently_activated', $recent); 46 50 } 51 47 52 wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above 48 53 exit; 49 54 break; 50 55 case 'activate-selected': 51 56 check_admin_referer('bulk-manage-plugins'); 52 activate_plugins($_POST['checked'], 'plugins.php?error=true');53 57 58 $plugins = $_POST['checked']; 59 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Only activate plugins which are not already active. 60 if ( empty($plugins) ) { 61 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 62 exit; 63 } 64 65 activate_plugins($plugins, 'plugins.php?error=true'); 66 54 67 $recent = (array)get_option('recently_activated'); 55 68 foreach( (array)$_POST['checked'] as $plugin => $time) { 56 69 if ( isset($recent[ $plugin ]) ) 57 70 unset($recent[ $plugin ]); 58 71 } 72 59 73 if( $recent != get_option('recently_activated') ) //If array changed, update it. 60 74 update_option('recently_activated', $recent); 61 75 … … 64 78 break; 65 79 case 'error_scrape': 66 80 check_admin_referer('plugin-activation-error_' . $plugin); 81 67 82 $valid = validate_plugin($plugin); 68 83 if ( is_wp_error($valid) ) 69 84 wp_die($valid); 85 70 86 error_reporting( E_ALL ^ E_NOTICE ); 71 87 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. 72 88 include(WP_PLUGIN_DIR . '/' . $plugin); … … 82 98 break; 83 99 case 'deactivate-selected': 84 100 check_admin_referer('bulk-manage-plugins'); 85 deactivate_plugins($_POST['checked']); 101 102 $plugins = (array)$_POST['checked']; 103 $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated. 104 if ( empty($plugins) ) { 105 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 106 exit; 107 } 108 109 deactivate_plugins($plugins); 110 86 111 $deactivated = array(); 87 foreach ( (array)$_POST['checked']as $plugin )112 foreach ( $plugins as $plugin ) 88 113 $deactivated[ $plugin ] = time(); 114 89 115 update_option('recently_activated', $deactivated + (array)get_option('recently_activated')); 90 116 wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page"); 91 117 exit; … … 96 122 97 123 check_admin_referer('bulk-manage-plugins'); 98 124 99 $plugins = $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen. 125 $plugins = (array)$_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen. 126 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins. 127 if ( empty($plugins) ) { 128 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 129 exit; 130 } 131 100 132 include(ABSPATH . 'wp-admin/update.php'); 101 133 102 134 $parent_file = 'plugins.php'; … … 369 401 if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 370 402 $actions[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; 371 403 372 if ( ! empty($plugin_data['PluginURI']) ) { 373 $actions[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin homepage' ) . '">' . __('View Site') . '</a>'; 374 } 404 if ( ! $is_active && current_user_can('delete_plugins') ) $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; if ( ! empty($plugin_data['PluginURI']) ) $actions[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin homepage' ) . '">' . __('View Site') . '</a>'; 375 405 376 406 if ( ! $is_active && current_user_can('delete_plugins') ) 377 407 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; … … 393 423 } 394 424 echo '</div>'; 395 425 echo "</td> 396 <td class='desc'><p>{$plugin_data['Description']}</p> ";426 <td class='desc'><p>{$plugin_data['Description']}</p><p>"; 397 427 if ( !empty($plugin_data['Version']) ) { 398 428 printf(__('Version: %s'), $plugin_data['Version']); 399 429 echo ' '; … … 404 434 $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 405 435 echo ' <cite>' . sprintf( __('By: %s'), $author ) . '</cite>'; 406 436 } 407 echo "</p>";437 echo '</p>'; 408 438 echo '</td> 409 439 </tr>'; 410 440 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context ); … … 421 451 * 422 452 * @param string $context 423 453 */ 424 function print_plugin_actions($context) { 454 function print_plugin_actions($context, $field_name = 'action' ) { 455 425 456 ?> 426 457 <div class="alignleft actions"> 427 <select name=" action">458 <select name="<?php echo $field_name ?>"> 428 459 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 429 460 <?php if ( 'active' != $context ) : ?> 430 461 <option value="activate-selected"><?php _e('Activate'); ?></option> … … 508 539 <?php 509 540 if ( $page_links ) 510 541 echo "<div class='tablenav-pages'>$page_links_text</div>"; 542 543 print_plugin_actions($status, "action2"); 511 544 ?> 512 <div class="alignleft actions">513 <!-- TODO lower bulk actions. -->514 545 </div> 515 </div>516 546 </form> 517 547 518 548 <?php if ( empty($all_plugins) ) : ?>