Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify post paging. Remove "posts paged" setting. We should always …
…page. Add posts_nav_link() to the default template.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
rboren committed Jul 29, 2004
1 parent 8560c92 commit 2a1d84e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 35 deletions.
2 changes: 2 additions & 0 deletions index.php
Expand Up @@ -59,6 +59,8 @@
<?php endforeach; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

<?php posts_nav_link(' &#8212; ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>
</div>


Expand Down
3 changes: 1 addition & 2 deletions wp-admin/install.php
Expand Up @@ -457,7 +457,7 @@
"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)",
Expand Down Expand Up @@ -532,7 +532,6 @@
// 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)",
Expand Down
1 change: 0 additions & 1 deletion wp-admin/options-reading.php
Expand Up @@ -56,7 +56,6 @@ function add_magic_quotes($array) {
<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>
Expand Down
7 changes: 5 additions & 2 deletions wp-admin/upgrade-functions.php
Expand Up @@ -255,7 +255,7 @@ function upgrade_072() {

// 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)",
Expand Down Expand Up @@ -422,7 +422,6 @@ function upgrade_072() {
// 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)",
Expand Down Expand Up @@ -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'");
}
}

?>
4 changes: 2 additions & 2 deletions wp-includes/functions.php
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
54 changes: 26 additions & 28 deletions wp-includes/template-functions-links.php
Expand Up @@ -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) {
Expand All @@ -361,54 +361,52 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
}

function next_posts_link($label='Next Page &raquo;', $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};)/', '&#038;$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};)/', '&#038;$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);
}
}

function previous_posts_link($label='&laquo; 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};)/', '&#038;$1', $label) .'</a>';
}
}

function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
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);
Expand Down

0 comments on commit 2a1d84e

Please sign in to comment.