Make WordPress Core

Ticket #35378: 35378.diff

File 35378.diff, 1.7 KB (added by jmdodd, 9 years ago)
  • wp-includes/comment-template.php

     
    12861286                'order' => 'ASC',
    12871287                'status'  => 'approve',
    12881288                'post_id' => $post->ID,
    1289                 'hierarchical' => 'threaded',
    12901289                'no_found_rows' => false,
    12911290                'update_comment_meta_cache' => false, // We lazy-load comment meta for performance.
    12921291        );
    12931292
     1293        if ( get_option('thread_comments') ) {
     1294                $comment_args['hierarchical'] = 'threaded';
     1295        } else {
     1296                $comment_args['hierarchical'] = false;
     1297        }
     1298
    12941299        if ( $user_ID ) {
    12951300                $comment_args['include_unapproved'] = array( $user_ID );
    12961301        } elseif ( ! empty( $comment_author_email ) ) {
     
    13361341        $_comments = $comment_query->comments;
    13371342
    13381343        // Trees must be flattened before they're passed to the walker.
    1339         $comments_flat = array();
    1340         foreach ( $_comments as $_comment ) {
    1341                 $comments_flat[]  = $_comment;
    1342                 $comment_children = $_comment->get_children( array(
    1343                         'format' => 'flat',
    1344                         'status' => $comment_args['status'],
    1345                         'orderby' => $comment_args['orderby']
    1346                 ) );
     1344        if ( $comment_args['hierarchical'] ) {
     1345                $comments_flat = array();
     1346                foreach ( $_comments as $_comment ) {
     1347                        $comments_flat[]  = $_comment;
     1348                        $comment_children = $_comment->get_children( array(
     1349                                'format' => 'flat',
     1350                                'status' => $comment_args['status'],
     1351                                'orderby' => $comment_args['orderby']
     1352                        ) );
    13471353
    1348                 foreach ( $comment_children as $comment_child ) {
    1349                         $comments_flat[] = $comment_child;
     1354                        foreach ( $comment_children as $comment_child ) {
     1355                                $comments_flat[] = $comment_child;
     1356                        }
    13501357                }
     1358        } else {
     1359                $comments_flat = $_comments;
    13511360        }
    13521361
    13531362        /**