Skip to content

Commit

Permalink
Register overrides attribute in block.json
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Jan 23, 2024
1 parent cd183cc commit c8ca2e9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/block/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"attributes": {
"ref": {
"type": "number"
},
"overrides": {
"type": "object"
}
},
"supports": {
Expand Down
25 changes: 0 additions & 25 deletions packages/block-library/src/block/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,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 );
}

0 comments on commit c8ca2e9

Please sign in to comment.