block_core_navigation_build_css_font_sizes

函数
block_core_navigation_build_css_font_sizes ( $attributes )
参数
  • (array) $attributes Navigation block attributes.
    Required:
返回值
  • (array) Font size CSS classes and inline styles.
定义位置
相关方法
block_core_navigation_link_build_css_font_sizesblock_core_navigation_submenu_build_css_font_sizesblock_core_navigation_build_css_colorsblock_core_page_list_build_css_font_sizesblock_core_home_link_build_css_font_sizes
引入
-
弃用
-

block_core_navigation_build_css_font_sizes: 这个函数用来生成导航块的CSS字体大小样式。它也是区块编辑器的核心导航块的一部分。

用CSS类和内联样式建立一个数组,定义将应用于前端的导航标记的字体大小。

function block_core_navigation_build_css_font_sizes( $attributes ) {
	// CSS classes.
	$font_sizes = array(
		'css_classes'   => array(),
		'inline_styles' => '',
	);

	$has_named_font_size  = array_key_exists( 'fontSize', $attributes );
	$has_custom_font_size = array_key_exists( 'customFontSize', $attributes );

	if ( $has_named_font_size ) {
		// Add the font size class.
		$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $attributes['fontSize'] );
	} elseif ( $has_custom_font_size ) {
		// Add the custom font size inline style.
		$font_sizes['inline_styles'] = sprintf( 'font-size: %spx;', $attributes['customFontSize'] );
	}

	return $font_sizes;
}

常见问题

FAQs
查看更多 >