Changeset 51382 for branches/5.8/src/wp-includes/blocks.php
- Timestamp:
- 07/08/2021 05:27:27 PM (3 years ago)
- Location:
- branches/5.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.8
- Property svn:mergeinfo changed
/trunk merged: 51348,51375
- Property svn:mergeinfo changed
-
branches/5.8/src/wp-includes/blocks.php
r51363 r51382 711 711 ); 712 712 713 $allowed_blocks = array_merge( $allowed_inner_blocks, array( 'core/columns' ) ); 713 $allowed_wrapper_blocks = array( 714 'core/columns', 715 'core/column', 716 'core/group', 717 ); 718 719 /** 720 * Filters the list of blocks that can be used as wrapper blocks, allowing 721 * excerpts to be generated from the `innerBlocks` of these wrappers. 722 * 723 * @since 5.8.0 724 * 725 * @param array $allowed_wrapper_blocks The list of allowed wrapper blocks. 726 */ 727 $allowed_wrapper_blocks = apply_filters( 'excerpt_allowed_wrapper_blocks', $allowed_wrapper_blocks ); 728 729 $allowed_blocks = array_merge( $allowed_inner_blocks, $allowed_wrapper_blocks ); 714 730 715 731 /** … … 730 746 if ( in_array( $block['blockName'], $allowed_blocks, true ) ) { 731 747 if ( ! empty( $block['innerBlocks'] ) ) { 732 if ( 'core/columns' === $block['blockName']) {733 $output .= _excerpt_render_inner_ columns_blocks( $block, $allowed_inner_blocks );748 if ( in_array( $block['blockName'], $allowed_wrapper_blocks, true ) ) { 749 $output .= _excerpt_render_inner_blocks( $block, $allowed_blocks ); 734 750 continue; 735 751 } … … 754 770 755 771 /** 756 * Render inner blocks from the `core/columns` block for generating an excerpt. 757 * 758 * @since 5.2.0 772 * Render inner blocks from the allowed wrapper blocks 773 * for generating an excerpt. 774 * 775 * @since 5.8 759 776 * @access private 760 777 * 761 * @param array $ columns The parsed columnsblock.778 * @param array $parsed_block The parsed block. 762 779 * @param array $allowed_blocks The list of allowed inner blocks. 763 780 * @return string The rendered inner blocks. 764 781 */ 765 function _excerpt_render_inner_ columns_blocks( $columns, $allowed_blocks ) {782 function _excerpt_render_inner_blocks( $parsed_block, $allowed_blocks ) { 766 783 $output = ''; 767 784 768 foreach ( $columns['innerBlocks'] as $column ) { 769 foreach ( $column['innerBlocks'] as $inner_block ) { 770 if ( in_array( $inner_block['blockName'], $allowed_blocks, true ) && empty( $inner_block['innerBlocks'] ) ) { 771 $output .= render_block( $inner_block ); 772 } 785 foreach ( $parsed_block['innerBlocks'] as $inner_block ) { 786 if ( ! in_array( $inner_block['blockName'], $allowed_blocks, true ) ) { 787 continue; 788 } 789 790 if ( empty( $inner_block['innerBlocks'] ) ) { 791 $output .= render_block( $inner_block ); 792 } else { 793 $output .= _excerpt_render_inner_blocks( $inner_block, $allowed_blocks ); 773 794 } 774 795 }
Note: See TracChangeset
for help on using the changeset viewer.