use_block_editor_for_post

函数
use_block_editor_for_post ( $post )
参数
  • (int|WP_Post) $post Post ID or WP_Post object.
    Required:
返回值
  • (bool) Whether the post can be edited in the block editor.
定义位置
相关方法
use_block_editor_for_post_typeuser_can_edit_post_disable_block_editor_for_navigation_post_typeget_block_editor_settingsget_block_editor_theme_styles
引入
5.0.0
弃用
-

use_block_editor_for_post: 这个函数决定新的区块编辑器是否应该用于一个特定的文章。

返回文章是否可以在区块编辑器中进行编辑的结果。

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 );
}

常见问题

FAQs
查看更多 >