Automattic\WooCommerce\Blocks\BlockTypes
Breadcrumbs::get_font_size_classes_and_styles
Gets font size classes and styles for the breadcrumbs block.
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_font_size_classes_and_styles( $attributes, $block );
- $attributes(array) (required)
- The block attributes.
- $block(WP_Block) (required)
- The block instance.
Breadcrumbs::get_font_size_classes_and_styles() Breadcrumbs::get font size classes and styles code WC 11.0.1
private function get_font_size_classes_and_styles( array $attributes, $block ) {
$custom_font_size = $attributes['style']['typography']['fontSize'] ?? '';
if ( '' !== $custom_font_size ) {
return array(
'class' => null,
'style' => sprintf( 'font-size: %s;', $custom_font_size ),
);
}
$explicit_font_size = isset( $block->parsed_block['attrs']['fontSize'] ) ? $block->parsed_block['attrs']['fontSize'] : null;
if ( is_string( $explicit_font_size ) && '' !== $explicit_font_size ) {
return array(
'class' => sprintf( 'has-font-size has-%s-font-size', $explicit_font_size ),
'style' => null,
);
}
$theme_font_size_classes_and_styles = $this->get_theme_font_size_classes_and_styles();
if ( $theme_font_size_classes_and_styles['class'] || $theme_font_size_classes_and_styles['style'] ) {
return $theme_font_size_classes_and_styles;
}
$font_size = $attributes['fontSize'] ?? '';
if ( $font_size ) {
return array(
'class' => sprintf( 'has-font-size has-%s-font-size', $font_size ),
'style' => null,
);
}
return array(
'class' => null,
'style' => null,
);
}