From 4710282f3320b66a02c0e5cd5535048f498edd6f Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 28 Apr 2022 01:18:13 +0000 Subject: [PATCH] Editor: Show comment previews in the Comment Query Loop. Update `build_comment_query_vars_from_block()` to show previews of unmoderated comments to the original author of the comment. This duplicates the existing logic in `wp_list_comments()`. Props darerodz, bernhard-reiter, czapla. Fixes #55634. Built from https://develop.svn.wordpress.org/trunk@53298 git-svn-id: http://core.svn.wordpress.org/trunk@52887 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks.php | 18 ++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 93ff0f7aaa..49b26cd5b6 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -1287,12 +1287,22 @@ add_filter( 'block_type_metadata', '_wp_multiple_block_styles' ); function build_comment_query_vars_from_block( $block ) { $comment_args = array( - 'orderby' => 'comment_date_gmt', - 'order' => 'ASC', - 'status' => 'approve', - 'no_found_rows' => false, + 'orderby' => 'comment_date_gmt', + 'order' => 'ASC', + 'status' => 'approve', + 'no_found_rows' => false, ); + if ( is_user_logged_in() ) { + $comment_args['include_unapproved'] = array( get_current_user_id() ); + } else { + $unapproved_email = wp_get_unapproved_comment_author_email(); + + if ( $unapproved_email ) { + $comment_args['include_unapproved'] = array( $unapproved_email ); + } + } + if ( ! empty( $block->context['postId'] ) ) { $comment_args['post_id'] = (int) $block->context['postId']; } diff --git a/wp-includes/version.php b/wp-includes/version.php index c28447469a..0b6f5f57cd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-beta3-53297'; +$wp_version = '6.0-beta3-53298'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.