Ticket #9838: 9838.3.diff
| File 9838.3.diff, 7.7 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) ) 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 }375 376 404 if ( ! $is_active && current_user_can('delete_plugins') ) 377 405 $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>'; 378 406 407 if ( ! empty($plugin_data['PluginURI']) ) 408 $actions[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin homepage' ) . '">' . __('View Site') . '</a>'; 409 379 410 $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); 380 411 $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); 381 412 $action_count = count($actions); … … 384 415 <tr class='$class'> 385 416 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th> 386 417 <td class='plugin-title'><strong>{$plugin_data['Name']}</strong>"; 387 $i = 0;388 418 echo '<div class="row-actions-visible">'; 389 419 foreach ( $actions as $action => $link ) { 390 ++$i; 391 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 420 $sep = end($actions) == $link ? '' : ' | '; 392 421 echo "<span class='$action'>$link$sep</span>"; 393 422 } 394 echo '</div>';395 echo "</td>396 <td class='desc'><p>{$plugin_data['Description']}</p> ";423 echo "</div> 424 </td> 425 <td class='desc'><p>{$plugin_data['Description']}</p><p>"; 397 426 if ( !empty($plugin_data['Version']) ) { 398 427 printf(__('Version: %s'), $plugin_data['Version']); 399 428 echo ' '; … … 402 431 $author = $plugin_data['Author']; 403 432 if ( !empty($plugin_data['AuthorURI']) ) 404 433 $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 405 echo ' <cite>' . sprintf( __('By: %s'), $author ) . '</cite>';434 echo '<cite>' . sprintf( __('By: %s'), $author ) . '</cite>'; 406 435 } 407 echo "</p>";408 echo '</td>436 echo '</p> 437 </td> 409 438 </tr>'; 410 439 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context ); 411 440 do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context ); … … 421 450 * 422 451 * @param string $context 423 452 */ 424 function print_plugin_actions($context) { 453 function print_plugin_actions($context, $field_name = 'action' ) { 454 425 455 ?> 426 456 <div class="alignleft actions"> 427 <select name=" action">457 <select name="<?php echo $field_name ?>"> 428 458 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 429 459 <?php if ( 'active' != $context ) : ?> 430 460 <option value="activate-selected"><?php _e('Activate'); ?></option> … … 508 538 <?php 509 539 if ( $page_links ) 510 540 echo "<div class='tablenav-pages'>$page_links_text</div>"; 541 542 print_plugin_actions($status, "action2"); 511 543 ?> 512 <div class="alignleft actions">513 <!-- TODO lower bulk actions. -->514 544 </div> 515 </div>516 545 </form> 517 546 518 547 <?php if ( empty($all_plugins) ) : ?>