get_typography_classes_for_block_core_search

函数
get_typography_classes_for_block_core_search ( $attributes )
参数
  • (array) $attributes The block attributes.
    Required:
返回值
  • (string) The typography color classnames to be applied to the block elements.
定义位置
相关方法
get_typography_styles_for_block_core_searchget_color_classes_for_block_core_searchget_border_color_classes_for_block_core_searchclassnames_for_block_core_searchstyles_for_block_core_search
引入
-
弃用
-

get_typography_classes_for_block_core_search: 这个函数返回Gutenberg编辑器中核心搜索块的排版类数组。这些排版类是用来设计搜索块的风格的。

根据是否有命名的字体大小/家族,返回排版的类名。

function get_typography_classes_for_block_core_search( $attributes ) {
	$typography_classes    = array();
	$has_named_font_family = ! empty( $attributes['fontFamily'] );
	$has_named_font_size   = ! empty( $attributes['fontSize'] );

	if ( $has_named_font_size ) {
		$typography_classes[] = sprintf( 'has-%s-font-size', esc_attr( $attributes['fontSize'] ) );
	}

	if ( $has_named_font_family ) {
		$typography_classes[] = sprintf( 'has-%s-font-family', esc_attr( $attributes['fontFamily'] ) );
	}

	return implode( ' ', $typography_classes );
}

常见问题

FAQs
查看更多 >