PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.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 All 404 releases
← All changes | build/scripts/block-library/home-link.php +19 -19 23.0.1 → 24.1.0 View file →
@@ -4,10 +4,8 @@
4 4 *
5 5 * @package WordPress
6 6 */
7 7
8 -require_once __DIR__ . '/navigation-link/shared/build-css-font-sizes.php';
9 -
10 8 /**
11 9 * Build an array with CSS classes and inline styles defining the colors
12 10 * which will be applied to the home link markup in the front-end.
13 11 *
@@ -12,9 +10,9 @@
12 10 * which will be applied to the home link markup in the front-end.
13 11 *
14 12 * @since 6.0.0
15 13 *
16 - * @param array $context home link block context.
14 + * @param array $context home link block context.
17 15 * @return array Colors CSS classes and inline styles.
18 16 */
19 17 function gutenberg_block_core_home_link_build_css_colors( $context ) {
20 18 $colors = array(
@@ -65,28 +63,18 @@
65 63 * Builds an array with classes and style for the li wrapper
66 64 *
67 65 * @since 6.0.0
68 66 *
69 - * @param array $context Home link block context.
67 + * @param array $context Home link block context.
70 68 * @return string The li wrapper attributes.
71 69 */
72 70 function gutenberg_block_core_home_link_build_li_wrapper_attributes( $context ) {
73 - $colors = gutenberg_block_core_home_link_build_css_colors( $context );
74 - // The build system prefixes this function with "gutenberg_" to avoid
75 - // collisions with the core version. Until this function is backported to
76 - // core, we need to guard it's use and only call the prefixed name in
77 - // the plugin.
78 - if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
79 - $font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $context );
80 - } else {
81 - $font_sizes = block_core_shared_navigation_build_css_font_sizes( $context );
82 - }
71 + $colors = gutenberg_block_core_home_link_build_css_colors( $context );
83 72 $classes = array_merge(
84 - $colors['css_classes'],
85 - $font_sizes['css_classes']
73 + $colors['css_classes']
86 74 );
87 75
88 - $style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
76 + $style_attribute = $colors['inline_styles'];
89 77 $classes[] = 'wp-block-navigation-item';
90 78
91 79 if ( is_front_page() ) {
92 80 $classes[] = 'current-menu-item';
@@ -128,14 +116,26 @@
128 116 // Edge case where the Reading settings has a posts page set but not a static homepage.
129 117 $aria_current = ' aria-current="page"';
130 118 }
131 119
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 +
132 130 return sprintf(
133 - '<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>',
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>',
134 132 gutenberg_block_core_home_link_build_li_wrapper_attributes( $block->context ),
135 133 esc_url( home_url() ),
134 + $target,
136 135 $aria_current,
137 - wp_kses_post( $attributes['label'] )
136 + wp_kses_post( $attributes['label'] ),
137 + $description
138 138 );
139 139 }
140 140
141 141 /**