Ticket #9838: 9838.4.diff
| File 9838.4.diff, 5.6 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'; … … 363 395 364 396 if ( $is_active ) 365 397 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>'; 366 else //Inactive or Recently deactivated398 else 367 399 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>'; 368 400 369 401 if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) … … 385 417 <tr class='$class second'> 386 418 <td></td> 387 419 <td class='plugin-title'>"; 388 $i = 0;389 420 echo '<div class="row-actions-visible">'; 390 421 foreach ( $actions as $action => $link ) { 391 ++$i; 392 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 422 $sep = end($actions) == $link ? '' : ' | '; 393 423 echo "<span class='$action'>$link$sep</span>"; 394 424 } 395 425 echo "</div></td> … … 425 455 * 426 456 * @param string $context 427 457 */ 428 function print_plugin_actions($context) { 458 function print_plugin_actions($context, $field_name = 'action' ) { 459 429 460 ?> 430 461 <div class="alignleft actions"> 431 <select name=" action">462 <select name="<?php echo $field_name ?>"> 432 463 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 433 464 <?php if ( 'active' != $context ) : ?> 434 465 <option value="activate-selected"><?php _e('Activate'); ?></option> … … 512 543 <?php 513 544 if ( $page_links ) 514 545 echo "<div class='tablenav-pages'>$page_links_text</div>"; 546 547 print_plugin_actions($status, "action2"); 515 548 ?> 516 <div class="alignleft actions">517 <!-- TODO lower bulk actions. -->518 549 </div> 519 </div>520 550 </form> 521 551 522 552 <?php if ( empty($all_plugins) ) : ?>