Simplify post paging. Remove "posts paged" setting. We should always page. Add posts_nav_link() to the default template.
git-svn-id: https://develop.svn.wordpress.org/trunk@1500 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
389f5e4369
commit
0f49ccc3d3
@ -59,6 +59,8 @@ require('./wp-blog-header.php');
|
||||
<?php endforeach; else: ?>
|
||||
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php posts_nav_link(' — ', __('« Previous Page'), __('Next Page »')); ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -457,7 +457,7 @@ $option_data = array(
|
||||
"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(46,'use_phoneemail', 2, '0', 'some mobile phone email services will send identical subject & content on the same line if you use such a service, set use_phoneemail to true, and indicate a separator string', 8, 20)",
|
||||
// original options from options page
|
||||
"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(48,'posts_per_page', 1, '20','How many posts/days to show on the index page.', 4, 20)",
|
||||
"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(49,'what_to_show', 5, 'posts','Posts, days, or posts paged', 4, 20)",
|
||||
"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(49,'what_to_show', 5, 'posts','Posts or days', 4, 20)",
|
||||
"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(50,'archive_mode', 5, 'monthly','Which \'unit\' to use for archives.', 4, 20)",
|
||||
"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(51,'time_difference', 6, '0', 'if you\'re not on the timezone of your server', 4, 20)",
|
||||
"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(52,'date_format', 3, 'n/j/Y', 'see note for format characters', 4, 20)",
|
||||
@ -532,7 +532,6 @@ $option_data = array(
|
||||
// select data for what to show
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days', 'days', null,null,1)",
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts', null,null,2)",
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'paged', 'posts paged', null,null,3)",
|
||||
// select data for archive mode
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'daily', 'daily', null,null,1)",
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'weekly', 'weekly', null,null,2)",
|
||||
|
@ -56,7 +56,6 @@ include('options-head.php');
|
||||
<select name="what_to_show" id="what_to_show" >
|
||||
<option value="days" <?php selected('days', get_settings('what_to_show')); ?>><?php _e('days') ?></option>
|
||||
<option value="posts" <?php selected('posts', get_settings('what_to_show')); ?>><?php _e('posts') ?></option>
|
||||
<option value="paged" <?php selected('paged', get_settings('what_to_show')); ?>><?php _e('posts paged') ?></option>
|
||||
</select> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -255,7 +255,7 @@ $guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $HTTP_HOST . $REQUES
|
||||
|
||||
// original options from options page
|
||||
"48" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (48,'posts_per_page', 1, '20','How many posts/days to show on the index page.', 4, 20)",
|
||||
"49" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (49,'what_to_show', 5, 'posts','Posts, days, or posts paged', 4, 20)",
|
||||
"49" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (49,'what_to_show', 5, 'posts','Posts or days', 4, 20)",
|
||||
"50" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (50,'archive_mode', 5, 'monthly','Which \'unit\' to use for archives.', 4, 20)",
|
||||
"51" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (51,'time_difference', 6, '0', 'if you\'re not on the timezone of your server', 4, 20)",
|
||||
"52" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (52,'date_format', 3, 'n/j/Y', 'see note for format characters', 4, 20)",
|
||||
@ -422,7 +422,6 @@ $guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $HTTP_HOST . $REQUES
|
||||
// select data for what to show
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days', 'days', null,null,1)",
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts', null,null,2)",
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'paged', 'posts paged', null,null,3)",
|
||||
// select data for archive mode
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'daily', 'daily', null,null,1)",
|
||||
"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'weekly', 'weekly', null,null,2)",
|
||||
@ -920,6 +919,10 @@ function upgrade_130() {
|
||||
}
|
||||
}
|
||||
|
||||
// The "paged" option for what_to_show is no more.
|
||||
if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') {
|
||||
$wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1669,7 +1669,7 @@ function query_posts($query) {
|
||||
}
|
||||
|
||||
if ( !empty($postend) && ($postend > $poststart) && (!$m) && empty($monthnum) && empty($year) && empty($day) &&(!$w) && (!$whichcat) && (!$s) && (!$p)) {
|
||||
if ($what_to_show == 'posts' || ($what_to_show == 'paged' && (!$paged))) {
|
||||
if ($what_to_show == 'posts') {
|
||||
$poststart = intval($poststart);
|
||||
$postend = intval($postend);
|
||||
$limposts = $postend - $poststart;
|
||||
@ -1686,7 +1686,7 @@ function query_posts($query) {
|
||||
$where .= " AND post_date > '$otherdate' AND post_date < '$startdate'";
|
||||
}
|
||||
} else {
|
||||
if (($what_to_show == 'paged') && (!$p) && (!$more)) {
|
||||
if (($what_to_show == 'posts') && (! is_single()) && (!$more)) {
|
||||
if ($pagenow != 'post.php') {
|
||||
$pgstrt = '';
|
||||
if ($paged) {
|
||||
|
@ -348,10 +348,10 @@ function get_pagenum_link($pagenum = 1){
|
||||
}
|
||||
|
||||
function next_posts($max_page = 0) { // original by cfactor at cooltux.org
|
||||
global $p, $paged, $what_to_show, $pagenow;
|
||||
global $paged, $pagenow;
|
||||
global $querystring_start, $querystring_equal, $querystring_separator;
|
||||
|
||||
if (empty($p) && ($what_to_show == 'paged')) {
|
||||
if (! is_single()) {
|
||||
if (!$paged) $paged = 1;
|
||||
$nextpage = intval($paged) + 1;
|
||||
if (!$max_page || $max_page >= $nextpage) {
|
||||
@ -361,36 +361,34 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
|
||||
}
|
||||
|
||||
function next_posts_link($label='Next Page »', $max_page=0) {
|
||||
global $p, $paged, $result, $request, $posts_per_page, $what_to_show, $wpdb;
|
||||
if ($what_to_show == 'paged') {
|
||||
if (!$max_page) {
|
||||
$nxt_request = $request;
|
||||
//if the query includes a limit clause, call it again without that
|
||||
//limit clause!
|
||||
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
|
||||
$nxt_request = substr($request, 0, $pos);
|
||||
}
|
||||
$nxt_result = $wpdb->query($nxt_request);
|
||||
$numposts = $wpdb->num_rows;
|
||||
$max_page = ceil($numposts / $posts_per_page);
|
||||
}
|
||||
if (!$paged)
|
||||
$paged = 1;
|
||||
$nextpage = intval($paged) + 1;
|
||||
if (empty($p) && (empty($paged) || $nextpage <= $max_page)) {
|
||||
echo '<a href="';
|
||||
next_posts($max_page);
|
||||
echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
|
||||
global $paged, $result, $request, $posts_per_page, $wpdb;
|
||||
if (!$max_page) {
|
||||
$nxt_request = $request;
|
||||
//if the query includes a limit clause, call it again without that
|
||||
//limit clause!
|
||||
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
|
||||
$nxt_request = substr($request, 0, $pos);
|
||||
}
|
||||
$nxt_result = $wpdb->query($nxt_request);
|
||||
$numposts = $wpdb->num_rows;
|
||||
$max_page = ceil($numposts / $posts_per_page);
|
||||
}
|
||||
if (!$paged)
|
||||
$paged = 1;
|
||||
$nextpage = intval($paged) + 1;
|
||||
if ((! is_single()) && (empty($paged) || $nextpage <= $max_page)) {
|
||||
echo '<a href="';
|
||||
next_posts($max_page);
|
||||
echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function previous_posts() { // original by cfactor at cooltux.org
|
||||
global $_SERVER, $p, $paged, $what_to_show, $pagenow;
|
||||
global $_SERVER, $paged, $pagenow;
|
||||
global $querystring_start, $querystring_equal, $querystring_separator;
|
||||
|
||||
if (empty($p) && ($what_to_show == 'paged')) {
|
||||
if (! is_single()) {
|
||||
$nextpage = intval($paged) - 1;
|
||||
if ($nextpage < 1) $nextpage = 1;
|
||||
echo get_pagenum_link($nextpage);
|
||||
@ -398,8 +396,8 @@ function previous_posts() { // original by cfactor at cooltux.org
|
||||
}
|
||||
|
||||
function previous_posts_link($label='« Previous Page') {
|
||||
global $p, $paged, $what_to_show;
|
||||
if (empty($p) && ($paged > 1) && ($what_to_show == 'paged')) {
|
||||
global $paged;
|
||||
if ((! is_single()) && ($paged > 1) ) {
|
||||
echo '<a href="';
|
||||
previous_posts();
|
||||
echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
|
||||
@ -407,8 +405,8 @@ function previous_posts_link($label='« Previous Page') {
|
||||
}
|
||||
|
||||
function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
|
||||
global $p, $what_to_show, $request, $posts_per_page, $wpdb;
|
||||
if (empty($p) && ($what_to_show == 'paged')) {
|
||||
global $request, $posts_per_page, $wpdb;
|
||||
if (! is_single()) {
|
||||
$nxt_request = $request;
|
||||
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
|
||||
$nxt_request = substr($request, 0, $pos);
|
||||
|
Loading…
Reference in New Issue
Block a user