Skip to content

Commit

Permalink
Sync with added support for multiple attributes in patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiomorales committed Jan 9, 2024
1 parent e0604df commit 25fa668
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/experimental/block-bindings/sources/pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

if ( function_exists( 'register_block_bindings_source' ) ) {
$pattern_source_callback = function ( $source_attrs, $block_content, $block, $block_instance ) {
$pattern_source_callback = function ( $source_attrs, $block_content, $block, $block_instance, $attribute_name ) {
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 ), null );
return _wp_array_get( $block_instance->context, array( 'pattern/overrides', $block_id, $attribute_name ), null );
};
register_block_bindings_source(
'pattern_attributes',
Expand Down
2 changes: 1 addition & 1 deletion lib/experimental/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function process_block_bindings( $block_content, $block, $block_instance ) {
} else {
$source_args = $binding_source['source']['attributes'];
}
$source_value = $source_callback( $source_args, $block_content, $block, $block_instance );
$source_value = $source_callback( $source_args, $block_content, $block, $block_instance, $binding_attribute );
// If the value is null, process next attribute.
if ( is_null( $source_value ) ) {
continue;
Expand Down

0 comments on commit 25fa668

Please sign in to comment.