Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed duplicate id issue with secondary nav menu #4259

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading