Site Editor: Remove call to wpautop that unintentionally alters block markup in template parts #30552
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.
Description
This change is very similar to an older draft PR (#20452 kudos @johnstonphilip) and follows on from discussion in #20343 (comment) where it was proposed to remove the call to
wpautop
when rendering template parts.It turns out, while working on a plugin that server renders a block (in this case it was the Jetpack Rating Star block), I noticed that when the block was rendered within a template part, the markup was incorrect and broke the styling for the block, however when the block was rendered within normal post content, the markup was correct.
In core, when
do_blocks
is called, it checks to see whether or not it's running withinthe_content
filter, and if so, it disables callingwpautop
for that run of the filter.However, in
render_block_core_template_part
we calldo_blocks
directly instead of within the context ofthe_content
, so the code to disablewpautop
doesn't fire (and it wouldn't do anything, anyway).Since the expected behaviour of calling
do_blocks
with block content is forwpautop
to be disabled, let's remove the call to it as proposed in #20343 (comment) and #20452How has this been tested?
Manually in a local development environment running the Gutenberg plugin and the Jetpack plugin, using the Star Rating block (a server-rendered block that expects not to have
<p>
tags injected into it).While I tested this with the Jetpack plugin, I believe other plugins will run into a similar issue with server rendered blocks in template parts, so thought it better to fix this in Gutenberg rather than add a workaround in the plugin.
Screenshots
Editor view
This is the editor view of inserting the Jetpack Star Rating block into the Footer template part:
Front-end view (without this change applied)
Front-end view (with this change applied)
Types of changes
Bug fix for blocks rendered within template parts.
Checklist:
I've tested my changes with keyboard and screen readers.N/AMy code has proper inline documentation.I've included developer documentation if appropriate.I've updated all React Native files affected by any refactorings/renamings in this PR(please manually search all*.native.js
files for terms that need renaming or removal).