Automattic\WooCommerce\Blocks\BlockTypes

Breadcrumbs::get_theme_font_size_classes_and_stylesprivateWC 1.0

Gets font size classes and styles from theme.json block styles.

Method of the class: Breadcrumbs{}

No Hooks.

Returns

array. The font size classes and styles.

Usage

// private - for code of main (parent) class only
$result = $this->get_theme_font_size_classes_and_styles();

Breadcrumbs::get_theme_font_size_classes_and_styles() code WC 11.0.1

private function get_theme_font_size_classes_and_styles() {
	$theme_font_size = wp_get_global_styles(
		array( 'blocks', 'woocommerce/breadcrumbs', 'typography', 'fontSize' )
	);

	if ( ! is_string( $theme_font_size ) || '' === $theme_font_size ) {
		return array(
			'class' => null,
			'style' => null,
		);
	}

	$preset_prefix = 'var(--wp--preset--font-size--';

	if ( str_starts_with( $theme_font_size, $preset_prefix ) ) {
		$slug = rtrim( substr( $theme_font_size, strlen( $preset_prefix ) ), ')' );

		return array(
			'class' => sprintf( 'has-font-size has-%s-font-size', $slug ),
			'style' => null,
		);
	}

	return array(
		'class' => null,
		'style' => sprintf( 'font-size: %s;', $theme_font_size ),
	);
}