Editor: Run autoembed() before do_blocks() in block content filters - #13508
i-am-chitti wants to merge 1 commit into
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 Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
cbd698b to
81be41b
Compare
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. |
autoembed() before do_blocks() in block content filters
| * This function runs the typical content processing filters that WordPress | ||
| * applies to post content, useful for blocks that render nested content. | ||
| * | ||
| * @since 7.1.0 |
There was a problem hiding this comment.
I think there should be another @since 7.x.x comment here documenting the change.
However we need to know which version this will ship in. I think we may consider shipping it in a 7.1.x release (probably 7.1.2 as I think it's late for 7.1.1, I'm not really up to date with the timeline of that release, maybe it already happened). That might be an idea because the function was only introduced in 7.1.0.
Alternatively it could go into 7.2. Lets discuss on the trac ticket.
talldan
left a comment
There was a problem hiding this comment.
The change looks good to me. I tested it and it works well. The reasoning is sound. I mentioned a little bit more in the gutenberg ticket.
I added one comment, but we'll have to figure out which version the PR/ticket is targeting to address it. The ticket is unmilestoned.
Description
_wp_apply_block_content_filters()calledWP_Embed::autoembed()afterdo_blocks(), so it ran over rendered block output instead of the source.the_content(autoembed at 8,do_blocks()at 9),get_the_block_template_html()andrender_block_core_block()all autoembed the source only. This moves the call beforedo_blocks()to match.render_block_core_pattern()has the same ordering problem and is the path behind the symptom reported in the ticket, but that file is synced from Gutenberg bytools/gutenberg/copy.js, so it is handled separately in GUTENBERG_PR_URL. This PR alone does not fix the reported bug — it aligns the one code path core owns.Trac ticket: https://core.trac.wordpress.org/ticket/66077
Testing instructions
npm run test:php -- --filter Tests_Blocks_WpApplyBlockContentFilters
test_autoembed_runs_before_do_blocksfails before the change and passes after. It asserts a URL present only in a nested block's rendered output is no longer turned into an embed, whiletest_applies_content_filterscontinues to assert a URL in the source still is.AI usage