Skip to content

Commit

Permalink
One more fix for the bad rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
michalczaplinski committed Jan 24, 2024
1 parent 15b2f72 commit 4205960
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/compat/wordpress-6.5/block-bindings/sources/pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,23 @@
if ( ! _wp_array_get( $block_instance->attributes, array( 'metadata', 'id' ), false ) ) {
return null;
}
$block_id = $block_instance->attributes['metadata']['id'];
return _wp_array_get( $block_instance->context, array( 'pattern/overrides', $block_id, $attribute_name ), null );
$block_id = $block_instance->attributes['metadata']['id'];
$attribute_override = _wp_array_get( $block_instance->context, array( 'pattern/overrides', $block_id, $attribute_name ), null );
if ( null === $attribute_override ) {
return null;
}
switch ( $attribute_override[0] ) {
case 0: // remove
/**
* TODO: This currently doesn't remove the attribute, but only set it to an empty string.
* It's a temporary solution until the block binding API supports different operations.
*/
return '';
case 1: // replace
return $attribute_override[1];
default:
return null;
}
};
wp_block_bindings_register_source(
'pattern_attributes',
Expand Down

0 comments on commit 4205960

Please sign in to comment.