Preserve search terms on plugin management pages during actions. Fixes #14905 for trunk.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-10-04 04:26:58 +00:00
parent 37c6a67d65
commit fa45b04e6e
2 changed files with 18 additions and 17 deletions

View File

@ -3507,7 +3507,7 @@ class WP_Plugins_Table extends WP_List_Table {
} }
function display_rows() { function display_rows() {
global $status, $page; global $status, $page, $s;
$context = $status; $context = $status;
@ -3557,24 +3557,24 @@ class WP_Plugins_Table extends WP_List_Table {
if ( is_network_admin() ) { if ( is_network_admin() ) {
if ( $is_active_for_network ) { if ( $is_active_for_network ) {
if ( current_user_can( 'manage_network_plugins' ) ) if ( current_user_can( 'manage_network_plugins' ) )
$actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>'; $actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
} else { } else {
if ( current_user_can( 'manage_network_plugins' ) ) if ( current_user_can( 'manage_network_plugins' ) )
$actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>'; $actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
if ( current_user_can('delete_plugins') ) if ( current_user_can('delete_plugins') )
$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'bulk-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
} }
} else { } else {
if ( $is_active ) { if ( $is_active ) {
$actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>'; $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
} else { } else {
if ( is_network_only_plugin( $plugin_file ) && !is_network_admin() ) if ( is_network_only_plugin( $plugin_file ) && !is_network_admin() )
continue; continue;
$actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>'; $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
if ( current_user_can('delete_plugins') ) if ( current_user_can('delete_plugins') )
$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'bulk-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
} // end if $is_active } // end if $is_active
} // end if is_network_admin() } // end if is_network_admin()

View File

@ -15,6 +15,7 @@ $wp_list_table->check_permissions();
$action = $wp_list_table->current_action(); $action = $wp_list_table->current_action();
$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : ''; $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected. // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']); $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
@ -34,7 +35,7 @@ if ( $action ) {
$result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin, $network_wide); $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin, $network_wide);
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
if ( 'unexpected_output' == $result->get_error_code() ) { if ( 'unexpected_output' == $result->get_error_code() ) {
$redirect = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin; $redirect = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin . "&plugin_status=$status&paged=$page&s=$s";
wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
exit; exit;
} else { } else {
@ -50,7 +51,7 @@ if ( $action ) {
if ( isset($_GET['from']) && 'import' == $_GET['from'] ) { if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
wp_redirect("import.php?import=" . str_replace('-importer', '', dirname($plugin)) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix wp_redirect("import.php?import=" . str_replace('-importer', '', dirname($plugin)) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix
} else { } else {
wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s"); // overrides the ?error=true one above
} }
exit; exit;
break; break;
@ -64,7 +65,7 @@ if ( $action ) {
$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active. $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active.
if ( empty($plugins) ) { if ( empty($plugins) ) {
wp_redirect("plugins.php?plugin_status=$status&paged=$page"); wp_redirect("plugins.php?plugin_status=$status&paged=$page&s=$s");
exit; exit;
} }
@ -77,7 +78,7 @@ if ( $action ) {
update_option('recently_activated', $recent); update_option('recently_activated', $recent);
wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page"); wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s");
exit; exit;
break; break;
case 'update-selected' : case 'update-selected' :
@ -143,9 +144,9 @@ if ( $action ) {
deactivate_plugins($plugin); deactivate_plugins($plugin);
update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated')); update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
if (headers_sent()) if (headers_sent())
echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page" ) . "' />"; echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
else else
wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page"); wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s");
exit; exit;
break; break;
case 'deactivate-selected': case 'deactivate-selected':
@ -157,7 +158,7 @@ if ( $action ) {
$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
$plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated. $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
if ( empty($plugins) ) { if ( empty($plugins) ) {
wp_redirect("plugins.php?plugin_status=$status&paged=$page"); wp_redirect("plugins.php?plugin_status=$status&paged=$page&s=$s");
exit; exit;
} }
@ -168,7 +169,7 @@ if ( $action ) {
$deactivated[ $plugin ] = time(); $deactivated[ $plugin ] = time();
update_option('recently_activated', $deactivated + (array)get_option('recently_activated')); update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page"); wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s");
exit; exit;
break; break;
case 'delete-selected': case 'delete-selected':
@ -181,7 +182,7 @@ if ( $action ) {
$plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins. $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
if ( empty($plugins) ) { if ( empty($plugins) ) {
wp_redirect("plugins.php?plugin_status=$status&paged=$page"); wp_redirect("plugins.php?plugin_status=$status&paged=$page&s=$s");
exit; exit;
} }
@ -275,7 +276,7 @@ if ( $action ) {
$delete_result = delete_plugins($plugins); $delete_result = delete_plugins($plugins);
set_transient('plugins_delete_result_'.$user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length set_transient('plugins_delete_result_'.$user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
wp_redirect("plugins.php?deleted=true&plugin_status=$status&paged=$page"); wp_redirect("plugins.php?deleted=true&plugin_status=$status&paged=$page&s=$s");
exit; exit;
break; break;
case 'clear-recent-list': case 'clear-recent-list':