diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index bee68530eeb239..ab6bb52b6b3b2a 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -42,7 +42,7 @@ Create and save content to reuse across your site. Update the pattern, and the c - **Name:** core/block - **Category:** reusable - **Supports:** ~~customClassName~~, ~~html~~, ~~inserter~~, ~~renaming~~ -- **Attributes:** ref +- **Attributes:** overrides, ref ## Button diff --git a/lib/block-supports/pattern.php b/lib/block-supports/pattern.php deleted file mode 100644 index 0c5868c1fea0cb..00000000000000 --- a/lib/block-supports/pattern.php +++ /dev/null @@ -1,46 +0,0 @@ - array( 'content' ), - 'core/heading' => array( 'content' ), - 'core/image' => array( 'url', 'title', 'alt' ), - 'core/button' => array( 'url', 'text' ), - ); - $pattern_support = array_key_exists( $block_type->name, $allowed_blocks ); - - if ( $pattern_support ) { - if ( ! $block_type->uses_context ) { - $block_type->uses_context = array(); - } - - if ( ! in_array( 'pattern/overrides', $block_type->uses_context, true ) ) { - $block_type->uses_context[] = 'pattern/overrides'; - } - } - } - - // Register the block support. - WP_Block_Supports::get_instance()->register( - 'pattern', - array( - 'register_attribute' => 'gutenberg_register_pattern_support', - ) - ); -} diff --git a/lib/load.php b/lib/load.php index 37e4d61c36832e..8c9c8532d573ca 100644 --- a/lib/load.php +++ b/lib/load.php @@ -213,7 +213,6 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/block-supports/duotone.php'; require __DIR__ . '/block-supports/shadow.php'; require __DIR__ . '/block-supports/background.php'; -require __DIR__ . '/block-supports/pattern.php'; // Data views. require_once __DIR__ . '/experimental/data-views.php'; diff --git a/packages/block-library/src/block/block.json b/packages/block-library/src/block/block.json index aeccdbfc1051db..b30c865e57a7f6 100644 --- a/packages/block-library/src/block/block.json +++ b/packages/block-library/src/block/block.json @@ -10,6 +10,9 @@ "attributes": { "ref": { "type": "number" + }, + "overrides": { + "type": "object" } }, "supports": { diff --git a/packages/block-library/src/block/index.php b/packages/block-library/src/block/index.php index 54b54fad139ff3..444001fa498595 100644 --- a/packages/block-library/src/block/index.php +++ b/packages/block-library/src/block/index.php @@ -46,17 +46,14 @@ function render_block_core_block( $attributes ) { $content = $wp_embed->run_shortcode( $reusable_block->post_content ); $content = $wp_embed->autoembed( $content ); - $gutenberg_experiments = get_option( 'gutenberg-experiments' ); - $has_partial_synced_overrides = $gutenberg_experiments - && array_key_exists( 'gutenberg-pattern-partial-syncing', $gutenberg_experiments ) - && isset( $attributes['overrides'] ); + $has_pattern_overrides = isset( $attributes['overrides'] ); /** * We set the `pattern/overrides` context through the `render_block_context` * filter so that it is available when a pattern's inner blocks are * rendering via do_blocks given it only receives the inner content. */ - if ( $has_partial_synced_overrides ) { + if ( $has_pattern_overrides ) { $filter_block_context = static function ( $context ) use ( $attributes ) { $context['pattern/overrides'] = $attributes['overrides']; return $context; @@ -67,7 +64,7 @@ function render_block_core_block( $attributes ) { $content = do_blocks( $content ); unset( $seen_refs[ $attributes['ref'] ] ); - if ( $has_partial_synced_overrides ) { + if ( $has_pattern_overrides ) { remove_filter( 'render_block_context', $filter_block_context, 1 ); } @@ -86,28 +83,3 @@ function register_block_core_block() { ); } add_action( 'init', 'register_block_core_block' ); - -$gutenberg_experiments = get_option( 'gutenberg-experiments' ); -if ( $gutenberg_experiments && array_key_exists( 'gutenberg-pattern-partial-syncing', $gutenberg_experiments ) ) { - /** - * Registers the overrides attribute for core/block. - * - * @param array $args Array of arguments for registering a block type. - * @param string $block_name Block name including namespace. - * @return array $args - */ - function register_block_core_block_args( $args, $block_name ) { - if ( 'core/block' === $block_name ) { - $args['attributes'] = array_merge( - $args['attributes'], - array( - 'overrides' => array( - 'type' => 'object', - ), - ) - ); - } - return $args; - } - add_filter( 'register_block_type_args', 'register_block_core_block_args', 10, 2 ); -} diff --git a/packages/block-library/src/button/block.json b/packages/block-library/src/button/block.json index 3c232700a876e6..f04d4642bb98e8 100644 --- a/packages/block-library/src/button/block.json +++ b/packages/block-library/src/button/block.json @@ -8,6 +8,7 @@ "description": "Prompt visitors to take action with a button-style link.", "keywords": [ "link" ], "textdomain": "default", + "usesContext": [ "pattern/overrides" ], "attributes": { "tagName": { "type": "string", diff --git a/packages/block-library/src/heading/block.json b/packages/block-library/src/heading/block.json index 72cc67caddd9ea..a1eb3fce32ef15 100644 --- a/packages/block-library/src/heading/block.json +++ b/packages/block-library/src/heading/block.json @@ -7,6 +7,7 @@ "description": "Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.", "keywords": [ "title", "subtitle" ], "textdomain": "default", + "usesContext": [ "pattern/overrides" ], "attributes": { "textAlign": { "type": "string" diff --git a/packages/block-library/src/image/block.json b/packages/block-library/src/image/block.json index c5191e3dd86543..a9357d28815b61 100644 --- a/packages/block-library/src/image/block.json +++ b/packages/block-library/src/image/block.json @@ -4,7 +4,12 @@ "name": "core/image", "title": "Image", "category": "media", - "usesContext": [ "allowResize", "imageCrop", "fixedHeight" ], + "usesContext": [ + "allowResize", + "imageCrop", + "fixedHeight", + "pattern/overrides" + ], "description": "Insert an image to make a visual statement.", "keywords": [ "img", "photo", "picture" ], "textdomain": "default", diff --git a/packages/block-library/src/paragraph/block.json b/packages/block-library/src/paragraph/block.json index a81d754d8ca1be..25a9a36fa8bf0a 100644 --- a/packages/block-library/src/paragraph/block.json +++ b/packages/block-library/src/paragraph/block.json @@ -7,7 +7,7 @@ "description": "Start with the basic building block of all narrative.", "keywords": [ "text" ], "textdomain": "default", - "usesContext": [ "postId" ], + "usesContext": [ "postId", "pattern/overrides" ], "attributes": { "align": { "type": "string"