wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



use_block_editor_for_post_type › WordPress Function

Da5.0.0
Deprecaton/a
use_block_editor_for_post_type ( $post_type )
Parametri:
  • (string) $post_type The post type.
    Richiesto:
Ritorna:
  • (bool) Whether the post type can be edited with the block editor.
Definito a:
Codex:
ChangeLog:
  • 6.1.0

Returns whether a post type is compatible with the block editor.

The block editor depends on the REST API, and if the post type is not shown in the REST API, then it won't work with the block editor.


Sorgenti

function use_block_editor_for_post_type( $post_type ) {
	if ( ! post_type_exists( $post_type ) ) {
		return false;
	}

	if ( ! post_type_supports( $post_type, 'editor' ) ) {
		return false;
	}

	$post_type_object = get_post_type_object( $post_type );
	if ( $post_type_object && ! $post_type_object->show_in_rest ) {
		return false;
	}

	/**
	 * 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 type can be edited or not. Default true.
	 * @param string $post_type         The post type being checked.
	 */
	return apply_filters( 'use_block_editor_for_post_type', true, $post_type );
}