PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
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/navigation-submenu.php +31 -20 23.0.1 → trunk View file →
@@ -6,11 +6,23 @@
6 6 */
7 7
8 8 require_once __DIR__ . '/navigation-link/shared/item-should-render.php';
9 9 require_once __DIR__ . '/navigation-link/shared/render-submenu-icon.php';
10 -require_once __DIR__ . '/navigation-link/shared/build-css-font-sizes.php';
11 10
12 11 /**
12 + * Renders the submenu icon SVG for the Navigation Submenu block.
13 + *
14 + * @since 5.9.0
15 + * @deprecated 7.0.0 Use block_core_shared_navigation_render_submenu_icon() instead.
16 + *
17 + * @return string SVG markup for the submenu icon.
18 + */
19 +function gutenberg_block_core_navigation_submenu_render_submenu_icon() {
20 + _deprecated_function( __FUNCTION__, '7.0.0', 'block_core_shared_navigation_render_submenu_icon()' );
21 + return block_core_shared_navigation_render_submenu_icon();
22 +}
23 +
24 +/**
13 25 * Returns the submenu visibility value with backward compatibility
14 26 * for the deprecated openSubmenusOnClick attribute.
15 27 *
16 28 * This function centralizes the migration logic from the boolean
@@ -63,12 +75,15 @@
63 75 */
64 76 function gutenberg_render_block_core_navigation_submenu( $attributes, $content, $block ) {
65 77 // Check if this navigation item should render based on post status.
66 78 if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
67 - if ( ! gutenberg_block_core_shared_navigation_item_should_render( $attributes, $block ) ) {
68 - return '';
69 - }
79 + $should_render = gutenberg_block_core_shared_navigation_item_should_render( $attributes, $block );
80 + } else {
81 + $should_render = block_core_shared_navigation_item_should_render( $attributes, $block );
70 82 }
83 + if ( ! $should_render ) {
84 + return '';
85 + }
71 86
72 87 // Don't render the block's subtree if it has no label.
73 88 if ( empty( $attributes['label'] ) ) {
74 89 return '';
@@ -73,19 +88,8 @@
73 88 if ( empty( $attributes['label'] ) ) {
74 89 return '';
75 90 }
76 91
77 - // The build system prefixes this function with "gutenberg_" to avoid
78 - // collisions with the core version. Until this function is backported to
79 - // core, we need to guard its use and only call the prefixed name in
80 - // the plugin.
81 - if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
82 - $font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $block->context );
83 - } else {
84 - $font_sizes = block_core_shared_navigation_build_css_font_sizes( $block->context );
85 - }
86 - $style_attribute = $font_sizes['inline_styles'];
87 -
88 92 // Render inner blocks first to check if any menu items will actually display.
89 93 $inner_blocks_html = '';
90 94 foreach ( $block->inner_blocks as $inner_block ) {
91 95 $inner_blocks_html .= $inner_block->render();
@@ -110,12 +114,9 @@
110 114
111 115 $classes = array(
112 116 'wp-block-navigation-item',
113 117 );
114 - $classes = array_merge(
115 - $classes,
116 - $font_sizes['css_classes']
117 - );
118 +
118 119 if ( $has_submenu ) {
119 120 $classes[] = 'has-child';
120 121 }
121 122 if ( $open_on_click ) {
@@ -133,9 +134,8 @@
133 134
134 135 $wrapper_attributes = get_block_wrapper_attributes(
135 136 array(
136 137 'class' => implode( ' ', $classes ),
137 - 'style' => $style_attribute,
138 138 )
139 139 );
140 140
141 141 $label = '';
@@ -270,8 +270,19 @@
270 270
271 271 $style_attribute = '';
272 272 if ( array_key_exists( 'style', $colors_supports ) ) {
273 273 $style_attribute = $colors_supports['style'];
274 + }
275 +
276 + /*
277 + * Shadow serialization is skipped for this block so the shadow lands on the
278 + * dropdown panel, the floating layer it is meant for, and not the menu item.
279 + */
280 + if ( ! empty( $attributes['style']['shadow'] ) ) {
281 + $shadow_styles = gutenberg_style_engine_get_styles( array( 'shadow' => $attributes['style']['shadow'] ) );
282 + if ( ! empty( $shadow_styles['css'] ) ) {
283 + $style_attribute .= $shadow_styles['css'];
284 + }
274 285 }
275 286
276 287 if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) {
277 288 $tag_processor = new WP_HTML_Tag_Processor( $html );