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 +18 -20 23.3.0 → trunk View file →
@@ -6,9 +6,8 @@
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 /**
13 12 * Renders the submenu icon SVG for the Navigation Submenu block.
14 13 *
@@ -76,12 +75,15 @@
76 75 */
77 76 function gutenberg_render_block_core_navigation_submenu( $attributes, $content, $block ) {
78 77 // Check if this navigation item should render based on post status.
79 78 if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
80 - if ( ! gutenberg_block_core_shared_navigation_item_should_render( $attributes, $block ) ) {
81 - return '';
82 - }
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 );
83 82 }
83 + if ( ! $should_render ) {
84 + return '';
85 + }
84 86
85 87 // Don't render the block's subtree if it has no label.
86 88 if ( empty( $attributes['label'] ) ) {
87 89 return '';
@@ -86,19 +88,8 @@
86 88 if ( empty( $attributes['label'] ) ) {
87 89 return '';
88 90 }
89 91
90 - // The build system prefixes this function with "gutenberg_" to avoid
91 - // collisions with the core version. Until this function is backported to
92 - // core, we need to guard its use and only call the prefixed name in
93 - // the plugin.
94 - if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
95 - $font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $block->context );
96 - } else {
97 - $font_sizes = block_core_shared_navigation_build_css_font_sizes( $block->context );
98 - }
99 - $style_attribute = $font_sizes['inline_styles'];
100 -
101 92 // Render inner blocks first to check if any menu items will actually display.
102 93 $inner_blocks_html = '';
103 94 foreach ( $block->inner_blocks as $inner_block ) {
104 95 $inner_blocks_html .= $inner_block->render();
@@ -123,12 +114,9 @@
123 114
124 115 $classes = array(
125 116 'wp-block-navigation-item',
126 117 );
127 - $classes = array_merge(
128 - $classes,
129 - $font_sizes['css_classes']
130 - );
118 +
131 119 if ( $has_submenu ) {
132 120 $classes[] = 'has-child';
133 121 }
134 122 if ( $open_on_click ) {
@@ -146,9 +134,8 @@
146 134
147 135 $wrapper_attributes = get_block_wrapper_attributes(
148 136 array(
149 137 'class' => implode( ' ', $classes ),
150 - 'style' => $style_attribute,
151 138 )
152 139 );
153 140
154 141 $label = '';
@@ -283,8 +270,19 @@
283 270
284 271 $style_attribute = '';
285 272 if ( array_key_exists( 'style', $colors_supports ) ) {
286 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 + }
287 285 }
288 286
289 287 if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) {
290 288 $tag_processor = new WP_HTML_Tag_Processor( $html );