Skip to content

Commit

Permalink
fix: create a unique id based on components
Browse files Browse the repository at this point in the history
  • Loading branch information
girishpanchal30 committed Jul 2, 2024
1 parent 93e8121 commit b65a9bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
13 changes: 1 addition & 12 deletions header-footer-grid/Core/Components/SecondNav.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ 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 @@ -316,9 +306,8 @@ 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', '', array( 'nav_num' => $this->secondary_nav_num ) );
Main::get_instance()->load( 'components/component-nav-secondary' );
do_action( 'neve_after_render_nav', $this->get_id() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace HFG;

use HFG\Core\Components\SecondNav;
use HFG\Core\Builder\Header as HeaderBuilder;

$style = component_setting( SecondNav::STYLE_ID );

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

0 comments on commit b65a9bf

Please sign in to comment.