wp_register_spacing_support

函式
wp_register_spacing_support ( $block_type )
Access
Private
引數
  • (WP_Block_Type) $block_type Block Type.
    Required:
定義位置
相關方法
wp_register_alignment_supportwp_register_layout_supportwp_register_colors_supportwp_register_duotone_supportwp_register_typography_support
引入
5.8.0
棄用
-

wp_register_spacing_support: 該函式用於註冊對編輯器中自定義行高和字母間距的支援。它接受幾個引數,包括編輯器型別、特徵名稱和特徵的引數。

為支援該屬性的塊型別註冊樣式塊屬性。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_register_spacing_support( $block_type ) {
$has_spacing_support = block_has_support( $block_type, array( 'spacing' ), false );
// Setup attributes and styles within that if needed.
if ( ! $block_type->attributes ) {
$block_type->attributes = array();
}
if ( $has_spacing_support && ! array_key_exists( 'style', $block_type->attributes ) ) {
$block_type->attributes['style'] = array(
'type' => 'object',
);
}
}
function wp_register_spacing_support( $block_type ) { $has_spacing_support = block_has_support( $block_type, array( 'spacing' ), false ); // Setup attributes and styles within that if needed. if ( ! $block_type->attributes ) { $block_type->attributes = array(); } if ( $has_spacing_support && ! array_key_exists( 'style', $block_type->attributes ) ) { $block_type->attributes['style'] = array( 'type' => 'object', ); } }
function wp_register_spacing_support( $block_type ) {
	$has_spacing_support = block_has_support( $block_type, array( 'spacing' ), false );

	// Setup attributes and styles within that if needed.
	if ( ! $block_type->attributes ) {
		$block_type->attributes = array();
	}

	if ( $has_spacing_support && ! array_key_exists( 'style', $block_type->attributes ) ) {
		$block_type->attributes['style'] = array(
			'type' => 'object',
		);
	}
}

常見問題

FAQs
檢視更多 >