diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 0d51c5dca2806..fb5b0005c1c91 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -482,8 +482,8 @@ Show a block pattern. ([Source](https://github.com/WordPress/gutenberg/tree/trun - **Name:** core/pattern - **Category:** theme -- **Supports:** ~~html~~, ~~inserter~~ -- **Attributes:** slug, unsynced +- **Supports:** align (full, wide) +- **Attributes:** align, layout, slug, syncStatus ## Post Author diff --git a/packages/block-library/src/pattern/index.php b/packages/block-library/src/pattern/index.php index 32a08601ca808..b60df3d43fdce 100644 --- a/packages/block-library/src/pattern/index.php +++ b/packages/block-library/src/pattern/index.php @@ -22,15 +22,20 @@ function register_block_core_pattern() { /** * Renders the `core/pattern` block on the server. * - * @param array $attributes Block attributes. + * @param array $attributes Block attributes. + * @param string $content The block rendered content. * * @return string Returns the output of the pattern. */ -function render_block_core_pattern( $attributes ) { +function render_block_core_pattern( $attributes, $content ) { if ( empty( $attributes['slug'] ) ) { return ''; } + if ( isset( $attributes['syncStatus'] ) && 'unsynced' === $attributes['syncStatus'] ) { + return $content; + } + $slug = $attributes['slug']; $registry = WP_Block_Patterns_Registry::get_instance(); if ( ! $registry->is_registered( $slug ) ) { diff --git a/packages/block-library/src/pattern/save.js b/packages/block-library/src/pattern/save.js index 05c3328904c45..a58adc56f8006 100644 --- a/packages/block-library/src/pattern/save.js +++ b/packages/block-library/src/pattern/save.js @@ -7,6 +7,7 @@ export default function save( { attributes } ) { if ( attributes.syncStatus === 'synced' ) { return null; } + const blockProps = useBlockProps.save(); const innerBlocksProps = useInnerBlocksProps.save( blockProps ); return <>{ innerBlocksProps.children }; diff --git a/test/integration/fixtures/blocks/core__pattern.json b/test/integration/fixtures/blocks/core__pattern.json index 3bb2c0891b06e..a92b57163082f 100644 --- a/test/integration/fixtures/blocks/core__pattern.json +++ b/test/integration/fixtures/blocks/core__pattern.json @@ -3,7 +3,12 @@ "name": "core/pattern", "isValid": true, "attributes": { - "slug": "core/text-two-columns" + "align": "full", + "layout": { + "type": "constrained" + }, + "slug": "core/text-two-columns", + "syncStatus": "synced" }, "innerBlocks": [] }