mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Fix comment paging for when $comments is passed in. props Viper007Bond. see #7927
git-svn-id: http://svn.automattic.com/wordpress/trunk@9317 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bfc531cd80
commit
de26116d76
@ -730,7 +730,7 @@ function wp_comment_form_unfiltered_html_nonce() {
|
||||
* @return null Returns null if no comments appear
|
||||
*/
|
||||
function comments_template( $file = '/comments.php', $separate_comments = false ) {
|
||||
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
|
||||
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
|
||||
|
||||
if ( ! (is_single() || is_page() || $withcomments) )
|
||||
return;
|
||||
@ -762,8 +762,11 @@ function comments_template( $file = '/comments.php', $separate_comments = false
|
||||
$comments_by_type = &$wp_query->comments_by_type;
|
||||
}
|
||||
|
||||
if ( '' == get_query_var('cpage') && get_option('page_comments') && 'newest' == get_option('default_comments_page') )
|
||||
$overridden_cpage = FALSE;
|
||||
if ( '' == get_query_var('cpage') && get_option('page_comments') && 'newest' == get_option('default_comments_page') ) {
|
||||
set_query_var( 'cpage', get_comment_pages_count() );
|
||||
$overridden_cpage = TRUE;
|
||||
}
|
||||
|
||||
define('COMMENTS_TEMPLATE', true);
|
||||
|
||||
@ -1129,7 +1132,7 @@ class Walker_Comment extends Walker {
|
||||
* @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
|
||||
*/
|
||||
function wp_list_comments($args = array(), $comments = null ) {
|
||||
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt;
|
||||
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage;
|
||||
|
||||
$comment_alt = $comment_thread_alt = 0;
|
||||
$comment_depth = 1;
|
||||
@ -1157,12 +1160,16 @@ function wp_list_comments($args = array(), $comments = null ) {
|
||||
if ( '' === $r['page'] ) {
|
||||
if ( empty($comments) ) {
|
||||
$r['page'] = get_query_var('cpage');
|
||||
} else {
|
||||
if ( empty($overridden_cpage) ) {
|
||||
$r['page'] = get_query_var('cpage');
|
||||
} else {
|
||||
$threaded = ( -1 == $r['depth'] ) ? false : true;
|
||||
$r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($comments, $r['per_page'], $threaded) : 1;
|
||||
set_query_var( 'cpage', $r['page'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
// Validation check
|
||||
$r['page'] = intval($r['page']);
|
||||
if ( 0 == $r['page'] && 0 != $r['per_page'] )
|
||||
|
Loading…
Reference in New Issue
Block a user