use_block_editor_for_post( int|WP_Post $post ): bool

In this article

Returns whether the post can be edited in the block editor.

Parameters

$postint|WP_Postrequired
Post ID or WP_Post object.

Return

bool Whether the post can be edited in the block editor.

Source

function use_block_editor_for_post( $post ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return false;
	}

	// We're in the meta box loader, so don't use the block editor.
	if ( is_admin() && isset( $_GET['meta-box-loader'] ) ) {
		check_admin_referer( 'meta-box-loader', 'meta-box-loader-nonce' );
		return false;
	}

	$use_block_editor = use_block_editor_for_post_type( $post->post_type );

	/**
	 * Filters whether a post is able to be edited in the block editor.
	 *
	 * @since 5.0.0
	 *
	 * @param bool    $use_block_editor Whether the post can be edited or not.
	 * @param WP_Post $post             The post being checked.
	 */
	return apply_filters( 'use_block_editor_for_post', $use_block_editor, $post );
}

Hooks

apply_filters( ‘use_block_editor_for_post’, bool $use_block_editor, WP_Post $post )

Filters whether a post is able to be edited in the block editor.

Changelog

VersionDescription
6.1.0Moved to wp-includes from wp-admin.
5.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.