WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/23/2008 04:08:47 PM (10 years ago)
Author:
ryan
Message:

Comment paging and sorting from Viper007Bond. see #7927

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment-template.php

    r9209 r9296  
    762762        $comments_by_type = &$wp_query->comments_by_type;
    763763    }
     764
     765    if ( '' == get_query_var('cpage') && get_option('page_comments') && 'newest' == get_option('default_comments_page') )
     766        set_query_var( 'cpage', get_comment_pages_count() );
    764767
    765768    define('COMMENTS_TEMPLATE', true);
     
    11231126 * @uses Walker_Comment
    11241127 *
    1125  * @param $args string|array Formatting options
    1126  * @param $comments array Optional array of comment objects.  Defaults to $wp_query->comments
     1128 * @param string|array $args Formatting options
     1129 * @param array $comments Optional array of comment objects.  Defaults to $wp_query->comments
    11271130 */
    11281131function wp_list_comments($args = array(), $comments = null ) {
     
    11331136
    11341137    $defaults = array('walker' => null, 'depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
    1135         'page' => get_query_var('cpage'), 'per_page' => '', 'avatar_size' => 32);
     1138        'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => '', 'reverse_children' => '');
    11361139
    11371140    $r = wp_parse_args( $args, $defaults );
     
    11431146        $r['per_page'] = 0;
    11441147        $r['page'] = 0;
    1145     } else {
    1146         $r['page'] = intval($r['page']);
    1147         if ( empty($r['page']) )
    1148             $r['page'] = 1;
    11491148    }
    11501149
     
    11551154            $r['depth'] = -1;
    11561155    }
     1156
     1157    if ( '' === $r['page'] ) {
     1158        if ( empty($comments) ) {
     1159            $r['page'] = get_query_var('cpage');
     1160        } else {
     1161            $threaded = ( -1 == $r['depth'] ) ? false : true;
     1162            $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($comments, $r['per_page'], $threaded) : 1;
     1163            set_query_var( 'cpage', $r['page'] );
     1164        }
     1165    }
     1166    // Validation check
     1167    $r['page'] = intval($r['page']);
     1168    if ( 0 == $r['page'] && 0 != $r['per_page'] )
     1169        $r['page'] = 1;
     1170
     1171    if ( '' == $r['reverse_top_level'] )
     1172        $r['reverse_top_level'] = ( 'asc' == get_option('comment_order') ) ? FALSE : TRUE;
    11571173
    11581174    extract( $r, EXTR_SKIP );
Note: See TracChangeset for help on using the changeset viewer.