mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Remove paging by days. fixes #3341
git-svn-id: http://svn.automattic.com/wordpress/trunk@4457 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bf8e2b03e2
commit
92bacd1a91
@ -53,10 +53,7 @@ include('admin-header.php');
|
||||
<tr valign="top">
|
||||
<th width="33%" scope="row"><?php _e('Show at most:') ?></th>
|
||||
<td>
|
||||
<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" />
|
||||
<select name="what_to_show" id="what_to_show" >
|
||||
<option value="days" <?php selected('days', get_option('what_to_show')); ?>><?php _e('days') ?></option>
|
||||
<option value="posts" <?php selected('posts', get_option('what_to_show')); ?>><?php _e('posts') ?></option>
|
||||
<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" /> <?php _e('posts') ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@ -93,7 +90,7 @@ include('admin-header.php');
|
||||
</p>
|
||||
<p class="submit">
|
||||
<input type="hidden" name="action" value="update" />
|
||||
<input type="hidden" name="page_options" value="posts_per_page,what_to_show,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts" />
|
||||
<input type="hidden" name="page_options" value="posts_per_page,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts" />
|
||||
<input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
@ -435,9 +435,9 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
|
||||
}
|
||||
|
||||
function next_posts_link($label='Next Page »', $max_page=0) {
|
||||
global $paged, $wpdb;
|
||||
global $paged, $wpdb, $wp_query;
|
||||
if ( !$max_page ) {
|
||||
$max_page = _max_num_pages();
|
||||
$max_page = $wp_query->max_num_pages;
|
||||
}
|
||||
if ( !$paged )
|
||||
$paged = 1;
|
||||
@ -471,32 +471,10 @@ function previous_posts_link($label='« Previous Page') {
|
||||
}
|
||||
}
|
||||
|
||||
function _max_num_pages() {
|
||||
global $max_num_pages;
|
||||
global $wpdb, $wp_query;
|
||||
|
||||
if (isset($max_num_pages)) return $max_num_pages;
|
||||
$posts_per = get_query_var('posts_per_page');
|
||||
if ( empty($posts_per) ) $posts_per = 1;
|
||||
|
||||
if ( 'posts' == get_query_var('what_to_show') ) {
|
||||
preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
|
||||
$fromwhere = $matches[1];
|
||||
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT $wpdb->posts.ID) FROM $fromwhere");
|
||||
$max_num_pages = ceil($numposts / $posts_per);
|
||||
} else {
|
||||
preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
|
||||
$fromwhere = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
|
||||
$num_days = $wpdb->query("SELECT DISTINCT post_date FROM $fromwhere GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
|
||||
$max_num_pages = ceil($num_days / $posts_per);
|
||||
}
|
||||
|
||||
return $max_num_pages;
|
||||
}
|
||||
|
||||
function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
|
||||
if ( !is_single() ) {
|
||||
$max_num_pages = _max_num_pages();
|
||||
global $wp_query;
|
||||
if ( !is_singular() ) {
|
||||
$max_num_pages = $wp_query->max_num_pages;
|
||||
$paged = get_query_var('paged');
|
||||
|
||||
//only have sep if there's both prev and next results
|
||||
|
@ -265,6 +265,9 @@ class WP_Query {
|
||||
var $in_the_loop = false;
|
||||
var $post;
|
||||
|
||||
var $found_posts = 0;
|
||||
var $max_num_pages = 0;
|
||||
|
||||
var $is_single = false;
|
||||
var $is_preview = false;
|
||||
var $is_page = false;
|
||||
@ -590,8 +593,6 @@ class WP_Query {
|
||||
$post_type = $q['post_type'];
|
||||
if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
|
||||
$q['posts_per_page'] = get_option('posts_per_page');
|
||||
if ( !isset($q['what_to_show']) )
|
||||
$q['what_to_show'] = get_option('what_to_show');
|
||||
if ( isset($q['showposts']) && $q['showposts'] ) {
|
||||
$q['showposts'] = (int) $q['showposts'];
|
||||
$q['posts_per_page'] = $q['showposts'];
|
||||
@ -607,7 +608,6 @@ class WP_Query {
|
||||
}
|
||||
if ( $this->is_feed ) {
|
||||
$q['posts_per_page'] = get_option('posts_per_rss');
|
||||
$q['what_to_show'] = 'posts';
|
||||
}
|
||||
$q['posts_per_page'] = (int) $q['posts_per_page'];
|
||||
if ( $q['posts_per_page'] < -1 )
|
||||
@ -941,33 +941,20 @@ class WP_Query {
|
||||
$join = apply_filters('posts_join', $join);
|
||||
|
||||
// Paging
|
||||
if (empty($q['nopaging']) && ! $this->is_single && ! $this->is_page) {
|
||||
if (empty($q['nopaging']) && !$this->is_singular) {
|
||||
$page = abs(intval($q['paged']));
|
||||
if (empty($page)) {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (($q['what_to_show'] == 'posts')) {
|
||||
if ( empty($q['offset']) ) {
|
||||
$pgstrt = '';
|
||||
$pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
|
||||
$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
|
||||
} else { // we're ignoring $page and using 'offset'
|
||||
$q['offset'] = abs(intval($q['offset']));
|
||||
$pgstrt = $q['offset'] . ', ';
|
||||
$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
|
||||
}
|
||||
} elseif ($q['what_to_show'] == 'days') {
|
||||
$startrow = $q['posts_per_page'] * (intval($page)-1);
|
||||
$start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1");
|
||||
$endrow = $startrow + $q['posts_per_page'] - 1;
|
||||
$end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1");
|
||||
|
||||
if ($page > 1) {
|
||||
$where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";
|
||||
} else {
|
||||
$where .= " AND post_date >= '$end_date'";
|
||||
}
|
||||
if ( empty($q['offset']) ) {
|
||||
$pgstrt = '';
|
||||
$pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
|
||||
$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
|
||||
} else { // we're ignoring $page and using 'offset'
|
||||
$q['offset'] = abs(intval($q['offset']));
|
||||
$pgstrt = $q['offset'] . ', ';
|
||||
$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -989,9 +976,8 @@ class WP_Query {
|
||||
|
||||
$this->posts = $wpdb->get_results($this->request);
|
||||
if ( !empty($limits) ) {
|
||||
$num_rows = $wpdb->get_var('SELECT FOUND_ROWS()');
|
||||
global $max_num_pages;
|
||||
$max_num_pages = $num_rows / $q['posts_per_page'];
|
||||
$this->found_posts = $wpdb->get_var('SELECT FOUND_ROWS()');
|
||||
$this->max_num_pages = $this->found_posts / $q['posts_per_page'];
|
||||
}
|
||||
// Check post status to determine if post should be displayed.
|
||||
if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user