@@ -530,20 +530,24 @@ public function test_rendering_comment_template_sets_comment_id_context() {
530530 );
531531 $ comment_author_name_block_markup = $ comment_author_name_block ->render ();
532532
533- $ render_block_callback = static function ( $ block_content , $ block ) use ( $ parsed_comment_author_name_block ) {
534- /*
535- * Insert a Comment Author Name block (which requires `commentId`
536- * block context to work) after the Comment Content block.
537- */
538- if ( 'core/comment-content ' !== $ block ['blockName ' ] ) {
539- return $ block_content ;
540- }
541-
542- $ inserted_content = render_block ( $ parsed_comment_author_name_block );
543- return $ inserted_content . $ block_content ;
544- };
533+ add_filter (
534+ 'render_block ' ,
535+ static function ( $ block_content , $ block ) use ( $ parsed_comment_author_name_block ) {
536+ /*
537+ * Insert a Comment Author Name block (which requires `commentId`
538+ * block context to work) after the Comment Content block.
539+ */
540+ if ( 'core/comment-content ' !== $ block ['blockName ' ] ) {
541+ return $ block_content ;
542+ }
543+
544+ $ inserted_content = render_block ( $ parsed_comment_author_name_block );
545+ return $ inserted_content . $ block_content ;
546+ },
547+ 10 ,
548+ 3
549+ );
545550
546- add_filter ( 'render_block ' , $ render_block_callback , 10 , 3 );
547551 $ parsed_blocks = parse_blocks (
548552 '<!-- wp:comment-template --><!-- wp:comment-content /--><!-- /wp:comment-template --> '
549553 );
@@ -554,7 +558,6 @@ public function test_rendering_comment_template_sets_comment_id_context() {
554558 )
555559 );
556560 $ markup = $ block ->render ();
557- remove_filter ( 'render_block ' , $ render_block_callback );
558561
559562 $ this ->assertStringContainsString ( $ comment_author_name_block_markup , $ markup );
560563 }
0 commit comments