-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Simplify block bindings object #58337
Changes from all commits
d3b01d0
805ecae
a75603b
2a6ac61
3f5a2af
5e66a6c
4f203ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,16 +76,12 @@ function gutenberg_process_block_bindings( $block_content, $block, $block_instan | |
* | ||
* "bindings": { | ||
* "title": { | ||
* "source": { | ||
* "name": "post_meta", | ||
* "attributes": { "value": "text_custom_field" } | ||
* } | ||
* "source": "core/post-meta", | ||
* "args": { "key": "text_custom_field" } | ||
* }, | ||
* "url": { | ||
* "source": { | ||
* "name": "post_meta", | ||
* "attributes": { "value": "text_custom_field" } | ||
* } | ||
* "source": "core/post-meta", | ||
* "args": { "key": "url_custom_field" } | ||
* } | ||
* } | ||
*/ | ||
|
@@ -99,16 +95,16 @@ function gutenberg_process_block_bindings( $block_content, $block, $block_instan | |
continue; | ||
} | ||
// If no source is provided, or that source is not registered, process next attribute. | ||
if ( ! isset( $binding_source['source'] ) || ! isset( $binding_source['source']['name'] ) || ! isset( $block_bindings_sources[ $binding_source['source']['name'] ] ) ) { | ||
if ( ! isset( $binding_source['source'] ) || ! is_string( $binding_source['source'] ) || ! isset( $block_bindings_sources[ $binding_source['source'] ] ) ) { | ||
continue; | ||
} | ||
|
||
$source_callback = $block_bindings_sources[ $binding_source['source']['name'] ]['apply']; | ||
$source_callback = $block_bindings_sources[ $binding_source['source'] ]['apply']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we might need to introduce There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could make sense 🤔 I've added that as a follow-up task in the tracking issue. |
||
// Get the value based on the source. | ||
if ( ! isset( $binding_source['source']['attributes'] ) ) { | ||
if ( ! isset( $binding_source['args'] ) ) { | ||
$source_args = array(); | ||
} else { | ||
$source_args = $binding_source['source']['attributes']; | ||
$source_args = $binding_source['args']; | ||
} | ||
$source_value = $source_callback( $source_args, $block_instance, $binding_attribute ); | ||
// If the value is null, process next attribute. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@talldan and @kevin940726, are you settled on the final name for the block binding source for Pattern Overrides? Tomorrow is the last day to change it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote for
core/pattern-overrides
but I wouldn't mind any other choices as long as it's consistent 😄.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree I would try to keep it as consistent as possible. What is the name of the feature? Synced pattern overrides?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm merging this pull request, but let's decide the name and we can change that in another pull request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also vote for core/pattern-overrides
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created this pull request to update that: link.