函数原型
block_has_support( WP_Block_Type $block_type, array $feature, mixed $default = false ): bool
函数描述
Checks whether the current block type supports the feature requested.
是否弃用
未弃用
函数参数
-
$block_type
WP_Block_Type
Required - Block type to check for support.
-
$feature
array
Required - Path to a specific feature to check support for.
-
$default
mixed
Optional - Fallback value for feature support.
Default:
false
函数返回值
bool Whether the feature is supported.
函数位置
File: wp-includes/blocks.php.
函数源码
function block_has_support( $block_type, $feature, $default = false ) {
$block_support = $default;
if ( $block_type && property_exists( $block_type, 'supports' ) ) {
$block_support = _wp_array_get( $block_type->supports, $feature, $default );
}
return true === $block_support || is_array( $block_support );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 5.8.0 | Introduced. |

