Changeset 57038
- Timestamp:
- 10/31/2023 07:23:25 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r57032 r57038 781 781 * `first_child`, respectively, to the serialized markup for the given block. 782 782 * 783 * @param array $block The block to inject the theme attribute into, and hooked blocks before. 784 * @param array $parent_block The parent block of the given block. 785 * @param array $prev The previous sibling block of the given block. 783 * @param array $block The block to inject the theme attribute into, and hooked blocks before. Passed by reference. 784 * @param array $parent_block The parent block of the given block. Passed by reference. Default null. 785 * @param array $prev The previous sibling block of the given block. Default null. 786 786 * @return string The serialized markup for the given block, with the markup for any hooked blocks prepended to it. 787 787 */ 788 return function ( &$block, $parent_block = null, $prev = null ) use ( $hooked_blocks, $context ) {788 return function ( &$block, &$parent_block = null, $prev = null ) use ( $hooked_blocks, $context ) { 789 789 _inject_theme_attribute_in_template_part_block( $block ); 790 790 … … 854 854 * `last_child`, respectively, to the serialized markup for the given block. 855 855 * 856 * @param array $block The block to inject the hooked blocks after. 857 * @param array $parent_block The parent block of the given block. 858 * @param array $next The next sibling block of the given block. 856 * @param array $block The block to inject the hooked blocks after. Passed by reference. 857 * @param array $parent_block The parent block of the given block. Passed by reference. Default null. 858 * @param array $next The next sibling block of the given block. Default null. 859 859 * @return string The serialized markup for the given block, with the markup for any hooked blocks appended to it. 860 860 */ 861 return function ( &$block, $parent_block = null, $next = null ) use ( $hooked_blocks, $context ) {861 return function ( &$block, &$parent_block = null, $next = null ) use ( $hooked_blocks, $context ) { 862 862 $markup = ''; 863 863 … … 1066 1066 $block_content .= call_user_func_array( 1067 1067 $pre_callback, 1068 array( &$inner_block, $block, $prev )1068 array( &$inner_block, &$block, $prev ) 1069 1069 ); 1070 1070 } … … 1077 1077 $post_markup = call_user_func_array( 1078 1078 $post_callback, 1079 array( &$inner_block, $block, $next )1079 array( &$inner_block, &$block, $next ) 1080 1080 ); 1081 1081 } … … 1132 1132 */ 1133 1133 function traverse_and_serialize_blocks( $blocks, $pre_callback = null, $post_callback = null ) { 1134 $result = ''; 1134 $result = ''; 1135 $parent_block = null; // At the top level, there is no parent block to pass to the callbacks; yet the callbacks expect a reference. 1136 1135 1137 foreach ( $blocks as $index => $block ) { 1136 1138 if ( is_callable( $pre_callback ) ) { … … 1141 1143 $result .= call_user_func_array( 1142 1144 $pre_callback, 1143 array( &$block, null, $prev ) // At the top level, there is no parent block to pass to the callback.1145 array( &$block, &$parent_block, $prev ) 1144 1146 ); 1145 1147 } … … 1152 1154 $post_markup = call_user_func_array( 1153 1155 $post_callback, 1154 array( &$block, null, $next ) // At the top level, there is no parent block to pass to the callback.1156 array( &$block, &$parent_block, $next ) 1155 1157 ); 1156 1158 }
Note: See TracChangeset
for help on using the changeset viewer.