From 7a6c1f2ee503619823931c999381ad9d66591754 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Tue, 31 Aug 2021 12:29:48 +1000 Subject: [PATCH] Allow Site Title and Logo inside Navigation block. (#33316) * 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 --- packages/block-library/src/navigation/edit.js | 2 ++ packages/block-library/src/navigation/index.php | 10 +++++++--- packages/block-library/src/navigation/style.scss | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/navigation/edit.js b/packages/block-library/src/navigation/edit.js index 0f55e958e5b97..79e06d370460a 100644 --- a/packages/block-library/src/navigation/edit.js +++ b/packages/block-library/src/navigation/edit.js @@ -46,6 +46,8 @@ const ALLOWED_BLOCKS = [ 'core/page-list', 'core/spacer', 'core/home-link', + 'core/site-title', + 'core/site-logo', ]; const LAYOUT = { diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index df93471feecbc..68246111ffe0e 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -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 .= ''; } - $inner_blocks_html .= $inner_block->render(); + if ( 'core/site-title' === $inner_block->name || 'core/site-logo' === $inner_block->name ) { + $inner_blocks_html .= '
  • ' . $inner_block->render() . '
  • '; + } else { + $inner_blocks_html .= $inner_block->render(); + } } if ( $is_list_open ) { diff --git a/packages/block-library/src/navigation/style.scss b/packages/block-library/src/navigation/style.scss index b96353903e7d6..bfccc9cb142bf 100644 --- a/packages/block-library/src/navigation/style.scss +++ b/packages/block-library/src/navigation/style.scss @@ -345,6 +345,7 @@ .items-justified-space-between .wp-block-navigation__container { justify-content: space-between; + flex: 1; } // Vertical justification.