Avoid changing default wpautop priority#11722
Conversation
| function gutenberg_wpautop( $content ) { | ||
| if ( has_blocks( $content ) ) { | ||
| return $content; | ||
| // If there are blocks in this content, we shouldn't run wpautop() on it later. |
There was a problem hiding this comment.
In Core, this block of code is run at the top of do_blocks(), there is no equivalent of gutenberg_wpautop(). Any particular reason why you chose to do it this way?
There was a problem hiding this comment.
There's no good reason.
I may have made a mental mistake and avoided do_blocks because it is only defined conditionally by this plugin, but actually, we only need to worry about avoiding wpautop when we define do_blocks. Thanks for asking.
| * | ||
| * @access private | ||
| * | ||
| * @since 4.4 |
There was a problem hiding this comment.
| * @since 4.4 | |
| * @since 4.4.0 |
e116708 to
bd83c88
Compare
| $priority = has_filter( 'the_content', 'wpautop' ); | ||
| if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) { | ||
| remove_filter( 'the_content', 'wpautop', $priority ); | ||
| add_filter( 'the_content', 'wpautop', $priority + 1 ); |
There was a problem hiding this comment.
Immediately re-adding wpautop here. 🤦♂️ Good example of why one shouldn't work during time set aside for recharging.
|
|
||
| if ( ! function_exists( '_restore_wpautop_hook' ) ) { | ||
| /** | ||
| * If do_blocks() needs to remove wp_autop() from the `the_content` filter, |
There was a problem hiding this comment.
Thanks for catching that. It's fixed now.
ae40f6d to
46b6887
Compare
|
This looks like it's ready for another pass, @brandonpayton? |
46b6887 to
e5ecd4a
Compare
Yep. It just needs a review. |
noisysocks
left a comment
There was a problem hiding this comment.
Confirmed that this fixes #11691 👍
Could we include the unit test that's in https://core.trac.wordpress.org/changeset/43879?
Will be good to remove all of these workarounds once the Gutenberg plugin relies on having WordPress 5.0 installed.
|
This should go into the next plugin release. My understanding is that that will be 4.7, not 4.6. |
|
@brandonpayton changed it to task because this is retrofitting the plugin with behaviour present in core, and since we are not doing another plugin release yet. |
|
ah, maybe I shouldn't be tagging PRs with "bug" at all. thanks for explaining @mtias |
|
It's fine :) I just wanted to have a clear overview in the milestone to figure out what needs to be merged before release and what can be added after release but before 5.0.1, if that makes sense. |
…rnmobile/danilo-try-to-fix-undo-redo * 'master' of https://github.com/WordPress/gutenberg: Avoid changing default wpautop priority (#11722) Try fixing the tab navigation issue (#12390) Polish editor style documentation (#12381)
Description
This is a change to avoid problems due to changing the default wpautop priority.
Fixes #11691.
How has this been tested?
Types of changes
Take a similar approach to core by removing the
wpautopfilter when block content is detected and subsequently restore it for later applications of thethe_contentfilter.The core changeset used for reference:
https://core.trac.wordpress.org/changeset/43879
Checklist: