<?php
/**
 * The template part for Middle Header
 *
 * @package Wall Decor Wallpaper
 * @subpackage wall-decor-wallpaper
 * @since wall-decor-wallpaper 1.0
 */
?>

<!-- Middle Header -->
<div class="main-header py-3">
  <div class="container">
    <div class="row">
      <div class="col-lg-4 col-md-4 align-self-center text-md-start text-center">
        <div class="logo">
          <?php if ( has_custom_logo() ) : ?>
            <div class="site-logo"><?php the_custom_logo(); ?></div>
          <?php endif; ?>
          <?php $blog_info = get_bloginfo( 'name' ); ?>
            <?php if ( ! empty( $blog_info ) ) : ?>
              <?php if ( is_front_page() && is_home() ) : ?>
                <?php if( get_theme_mod('wall_decor_wallpaper_logo_title_hide_show',true) == 1){ ?>
                  <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
                <?php } ?>
              <?php else : ?>
                <?php if( get_theme_mod('wall_decor_wallpaper_logo_title_hide_show',true) == 1){ ?>
                  <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
                <?php } ?>
              <?php endif; ?>
            <?php endif; ?>
            <?php
              $description = get_bloginfo( 'description', 'display' );
              if ( $description || is_customize_preview() ) :
            ?>
            <?php if( get_theme_mod('wall_decor_wallpaper_tagline_hide_show',false) == 1){ ?>
              <p class="site-description mb-0">
                <?php echo esc_html($description); ?>
              </p>
            <?php } ?>
          <?php endif; ?>
        </div>
      </div>
      <div class="col-lg-5 col-md-5 py-md-0 py-3 align-self-lg-center align-self-md-center">
        <?php if(class_exists('woocommerce')){ ?>
          <?php get_product_search_form(); ?>
        <?php } ?>
      </div>
      <div class="col-lg-1 col-md-1 col-4 pt-md-0 pt-3 pb-md-0 pb-3 align-self-center text-md-end text-center">
        <?php if( get_theme_mod( 'wall_decor_wallpaper_wishlist_hide_show', true) == 1) { ?>
          <div class="wishlist">
            <?php if(defined('YITH_WCWL')){ ?>
              <a class="wishlist_view" href="<?php echo YITH_WCWL()->get_wishlist_url(); ?>" title="<?php esc_attr_e('Wishlist','wall-decor-wallpaper'); ?>"><i class="fas fa-heart" ></i>
              </a>
            <?php }?>
          </div>
        <?php }?>
      </div>
      <div class="col-lg-1 col-md-1 col-4 pt-md-0 pt-3 pb-md-0 pb-3 align-self-center text-md-end text-center">
        <?php if( get_theme_mod( 'wall_decor_wallpaper_my_account_hide_show', true) == 1) { ?>
            <div class="account">
              <?php if(class_exists('woocommerce')){ ?>
                <?php if ( is_user_logged_in() ) { ?>
                  <a href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_attr_e('My Account','wall-decor-wallpaper'); ?>"><i class="fas fa-user"></i></a>
                <?php }
                else { ?>
                  <a href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_attr_e('Login / Register','wall-decor-wallpaper'); ?>"><i class="fas fa-user"></i><span class="screen-reader-text"><?php esc_html_e( 'Login / Register','wall-decor-wallpaper' );?></span></a>
                <?php } ?>
              <?php }?>
            </div>
          <?php } ?>
          </div>
        <?php if( get_theme_mod( 'wall_decor_wallpaper_cart_hide_show',true) == 1) { ?>
          <div class="col-lg-1 col-md-1 col-4 pt-md-0 pt-3 pb-md-0 pb-3 align-self-center text-md-end text-center">
            <?php if(class_exists('woocommerce')){ ?>
              <span class="cart_no">
                <a href="<?php if(function_exists('wc_get_cart_url')){ echo esc_url(wc_get_cart_url()); } ?>" title="<?php esc_attr_e( 'shopping cart','wall-decor-wallpaper' ); ?>"><i class="fas fa-shopping-basket"></i><span class="screen-reader-text"><?php esc_html_e( 'Shopping Cart','wall-decor-wallpaper' );?></span></a>
              </span>
            <?php } ?>
          </div>
        <?php } ?>
    </div>
  </div>
</div>

<div class="menu-header py-md-0 py-md-3 py-4 <?php if( get_theme_mod( 'wall_decor_wallpaper_sticky_header', false) == 1 || get_theme_mod( 'wall_decor_wallpaper_stickyheader_hide_show', false) == 1) { ?> header-sticky"<?php } else { ?>close-sticky <?php } ?>">
  <div class="container">
    <div class="row">
      <div class="col-lg-4 col-md-8 col-8 align-self-center text-lg-start text-md-center text-center">
          <?php if(class_exists('woocommerce')){ ?>
            <div class=" position-relative">
              <button class="product-btn"><i class="fas fa-bars"></i><?php esc_html_e('All CATEGORIES','wall-decor-wallpaper'); ?></button>
                <div class="product-cat">
                  <?php
                    $args = array(
                      'orderby'    => 'title',
                      'order'      => 'ASC',
                      'hide_empty' => 0,
                      'parent'  => 0
                    );
                    $product_categories = get_terms( 'product_cat', $args );
                    $count = count($product_categories);
                    if ( $count > 0 ){
                        foreach ( $product_categories as $product_category ) {
                          $product_cat_id = $product_category->term_id;
                          $cat_link = get_category_link( $product_cat_id );
                          if ($product_category->category_parent == 0) { ?>
                        <li class="drp_dwn_menu"><a href="<?php echo esc_url(get_term_link( $product_category ) ); ?>">
                        <?php
                      }
                      echo esc_html( $product_category->name ); ?></a><i class="fas fa-chevron-right"></i></li>
                  <?php } } ?>
                </div>
            </div>
          <?php }?>
        </div>
        <div class="col-lg-8 col-md-4 col-4 align-self-md-center text-md-end text-center">
          <?php get_template_part('template-parts/header/navigation'); ?>
        </div>
    </div>
  </div>
</div>

