Changeset 11474
- Timestamp:
- 05/28/2009 11:02:16 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/plugins.php
r11450 r11474 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; … … 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 ]) ) { … … 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; … … 50 55 case 'activate-selected': 51 56 check_admin_referer('bulk-manage-plugins'); 52 activate_plugins($_POST['checked'], 'plugins.php?error=true'); 57 58 $plugins = (array) $_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'); 53 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); 71 72 update_option('recently_activated', $recent); 61 73 62 74 wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page"); … … 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. … … 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"); … … 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 … … 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 … … 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 } … … 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); … … 426 454 * @param string $context 427 455 */ 428 function print_plugin_actions($context ) {456 function print_plugin_actions($context, $field_name = 'action' ) { 429 457 ?> 430 458 <div class="alignleft actions"> 431 <select name=" action">459 <select name="<?php echo $field_name; ?>"> 432 460 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 433 461 <?php if ( 'active' != $context ) : ?> … … 513 541 if ( $page_links ) 514 542 echo "<div class='tablenav-pages'>$page_links_text</div>"; 515 ?> 516 <div class="alignleft actions"> 517 <!-- TODO lower bulk actions. --> 518 </div> 543 544 print_plugin_actions($status, "action2"); 545 ?> 519 546 </div> 520 547 </form>
Note: See TracChangeset
for help on using the changeset viewer.