Skip to content

Commit

Permalink
Merge pull request #2708 from WordPress/fix/removep-gutenberg
Browse files Browse the repository at this point in the history
Compat: Disable wpautop in Classic Editor when post contains block
  • Loading branch information
aduth authored Sep 25, 2017
2 parents 7b25dff + 57aa9bc commit 95cf846
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,19 @@ function gutenberg_ensure_wp_api_request() {
}
add_action( 'wp_enqueue_scripts', 'gutenberg_ensure_wp_api_request', 20 );
add_action( 'admin_enqueue_scripts', 'gutenberg_ensure_wp_api_request', 20 );

/**
* Disables wpautop behavior in classic editor when post contains blocks, to
* prevent removep from invalidating paragraph blocks.
*
* @param array $settings Original editor settings.
* @return array Filtered settings.
*/
function gutenberg_disable_editor_settings_wpautop( $settings ) {
if ( ! isset( $settings['wpautop'] ) ) {
$settings['wpautop'] = ! gutenberg_post_has_blocks( get_post()->ID );
}

return $settings;
}
add_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );

0 comments on commit 95cf846

Please sign in to comment.