Skip to content

Commit

Permalink
Allow Site Title and Logo inside Navigation block. (#33316)
Browse files Browse the repository at this point in the history
* Allow Site Title and Logo inside Navigation block.

* Fix space-between issue.

* Include site title and logo in list of links

* Fix php linting errors

* Add navigation item class to list item wrappers.

Co-authored-by: jasmussen <[email protected]>
  • Loading branch information
tellthemachines and jasmussen authored Aug 31, 2021
1 parent b72adf8 commit 7a6c1f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const ALLOWED_BLOCKS = [
'core/page-list',
'core/spacer',
'core/home-link',
'core/site-title',
'core/site-logo',
];

const LAYOUT = {
Expand Down
10 changes: 7 additions & 3 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,19 @@ function render_block_core_navigation( $attributes, $content, $block ) {
$inner_blocks_html = '';
$is_list_open = false;
foreach ( $inner_blocks as $inner_block ) {
if ( ( 'core/navigation-link' === $inner_block->name || 'core/home-link' === $inner_block->name ) && ! $is_list_open ) {
if ( ( 'core/navigation-link' === $inner_block->name || 'core/home-link' === $inner_block->name || 'core/site-title' === $inner_block->name || 'core/site-logo' === $inner_block->name ) && ! $is_list_open ) {
$is_list_open = true;
$inner_blocks_html .= '<ul class="wp-block-navigation__container">';
}
if ( 'core/navigation-link' !== $inner_block->name && 'core/home-link' !== $inner_block->name && $is_list_open ) {
if ( 'core/navigation-link' !== $inner_block->name && 'core/home-link' !== $inner_block->name && 'core/site-title' !== $inner_block->name && 'core/site-logo' !== $inner_block->name && $is_list_open ) {
$is_list_open = false;
$inner_blocks_html .= '</ul>';
}
$inner_blocks_html .= $inner_block->render();
if ( 'core/site-title' === $inner_block->name || 'core/site-logo' === $inner_block->name ) {
$inner_blocks_html .= '<li class="wp-block-navigation-item">' . $inner_block->render() . '</li>';
} else {
$inner_blocks_html .= $inner_block->render();
}
}

if ( $is_list_open ) {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/navigation/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@

.items-justified-space-between .wp-block-navigation__container {
justify-content: space-between;
flex: 1;
}

// Vertical justification.
Expand Down

0 comments on commit 7a6c1f2

Please sign in to comment.