-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Avoid changing default wpautop priority #11722
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
Conversation
lib/compat.php
Outdated
*/ | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
lib/compat.php
Outdated
* | ||
* @access private | ||
* | ||
* @since 4.4 |
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.
* @since 4.4 | |
* @since 4.4.0 |
e116708
to
bd83c88
Compare
lib/blocks.php
Outdated
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Immediately re-adding wpautop here. 🤦♂️ Good example of why one shouldn't work during time set aside for recharging.
lib/blocks.php
Outdated
@@ -187,6 +194,29 @@ function do_blocks( $content ) { | |||
add_filter( 'the_content', 'do_blocks', 7 ); // BEFORE do_shortcode() and oembed. | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wp_autop
~> wpautop
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.
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. |
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.
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
wpautop
filter when block content is detected and subsequently restore it for later applications of thethe_content
filter.The core changeset used for reference:
https://core.trac.wordpress.org/changeset/43879
Checklist: