mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@37655 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user