Skip to content

Commit

Permalink
Change markup on front end
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Apr 7, 2021
1 parent 22f2be9 commit de31820
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
45 changes: 19 additions & 26 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,24 @@ function Navigation( {
clientId
);

const innerBlocksProps = useInnerBlocksProps(
{
className: 'wp-block-navigation__container',
},
{
allowedBlocks: ALLOWED_BLOCKS,
orientation: attributes.orientation || 'horizontal',
renderAppender:
( isImmediateParentOfSelectedBlock &&
! selectedBlockHasDescendants ) ||
isSelected
? InnerBlocks.DefaultAppender
: false,
__experimentalAppenderTagName: 'li',
__experimentalCaptureToolbars: true,
// Template lock set to false here so that the Nav
// Block on the experimental menus screen does not
// inherit templateLock={ 'all' }.
templateLock: false,
__experimentalLayout: LAYOUT,
placeholder: <PlaceholderPreview />,
}
);
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: ALLOWED_BLOCKS,
orientation: attributes.orientation || 'horizontal',
renderAppender:
( isImmediateParentOfSelectedBlock &&
! selectedBlockHasDescendants ) ||
isSelected
? InnerBlocks.DefaultAppender
: false,
__experimentalAppenderTagName: 'li',
__experimentalCaptureToolbars: true,
// Template lock set to false here so that the Nav
// Block on the experimental menus screen does not
// inherit templateLock={ 'all' }.
templateLock: false,
__experimentalLayout: LAYOUT,
placeholder: <PlaceholderPreview />,
} );

if ( isPlaceholderShown ) {
return (
Expand Down Expand Up @@ -145,9 +140,7 @@ function Navigation( {
</PanelBody>
) }
</InspectorControls>
<nav { ...blockProps }>
<ul { ...innerBlocksProps } />
</nav>
<nav { ...innerBlocksProps } />
</>
);
}
Expand Down
11 changes: 10 additions & 1 deletion packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,16 @@ function render_block_core_navigation( $attributes, $content, $block ) {
);

$inner_blocks_html = '';
$is_list_open = false;
foreach ( $block->inner_blocks as $inner_block ) {
if ($inner_block->name === "core/navigation-link" && $is_list_open === false) {
$is_list_open = true;
$inner_blocks_html .= '<ul class="wp-block-navigation__container">';
}
if ($inner_block->name !== "core/navigation-link" && $inner_block->name !== "core/spacer" && $is_list_open === true) {
$is_list_open = false;
$inner_blocks_html .= '</ul>';
}
$inner_blocks_html .= $inner_block->render();
}

Expand All @@ -149,7 +158,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
);

return sprintf(
'<nav %1$s><ul class="wp-block-navigation__container">%2$s</ul></nav>',
'<nav %1$s>%2$s</nav>',
$wrapper_attributes,
$inner_blocks_html
);
Expand Down

0 comments on commit de31820

Please sign in to comment.