Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Bindings API: Add block bindings "Post data" source #57260

Closed
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
Prev Previous commit
Next Next commit
Add pattern source
  • Loading branch information
SantosGuillamot committed Dec 20, 2023
commit e55b1a84716d8be9837d80b6eda87e9ac1cbbeb3
23 changes: 23 additions & 0 deletions lib/experimental/block-bindings/sources/pattern.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Add the metadata source to the block bindings API.
*
* @package gutenberg
*/

if ( function_exists( 'register_block_bindings_source' ) ) {
$pattern_source_callback = function ( $source_attrs, $block_content, $block, $block_instance ) {
if ( ! _wp_array_get( $block_instance->attributes, array( 'metadata', 'id' ), false ) ) {
return;
}
$block_id = $block_instance->attributes['metadata']['id'];
return _wp_array_get( $block_instance->context, array( 'pattern/overrides', $block_id ), false );
};
register_block_bindings_source(
'pattern_attributes',
array(
'label' => __( 'Pattern Attributes' ),
'apply' => $pattern_source_callback,
)
);
}