Skip to content

Commit

Permalink
Move content_has_blocks to register.php to be compat with PR #2806
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaz committed Oct 3, 2017
1 parent f771140 commit 9377638
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 2 additions & 12 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,14 @@ function gutenberg_disable_editor_settings_wpautop( $settings ) {
}
add_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );

/**
* Determine whether a content string contains blocks.
*
* @since 1.3
* @param string $content Content to test.
* @return bool Whether the content contains blocks.
*/
function content_has_blocks( $content ) {
return false !== strpos( $content, '<!-- wp:' );
}

/**
* WPCOM markdown support causes issues when saving a Gutenberg post by
* stripping out the <p> tags. This adds a filter prior to saving the post via
* REST API to disable markdown support. Markdown support most typically
* provided by Jetpack.
*
* @since 1.3
* @since 1.3.0
*
* @param array $post Post object which contains content to check for block.
* @return array $post Post object.
*/
Expand Down
12 changes: 12 additions & 0 deletions lib/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ function gutenberg_post_has_blocks( $post_id ) {
return $post && strpos( $post->post_content, '<!-- wp:' ) !== false;
}

/**
* Determine whether a content string contains blocks.
*
* @since 1.3.0
*
* @param string $content Content to test.
* @return bool Whether the content contains blocks.
*/
function content_has_blocks( $content ) {
return false !== strpos( $content, '<!-- wp:' );
}

/**
* Adds a "Gutenberg" post state for post tables, if the post contains blocks.
*
Expand Down

0 comments on commit 9377638

Please sign in to comment.