Skip to content

Commit

Permalink
Fix markdown conflicts
Browse files Browse the repository at this point in the history
Here's the test case I have that duplicates this issue:
1. Install Jetpack and enable markdown
2. Create post in Gutenberg with a couple paragraphs.
3. Open post in classic editor and click update
4. One big paragraph.

This change adds the filter on `wp_insert_post_data` since
edits in classic editor do not go through the rest API.

Additionally, it changes the call to remove markdown which
is more inclusive of all the actions and filters this markdown
implementation touches.
  • Loading branch information
mkaz committed Feb 27, 2018
1 parent cc87946 commit 23fed49
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/plugin-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
* @param array $post Post object which contains content to check for block.
* @return array $post Post object.
*/
function gutenberg_remove_wpcom_markdown_support( $post ) {
if ( gutenberg_content_has_blocks( $post->post_content ) ) {
remove_post_type_support( 'post', 'wpcom-markdown' );
function gutenberg_remove_wpcom_markdown_support( $post_data ) {
if ( gutenberg_content_has_blocks( implode( "\n", $post_data ) ) ) {
if ( class_exists ( 'WPCom_Markdown' ) ) {
WPCom_Markdown::get_instance()->unload_markdown_for_posts();
}
}
return $post;
return $post_data;
}
add_filter( 'rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support' );
add_filter( 'wp_insert_post_data', 'gutenberg_remove_wpcom_markdown_support', 1, 1 );

0 comments on commit 23fed49

Please sign in to comment.