diff --git a/packages/block-library/src/pattern/index.php b/packages/block-library/src/pattern/index.php index 4af986c423d01..cb3be0370a4f6 100644 --- a/packages/block-library/src/pattern/index.php +++ b/packages/block-library/src/pattern/index.php @@ -22,30 +22,35 @@ function register_block_core_pattern() { /** * Renders the `core/pattern` block on the server. * - * @param array $attributes Block attributes. - * @param string $content The block rendered content. + * @param array $attributes Block attributes. * * @return string Returns the output of the pattern. */ -function render_block_core_pattern( $attributes, $content ) { +function render_block_core_pattern( $attributes ) { if ( empty( $attributes['slug'] ) ) { return ''; } - $slug_classname = str_replace( '/', '-', $attributes['slug'] ); - $classnames = isset( $attributes['className'] ) ? $attributes['className'] . ' ' . $slug_classname : $slug_classname; - $wrapper = '
%s
'; - - if ( isset( $attributes['syncStatus'] ) && 'unsynced' === $attributes['syncStatus'] ) { - return sprintf( $wrapper, $content ); - } $slug = $attributes['slug']; $registry = WP_Block_Patterns_Registry::get_instance(); + if ( ! $registry->is_registered( $slug ) ) { return ''; } $pattern = $registry->get_registered( $slug ); + + // Currently all existing blocks should be returned here without a wp-block-pattern wrapper + // as the syncStatus attribute is only used if the gutenberg-pattern-enhancements experiment + // is enabled. + if ( ! isset( $attributes['syncStatus'] ) ) { + return do_blocks( $pattern['content'] ); + } + + $block_classnames = 'wp-block-pattern ' . str_replace( '/', '-', $attributes['slug'] ); + $classnames = isset( $attributes['className'] ) ? $attributes['className'] . ' ' . $block_classnames : $block_classnames; + $wrapper = '
%s
'; + return sprintf( $wrapper, do_blocks( $pattern['content'] ) ); }