Skip to content

Commit e41ba30

Browse files
Move supported blocks to private variables
1 parent 42575c4 commit e41ba30

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/wp-includes/class-wp-block-bindings-registry.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ final class WP_Block_Bindings_Registry {
3333
private static $instance = null;
3434

3535
/**
36-
* Allowed block that can use the block bindings API.
36+
* Supported blocks that can use the block bindings API.
3737
*
3838
* @since 6.5.0
3939
* @var WP_Block_Bindings_Registry[]
4040
*/
41-
public $allowed_blocks = array(
41+
private $supported_blocks = array(
4242
'core/paragraph' => array( 'content' ),
4343
'core/heading' => array( 'content' ),
4444
'core/image' => array( 'url', 'title', 'alt' ),
@@ -162,8 +162,7 @@ public function register( string $source_name, array $source_properties ) {
162162
add_filter(
163163
'get_block_type_uses_context',
164164
function ( $uses_context, $block_type ) use ( $source ) {
165-
$allowed_blocks = $this->allowed_blocks;
166-
if ( empty( $allowed_blocks[ $block_type->name ] ) || empty( $source->uses_context ) ) {
165+
if ( empty( $this->supported_blocks[ $block_type->name ] ) || empty( $source->uses_context ) ) {
167166
return $uses_context;
168167
}
169168
// Use array_values to reset the array keys.

src/wp-includes/class-wp-block.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -235,21 +235,26 @@ private function process_block_bindings() {
235235

236236
$computed_attributes = array();
237237

238-
$allowed_blocks = WP_Block_Bindings_Registry::get_instance()->allowed_blocks;
238+
$supported_blocks = array(
239+
'core/paragraph' => array( 'content' ),
240+
'core/heading' => array( 'content' ),
241+
'core/image' => array( 'url', 'title', 'alt' ),
242+
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
243+
);
239244

240-
// If the block doesn't have the bindings property, isn't one of the allowed
245+
// If the block doesn't have the bindings property, isn't one of the supported
241246
// block types, or the bindings property is not an array, return the block content.
242247
if (
243-
! isset( $allowed_blocks[ $this->name ] ) ||
248+
! isset( $supported_blocks[ $this->name ] ) ||
244249
empty( $parsed_block['attrs']['metadata']['bindings'] ) ||
245250
! is_array( $parsed_block['attrs']['metadata']['bindings'] )
246251
) {
247252
return $computed_attributes;
248253
}
249254

250255
foreach ( $parsed_block['attrs']['metadata']['bindings'] as $attribute_name => $block_binding ) {
251-
// If the attribute is not in the allowed list, process next attribute.
252-
if ( ! in_array( $attribute_name, $allowed_blocks[ $this->name ], true ) ) {
256+
// If the attribute is not in the supported list, process next attribute.
257+
if ( ! in_array( $attribute_name, $supported_blocks[ $this->name ], true ) ) {
253258
continue;
254259
}
255260
// If no source is provided, or that source is not registered, process next attribute.

0 commit comments

Comments
 (0)