use_block_editor_for_post_type
函数
use_block_editor_for_post_type ( $post_type )
- 参数
-
-
(string)
$post_type
The post type.- Required: 是
-
(string)
- 返回值
-
- (bool) Whether the post type can be edited with the block editor.
- 定义位置
-
-
wp-includes/post.php
, line 8106
-
wp-includes/post.php
- 引入
- 5.0.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.
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 ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。