diff --git a/packages/block-library/src/navigation-submenu/index.php b/packages/block-library/src/navigation-submenu/index.php index 97a355faadbc4d..c0fdbfa271cfa4 100644 --- a/packages/block-library/src/navigation-submenu/index.php +++ b/packages/block-library/src/navigation-submenu/index.php @@ -163,7 +163,32 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { 'style' => $style_attribute, ) ); - $html = '
  • '; + + $label = ''; + + if ( isset( $attributes['label'] ) ) { + $label .= wp_kses( + $attributes['label'], + array( + 'code' => array(), + 'em' => array(), + 'img' => array( + 'scale' => array(), + 'class' => array(), + 'style' => array(), + 'src' => array(), + 'alt' => array(), + ), + 's' => array(), + 'span' => array( + 'style' => array(), + ), + 'strong' => array(), + ) + ); + } + + $html = '
  • '; // If Submenus open on hover, we render an anchor tag with attributes. // If submenu icons are set to show, we also render a submenu button, so the submenu can be opened on click. @@ -193,27 +218,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { $html .= '>'; // End appending HTML attributes to anchor tag. - if ( isset( $attributes['label'] ) ) { - $html .= wp_kses( - $attributes['label'], - array( - 'code' => array(), - 'em' => array(), - 'img' => array( - 'scale' => array(), - 'class' => array(), - 'style' => array(), - 'src' => array(), - 'alt' => array(), - ), - 's' => array(), - 'span' => array( - 'style' => array(), - ), - 'strong' => array(), - ) - ); - } + $html .= $label; $html .= ''; // End anchor tag content. @@ -221,36 +226,16 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { if ( $show_submenu_indicators ) { // The submenu icon is rendered in a button here // so that there's a clickable elment to open the submenu. - $html .= ''; + $html .= ''; } } else { // If menus open on click, we render the parent as a button. - $html .= ''; } else { - $markup .= '' . wp_kses( - $page['title'], - wp_kses_allowed_html( 'post' ) - ) . ''; + $markup .= '' . $title . ''; } if ( isset( $page['children'] ) ) { if ( $is_navigation_child && $show_submenu_icons && ! $open_submenus_on_click ) { - $markup .= ''; }