Don't fallback to the options database when retrieving *_per_page user options. Props nacin. fixes #11385

git-svn-id: http://svn.automattic.com/wordpress/trunk@12375 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-12-11 23:14:43 +00:00
parent 776d9aadf0
commit 657aa5adc3
8 changed files with 34 additions and 26 deletions

View File

@ -166,10 +166,10 @@ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
$cats_per_page = get_user_option('categories_per_page');
if ( empty($cats_per_page) )
$cats_per_page = (int) get_user_option( 'categories_per_page', 0, false );
if ( empty( $cats_per_page ) || $cats_per_page < 1 )
$cats_per_page = 20;
$cats_per_page = apply_filters('edit_categories_per_page', $cats_per_page);
$cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page );
if ( !empty($_GET['s']) )
$num_cats = count(get_categories(array('hide_empty' => 0, 'search' => $_GET['s'])));

View File

@ -236,10 +236,10 @@ unset($status_links);
</p>
<?php
$comments_per_page = get_user_option('edit_comments_per_page');
if ( empty($comments_per_page) )
$comments_per_page = (int) get_user_option( 'edit_comments_per_page', 0, false );
if ( empty( $comments_per_page ) || $comments_per_page < 1 )
$comments_per_page = 20;
$comments_per_page = apply_filters('comments_per_page', $comments_per_page, $comment_status);
$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
if ( isset( $_GET['apage'] ) )
$page = abs( (int) $_GET['apage'] );

View File

@ -228,9 +228,10 @@ endif;
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
$per_page = get_user_option('edit_pages_per_page');
if ( empty( $per_page ) || $per_page < 0 )
$per_page = (int) get_user_option( 'edit_pages_per_page', 0, false );
if ( empty( $per_page ) || $per_page < 1 )
$per_page = 20;
$per_page = apply_filters( 'edit_pages_per_page', $per_page );
$num_pages = ceil($wp_query->post_count / $per_page);
$page_links = paginate_links( array(

View File

@ -184,11 +184,11 @@ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
$tags_per_page = get_user_option('edit_tags_per_page');
if ( empty($tags_per_page) )
$tags_per_page = (int) get_user_option( 'edit_tags_per_page', 0, false );
if ( empty($tags_per_page) || $tags_per_page < 1 )
$tags_per_page = 20;
$tags_per_page = apply_filters('edit_tags_per_page', $tags_per_page);
$tags_per_page = apply_filters('tagsperpage', $tags_per_page); // Old filter
$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ),

View File

@ -845,10 +845,10 @@ function wp_edit_posts_query( $q = false ) {
$orderby = 'date';
}
$posts_per_page = get_user_option('edit_per_page');
if ( empty($posts_per_page) )
$posts_per_page = (int) get_user_option( 'edit_per_page', 0, false );
if ( empty( $posts_per_page ) || $posts_per_page < 1 )
$posts_per_page = 15;
$posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page);
$posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page );
wp("post_type=post&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");
@ -903,10 +903,10 @@ function wp_edit_attachments_query( $q = false ) {
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$q['post_type'] = 'attachment';
$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit';
$media_per_page = get_user_option('upload_per_page');
if ( empty($media_per_page) )
$media_per_page = (int) get_user_option( 'upload_per_page', 0, false );
if ( empty( $media_per_page ) || $media_per_page < 1 )
$media_per_page = 20;
$q['posts_per_page'] = $media_per_page;
$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
$post_mime_types = get_post_mime_types();
$avail_post_mime_types = get_available_post_mime_types('attachment');

View File

@ -3716,14 +3716,20 @@ function screen_options($screen) {
return '';
}
$option = str_replace('-', '_', "${screen}_per_page");
$per_page = get_user_option($option);
if ( empty($per_page) ) {
$option = str_replace( '-', '_', "${screen}_per_page" );
$per_page = (int) get_user_option( $option, 0, false );
if ( empty( $per_page ) || $per_page < 1 ) {
if ( 'plugins' == $screen )
$per_page = 999;
else
$per_page = 20;
}
if ( 'edit_comments_per_page' == $option )
$per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' );
elseif ( 'categories' == $option )
$per_page = apply_filters( 'edit_categories_per_page', $per_page );
else
$per_page = apply_filters( $option, $per_page );
$return = '<h5>' . __('Options') . "</h5>\n";
$return .= "<div class='screen-options'>\n";

View File

@ -350,10 +350,10 @@ $plugins = &$$plugin_array_name;
//Paging.
$total_this_page = "total_{$status}_plugins";
$total_this_page = $$total_this_page;
$plugins_per_page = get_user_option('plugins_per_page');
if ( empty($plugins_per_page) )
$plugins_per_page = (int) get_user_option( 'plugins_per_page', 0, false );
if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
$plugins_per_page = 999;
$plugins_per_page = apply_filters('plugins_per_page', $plugins_per_page);
$plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
$start = ($page - 1) * $plugins_per_page;

View File

@ -134,9 +134,10 @@ if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
if ( isset($_GET['detached']) ) {
$media_per_page = (int) get_user_option('upload_per_page');
if ( empty($media_per_page) )
$media_per_page = (int) get_user_option( 'upload_per_page', 0, false );
if ( empty($media_per_page) || $media_per_page < 1 )
$media_per_page = 20;
$media_per_page = apply_filters( 'upload_per_page', $media_per_page );
if ( !empty($lost) ) {
$start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;