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

Replace has_blocks with use_block_editor_for_post in is_using_gutenberg #514

Merged
merged 3 commits into from
Feb 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,14 @@ function is_using_gutenberg( $post ) {
return false;
}

// WordPress 5.0 introduces the has_blocks function.
// We pass `post_content` directly because `has_blocks()`
// tries to retrieve a local post object, but this may be a remote post.
if ( function_exists( 'has_blocks' ) ) {
return has_blocks( $post->post_content );
if ( function_exists( 'use_block_editor_for_post' ) ) {
return use_block_editor_for_post( $post );
} else {
// This duplicates the check from `has_blocks()` as of WP 5.2.
return false !== strpos( (string) $post->post_content, '<!-- wp:' );
}
}


/**
* Get Distributor settings with defaults
*
Expand Down Expand Up @@ -351,6 +347,7 @@ function prepare_meta( $post_id ) {
$meta_value = maybe_unserialize( $meta_value );
/**
* Filter whether to sync meta.
*
* @hook dt_sync_meta
*
* @param {bool} $sync_meta Whether to sync meta. Default `true`.
Expand Down