wp_restore_group_inner_container
函数
wp_restore_group_inner_container ( $block_content, $block )
- Access
- Private
- 参数
-
-
(string)
$block_content
Rendered block content.- Required: 是
-
(array)
$block
Block object.- Required: 是
-
(string)
- 返回值
-
- (string) Filtered block content.
- 定义位置
-
-
wp-includes/block-supports/layout.php
, line 459
-
wp-includes/block-supports/layout.php
- 引入
- 5.8.0
- 弃用
- –
For themes without theme.json file, make sure
to restore the inner div for the group block
to avoid breaking styles relying on that div.
function wp_restore_group_inner_container( $block_content, $block ) {
$tag_name = isset( $block['attrs']['tagName'] ) ? $block['attrs']['tagName'] : 'div';
$group_with_inner_container_regex = sprintf(
'/(^s*]*wp-block-group(s|")[^>]*>)(s*]*wp-block-group__inner-container(s|")[^>]*>)((.|S|s)*)/U',
preg_quote( $tag_name, '/' )
);
if (
WP_Theme_JSON_Resolver::theme_has_support() ||
1 === preg_match( $group_with_inner_container_regex, $block_content ) ||
( isset( $block['attrs']['layout']['type'] ) && 'flex' === $block['attrs']['layout']['type'] )
) {
return $block_content;
}
$replace_regex = sprintf(
'/(^s*]*wp-block-group[^>]*>)(.*)(%1$s>s*$)/ms',
preg_quote( $tag_name, '/' )
);
$updated_content = preg_replace_callback(
$replace_regex,
static function( $matches ) {
return $matches[1] . '' . $matches[2] . '' . $matches[3];
},
$block_content
);
return $updated_content;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


