Make WordPress Core

Changeset 9667


Ignore:
Timestamp:
11/13/2008 08:36:36 PM (16 years ago)
Author:
ryan
Message:

wp_list_comments() fixes when passing type. Props Viper007Bond. fixes #8168

File:
1 edited

Legend:

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

    r9540 r9667  
    12141214    $r = wp_parse_args( $args, $defaults );
    12151215
     1216    // Figure out what comments we'll be looping through ($_comments)
     1217    if ( null !== $comments ) {
     1218        $comments = (array) $comments;
     1219        if ( empty($comments) )
     1220            return;
     1221        if ( 'all' != $r['type'] ) {
     1222            $comments_by_type = &separate_comments($comments);
     1223            if ( empty($comments_by_type[$r['type']]) )
     1224                return;
     1225            $_comments = $comments_by_type[$r['type']];
     1226        } else {
     1227            $_comments = $comments;
     1228        }
     1229    } else {
     1230        if ( empty($wp_query->comments) )
     1231            return;
     1232        if ( 'all' != $r['type'] ) {
     1233            if ( empty($wp_query->comments_by_type) )
     1234                $wp_query->comments_by_type = &separate_comments($wp_query->comments);
     1235            if ( empty($wp_query->comments_by_type[$r['type']]) )
     1236                return;
     1237            $_comments = $wp_query->comments_by_type[$r['type']];
     1238        } else {
     1239            $_comments = $wp_query->comments;
     1240        }
     1241    }
     1242
    12161243    if ( '' === $r['per_page'] && get_option('page_comments') )
    12171244        $r['per_page'] = get_query_var('comments_per_page');
     
    12301257
    12311258    if ( '' === $r['page'] ) {
    1232         if ( empty($comments) ) {
     1259        if ( empty($overridden_cpage) ) {
    12331260            $r['page'] = get_query_var('cpage');
    12341261        } else {
    1235             if ( empty($overridden_cpage) ) {
    1236                 $r['page'] = get_query_var('cpage');
    1237             } else {
    1238                 $threaded = ( -1 == $r['max_depth'] ) ? false : true;
    1239                 $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($comments, $r['per_page'], $threaded) : 1;
    1240                 set_query_var( 'cpage', $r['page'] );
    1241             }
     1262            $threaded = ( -1 == $r['max_depth'] ) ? false : true;
     1263            $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
     1264            set_query_var( 'cpage', $r['page'] );
    12421265        }
    12431266    }
     
    12531276
    12541277    if ( empty($walker) )
    1255     $walker = new Walker_Comment;
    1256 
    1257     if ( empty($comments) ) {
    1258         if ( empty($wp_query->comments) )
    1259             return;
    1260         if ( 'all' != $type ) {
    1261             if ( empty($wp_query->comments_by_type) )
    1262                 $wp_query->comments_by_type = &separate_comments($wp_query->comments);
    1263             if ( empty($wp_query->comments_by_type[$type]) )
    1264                 return;
    1265             $walker->paged_walk($wp_query->comments_by_type[$type], $max_depth, $page, $per_page, $r);
    1266             $wp_query->max_num_comment_pages = $walker->max_pages;
    1267             return;
    1268         }
    1269         $walker->paged_walk($wp_query->comments, $max_depth, $page, $per_page, $r);
    1270         $wp_query->max_num_comment_pages = $walker->max_pages;
    1271     } else {
    1272         if ( empty($comments) )
    1273             return;
    1274         if ( 'all' != $type ) {
    1275             $comments_by_type = &separate_comments($comments);
    1276             if ( empty($comments_by_type[$type]) )
    1277                 return;
    1278             $walker->paged_walk($comments_by_type[$type], $max_depth, $page, $per_page, $r);
    1279             $wp_query->max_num_comment_pages = $walker->max_pages;
    1280             return;
    1281         }
    1282         $walker->paged_walk($comments, $max_depth, $page, $per_page, $r);
    1283         $wp_query->max_num_comment_pages = $walker->max_pages;
    1284     }
     1278        $walker = new Walker_Comment;
     1279
     1280    $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
     1281    $wp_query->max_num_comment_pages = $walker->max_pages;
    12851282}
    12861283
Note: See TracChangeset for help on using the changeset viewer.