Astra_Gutenberg::restore_group_inner_container( string $block_content, array $block )
Add Group block inner container when theme.json is added to avoid the group block width from changing to full width.
Description
Parameters
- $block_content
-
(string) (Required) Rendered block content.
- $block
-
(array) (Required) Block object.
Return
(string) Filtered block content.
Source
File: inc/compatibility/class-astra-gutenberg.php
public function restore_group_inner_container( $block_content, $block ) { $group_with_inner_container_regex = '/(^\s*<div\b[^>]*wp-block-group(\s|")[^>]*>)(\s*<div\b[^>]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/'; if ( ( isset( $block['blockName'] ) && 'core/group' !== $block['blockName'] ) || 1 === preg_match( $group_with_inner_container_regex, $block_content ) ) { return $block_content; } $replace_regex = '/(^\s*<div\b[^>]*wp-block-group[^>]*>)(.*)(<\/div>\s*$)/ms'; $updated_content = preg_replace_callback( $replace_regex, array( $this, 'group_block_replace_regex' ), $block_content ); return $updated_content; }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
3.7.1 | Introduced. |