<?php
$default_settings = [
    'menu' => '',
    'style_l1' => '',
    'item_item_menu' => '',
    'line_item' => '',
];
$settings = array_merge($default_settings, $settings);
extract($settings);
$html_id = ct_get_element_id($settings);
$h_custom_main_menu = grupi_get_page_opt('h_custom_main_menu');
if(!empty($h_custom_main_menu)) {
    $menu = $h_custom_main_menu;
}

if(!empty($menu)) { ?>
    <div id="<?php echo esc_attr($html_id); ?>" class="ct-nav-menu ct-nav-menu1 <?php if($style_l1 == 'style3') { echo 'line-'.$line_item; } ?> <?php echo esc_attr($style_l1.' '.$item_item_menu); ?>">
        <?php wp_nav_menu(array(
            'menu_id'    => 'ct-main-menu',
            'menu_class' => 'ct-main-menu clearfix',
            'walker'     => class_exists( 'EFramework_Mega_Menu_Walker' ) ? new EFramework_Mega_Menu_Walker : '',
            'link_before'     => '<span class="ct-menu-item"><span class="ct-item--number"><span></span></span>',
            'link_after'      => '</span><span class="ct-menu--plus"></span>',
            'menu'        => wp_get_nav_menu_object($menu))
        ); ?>
    </div>
<?php } elseif( has_nav_menu( 'primary' ) ) { ?>
    <div id="<?php echo esc_attr($html_id); ?>" class="ct-nav-menu ct-nav-menu1 <?php if($style_l1 == 'style3') { echo 'line-'.$line_item; } ?> <?php echo esc_attr($style_l1.' '.$item_item_menu); ?>">
        <?php $attr_menu = array(
            'theme_location' => 'primary',
            'menu_id'    => 'ct-main-menu',
            'menu_class' => 'ct-main-menu clearfix',
            'link_before'     => '<span class="ct-menu-item"><span class="ct-item--number"><span></span></span>',
            'link_after'      => '</span><span class="ct-menu--plus"></span>',
            'walker'         => class_exists( 'EFramework_Mega_Menu_Walker' ) ? new EFramework_Mega_Menu_Walker : '',
        );
        wp_nav_menu( $attr_menu ); ?>
    </div>
<?php } ?>