Centralize pagination bound exceeding redirects for list tables. props garyc40. props johnjamesjacoby. fixes #16208

git-svn-id: http://svn.automattic.com/wordpress/trunk@17900 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2011-05-12 06:09:42 +00:00
parent 8abc94a139
commit 0e57bd3a37
9 changed files with 6 additions and 46 deletions

View File

@ -101,12 +101,6 @@ if ( $doaction ) {
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
wp_enqueue_script('admin-comments');
enqueue_comment_hotkeys_js();

View File

@ -142,12 +142,6 @@ if ( $doaction ) {
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
wp_enqueue_script('inline-edit-post');
$title = $post_type_object->labels->name;

View File

@ -139,6 +139,12 @@ class WP_List_Table {
if ( !$args['total_pages'] && $args['per_page'] > 0 )
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
// redirect if page number is invalid and headers are not already sent
if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
exit;
}
$this->_pagination_args = $args;
}

View File

@ -88,12 +88,6 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty(
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
require_once( '../admin-header.php' );
?>

View File

@ -171,12 +171,6 @@ if ( $action ) {
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
add_thickbox();
add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' )) );

View File

@ -23,11 +23,6 @@ if ( is_multisite() && ! is_network_admin() ) {
$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
$title = __('Install Plugins');
$parent_file = 'plugins.php';

View File

@ -313,12 +313,6 @@ if ( $action ) {
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
wp_enqueue_script('plugin-install');
add_thickbox();

View File

@ -23,11 +23,6 @@ if ( is_multisite() && ! is_network_admin() ) {
$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
$title = __('Install Themes');
$parent_file = 'themes.php';

View File

@ -130,12 +130,6 @@ if ( $doaction ) {
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
$title = __('Media Library');
$parent_file = 'upload.php';