get_typography_styles_for_block_core_search

函数
get_typography_styles_for_block_core_search ( $attributes )
参数
  • (array) $attributes The block attributes.
    Required:
返回值
  • (string) A string of typography CSS declarations.
定义位置
相关方法
get_typography_classes_for_block_core_searchstyles_for_block_core_searchget_color_classes_for_block_core_searchget_border_color_classes_for_block_core_searchclassnames_for_block_core_search
引入
-
弃用
-

get_typography_styles_for_block_core_search: 这个函数返回Gutenberg编辑器中核心搜索块的排版样式数组。这些排版样式将用于搜索块的样式。

返回要包含在HTML样式标签中的排版样式。

这不包括文本装饰,它只适用于搜索块的标签和按钮元素。

function get_typography_styles_for_block_core_search( $attributes ) {
	$typography_styles = array();

	// Add typography styles.
	if ( ! empty( $attributes['style']['typography']['fontSize'] ) ) {
		$typography_styles[] = sprintf(
			'font-size: %s;',
			wp_get_typography_font_size_value(
				array(
					'size' => $attributes['style']['typography']['fontSize'],
				)
			)
		);

	}

	if ( ! empty( $attributes['style']['typography']['fontFamily'] ) ) {
		$typography_styles[] = sprintf( 'font-family: %s;', $attributes['style']['typography']['fontFamily'] );
	}

	if ( ! empty( $attributes['style']['typography']['letterSpacing'] ) ) {
		$typography_styles[] = sprintf( 'letter-spacing: %s;', $attributes['style']['typography']['letterSpacing'] );
	}

	if ( ! empty( $attributes['style']['typography']['fontWeight'] ) ) {
		$typography_styles[] = sprintf( 'font-weight: %s;', $attributes['style']['typography']['fontWeight'] );
	}

	if ( ! empty( $attributes['style']['typography']['fontStyle'] ) ) {
		$typography_styles[] = sprintf( 'font-style: %s;', $attributes['style']['typography']['fontStyle'] );
	}

	if ( ! empty( $attributes['style']['typography']['lineHeight'] ) ) {
		$typography_styles[] = sprintf( 'line-height: %s;', $attributes['style']['typography']['lineHeight'] );
	}

	if ( ! empty( $attributes['style']['typography']['textTransform'] ) ) {
		$typography_styles[] = sprintf( 'text-transform: %s;', $attributes['style']['typography']['textTransform'] );
	}

	return implode( '', $typography_styles );
}

常见问题

FAQs
查看更多 >