Skip to content
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

Feature: Markdown support as a Jetpack Markdown-specific Gutenberg Block #6491

Closed
wants to merge 13 commits into from
5 changes: 5 additions & 0 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,11 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
wp_die( $post_to_edit->get_error_message() );
}

/**
* Apply filter to modify WP_Post prior to sending it to Gutenberg.
*/
$post_to_edit = apply_filters( 'after_block_editor_gets_post_to_edit', $post_to_edit );

// Set initial title to empty string for auto draft for duration of edit.
// Otherwise, title defaults to and displays as "Auto Draft".
$is_new_post = 'auto-draft' === $post_to_edit['status'];
Expand Down
12 changes: 10 additions & 2 deletions lib/plugin-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@
*
* @since 1.3.0
*
* @param array $post Post object which contains content to check for block.
* @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 ( class_exists( 'WPCom_Markdown' ) && gutenberg_content_has_blocks( $post['post_content'] ) ) {
if (
class_exists( 'WPCom_Markdown' )
&& gutenberg_content_has_blocks( $post['post_content'] )
&& (
! isset( WPCom_Markdown::$is_block_editor_compatible )
|| true !== WPCom_Markdown::$is_block_editor_compatible
)
) {
WPCom_Markdown::get_instance()->unload_markdown_for_posts();
}
return $post;
}

add_filter( 'wp_insert_post_data', 'gutenberg_remove_wpcom_markdown_support', 9 );