diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 58acf379a3..a9b4af11da 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -149,7 +149,7 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { if ( is_feed() ) { $paged_redirect['path'] = user_trailingslashit( trailingslashit( $paged_redirect['path'] ) . 'feed/' . ( ( 'rss2' == get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' ); } - if ( get_query_var('cpage') > 1 ) { + if ( ( 'newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 ) || ( 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1 ) ) { $paged_redirect['path'] = user_trailingslashit( trailingslashit( $paged_redirect['path'] ) . 'comment-page-' . get_query_var('cpage'), 'commentpaged' ); } $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path']; diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 1348145cdb..5efe57a838 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1148,16 +1148,25 @@ function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { $request = preg_replace('|^'. $home_root . '|', '', $request); $request = preg_replace('|^/+|', '', $request); + $request = preg_replace('|comment-page-[0-9]+/?$|', '', $request); $base = trailingslashit( get_bloginfo( 'home' ) ); $result = $base . $request; if ( 'newest' == get_option('default_comments_page') ) { - if ( $pagenum != $max_page ) + if ( $pagenum != $max_page ) { + if ( $wp_rewrite->using_permalinks() ) + $result = user_trailingslashit( trailingslashit($base . $request) . 'comment-page-' . $pagenum, 'commentpaged'); + else + $result = add_query_arg( 'cpage', $pagenum, $base . $request ); + } + } elseif ( $pagenum > 1 ) { + if ( $wp_rewrite->using_permalinks() ) + $result = user_trailingslashit( trailingslashit($base . $request) . 'comment-page-' . $pagenum, 'commentpaged'); + else $result = add_query_arg( 'cpage', $pagenum, $base . $request ); - } elseif ( $pagenum > 1 ) - $result = add_query_arg( 'cpage', $pagenum, $base . $request ); + } $result .= '#comments'; @@ -1181,7 +1190,7 @@ function next_comments_link($label='', $max_page = 0) { return; $page = get_query_var('cpage'); - + if ( !$page ) $page = 1; @@ -1209,7 +1218,6 @@ function next_comments_link($label='', $max_page = 0) { * @param string $label Optional. Label for comments link text. */ function previous_comments_link($label='') { - global $wp_query; if ( !is_singular() ) return; @@ -1222,12 +1230,12 @@ function previous_comments_link($label='') { if ( $page <= 1 ) return; - $nextpage = intval($page) - 1; + $prevpage = intval($page) - 1; if ( empty($label) ) $label = __('« Older Comments'); - echo '". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; }