mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-02 16:59:35 +01:00
c3ea09ebb8
It contains several changes in addition to regular update to WordPress packages: - All newly exposed blocks are now registered on the server. - Dutone block support was added. - Border block support was updated. - New shared function `construct_wp_query_args` was added for the family of Query blocks - it might need some further work. Props youknowriad. See #52991. Built from https://develop.svn.wordpress.org/trunk@50929 git-svn-id: http://core.svn.wordpress.org/trunk@50538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Layout block support flag.
|
|
*
|
|
* @package WordPress
|
|
* @since 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.
|
|
*
|
|
* @since 5.8.0
|
|
* @access private
|
|
*
|
|
* @param string $block_content Rendered block content.
|
|
* @param array $block Block object.
|
|
*
|
|
* @return string Filtered block content.
|
|
*/
|
|
function wp_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)*)/';
|
|
|
|
// TODO: Add check for theme.json presence.
|
|
if (
|
|
'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,
|
|
function( $matches ) {
|
|
return $matches[1] . '<div class="wp-block-group__inner-container">' . $matches[2] . '</div>' . $matches[3];
|
|
},
|
|
$block_content
|
|
);
|
|
return $updated_content;
|
|
}
|
|
|
|
add_filter( 'render_block', 'wp_restore_group_inner_container', 10, 2 );
|