Skip to content

Commit

Permalink
fix: duplicate id issue with secondary nav menu
Browse files Browse the repository at this point in the history
  • Loading branch information
girishpanchal30 committed Jul 1, 2024
1 parent d868412 commit 93e8121
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion header-footer-grid/Core/Components/SecondNav.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class SecondNav extends Abstract_Component {
const ITEM_HEIGHT = 'item_height';
const SPACING = 'spacing';

/**
* Secondary nav number
*
* @since 3.8.7
* @access private
*
* @var int $secondary_nav_num
*/
private $secondary_nav_num = 0;

/**
* Nav constructor.
*
Expand Down Expand Up @@ -306,8 +316,9 @@ public function add_settings() {
* @access public
*/
public function render_component() {
$this->secondary_nav_num++;
do_action( 'neve_before_render_nav', $this->get_id() );
Main::get_instance()->load( 'components/component-nav-secondary' );
Main::get_instance()->load( 'components/component-nav-secondary', '', array( 'nav_num' => $this->secondary_nav_num ) );
do_action( 'neve_after_render_nav', $this->get_id() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$container_classes[] = $style;
$container_classes[] = 'm-style';
}

$nav_num = ! empty( $args['nav_num'] ) ? (int) $args['nav_num'] : 0;
?>
<div class="nv-top-bar">
<div role="navigation" class="menu-content <?php echo esc_attr( join( ' ', $container_classes ) ); ?>"
Expand All @@ -28,7 +28,7 @@
array(
'theme_location' => 'top-bar',
'menu_class' => 'nav-ul',
'menu_id' => 'secondary-menu',
'menu_id' => $nav_num > 1 ? "secondary-menu_$nav_num" : 'secondary-menu',
'container' => 'ul',
'depth' => - 1,
'fallback_cb' => '__return_false',
Expand Down

0 comments on commit 93e8121

Please sign in to comment.