WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/08/2016 04:00:18 AM (4 years ago)
Author:
boonebgorges
Message:

Comments: In wp_list_comments(), queries with custom pagination params should obey default comment_status logic.

When custom pagination parameters are passed to wp_list_comments(), a
secondary query must be performed to fetch the proper comments. See [36157].
This query should show comments of the same comment_status as the default
query initialized in comments_template(): show only comments that are
approved, or those that are unapproved but belong to the current user.

Props smerriman.
Fixes #37048.

File:
1 edited

Legend:

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

    r37542 r37655  
    19611961            $current_per_page = get_query_var( 'comments_per_page' );
    19621962            if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
    1963 
    1964                 $comments = get_comments( array(
     1963                $comment_args = array(
    19651964                    'post_id' => get_the_ID(),
    19661965                    'orderby' => 'comment_date_gmt',
    19671966                    'order' => 'ASC',
    1968                     'status' => 'all',
    1969                 ) );
     1967                    'status' => 'approve',
     1968                );
     1969
     1970                if ( is_user_logged_in() ) {
     1971                    $comment_args['include_unapproved'] = get_current_user_id();
     1972                } else {
     1973                    $commenter = wp_get_current_commenter();
     1974                    if ( $commenter['comment_author_email'] ) {
     1975                        $comment_args['include_unapproved'] = $commenter['comment_author_email'];
     1976                    }
     1977                }
     1978
     1979                $comments = get_comments( $comment_args );
    19701980
    19711981                if ( 'all' != $r['type'] ) {
Note: See TracChangeset for help on using the changeset viewer.