Editor: add layout classes to legacy Group inner container.
Moves generated layout classes into the Group block inner container in classic themes, so that block gap support can work correctly. Props flixos90, mukesh27. Fixes #60130. Built from https://develop.svn.wordpress.org/trunk@57246 git-svn-id: http://core.svn.wordpress.org/trunk@56752 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
45df401868
commit
2b005a61ef
|
@ -638,7 +638,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
|
|||
* for features like the enhanced pagination of the Query block.
|
||||
*/
|
||||
$container_class = wp_unique_prefixed_id(
|
||||
'wp-container-' . sanitize_title( $block['blockName'] ) . '-layout-'
|
||||
'wp-container-' . sanitize_title( $block['blockName'] ) . '-is-layout-'
|
||||
);
|
||||
|
||||
// Set the correct layout type for blocks using legacy content width.
|
||||
|
@ -883,6 +883,23 @@ function wp_restore_group_inner_container( $block_content, $block ) {
|
|||
return $block_content;
|
||||
}
|
||||
|
||||
/*
|
||||
* This filter runs after the layout classnames have been added to the block, so they
|
||||
* have to be removed from the outer wrapper and then added to the inner.
|
||||
*/
|
||||
$layout_classes = array();
|
||||
$processor = new WP_HTML_Tag_Processor( $block_content );
|
||||
|
||||
if ( $processor->next_tag( array( 'class_name' => 'wp-block-group' ) ) ) {
|
||||
foreach ( $processor->class_list() as $class_name ) {
|
||||
if ( str_contains( $class_name, 'is-layout-' ) ) {
|
||||
$layout_classes[] = $class_name;
|
||||
$processor->remove_class( $class_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content_without_layout_classes = $processor->get_updated_html();
|
||||
$replace_regex = sprintf(
|
||||
'/(^\s*<%1$s\b[^>]*wp-block-group[^>]*>)(.*)(<\/%1$s>\s*$)/ms',
|
||||
preg_quote( $tag_name, '/' )
|
||||
|
@ -892,8 +909,19 @@ function wp_restore_group_inner_container( $block_content, $block ) {
|
|||
static function ( $matches ) {
|
||||
return $matches[1] . '<div class="wp-block-group__inner-container">' . $matches[2] . '</div>' . $matches[3];
|
||||
},
|
||||
$block_content
|
||||
$content_without_layout_classes
|
||||
);
|
||||
|
||||
// Add layout classes to inner wrapper.
|
||||
if ( ! empty( $layout_classes ) ) {
|
||||
$processor = new WP_HTML_Tag_Processor( $updated_content );
|
||||
if ( $processor->next_tag( array( 'class_name' => 'wp-block-group__inner-container' ) ) ) {
|
||||
foreach ( $layout_classes as $class_name ) {
|
||||
$processor->add_class( $class_name );
|
||||
}
|
||||
}
|
||||
$updated_content = $processor->get_updated_html();
|
||||
}
|
||||
return $updated_content;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.5-alpha-57245';
|
||||
$wp_version = '6.5-alpha-57246';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue