Pagination fixes. Props garyc40. fixes #16357

git-svn-id: http://svn.automattic.com/wordpress/trunk@17361 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-01-25 19:20:20 +00:00
parent 4ffa4e4f4e
commit b345e996c7
5 changed files with 35 additions and 10 deletions

View File

@ -13,6 +13,7 @@ if ( !current_user_can( $tax->cap->manage_terms ) )
wp_die( __( 'Cheatin’ uh?' ) ); wp_die( __( 'Cheatin’ uh?' ) );
$wp_list_table = _get_list_table('WP_Terms_List_Table'); $wp_list_table = _get_list_table('WP_Terms_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$title = $tax->labels->name; $title = $tax->labels->name;
@ -148,13 +149,23 @@ case 'editedtag':
break; break;
default: default:
if ( ! empty($_REQUEST['_wp_http_referer']) ) { if ( ! empty($_REQUEST['_wp_http_referer']) ) {
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); $location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) );
exit;
if ( ! empty( $_REQUEST['paged'] ) )
$location = add_query_arg( 'paged', (int) $_REQUEST['paged'] );
wp_redirect( $location );
exit;
} }
$wp_list_table->prepare_items(); $wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
wp_enqueue_script('admin-tags'); wp_enqueue_script('admin-tags');
if ( current_user_can($tax->cap->edit_terms) ) if ( current_user_can($tax->cap->edit_terms) )

View File

@ -427,7 +427,11 @@ switch ( $_GET['action'] ) {
wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) ); wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
} else { } else {
wp_redirect( network_admin_url( 'users.php' ) ); $location = network_admin_url( 'users.php' );
if ( ! empty( $_REQUEST['paged'] ) )
$location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
wp_redirect( $location );
} }
exit(); exit();
break; break;

View File

@ -17,8 +17,14 @@ if ( ! current_user_can( 'manage_network_users' ) )
wp_die( __( 'You do not have permission to access this page.' ) ); wp_die( __( 'You do not have permission to access this page.' ) );
$wp_list_table = _get_list_table('WP_MS_Users_List_Table'); $wp_list_table = _get_list_table('WP_MS_Users_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$wp_list_table->prepare_items(); $wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
$title = __( 'Users' ); $title = __( 'Users' );
$parent_file = 'users.php'; $parent_file = 'users.php';

View File

@ -13,7 +13,7 @@ if ( ! current_user_can( 'list_users' ) )
wp_die( __( 'Cheatin’ uh?' ) ); wp_die( __( 'Cheatin’ uh?' ) );
$wp_list_table = _get_list_table('WP_Users_List_Table'); $wp_list_table = _get_list_table('WP_Users_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$title = __('Users'); $title = __('Users');
$parent_file = 'users.php'; $parent_file = 'users.php';
@ -290,7 +290,11 @@ default:
} }
$wp_list_table->prepare_items(); $wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
include('./admin-header.php'); include('./admin-header.php');
$messages = array(); $messages = array();

View File

@ -542,19 +542,19 @@ class WP_User_Query {
*/ */
function query() { function query() {
global $wpdb; global $wpdb;
if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) { if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) {
$this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
} else { } else {
$this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
} }
if ( $this->query_vars['count_total'] )
$this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where");
if ( !$this->results ) if ( !$this->results )
return; return;
if ( $this->query_vars['count_total'] )
$this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where");
if ( 'all_with_meta' == $this->query_vars['fields'] ) { if ( 'all_with_meta' == $this->query_vars['fields'] ) {
cache_users( $this->results ); cache_users( $this->results );