block_has_support

函数


block_has_support ( $block_type, $feature, $default = false )
参数
  • (WP_Block_Type)
    $block_type
    Block type to check for support.
    Required:
  • (array)
    $feature
    Path to a specific feature to check support for.
    Required:
  • (mixed)
    $default
    Optional. Fallback value for feature support. Default false.
    Required:
    Default: false
返回值
  • (bool) Whether the feature is supported.
定义位置
  • wp-includes/blocks.php
    , line 1175
引入
5.8.0
弃用

Checks whether the current block type supports the feature requested.

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