PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/scripts/block-library/home-link.php +38 -19 23.6.2 → 22.7.0 View file →
@@ -59,8 +59,38 @@
59 59 return $colors;
60 60 }
61 61
62 62 /**
63 + * Build an array with CSS classes and inline styles defining the font sizes
64 + * which will be applied to the home link markup in the front-end.
65 + *
66 + * @since 6.0.0
67 + *
68 + * @param array $context Home link block context.
69 + * @return array Font size CSS classes and inline styles.
70 + */
71 +function gutenberg_block_core_home_link_build_css_font_sizes( $context ) {
72 + // CSS classes.
73 + $font_sizes = array(
74 + 'css_classes' => array(),
75 + 'inline_styles' => '',
76 + );
77 +
78 + $has_named_font_size = array_key_exists( 'fontSize', $context );
79 + $has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
80 +
81 + if ( $has_named_font_size ) {
82 + // Add the font size class.
83 + $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
84 + } elseif ( $has_custom_font_size ) {
85 + // Add the custom font size inline style.
86 + $font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] );
87 + }
88 +
89 + return $font_sizes;
90 +}
91 +
92 +/**
63 93 * Builds an array with classes and style for the li wrapper
64 94 *
65 95 * @since 6.0.0
66 96 *
@@ -67,14 +97,15 @@
67 97 * @param array $context Home link block context.
68 98 * @return string The li wrapper attributes.
69 99 */
70 100 function gutenberg_block_core_home_link_build_li_wrapper_attributes( $context ) {
71 - $colors = gutenberg_block_core_home_link_build_css_colors( $context );
72 - $classes = array_merge(
73 - $colors['css_classes']
101 + $colors = gutenberg_block_core_home_link_build_css_colors( $context );
102 + $font_sizes = gutenberg_block_core_home_link_build_css_font_sizes( $context );
103 + $classes = array_merge(
104 + $colors['css_classes'],
105 + $font_sizes['css_classes']
74 106 );
75 -
76 - $style_attribute = $colors['inline_styles'];
107 + $style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
77 108 $classes[] = 'wp-block-navigation-item';
78 109
79 110 if ( is_front_page() ) {
80 111 $classes[] = 'current-menu-item';
@@ -116,26 +147,14 @@
116 147 // Edge case where the Reading settings has a posts page set but not a static homepage.
117 148 $aria_current = ' aria-current="page"';
118 149 }
119 150
120 - $target = '';
121 - if ( isset( $attributes['opensInNewTab'] ) && true === $attributes['opensInNewTab'] ) {
122 - $target = ' target="_blank"';
123 - }
124 -
125 - $description = '';
126 - if ( ! empty( $attributes['description'] ) ) {
127 - $description = '<span class="wp-block-navigation-item__description">' . wp_kses_post( $attributes['description'] ) . '</span>';
128 - }
129 -
130 151 return sprintf(
131 - '<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" rel="home" %3$s%4$s>%5$s%6$s</a></li>',
152 + '<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" rel="home"%3$s>%4$s</a></li>',
132 153 gutenberg_block_core_home_link_build_li_wrapper_attributes( $block->context ),
133 154 esc_url( home_url() ),
134 - $target,
135 155 $aria_current,
136 - wp_kses_post( $attributes['label'] ),
137 - $description
156 + wp_kses_post( $attributes['label'] )
138 157 );
139 158 }
140 159
141 160 /**