Changeset 53298
- Timestamp:
- 04/28/2022 01:16:18 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r53235 r53298 1288 1288 1289 1289 $comment_args = array( 1290 'orderby' => 'comment_date_gmt', 1291 'order' => 'ASC', 1292 'status' => 'approve', 1293 'no_found_rows' => false, 1294 ); 1290 'orderby' => 'comment_date_gmt', 1291 'order' => 'ASC', 1292 'status' => 'approve', 1293 'no_found_rows' => false, 1294 ); 1295 1296 if ( is_user_logged_in() ) { 1297 $comment_args['include_unapproved'] = array( get_current_user_id() ); 1298 } else { 1299 $unapproved_email = wp_get_unapproved_comment_author_email(); 1300 1301 if ( $unapproved_email ) { 1302 $comment_args['include_unapproved'] = array( $unapproved_email ); 1303 } 1304 } 1295 1305 1296 1306 if ( ! empty( $block->context['postId'] ) ) { -
trunk/tests/phpunit/tests/blocks/renderCommentTemplate.php
r53258 r53298 251 251 ); 252 252 } 253 254 /** 255 * Test that unapproved comments are included if it is a preview. 256 * 257 * @ticket 55634 258 * @covers ::build_comment_query_vars_from_block 259 */ 260 function test_build_comment_query_vars_from_block_with_comment_preview() { 261 $parsed_blocks = parse_blocks( 262 '<!-- wp:comment-template --><!-- wp:comment-author-name /--><!-- wp:comment-content /--><!-- /wp:comment-template -->' 263 ); 264 265 $block = new WP_Block( 266 $parsed_blocks[0], 267 array( 268 'postId' => self::$custom_post->ID, 269 ) 270 ); 271 272 $commenter_filter = function () { 273 return array( 274 'comment_author_email' => 'unapproved@example.org', 275 ); 276 }; 277 278 add_filter( 'wp_get_current_commenter', $commenter_filter ); 279 280 $this->assertEquals( 281 build_comment_query_vars_from_block( $block ), 282 array( 283 'orderby' => 'comment_date_gmt', 284 'order' => 'ASC', 285 'status' => 'approve', 286 'no_found_rows' => false, 287 'include_unapproved' => array( 'unapproved@example.org' ), 288 'post_id' => self::$custom_post->ID, 289 'hierarchical' => 'threaded', 290 'number' => 5, 291 'paged' => 1, 292 ) 293 ); 294 } 253 295 }
Note: See TracChangeset
for help on using the changeset viewer.