mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-16 07:35:39 +01:00
Keep sorting and paging for bulk actions. props garyc40, see #16166.
git-svn-id: http://svn.automattic.com/wordpress/trunk@17270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
43fa1e5294
commit
7c5fd789ac
@ -37,7 +37,7 @@ if ( $doaction ) {
|
|||||||
$approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0;
|
$approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0;
|
||||||
|
|
||||||
$redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() );
|
$redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() );
|
||||||
$redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to );
|
$redirect_to = $wp_list_table->add_query_args( $redirect_to );
|
||||||
|
|
||||||
foreach ( $comment_ids as $comment_id ) { // Check the permissions on each
|
foreach ( $comment_ids as $comment_id ) { // Check the permissions on each
|
||||||
if ( !current_user_can( 'edit_comment', $comment_id ) )
|
if ( !current_user_can( 'edit_comment', $comment_id ) )
|
||||||
|
@ -78,6 +78,7 @@ case 'delete':
|
|||||||
|
|
||||||
wp_delete_term( $tag_ID, $taxonomy );
|
wp_delete_term( $tag_ID, $taxonomy );
|
||||||
|
|
||||||
|
$location = $wp_list_table->add_query_args( $location );
|
||||||
$location = add_query_arg( 'message', 2, $location );
|
$location = add_query_arg( 'message', 2, $location );
|
||||||
wp_redirect( $location );
|
wp_redirect( $location );
|
||||||
exit;
|
exit;
|
||||||
@ -104,6 +105,7 @@ case 'bulk-delete':
|
|||||||
}
|
}
|
||||||
|
|
||||||
$location = add_query_arg( 'message', 6, $location );
|
$location = add_query_arg( 'message', 6, $location );
|
||||||
|
$location = $wp_list_table->add_query_args( $location );
|
||||||
wp_redirect( $location );
|
wp_redirect( $location );
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ if ( $doaction ) {
|
|||||||
check_admin_referer('bulk-posts');
|
check_admin_referer('bulk-posts');
|
||||||
|
|
||||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
||||||
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
|
$sendback = $wp_list_table->add_query_args( $sendback );
|
||||||
if ( strpos($sendback, 'post.php') !== false )
|
if ( strpos($sendback, 'post.php') !== false )
|
||||||
$sendback = admin_url($post_new_file);
|
$sendback = admin_url($post_new_file);
|
||||||
|
|
||||||
|
@ -615,6 +615,29 @@ class WP_List_Table {
|
|||||||
return count( $columns ) - count( $hidden );
|
return count( $columns ) - count( $hidden );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_order_info() {
|
||||||
|
$current_orderby = isset( $_GET['orderby'] ) ? $_GET['orderby'] : '';
|
||||||
|
|
||||||
|
if ( ! $current_orderby )
|
||||||
|
$current_order = '';
|
||||||
|
elseif ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] )
|
||||||
|
$current_order = 'desc';
|
||||||
|
else
|
||||||
|
$current_order = 'asc';
|
||||||
|
|
||||||
|
return array( $current_orderby, $current_order );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_query_args( $location ) {
|
||||||
|
$pagenum = $this->get_pagenum();
|
||||||
|
list( $current_orderby, $current_order ) = $this->get_order_info();
|
||||||
|
$location = add_query_arg( 'paged', $pagenum, $location );
|
||||||
|
if ( $current_orderby )
|
||||||
|
$location = add_query_arg( array( 'orderby' => $current_orderby, 'order' => $current_order ), $location );
|
||||||
|
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print column headers, accounting for hidden and sortable columns.
|
* Print column headers, accounting for hidden and sortable columns.
|
||||||
*
|
*
|
||||||
@ -630,15 +653,7 @@ class WP_List_Table {
|
|||||||
|
|
||||||
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
if ( isset( $_GET['orderby'] ) )
|
list( $current_orderby, $current_order ) = $this->get_order_info();
|
||||||
$current_orderby = $_GET['orderby'];
|
|
||||||
else
|
|
||||||
$current_orderby = '';
|
|
||||||
|
|
||||||
if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] )
|
|
||||||
$current_order = 'desc';
|
|
||||||
else
|
|
||||||
$current_order = 'asc';
|
|
||||||
|
|
||||||
foreach ( $columns as $column_key => $column_display_name ) {
|
foreach ( $columns as $column_key => $column_display_name ) {
|
||||||
$class = array( 'manage-column', "column-$column_key" );
|
$class = array( 'manage-column', "column-$column_key" );
|
||||||
@ -733,8 +748,11 @@ class WP_List_Table {
|
|||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function display_tablenav( $which ) {
|
function display_tablenav( $which ) {
|
||||||
if ( 'top' == $which )
|
if ( 'top' == $which ) {
|
||||||
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
|
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
|
||||||
|
list( $current_orderby, $current_order ) = $this->get_order_info();
|
||||||
|
echo '<input type="hidden" name="orderby" value="' . esc_attr( $current_orderby ) . '" /><input type="hidden" name="order" value="' . esc_attr( $current_order ) . '" />';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
||||||
|
|
||||||
|
@ -122,7 +122,9 @@ window.listTable = {
|
|||||||
if ( 'object' != typeof response ) {
|
if ( 'object' != typeof response ) {
|
||||||
this.handle_error();
|
this.handle_error();
|
||||||
} else {
|
} else {
|
||||||
var tablenav = $('.tablenav-pages');
|
var tablenav = $('.tablenav-pages'),
|
||||||
|
order = $.query.GET('order'),
|
||||||
|
orderby = order ? $.query.GET('orderby') : '';
|
||||||
|
|
||||||
this.stop_loading();
|
this.stop_loading();
|
||||||
|
|
||||||
@ -144,6 +146,9 @@ window.listTable = {
|
|||||||
tablenav.find('.first-page, .prev-page').toggleClass('disabled', 1 == $.query.GET('paged'));
|
tablenav.find('.first-page, .prev-page').toggleClass('disabled', 1 == $.query.GET('paged'));
|
||||||
tablenav.find('.next-page, .last-page').toggleClass('disabled', response.total_pages == $.query.GET('paged'));
|
tablenav.find('.next-page, .last-page').toggleClass('disabled', response.total_pages == $.query.GET('paged'));
|
||||||
|
|
||||||
|
$('input[name=order]').val(order);
|
||||||
|
$('input[name=orderby]').val(orderby);
|
||||||
|
|
||||||
$('th.column-cb :input').attr('checked', false);
|
$('th.column-cb :input').attr('checked', false);
|
||||||
|
|
||||||
if ( history.replaceState ) {
|
if ( history.replaceState ) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -83,6 +83,7 @@ if ( $doaction ) {
|
|||||||
$location = $referer;
|
$location = $referer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$location = $wp_list_table->add_query_args( $locations );
|
||||||
$location = add_query_arg( array( 'attached' => $attached ) , $location );
|
$location = add_query_arg( array( 'attached' => $attached ) , $location );
|
||||||
wp_redirect( $location );
|
wp_redirect( $location );
|
||||||
exit;
|
exit;
|
||||||
@ -120,6 +121,7 @@ if ( $doaction ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$location = $wp_list_table->add_query_args( $locations );
|
||||||
wp_redirect( $location );
|
wp_redirect( $location );
|
||||||
exit;
|
exit;
|
||||||
} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
||||||
|
@ -302,7 +302,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
|
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
|
||||||
$scripts->add_data( 'admin-custom-fields', 'group', 1 );
|
$scripts->add_data( 'admin-custom-fields', 'group', 1 );
|
||||||
|
|
||||||
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery-query', 'jquery-serialize-object' ), '20110111a' );
|
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery-query', 'jquery-serialize-object' ), '20110112' );
|
||||||
$scripts->add_data( 'list-table', 'group', 1 );
|
$scripts->add_data( 'list-table', 'group', 1 );
|
||||||
$scripts->localize( 'list-table', 'listTableL10n', array(
|
$scripts->localize( 'list-table', 'listTableL10n', array(
|
||||||
'error' => __('An error has occurred while loading the items.'),
|
'error' => __('An error has occurred while loading the items.'),
|
||||||
|
Loading…
Reference in New Issue
Block a user