| @@ -1049,31 +1049,12 @@ | ||
| 1049 | 1049 | $inner_block_wrapper_classes = null; |
| 1050 | 1050 | $first_chunk = $block['innerContent'][0] ?? null; |
| 1051 | 1051 | if ( is_string( $first_chunk ) && count( $block['innerContent'] ) > 1 ) { |
| 1052 | 1052 | $first_chunk_processor = new WP_HTML_Tag_Processor( $first_chunk ); |
| 1053 | - /* | |
| 1054 | - * Use a stack to track open elements as tags are visited. Void elements | |
| 1055 | - * (those without a matching closing tag) are excluded so they don't | |
| 1056 | - * accumulate on the stack. At the end of the chunk, every element still | |
| 1057 | - * on the stack is unclosed — meaning its closing tag lives in a later | |
| 1058 | - * innerContent entry alongside the inner blocks, which makes it the | |
| 1059 | - * inner-block container. Elements that open and close within this chunk | |
| 1060 | - * are siblings that precede the inner blocks and should be ignored. | |
| 1061 | - * The last unclosed element with a class attribute is the best candidate | |
| 1062 | - * for the inner-block wrapper. | |
| 1063 | - */ | |
| 1064 | - $tag_stack = array(); | |
| 1065 | - while ( $first_chunk_processor->next_tag( array( 'tag_closers' => 'visit' ) ) ) { | |
| 1066 | - if ( $first_chunk_processor->is_tag_closer() ) { | |
| 1067 | - array_pop( $tag_stack ); | |
| 1068 | - } elseif ( ! WP_HTML_Processor::is_void( $first_chunk_processor->get_tag() ) ) { | |
| 1069 | - $tag_stack[] = $first_chunk_processor->get_attribute( 'class' ); | |
| 1070 | - } | |
| 1071 | - } | |
| 1072 | - foreach ( array_reverse( $tag_stack ) as $class_attribute ) { | |
| 1053 | + while ( $first_chunk_processor->next_tag() ) { | |
| 1054 | + $class_attribute = $first_chunk_processor->get_attribute( 'class' ); | |
| 1073 | 1055 | if ( is_string( $class_attribute ) && ! empty( $class_attribute ) ) { |
| 1074 | 1056 | $inner_block_wrapper_classes = $class_attribute; |
| 1075 | - break; | |
| 1076 | 1057 | } |
| 1077 | 1058 | } |
| 1078 | 1059 | } |
| 1079 | 1060 | |