From 838156a95805b8032199d302ac4e0e705b7053ff Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 8 Jun 2016 04:01:27 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@37655 git-svn-id: http://core.svn.wordpress.org/trunk@37621 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 18 ++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 41accc9a46..1b5684b921 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -1960,13 +1960,23 @@ function wp_list_comments( $args = array(), $comments = null ) { $current_per_page = get_query_var( 'comments_per_page' ); if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { - - $comments = get_comments( array( + $comment_args = array( 'post_id' => get_the_ID(), 'orderby' => 'comment_date_gmt', 'order' => 'ASC', - 'status' => 'all', - ) ); + 'status' => 'approve', + ); + + if ( is_user_logged_in() ) { + $comment_args['include_unapproved'] = get_current_user_id(); + } else { + $commenter = wp_get_current_commenter(); + if ( $commenter['comment_author_email'] ) { + $comment_args['include_unapproved'] = $commenter['comment_author_email']; + } + } + + $comments = get_comments( $comment_args ); if ( 'all' != $r['type'] ) { $comments_by_type = separate_comments( $comments ); diff --git a/wp-includes/version.php b/wp-includes/version.php index dc1314c814..61ac7db5c2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37654'; +$wp_version = '4.6-alpha-37655'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.