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_http_supportswp_cache_supportsremove_theme_supportget_theme_supportwp_is_https_supported
引入
5.8.0
棄用
-

block_has_support: 這個函式檢查一個塊是否支援某個特定的功能或屬性: 該函式需要兩個引數:區塊型別(如”core/image”)和特徵名稱(如”align”)。

檢查當前區塊型別是否支援所請求的功能。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常見問題

FAQs
檢視更多 >