<?php
/*
* Display Logo and Menu Social Icons Details
*/
?>

<div class="headerbox">
  <div class="row sidebar-position m-0">
    <div class="col-lg-12 col-md-4 col-sm-4 align-self-center">
      <?php $carpenter_workshop_logo_settings = get_theme_mod( 'carpenter_workshop_logo_settings','Different Line');
      if($carpenter_workshop_logo_settings == 'Different Line'){ ?>
        <div class="logo">
          <?php if( has_custom_logo() ) carpenter_workshop_the_custom_logo(); ?>
          <?php if( get_theme_mod('carpenter_workshop_site_title_text',true) == 1){ ?>
            <?php if (is_front_page() || is_home()) : ?>
              <h1 class="text-capitalize">
                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
              </h1>
            <?php else : ?>
              <p class="text-capitalize site-title">
                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
              </p>
            <?php endif; ?>
          <?php }?>
          <?php $carpenter_workshop_description = get_bloginfo( 'description', 'display' );
          if ( $carpenter_workshop_description || is_customize_preview() ) : ?>
            <?php if( get_theme_mod('carpenter_workshop_site_tagline_text',false)){ ?>
              <p class="site-description"><?php echo esc_html($carpenter_workshop_description); ?></p>
            <?php }?>
          <?php endif; ?>
        </div>
      <?php }else if($carpenter_workshop_logo_settings == 'Same Line'){ ?>
        <div class="logo logo-same-line">
          <div class="row">
            <div class="col-lg-5 col-md-5 align-self-center">
              <?php if( has_custom_logo() ) carpenter_workshop_the_custom_logo(); ?>
            </div>
            <div class="col-lg-7 col-md-7 align-self-center">
              <?php if( get_theme_mod('carpenter_workshop_site_title_text',true) == 1){ ?>
                <?php if (is_front_page() || is_home()) : ?>
                  <h1 class="text-capitalize">
                      <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                  </h1>
                <?php else : ?>
                    <p class="text-capitalize site-title">
                        <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                    </p>
                <?php endif; ?>
              <?php }?>
              <?php $carpenter_workshop_description = get_bloginfo( 'description', 'display' );
              if ( $carpenter_workshop_description || is_customize_preview() ) : ?>
                <?php if( get_theme_mod('carpenter_workshop_site_tagline_text',false)){ ?>
                  <p class="site-description"><?php echo esc_html($carpenter_workshop_description); ?></p>
                <?php }?>
              <?php endif; ?>
            </div>
          </div>
        </div>
      <?php }?>
    </div>
    <div class="col-lg-12 col-md-2 col-sm-2 align-self-center menubar px-0">
      <div class="menubox align-self-center">
          <div class="innermenubox">                  
            <div class="toggle-nav mobile-menu">
              <button onclick="carpenter_workshop_menu_open()" class="responsivetoggle"><i class="fas fa-bars"></i><span class="screen-reader-text"><?php esc_html_e('Open Button','carpenter-workshop'); ?></span></button>
            </div>
          <div id="mySidenav" class="nav sidenav">
              <nav id="site-navigation" class="main-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Top Menu', 'carpenter-workshop' ); ?>">
                  <?php
                    wp_nav_menu( array(
                      'theme_location' => 'primary-menu',
                      'container_class' => 'main-menu clearfix' ,
                      'menu_class' => 'clearfix',
                      'items_wrap' => '<ul id="%1$s" class="%2$s mobile_nav">%3$s</ul>',
                      'fallback_cb' => 'wp_page_menu',
                    ) );
                  ?>
                  <a href="javascript:void(0)" class="closebtn mobile-menu" onclick="carpenter_workshop_menu_close()"><i class="fas fa-times"></i><span class="screen-reader-text"><?php esc_html_e('Close Button','carpenter-workshop'); ?></span></a>
                </nav>
              </div>
            <div class="clearfix"></div>
        </div>
      </div>
    </div>
    <div class="col-lg-12 col-md-6 col-sm-6 align-self-center side-dropdown px-0">
       <?php if(class_exists('woocommerce')){ ?>
          <div class="category-btn"><?php echo esc_html(get_theme_mod('carpenter_workshop_category_text','Category','carpenter-workshop')); ?></div>
          <div class="category-dropdown">
            <ul>
             <?php 
                $args = array(
                  'taxonomy' => 'product_cat',
                  'hide_empty' => false,
                  'parent'   => 0
                );
                $product_cat = get_terms( $args );
                foreach ($product_cat as $carpenter_workshop_parent_product_cat)
                { ?>
                  <li>
                    <a href="<?php echo get_term_link($carpenter_workshop_parent_product_cat->term_id); ?>">
                      <i class="far fa-square px-2"></i>
                        <span><?php echo $carpenter_workshop_parent_product_cat->name; ?><?php echo (' (');?><?php echo $carpenter_workshop_parent_product_cat->count; ?><?php echo (')');?></span>
                    </a>
                    <ul class="subcategory-box">
                      <?php $child_args = array(
                        'taxonomy' => 'product_cat',
                        'hide_empty' => false,
                        'parent'   => $carpenter_workshop_parent_product_cat->term_id
                      );
                      $carpenter_workshop_child_product_cats = get_terms( $child_args );
                      foreach ($carpenter_workshop_child_product_cats as $carpenter_workshop_child_product_cat)
                        { ?>
                        <li>
                          <a href="<?php echo get_term_link($carpenter_workshop_child_product_cat->term_id); ?>">
                            <i class="far fa-check-square"></i>
                              <span><?php echo $carpenter_workshop_child_product_cat->name; ?></span>
                            </a>
                        </li>
                      <?php } ?>
                    </ul>
                  </li>
              
                <?php } ?>
              </ul>
          </div>
        <?php }?>
    </div>
    <div class="clear"></div>
  </div>
</div>