Skip to content

Commit

Permalink
Block Locking: Register the 'lock' attribute on the server
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Apr 20, 2022
1 parent 29c0c42 commit 9d1cb2c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/block-supports/lock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Spacing block support flag.
*
* Once 6.0 is the minimum supported WordPress version for the Gutenberg
* plugin, this shim can be removed
*
* @package gutenberg
*/

/**
* Registers the lock block attribute for block types.
*
* @param WP_Block_Type $block_type Block Type.
*/
function gutenberg_register_lock_support( $block_type ) {
// Setup attributes if needed.
if ( ! $block_type->attributes ) {
$block_type->attributes = array();
}

if ( ! array_key_exists( 'lock', $block_type->attributes ) ) {
$block_type->attributes['lock'] = array(
'type' => 'object',
);
}
}

// Register the block support.
WP_Block_Supports::get_instance()->register(
'lock',
array(
'register_attribute' => 'gutenberg_register_lock_support',
)
);
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/block-supports/typography.php';
require __DIR__ . '/block-supports/border.php';
require __DIR__ . '/block-supports/layout.php';
require __DIR__ . '/block-supports/lock.php';
require __DIR__ . '/block-supports/spacing.php';
require __DIR__ . '/block-supports/dimensions.php';
require __DIR__ . '/block-supports/duotone.php';

0 comments on commit 9d1cb2c

Please sign in to comment.