block_core_navigation_link_build_css_font_sizes() │ WP 5.9.0

Устарела с версии 7.0.0. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.

Build an array with CSS classes and inline styles defining the font sizes which will be applied to the navigation markup in the front-end.

This function is no longer used internally and is kept only for backward compatibility with third-party code that may call it directly.

Хуков нет.

Возвращает

array. Font size CSS classes and inline styles.

Использование

block_core_navigation_link_build_css_font_sizes( $context );
$context(массив) (обязательный)
Navigation block context.

Список изменений

С версии 5.9.0 Введена.
Устарела с 7.0.0

Код block_core_navigation_link_build_css_font_sizes() WP 7.1.4

function block_core_navigation_link_build_css_font_sizes( $context ) {
	_deprecated_function( __FUNCTION__, '7.0.0' );

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

	$has_named_font_size  = array_key_exists( 'fontSize', $context );
	$has_custom_font_size = isset( $context['style']['typography']['fontSize'] );

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

	return $font_sizes;
}