-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Editor: Move pre_render_block, render_block_data, render_block_context #691
Conversation
@noisysocks - nice one, it would be really helpful to add unit tests to prevent future regressions. |
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.
Good changes applied. The solution proposed should be fine in terms of the backward compatibility.
I don't really understand why these filters are in the constructor and not inside |
By "model object" do you mean that you'd expect
We could lazily instantiate this data in So, I'd like to move these filters to |
Exactly.
Can we initialize the property in the constructor, but then in |
I dislike that this would mean we're doing unnecessary work in the constructor. I'll have a play. It might be possible to move all of the work into |
Move the pre_render_block, render_block_data, and render_block_context filters from render_block() to WP_Block. This ensures that they are called for all blocks, including nested blocks, not just top-level blocks.
b1baaad
to
cc5c894
Compare
OK, I've moved the two filters to I did this by making it so that most of the properties that are derived from We can then, in In real usage, this means we compute the properties at most once per render. |
This looks great to me! |
Move the pre_render_block, render_block_data, and render_block_context filters from render_block() to WP_Block. This ensures that they are called for all blocks, including nested blocks, not just top-level blocks.
Trac ticket: https://core.trac.wordpress.org/ticket/51612
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.