<?php
/**
 * The Header for our theme.
 * @package Affiliate Marketing Business
 */
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
  <meta charset="<?php bloginfo( 'charset' ); ?>">
  <meta name="viewport" content="width=device-width">
  <?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
  <?php if ( function_exists( 'wp_body_open' ) ) {
    wp_body_open();
  } else {
    do_action( 'wp_body_open' );
  } ?>
  <?php if(get_theme_mod('affiliate_marketing_business_preloader',false) != '' || get_theme_mod( 'affiliate_marketing_business_display_preloader',false) != ''){ ?>
    <div class="frame w-100 h-100">
      <div class="loader">
        <div class="dot-1"></div>
        <div class="dot-2"></div>
        <div class="dot-3"></div>
      </div>
    </div>
  <?php }?>
<header role="banner" class="header-box">
  <a class="screen-reader-text skip-link" href="#skip_content"><?php esc_html_e( 'Skip to content', 'affiliate-marketing-business' ); ?></a>
  <div class="top-header">
    <?php if( get_theme_mod( 'affiliate_marketing_business_show_header', true) != '') { ?>
      <div class="header py-2">
        <div class="container">
          <div class="row">
            <div class="col-xl-2 col-lg-2 col-md-2 col-sm-12 col-12 py-0 py-lg-0 py-md-2 text-lg-start text-md-start text-center p-2 p-lg-0 p-md-0 align-self-center logo-sec">
              <div class="logo py-2">
                <div class="row">
                  <div class="<?php if( get_theme_mod( 'affiliate_marketing_business_site_logo_inline') != '') { ?>col-lg-5 col-md-5 col-5<?php } else { ?>col-lg-12 col-md-12 <?php } ?>">
                    <?php if ( has_custom_logo() ) : ?>
                      <div class="site-logo"><?php the_custom_logo(); ?></div>
                    <?php endif; ?>
                  </div>
                  <div class="<?php if( get_theme_mod( 'affiliate_marketing_business_site_logo_inline') != '') { ?>col-lg-7 col-md-7 col-7 site-logo-inline"<?php } else { ?>col-lg-12 col-md-12 <?php } ?>">
                    <?php $affiliate_marketing_business_blog_info = get_bloginfo( 'name' ); ?>
                    <?php if ( ! empty( $affiliate_marketing_business_blog_info ) ) : ?>
                      <?php if( get_theme_mod('affiliate_marketing_business_site_title_enable',true) != ''){ ?>
                        <?php if ( is_front_page() && is_home() ) : ?>
                          <h1 class="site-title pb-0"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
                        <?php else : ?>
                          <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
                        <?php endif; ?>
                      <?php }?>
                    <?php endif; ?>
                    <?php
                    $affiliate_marketing_business_description = get_bloginfo( 'description', 'display' );
                    if ( $affiliate_marketing_business_description || is_customize_preview() ) : ?>
                      <?php if( get_theme_mod('affiliate_marketing_business_site_tagline_enable',false) != ''){ ?>
                        <p class="site-description"><?php echo esc_html($affiliate_marketing_business_description); ?></p>
                      <?php }?>
                    <?php endif; ?>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-xl-7 col-lg-7 col-md-5 col-sm-12 col-12 align-self-center product-header-search">
              <div class="search-cat">
                <div class="row">
                  <div class="col-xl-3 col-lg-4 col-md-6 col-5 pe-0">
                    <div class="product-headcat">
                      <?php if(class_exists('woocommerce')){ ?>
                        <button role="tab" class="product-button py-2 px-3"><?php echo esc_html_e('All Categories','affiliate-marketing-business'); ?><i class="fa fa-caret-down my-2 ps-2" aria-hidden="true"></i></button>
                        <div class="product-category">
                          <?php
                            $args = array(
                             //'number'     => $number,
                             'orderby'    => 'title',
                             'order'      => 'ASC',
                             'hide_empty' => 0,
                             'parent'  => 0
                             //'include'    => $ids
                            );
                           $affiliate_marketing_business_product_categories = get_terms( 'product_cat', $args );
                           $affiliate_marketing_business_count = count($affiliate_marketing_business_product_categories);
                            if ( $affiliate_marketing_business_count > 0 ){
                              foreach ( $affiliate_marketing_business_product_categories as $affiliate_marketing_business_product_category) {
                              $affiliate_marketing_business_cats_id   = $affiliate_marketing_business_product_category->term_id;
                              $affiliate_marketing_business_cat_link = get_category_link( $affiliate_marketing_business_cats_id );
                              if ($affiliate_marketing_business_product_category->category_parent == 0) { ?>
                              <li class="drp_dwn_menu py-2 mx-3"><a href="<?php echo esc_url(get_term_link( $affiliate_marketing_business_product_category ) ); ?>">
                              <?php
                              }
                              echo esc_html( $affiliate_marketing_business_product_category->name ); ?></a><i class="fas fa-chevron-right"></i></li>
                              <?php
                              }
                            }
                          ?>
                        </div>
                      <?php }?>
                    </div>
                  </div>
                  <div class="col-xl-9 col-lg-8 col-md-6 col-7 ps-0">
                    <?php if(class_exists('woocommerce')){ ?>
                      <div class="header-search">
                        <?php get_product_search_form(); ?>
                      </div>
                    <?php }?>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-xl-2 col-lg-2 col-md-3 col-sm-9 col-8 px-md-0 align-self-center phone">
              <?php if (get_theme_mod('affiliate_marketing_business_phone_text') != '' || get_theme_mod('affiliate_marketing_business_phone_number') != '') { ?>
                <div class="row mx-md-0">
                  <div class="col-lg-3 col-md-2 col-2 pe-md-0 align-self-center text-center"><i class="<?php echo esc_attr(get_theme_mod('affiliate_marketing_business_phone_icon','fa-solid fa-headset')); ?>"></i></div>
                  <div class="col-lg-9 col-md-10 col-10 align-self-center">
                    <p><?php echo esc_html(get_theme_mod('affiliate_marketing_business_phone_text')); ?></p>
                    <a href="tel:<?php echo esc_attr(get_theme_mod('affiliate_marketing_business_phone_number')); ?>"><?php echo esc_html(get_theme_mod('affiliate_marketing_business_phone_number')); ?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('affiliate_marketing_business_phone_number')); ?></span></a>
                  </div>
                </div>
              <?php }?>
            </div>
            <div class="col-xl-1 col-lg-1 col-md-2 col-sm-3 col-4 align-self-center text-center d-flex justify-content-between icon-sec">
              <div class="wishlist">
                <?php if(defined('YITH_WCWL')){ ?>
                  <a class="wishlist_view position-relative" href="<?php echo YITH_WCWL()->get_wishlist_url(); ?>"><i class="<?php echo esc_attr(get_theme_mod('affiliate_marketing_business_wishlist_icon','fa-regular fa-heart')); ?>"></i><span class="screen-reader-text"><?php esc_html_e( 'Wishlist','affiliate-marketing-business' );?></span></a>
                <?php }?>
              </div>
              <div class="my-account">
                <?php if(class_exists('woocommerce')){ ?>
                  <a href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>" class="myaccount-link"><i class="<?php echo esc_attr(get_theme_mod('affiliate_marketing_business_my_account_icon','fa-solid fa-user')); ?>"></i><span class="screen-reader-text"><?php esc_html_e( 'My Account','affiliate-marketing-business' );?></span></a>
                <?php }?>
              </div>
            </div>
          </div>
        </div>
      </div>
    <?php }?>

    <!-- menu header -->
    <div class="menu-header py-2">
      <div class="container">
        <div class="row">
          <div class="col-xl-2 col-lg-2 col-md-4 col-8 align-self-center ps-lg-0">
            <?php if(class_exists('woocommerce')){ ?>
              <div class=" position-relative">
                <button class="product-btn"><?php echo esc_html_e('Categories','affiliate-marketing-business'); ?><i class="fa-solid fa-angle-down"></i></button>
                <div class="product-cat">
                  <?php
                    $args = array(
                      'orderby'    => 'title',
                      'order'      => 'ASC',
                      'hide_empty' => 0,
                      'parent'  => 0
                    );
                    $affiliate_marketing_business_product_categories = get_terms( 'product_cat', $args );
                    $affiliate_marketing_business_count = count($affiliate_marketing_business_product_categories);
                    if ( $affiliate_marketing_business_count > 0 ){
                        foreach ( $affiliate_marketing_business_product_categories as $affiliate_marketing_business_product_category ) {
                          $affiliate_marketing_business_product_cat_id   = $affiliate_marketing_business_product_category->term_id;
                          $affiliate_marketing_business_cat_link = get_category_link( $affiliate_marketing_business_product_cat_id );
                          if ($affiliate_marketing_business_product_category->category_parent == 0) { ?>
                        <li class="drp_dwn_menu"><a href="<?php echo esc_url(get_term_link( $affiliate_marketing_business_product_category ) ); ?>">
                        <?php
                      }
                      echo esc_html( $affiliate_marketing_business_product_category->name ); ?></a><i class="fas fa-chevron-right"></i></li>
                  <?php } } ?>
                </div>
              </div>
            <?php }?>
          </div>
          <div class="col-xl-8 col-lg-8 col-md-2 col-4 text-lg-start text-md-end text-start align-self-center">
            <div class="toggle-menu responsive-menu text-md-center text-end">
              <button role="tab" onclick="affiliate_marketing_business_menu_open()" class="mobiletoggle"><i class="<?php echo esc_attr(get_theme_mod('affiliate_marketing_business_responsive_menu_open_icon','fas fa-bars')); ?>"></i><span class="screen-reader-text"><?php esc_html_e('Open Menu','affiliate-marketing-business'); ?></span>
              </button>
            </div>
            <div id="navbar-header" class="menu-brand primary-nav">
              <nav id="site-navigation" class="primary-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Primary Menu', 'affiliate-marketing-business' ); ?>">
                <?php
                  wp_nav_menu( array(
                    'theme_location' => 'primary',
                    'container_class' => 'main-menu-navigation clearfix' ,
                    'menu_class' => 'main-menu-navigation clearfix',
                    'items_wrap' => '<ul id="%1$s" class="%2$s mobile_nav m-0 ps-0">%3$s</ul>',
                    'fallback_cb' => 'wp_page_menu',
                  ) );
                ?>
              </nav>
              <a href="javascript:void(0)" class="closebtn responsive-menu" onclick="affiliate_marketing_business_menu_close()"><i class="<?php echo esc_attr(get_theme_mod('affiliate_marketing_business_responsive_menu_close_icon','fas fa-times')); ?>"></i><span class="screen-reader-text"><?php esc_html_e('Close Menu','affiliate-marketing-business'); ?></span></a>
            </div> 
          </div>  
          <div class="col-xl-1 col-lg-1 col-md-3 col-8 align-self-center py-lg-0 py-md-0 py-3 text-md-end">
            <?php if(class_exists('woocommerce')){ ?>
              <div class="currency-box">
                <?php echo do_shortcode( '[woocommerce_currency_switcher_drop_down_box]' );?>
              </div>
            <?php } ?>
          </div>
          <div class="col-xl-1 col-lg-1 col-md-3 col-4 align-self-center text-lg-end py-lg-0 py-md-0 py-3 text-md-end text-end">
            <?php if(class_exists('GTranslate')){ ?>
              <div class="translate-lang">
                <?php echo do_shortcode( '[gtranslate]' );?>
              </div>
            <?php }?>
          </div>
        </div>
      </div>
    </div>
  </div>
</header>
