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
This commit is contained in:
Peter Wilson 2022-04-28 01:18:13 +00:00
parent b4eb72f714
commit 4710282f33
2 changed files with 15 additions and 5 deletions

View File

@ -1287,12 +1287,22 @@ add_filter( 'block_type_metadata', '_wp_multiple_block_styles' );
function build_comment_query_vars_from_block( $block ) { function build_comment_query_vars_from_block( $block ) {
$comment_args = array( $comment_args = array(
'orderby' => 'comment_date_gmt', 'orderby' => 'comment_date_gmt',
'order' => 'ASC', 'order' => 'ASC',
'status' => 'approve', 'status' => 'approve',
'no_found_rows' => false, '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'] ) ) { if ( ! empty( $block->context['postId'] ) ) {
$comment_args['post_id'] = (int) $block->context['postId']; $comment_args['post_id'] = (int) $block->context['postId'];
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.