-
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 Hooks: Fix truncation of post content #68926
Merged
+96
−151
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
235e851
Block Hooks: Repurpose GB compat function
ockham 2c18d63
Block Hooks: Absorb temporary wrapper block functionality into apply_…
ockham ab04995
Remove now-obsolete logic from Post Content block
ockham 508c116
Remove now-obsolete logic from Synced Pattern block
ockham 555cb7e
Whitespace
ockham d0fe0eb
Use in gutenberg_insert_hooked_blocks_into_rest_response
ockham acb88e5
Remove now-obsolete variable
ockham 87d8855
Use in Navigation block
ockham 59d9431
Navigation block: Remove now-obsolete Block Hooks helpers
ockham fb93422
Rename function
ockham b4a070d
Replace filters correctly
ockham 1950380
Rename context to post
ockham 558cb74
Add type annotation
ockham e0e001e
Add PHPDoc
ockham 8d1e654
Add backport changelog
ockham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/8212 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/68926 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,33 +46,10 @@ function render_block_core_post_content( $attributes, $content, $block ) { | |
$content .= wp_link_pages( array( 'echo' => 0 ) ); | ||
} | ||
|
||
$ignored_hooked_blocks = get_post_meta( $post_id, '_wp_ignored_hooked_blocks', true ); | ||
if ( ! empty( $ignored_hooked_blocks ) ) { | ||
$ignored_hooked_blocks = json_decode( $ignored_hooked_blocks, true ); | ||
$attributes['metadata'] = array( | ||
'ignoredHookedBlocks' => $ignored_hooked_blocks, | ||
); | ||
} | ||
|
||
// Wrap in Post Content block so the Block Hooks algorithm can insert blocks | ||
// that are hooked as first or last child of `core/post-content`. | ||
$content = get_comment_delimited_block_content( | ||
'core/post-content', | ||
$attributes, | ||
$content | ||
); | ||
|
||
// We need to remove the `core/post-content` block wrapper after the Block Hooks algorithm, | ||
// but before `do_blocks` runs, as it would otherwise attempt to render the same block again -- | ||
// thus recursing infinitely. | ||
add_filter( 'the_content', 'remove_serialized_parent_block', 8 ); | ||
|
||
/** This filter is documented in wp-includes/post-template.php */ | ||
$content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) ); | ||
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. The Post Content block runs the |
||
unset( $seen_ids[ $post_id ] ); | ||
|
||
remove_filter( 'the_content', 'remove_serialized_parent_block', 8 ); | ||
|
||
if ( empty( $content ) ) { | ||
return ''; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note that each block that fetches content from a post object in the DB does so in a different way. Specifically, the Synced Pattern block (
core/block
) does not invoke thethe_content
filter, so we need to runapply_block_hooks_to_content_from_post_object
manually.