wp_has_border_feature_support

函数
wp_has_border_feature_support ( $block_type, $feature, $default_value = false )
Access
Private
参数
  • (WP_Block_Type) $block_type Block type to check for support.
    Required:
  • (string) $feature Name of the feature to check support for.
    Required:
  • (mixed) $default_value Fallback value for feature support, defaults to false.
    Required:
    Default: false
返回值
  • (bool) Whether the feature is supported.
定义位置
相关方法
wp_apply_border_supportwp_register_border_supportwp_render_duotone_supportwp_render_elements_supportwp_render_typography_support
引入
5.8.0
弃用
-

wp_has_border_feature_support: 该函数用于检查当前浏览器是否支持CSS border-image属性。它不接受任何参数,返回真或假。

检查当前区块类型是否支持所请求的边界特征。

如果`__experimentalBorder`支持标志是一个布尔值`true`,那么所有的边界支持功能都是可用的。否则,嵌套在`experimentalBorder`下的特定特征支持标志必须被启用,才能选择该特征。

function wp_has_border_feature_support( $block_type, $feature, $default_value = false ) {
	// Check if all border support features have been opted into via `"__experimentalBorder": true`.
	if (
		property_exists( $block_type, 'supports' ) &&
		( true === _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), $default_value ) )
	) {
		return true;
	}

	// Check if the specific feature has been opted into individually
	// via nested flag under `__experimentalBorder`.
	return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default_value );
}

常见问题

FAQs
查看更多 >