-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: Refactor the way sources are handled #6016
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core SVNIf you're a Core Committer, use this list when committing to
GitHub Merge commitsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Thanks for handing the follow-up @gziolo I appreciate it. On a quick glance, everything looks good to me. |
* @param string $attribute_name The name of the target attribute. | ||
* @return mixed The value computed for the source. | ||
*/ | ||
function _block_bindings_pattern_overrides_get_value( array $source_args, $block_instance, string $attribute_name ) { |
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.
This kind of private function is in general better as inline functions/closures. I think these are not authorized in Core yet right? Do you know more about the reasoning...
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 was thinking about it, too. I’ll ask around and check the codebase. The only benefit of using another regular function like at the moment is the PHPDoc included.
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.
You definitely can find places where inline functions are defined as params passed. You shouldn't use them when passing the callback to WP hooks, but here, it would make perfect sense. I'll confirm that and refactor the code, if possible, after adding more unit tests.
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.
It looks good to me and the refactor makes sense 🙂
Co-authored-by: Mukesh Panchal <[email protected]>
668fe1b
to
b337f01
Compare
Committed with https://core.trac.wordpress.org/changeset/57526. |
Trac ticket: https://core.trac.wordpress.org/ticket/60282
Follow-up for #5888.
It fixes the coding style issues reported. It goes further and improves the code quality it other places where the logic for block bindings was added.
There are no functional changes.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.