Changeset 57157 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 12/04/2023 08:24:33 PM (2 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/blocks.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r57120 r57157 759 759 760 760 /** 761 * Conditionally returns the markup for a given hooked block type. 762 * 763 * Accepts two arguments: A reference to an anchor block, and the name of a hooked block type. 764 * If the anchor block has already been processed, and the given hooked block type is in the list 765 * of ignored hooked blocks, an empty string is returned. 766 * 767 * This function is meant for internal use only. 768 * 769 * @since 6.5.0 770 * @access private 771 * 772 * @param array $anchor_block The anchor block. Passed by reference. 773 * @param string $hooked_block_type The name of the hooked block type. 774 * @return string The markup for the given hooked block type, or an empty string if the block is ignored. 775 */ 776 function get_hooked_block_markup( &$anchor_block, $hooked_block_type ) { 777 if ( ! isset( $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ) ) { 778 $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] = array(); 779 } 780 781 if ( in_array( $hooked_block_type, $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ) ) { 782 return ''; 783 } 784 785 // The following is only needed for the REST API endpoint. 786 // However, its presence does not affect the frontend. 787 $anchor_block['attrs']['metadata']['ignoredHookedBlocks'][] = $hooked_block_type; 788 789 return get_comment_delimited_block_content( $hooked_block_type, array(), '' ); 790 } 791 792 /** 761 793 * Returns a function that injects the theme attribute into, and hooked blocks before, a given block. 762 794 * … … 814 846 $hooked_block_types = apply_filters( 'hooked_block_types', $hooked_block_types, $relative_position, $anchor_block_type, $context ); 815 847 foreach ( $hooked_block_types as $hooked_block_type ) { 816 $markup .= get_ comment_delimited_block_content( $hooked_block_type, array(), '');848 $markup .= get_hooked_block_markup( $parent_block, $hooked_block_type ); 817 849 } 818 850 } … … 827 859 $hooked_block_types = apply_filters( 'hooked_block_types', $hooked_block_types, $relative_position, $anchor_block_type, $context ); 828 860 foreach ( $hooked_block_types as $hooked_block_type ) { 829 $markup .= get_ comment_delimited_block_content( $hooked_block_type, array(), '');861 $markup .= get_hooked_block_markup( $block, $hooked_block_type ); 830 862 } 831 863 … … 875 907 $hooked_block_types = apply_filters( 'hooked_block_types', $hooked_block_types, $relative_position, $anchor_block_type, $context ); 876 908 foreach ( $hooked_block_types as $hooked_block_type ) { 877 $markup .= get_ comment_delimited_block_content( $hooked_block_type, array(), '');909 $markup .= get_hooked_block_markup( $block, $hooked_block_type ); 878 910 } 879 911 … … 889 921 $hooked_block_types = apply_filters( 'hooked_block_types', $hooked_block_types, $relative_position, $anchor_block_type, $context ); 890 922 foreach ( $hooked_block_types as $hooked_block_type ) { 891 $markup .= get_ comment_delimited_block_content( $hooked_block_type, array(), '');923 $markup .= get_hooked_block_markup( $parent_block, $hooked_block_type ); 892 924 } 893 925 }
Note: See TracChangeset
for help on using the changeset viewer.