Changeset 57043
- Timestamp:
- 11/01/2023 12:44:02 PM (11 months ago)
- Location:
- branches/6.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.4/src/wp-includes/blocks.php
r57040 r57043 1064 1064 } 1065 1065 1066 $block_content .= traverse_and_serialize_block( $inner_block, $pre_callback, $post_callback );1067 1068 1066 if ( is_callable( $post_callback ) ) { 1069 1067 $next = count( $block['innerBlocks'] ) - 1 === $block_index … … 1071 1069 : $block['innerBlocks'][ $block_index + 1 ]; 1072 1070 1073 $ block_content .= call_user_func_array(1071 $post_markup = call_user_func_array( 1074 1072 $post_callback, 1075 1073 array( &$inner_block, &$block, $next ) 1076 1074 ); 1077 1075 } 1076 1077 $block_content .= traverse_and_serialize_block( $inner_block, $pre_callback, $post_callback ); 1078 $block_content .= isset( $post_markup ) ? $post_markup : ''; 1079 1078 1080 ++$block_index; 1079 1081 } … … 1139 1141 } 1140 1142 1141 $result .= traverse_and_serialize_block( $block, $pre_callback, $post_callback );1142 1143 1143 if ( is_callable( $post_callback ) ) { 1144 1144 $next = count( $blocks ) - 1 === $index … … 1146 1146 : $blocks[ $index + 1 ]; 1147 1147 1148 $ result .= call_user_func_array(1148 $post_markup = call_user_func_array( 1149 1149 $post_callback, 1150 1150 array( &$block, &$parent_block, $next ) 1151 1151 ); 1152 1152 } 1153 1154 $result .= traverse_and_serialize_block( $block, $pre_callback, $post_callback ); 1155 $result .= isset( $post_markup ) ? $post_markup : ''; 1153 1156 } 1154 1157 -
branches/6.4/tests/phpunit/tests/blocks/serialize.php
r56701 r57043 75 75 } 76 76 77 /** 78 * @ticket 59669 79 * 80 * @covers ::traverse_and_serialize_blocks 81 */ 82 public function test_traverse_and_serialize_blocks_post_callback_modifies_current_block() { 83 $markup = "<!-- wp:outer --><!-- wp:inner {\"key\":\"value\"} -->Example.<!-- /wp:inner -->\n\nExample.\n\n<!-- wp:void /--><!-- /wp:outer -->"; 84 $blocks = parse_blocks( $markup ); 85 86 $actual = traverse_and_serialize_blocks( $blocks, null, array( __CLASS__, 'add_attribute_to_inner_block' ) ); 87 88 $this->assertSame( 89 "<!-- wp:outer --><!-- wp:inner {\"key\":\"value\",\"myattr\":\"myvalue\"} -->Example.<!-- /wp:inner -->\n\nExample.\n\n<!-- wp:void /--><!-- /wp:outer -->", 90 $actual 91 ); 92 } 93 77 94 public static function add_attribute_to_inner_block( &$block ) { 78 95 if ( 'core/inner' === $block['blockName'] ) {
Note: See TracChangeset
for help on using the changeset viewer.