Skip to content
Merged
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
Next Next commit
Block Hooks: Repurpose GB compat function
  • Loading branch information
ockham committed Jan 28, 2025
commit 235e8512ed4894fbbf9c691e7b659a5e22fa0d66
12 changes: 7 additions & 5 deletions lib/compat/wordpress-6.8/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
* @package gutenberg
*/

function gutenberg_apply_block_hooks_to_post_content( $content ) {
// The `the_content` filter does not provide the post that the content is coming from.
// However, we can infer it by calling `get_post()`, which will return the current post
// if no post ID is provided.
return apply_block_hooks_to_content( $content, get_post(), 'insert_hooked_blocks' );
function gutenberg_apply_block_hooks_to_post_content( $content, $context = null, $callback = 'insert_hooked_blocks' ) {
// Default to the current post if no context is provided.
if ( null === $context ) {
$context = get_post();
}

return apply_block_hooks_to_content( $content, $context, $callback );
}
// We need to apply this filter before `do_blocks` (which is hooked to `the_content` at priority 9).
add_filter( 'the_content', 'gutenberg_apply_block_hooks_to_post_content', 8 );
Expand Down