| 1 | Index: wp-admin/plugins.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/plugins.php (revision 11460) |
|---|
| 4 | +++ wp-admin/plugins.php (working copy) |
|---|
| 5 | @@ -11,8 +11,10 @@ |
|---|
| 6 | |
|---|
| 7 | if ( isset($_POST['clear-recent-list']) ) |
|---|
| 8 | $action = 'clear-recent-list'; |
|---|
| 9 | -elseif ( isset($_REQUEST['action']) ) |
|---|
| 10 | +elseif ( !empty($_REQUEST['action']) ) |
|---|
| 11 | $action = $_REQUEST['action']; |
|---|
| 12 | +elseif ( !empty($_REQUEST['action2']) ) |
|---|
| 13 | + $action = $_REQUEST['action2']; |
|---|
| 14 | else |
|---|
| 15 | $action = false; |
|---|
| 16 | |
|---|
| 17 | @@ -36,37 +38,49 @@ |
|---|
| 18 | switch ( $action ) { |
|---|
| 19 | case 'activate': |
|---|
| 20 | check_admin_referer('activate-plugin_' . $plugin); |
|---|
| 21 | + |
|---|
| 22 | $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin); |
|---|
| 23 | if ( is_wp_error( $result ) ) |
|---|
| 24 | wp_die($result); |
|---|
| 25 | + |
|---|
| 26 | $recent = (array)get_option('recently_activated'); |
|---|
| 27 | if ( isset($recent[ $plugin ]) ) { |
|---|
| 28 | unset($recent[ $plugin ]); |
|---|
| 29 | update_option('recently_activated', $recent); |
|---|
| 30 | } |
|---|
| 31 | + |
|---|
| 32 | wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above |
|---|
| 33 | exit; |
|---|
| 34 | break; |
|---|
| 35 | case 'activate-selected': |
|---|
| 36 | check_admin_referer('bulk-manage-plugins'); |
|---|
| 37 | - activate_plugins($_POST['checked'], 'plugins.php?error=true'); |
|---|
| 38 | |
|---|
| 39 | + $plugins = $_POST['checked']; |
|---|
| 40 | + $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Only activate plugins which are not already active. |
|---|
| 41 | + if ( empty($plugins) ) { |
|---|
| 42 | + wp_redirect("plugins.php?plugin_status=$status&paged=$page"); |
|---|
| 43 | + exit; |
|---|
| 44 | + } |
|---|
| 45 | + |
|---|
| 46 | + activate_plugins($plugins, 'plugins.php?error=true'); |
|---|
| 47 | + |
|---|
| 48 | $recent = (array)get_option('recently_activated'); |
|---|
| 49 | - foreach( (array)$_POST['checked'] as $plugin => $time) { |
|---|
| 50 | + foreach ( $plugins as $plugin => $time) |
|---|
| 51 | if ( isset($recent[ $plugin ]) ) |
|---|
| 52 | unset($recent[ $plugin ]); |
|---|
| 53 | - } |
|---|
| 54 | - if( $recent != get_option('recently_activated') ) //If array changed, update it. |
|---|
| 55 | - update_option('recently_activated', $recent); |
|---|
| 56 | |
|---|
| 57 | + update_option('recently_activated', $recent); |
|---|
| 58 | + |
|---|
| 59 | wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page"); |
|---|
| 60 | exit; |
|---|
| 61 | break; |
|---|
| 62 | case 'error_scrape': |
|---|
| 63 | check_admin_referer('plugin-activation-error_' . $plugin); |
|---|
| 64 | + |
|---|
| 65 | $valid = validate_plugin($plugin); |
|---|
| 66 | if ( is_wp_error($valid) ) |
|---|
| 67 | wp_die($valid); |
|---|
| 68 | + |
|---|
| 69 | error_reporting( E_ALL ^ E_NOTICE ); |
|---|
| 70 | @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. |
|---|
| 71 | include(WP_PLUGIN_DIR . '/' . $plugin); |
|---|
| 72 | @@ -82,10 +96,20 @@ |
|---|
| 73 | break; |
|---|
| 74 | case 'deactivate-selected': |
|---|
| 75 | check_admin_referer('bulk-manage-plugins'); |
|---|
| 76 | - deactivate_plugins($_POST['checked']); |
|---|
| 77 | + |
|---|
| 78 | + $plugins = (array)$_POST['checked']; |
|---|
| 79 | + $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated. |
|---|
| 80 | + if ( empty($plugins) ) { |
|---|
| 81 | + wp_redirect("plugins.php?plugin_status=$status&paged=$page"); |
|---|
| 82 | + exit; |
|---|
| 83 | + } |
|---|
| 84 | + |
|---|
| 85 | + deactivate_plugins($plugins); |
|---|
| 86 | + |
|---|
| 87 | $deactivated = array(); |
|---|
| 88 | - foreach ( (array)$_POST['checked'] as $plugin ) |
|---|
| 89 | + foreach ( $plugins as $plugin ) |
|---|
| 90 | $deactivated[ $plugin ] = time(); |
|---|
| 91 | + |
|---|
| 92 | update_option('recently_activated', $deactivated + (array)get_option('recently_activated')); |
|---|
| 93 | wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page"); |
|---|
| 94 | exit; |
|---|
| 95 | @@ -96,7 +120,13 @@ |
|---|
| 96 | |
|---|
| 97 | check_admin_referer('bulk-manage-plugins'); |
|---|
| 98 | |
|---|
| 99 | - $plugins = $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen. |
|---|
| 100 | + $plugins = (array)$_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen. |
|---|
| 101 | + $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins. |
|---|
| 102 | + if ( empty($plugins) ) { |
|---|
| 103 | + wp_redirect("plugins.php?plugin_status=$status&paged=$page"); |
|---|
| 104 | + exit; |
|---|
| 105 | + } |
|---|
| 106 | + |
|---|
| 107 | include(ABSPATH . 'wp-admin/update.php'); |
|---|
| 108 | |
|---|
| 109 | $parent_file = 'plugins.php'; |
|---|
| 110 | @@ -363,7 +393,7 @@ |
|---|
| 111 | |
|---|
| 112 | if ( $is_active ) |
|---|
| 113 | $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>'; |
|---|
| 114 | - else //Inactive or Recently deactivated |
|---|
| 115 | + else |
|---|
| 116 | $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>'; |
|---|
| 117 | |
|---|
| 118 | if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) |
|---|
| 119 | @@ -385,11 +415,9 @@ |
|---|
| 120 | <tr class='$class second'> |
|---|
| 121 | <td></td> |
|---|
| 122 | <td class='plugin-title'>"; |
|---|
| 123 | - $i = 0; |
|---|
| 124 | echo '<div class="row-actions-visible">'; |
|---|
| 125 | foreach ( $actions as $action => $link ) { |
|---|
| 126 | - ++$i; |
|---|
| 127 | - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|---|
| 128 | + $sep = end($actions) == $link ? '' : ' | '; |
|---|
| 129 | echo "<span class='$action'>$link$sep</span>"; |
|---|
| 130 | } |
|---|
| 131 | echo "</div></td> |
|---|
| 132 | @@ -403,9 +431,9 @@ |
|---|
| 133 | $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; |
|---|
| 134 | $plugin_meta[] = sprintf( __('By %s'), $author ); |
|---|
| 135 | } |
|---|
| 136 | - if ( ! empty($plugin_data['PluginURI']) ) { |
|---|
| 137 | + if ( ! empty($plugin_data['PluginURI']) ) |
|---|
| 138 | $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>'; |
|---|
| 139 | - } |
|---|
| 140 | + |
|---|
| 141 | $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context); |
|---|
| 142 | echo implode(' | ', $plugin_meta); |
|---|
| 143 | echo "</p></td> |
|---|
| 144 | @@ -425,10 +453,11 @@ |
|---|
| 145 | * |
|---|
| 146 | * @param string $context |
|---|
| 147 | */ |
|---|
| 148 | -function print_plugin_actions($context) { |
|---|
| 149 | +function print_plugin_actions($context, $field_name = 'action' ) { |
|---|
| 150 | + |
|---|
| 151 | ?> |
|---|
| 152 | <div class="alignleft actions"> |
|---|
| 153 | - <select name="action"> |
|---|
| 154 | + <select name="<?php echo $field_name ?>"> |
|---|
| 155 | <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> |
|---|
| 156 | <?php if ( 'active' != $context ) : ?> |
|---|
| 157 | <option value="activate-selected"><?php _e('Activate'); ?></option> |
|---|
| 158 | @@ -512,11 +541,10 @@ |
|---|
| 159 | <?php |
|---|
| 160 | if ( $page_links ) |
|---|
| 161 | echo "<div class='tablenav-pages'>$page_links_text</div>"; |
|---|
| 162 | + |
|---|
| 163 | +print_plugin_actions($status, "action2"); |
|---|
| 164 | ?> |
|---|
| 165 | -<div class="alignleft actions"> |
|---|
| 166 | -<!-- TODO lower bulk actions. --> |
|---|
| 167 | </div> |
|---|
| 168 | -</div> |
|---|
| 169 | </form> |
|---|
| 170 | |
|---|
| 171 | <?php if ( empty($all_plugins) ) : ?> |
|---|