Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Block Locking: Register the 'lock' attribute on the server
  • Loading branch information
Mamaduka committed Apr 20, 2022
commit 59936a17e9fa7d4393d2ec60ac375f8c4abcc61d
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 @@ -156,6 +156,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';