WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4/src/wp-includes/comment-template.php

    r35748 r36158  
    737737    }
    738738
    739     if ( $cpage ) {
     739    if ( $cpage && get_option( 'page_comments' ) ) {
    740740        if ( $wp_rewrite->using_permalinks() ) {
    741741            if ( $cpage ) {
     
    13141314            // If fetching the first page of 'newest', we need a top-level comment count.
    13151315            $top_level_query = new WP_Comment_Query();
    1316             $top_level_count = $top_level_query->query( array(
     1316            $top_level_args  = array(
    13171317                'count'   => true,
    13181318                'orderby' => false,
    13191319                'post_id' => $post->ID,
    13201320                'parent'  => 0,
    1321             ) );
     1321                'status'  => 'approve',
     1322            );
     1323
     1324            if ( isset( $comment_args['include_unapproved'] ) ) {
     1325                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
     1326            }
     1327
     1328            $top_level_count = $top_level_query->query( $top_level_args );
    13221329
    13231330            $comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page;
     
    13311338    $comments_flat = array();
    13321339    foreach ( $_comments as $_comment ) {
    1333         $comments_flat = array_merge( $comments_flat, array( $_comment ), $_comment->get_children( array(
     1340        $comments_flat[]  = $_comment;
     1341        $comment_children = $_comment->get_children( array(
    13341342            'format' => 'flat',
    13351343            'status' => $comment_args['status'],
    13361344            'orderby' => $comment_args['orderby']
    1337         ) ) );
     1345        ) );
     1346
     1347        foreach ( $comment_children as $comment_child ) {
     1348            $comments_flat[] = $comment_child;
     1349        }
    13381350    }
    13391351
     
    19131925     */
    19141926    $r = apply_filters( 'wp_list_comments_args', $r );
     1927
     1928    /*
     1929     * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
     1930     * perform a separate comment query and allow Walker_Comment to paginate.
     1931     */
     1932    if ( is_singular() && ( $r['page'] || $r['per_page'] ) ) {
     1933        $current_cpage = get_query_var( 'cpage' );
     1934        if ( ! $current_cpage ) {
     1935            $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
     1936        }
     1937
     1938        $current_per_page = get_query_var( 'comments_per_page' );
     1939        if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
     1940            $comments = get_comments( array(
     1941                'post_id' => get_queried_object_id(),
     1942                'orderby' => 'comment_date_gmt',
     1943                'order' => 'ASC',
     1944                'status' => 'all',
     1945            ) );
     1946        }
     1947    }
    19151948
    19161949    // Figure out what comments we'll be looping through ($_comments)
Note: See TracChangeset for help on using the changeset viewer.