-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 Hooks: Apply to Post Content (on frontend) #7889
Block Hooks: Apply to Post Content (on frontend) #7889
Conversation
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. |
@@ -192,6 +192,7 @@ | |||
add_filter( 'the_title', 'convert_chars' ); | |||
add_filter( 'the_title', 'trim' ); | |||
|
|||
add_filter( 'the_content', 'apply_block_hooks_to_content', 8 ); // BEFORE do_blocks(). |
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.
apply_block_hooks_to_content
parses blocks, traverses the block tree (to insert hooked blocks), and reserializes them. Note that it's followed immediately by do_blocks
(on the line below), which also parses blocks.
This means that in theory, there's some potential for optimization (parse only once inside of do_blocks
, and traverse to insert hooked blocks there).
In practice, I'm not sure if that's viable, or if that might cause some collisions; in particular if do_blocks
is already used in other contexts where hooked blocks are already inserted (through a different mechanism), e.g. in templates or wp_navigation
posts.
I have drafted an alternative PR based on this one to explore also inserting hooked blocks into Post Content in the editor: #7898 |
Closing in favor of #7898. |
Port of WordPress/gutenberg#67272.
Trac ticket: https://core.trac.wordpress.org/ticket/61074
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.