Ticket #9838: 9838.5.diff
| File 9838.5.diff, 6.3 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 foreach ( (array)$_POST['checked'] as $plugin => $time) {68 foreach ( $plugins as $plugin => $time) 56 69 if ( isset($recent[ $plugin ]) ) 57 70 unset($recent[ $plugin ]); 58 }59 if( $recent != get_option('recently_activated') ) //If array changed, update it.60 update_option('recently_activated', $recent);61 71 72 update_option('recently_activated', $recent); 73 62 74 wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page"); 63 75 exit; 64 76 break; 65 77 case 'error_scrape': 66 78 check_admin_referer('plugin-activation-error_' . $plugin); 79 67 80 $valid = validate_plugin($plugin); 68 81 if ( is_wp_error($valid) ) 69 82 wp_die($valid); 83 70 84 error_reporting( E_ALL ^ E_NOTICE ); 71 85 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. 72 86 include(WP_PLUGIN_DIR . '/' . $plugin); … … 82 96 break; 83 97 case 'deactivate-selected': 84 98 check_admin_referer('bulk-manage-plugins'); 85 deactivate_plugins($_POST['checked']); 99 100 $plugins = (array)$_POST['checked']; 101 $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated. 102 if ( empty($plugins) ) { 103 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 104 exit; 105 } 106 107 deactivate_plugins($plugins); 108 86 109 $deactivated = array(); 87 foreach ( (array)$_POST['checked']as $plugin )110 foreach ( $plugins as $plugin ) 88 111 $deactivated[ $plugin ] = time(); 112 89 113 update_option('recently_activated', $deactivated + (array)get_option('recently_activated')); 90 114 wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page"); 91 115 exit; … … 96 120 97 121 check_admin_referer('bulk-manage-plugins'); 98 122 99 $plugins = $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen. 123 $plugins = (array)$_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen. 124 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins. 125 if ( empty($plugins) ) { 126 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 127 exit; 128 } 129 100 130 include(ABSPATH . 'wp-admin/update.php'); 101 131 102 132 $parent_file = 'plugins.php'; … … 363 393 364 394 if ( $is_active ) 365 395 $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 deactivated396 else 367 397 $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 398 369 399 if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) … … 385 415 <tr class='$class second'> 386 416 <td></td> 387 417 <td class='plugin-title'>"; 388 $i = 0;389 418 echo '<div class="row-actions-visible">'; 390 419 foreach ( $actions as $action => $link ) { 391 ++$i; 392 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 420 $sep = end($actions) == $link ? '' : ' | '; 393 421 echo "<span class='$action'>$link$sep</span>"; 394 422 } 395 423 echo "</div></td> … … 403 431 $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 404 432 $plugin_meta[] = sprintf( __('By %s'), $author ); 405 433 } 406 if ( ! empty($plugin_data['PluginURI']) ) {434 if ( ! empty($plugin_data['PluginURI']) ) 407 435 $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>'; 408 } 436 409 437 $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context); 410 438 echo implode(' | ', $plugin_meta); 411 439 echo "</p></td> … … 425 453 * 426 454 * @param string $context 427 455 */ 428 function print_plugin_actions($context) { 456 function print_plugin_actions($context, $field_name = 'action' ) { 457 429 458 ?> 430 459 <div class="alignleft actions"> 431 <select name=" action">460 <select name="<?php echo $field_name ?>"> 432 461 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 433 462 <?php if ( 'active' != $context ) : ?> 434 463 <option value="activate-selected"><?php _e('Activate'); ?></option> … … 512 541 <?php 513 542 if ( $page_links ) 514 543 echo "<div class='tablenav-pages'>$page_links_text</div>"; 544 545 print_plugin_actions($status, "action2"); 515 546 ?> 516 <div class="alignleft actions">517 <!-- TODO lower bulk actions. -->518 547 </div> 519 </div>520 548 </form> 521 549 522 550 <?php if ( empty($all_plugins) ) : ?>