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
查看更多 >