<?php
/**
 * The header for our theme
 *
 * @subpackage Green Farm
 * @since 1.0
 */

?><!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

<?php
	if ( function_exists( 'wp_body_open' ) ) {
	    wp_body_open();
	} else {
	    do_action( 'wp_body_open' );
	}
?>
	<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'green-farm' ); ?></a>
	<?php if( get_option('organic_farm_theme_loader',true) != 'off'){ ?>
		<?php $organic_farm_loader_option = get_theme_mod( 'organic_farm_loader_style','style_one');
		if($organic_farm_loader_option == 'style_one'){ ?>
			<div id="preloader" class="circle">
				<div id="loader"></div>
			</div>
		<?php }
		else if($organic_farm_loader_option == 'style_two'){ ?>
			<div id="preloader">
				<div class="spinner">
					<div class="rect1"></div>
					<div class="rect2"></div>
					<div class="rect3"></div>
					<div class="rect4"></div>
					<div class="rect5"></div>
				</div>
			</div>
		<?php }?>
	<?php }?>
	<div id="page" class="site">
		<div class="header-top py-2 text-center text-lg-start wow slideInDown">
			<div class="container">
				<div class="row">
					<div class="col-lg-4 col-sm-12 box-center">
						<?php if( get_theme_mod('green_farm_header_top_text') != '' ){ ?>
							<p class="mb-md-0"><?php echo esc_html(get_theme_mod('green_farm_header_top_text','')); ?></p>
						<?php }?>
					</div>
					<div class="col-lg-3 col-sm-4 box-center">
						<?php if( get_theme_mod('organic_farm_email') != '' ){ ?>
							<p class="mb-md-0"><i class="<?php echo esc_attr(get_theme_mod('organic_farm_email_icon','fas fa-envelope')); ?> me-2"></i><a href="mailto:<?php echo esc_attr(get_theme_mod('organic_farm_email', '')); ?>"><?php echo esc_html(get_theme_mod('organic_farm_email', '')); ?></a></p>
						<?php }?>
					</div>
					<div class="col-lg-3 col-sm-4 box-center">
						<?php if( get_theme_mod('organic_farm_call') != ''){ ?>
							<p class="mb-md-0"><i class="<?php echo esc_attr(get_theme_mod('organic_farm_call_icon','fas fa-phone')); ?> me-2"></i><a href="tel:<?php echo esc_attr(get_theme_mod('organic_farm_call', '')); ?>"><?php echo esc_html(get_theme_mod('organic_farm_call', '')); ?></a></p>
						<?php }?>
					</div>
					<div class="col-lg-2 col-sm-4 box-center">
						<?php if( get_option('header_social_icon_enable',false) != 'off'){ ?>
							<?php						  		
						 		$organic_farm_header_twt_target = esc_attr(get_option('organic_farm_header_twt_target','true'));
					            $organic_farm_header_fb_target = esc_attr(get_option('organic_farm_header_fb_target','true'));
					            $organic_farm_header_youtube_target = esc_attr(get_option('organic_farm_header_youtube_target','true'));
					            $organic_farm_header_instagram_target = esc_attr(get_option('organic_farm_header_instagram_target','true'));
					 		?>								
							<div class="links my-2 text-center text-lg-end text-md-end">
								<?php if( get_theme_mod('organic_farm_twitter') != ''){ ?>
					            <a target="<?php echo $organic_farm_header_twt_target !='off' ? '_blank' : '' ?>" href="<?php echo esc_url(get_theme_mod('organic_farm_twitter','')); ?>">
					              <i class="<?php echo esc_attr(get_theme_mod('organic_farm_twitter_icon','fab fa-x-twitter')); ?>"></i>
					            </a>
					          <?php }?>
					          <?php if( get_theme_mod('organic_farm_fb') != ''){ ?>
					            <a target="<?php echo $organic_farm_header_fb_target !='off' ? '_blank' : '' ?>" href="<?php echo esc_url(get_theme_mod('organic_farm_fb','')); ?>">
					              <i class="<?php echo esc_attr(get_theme_mod('organic_farm_fb_icon','fab fa-facebook-f')); ?>"></i>
					            </a>
					          <?php }?>
					          <?php if( get_theme_mod('organic_farm_youtube') != ''){ ?>
					            <a target="<?php echo $organic_farm_header_youtube_target !='off' ? '_blank' : '' ?>" href="<?php echo esc_url(get_theme_mod('organic_farm_youtube','')); ?>">
					              <i class="<?php echo esc_attr(get_theme_mod('organic_farm_youtube_icon','fab fa-youtube')); ?>"></i>
					            </a>
					          <?php }?>
					          <?php if( get_theme_mod('organic_farm_instagram') != ''){ ?>
					            <a target="<?php echo $organic_farm_header_instagram_target !='off' ? '_blank' : '' ?>" href="<?php echo esc_url(get_theme_mod('organic_farm_instagram','')); ?>">
					              <i class="<?php echo esc_attr(get_theme_mod('organic_farm_instagram_icon','fab fa-instagram')); ?>"></i>
					            </a>
					          <?php }?>
							</div>
						<?php }?>
					</div>
				</div>
			</div>
		</div>
		<div id="header" class="py-3">
			<div class="container">
				<div class="row">
					<div class="col-lg-5 col-md-4 col-sm-4 box-center">
						<div class="logo mb-lg-0 mb-md-3 mb-3 text-center text-md-start">
					        <?php if ( has_custom_logo() ) : ?>
			            		<?php the_custom_logo(); ?>
				            <?php endif; ?>
			              	<?php $blog_info = get_bloginfo( 'name' ); ?>
			              		<?php if( get_option('organic_farm_logo_title',false) != 'off'){ ?>
					                <?php if ( ! empty( $blog_info ) ) : ?>
					                  	<?php if ( is_front_page() && is_home() ) : ?>
					                    	<h1 class="site-title"><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 endif; ?>
					            <?php }?>
				                <?php
			                  		$description = get_bloginfo( 'description', 'display' );
				                  	if ( $description || is_customize_preview() ) :
				                ?>
				                <?php if( get_option('organic_farm_logo_text',true) != 'off'){ ?>
				                  	<p class="site-description">
				                    	<?php echo esc_html($description); ?>
				                  	</p>
				                <?php }?>
			              	<?php endif; ?>
					    </div>
					</div>
					<div class="col-lg-6 col-md-6 col-sm-6 col-9 box-center">
						<div class="product-search">
							<?php
							if ( class_exists( 'WooCommerce' ) ) { ?>
								<?php get_product_search_form(); ?>
							<?php }?>
						</div>
					</div>
					<div class="col-lg-1 col-md-2 col-sm-2 col-3 box-center text-end">
						<?php
							if ( class_exists( 'WooCommerce' ) ) { ?>
							<?php global $woocommerce; ?>
							<a href="<?php echo esc_url(wc_get_cart_url()); ?>" class="header-cart"><i class="fas fa-shopping-cart"></i> <span><?php echo esc_html($woocommerce->cart->cart_contents_count); ?></span></a>
						<?php }?>
					</div>
				</div>
			</div>
		</div>
		<div class="menu_header py-2 wow slideInUp">
			<div class="container">
				<div class="row">
					<div class="col-lg-9 col-md-7 col-sm-7 col-3 box-center">
							<div class="toggle-menu gb_menu ">
								<button onclick="organic_farm_gb_Menu_open()" class="gb_toggle p-2 mb-2 mb-md-0"><i class="<?php echo esc_attr(get_theme_mod('organic_farm_menu_icon','fas fa-bars')); ?>"></i></button>
							</div>                                      
		   				<?php get_template_part('template-parts/navigation/navigation'); ?>
					</div>
					<div class="col-lg-3 col-md-5 col-sm-5 col-9 box-center">
						<?php if ( class_exists( 'WooCommerce' ) ) { ?>
									<div class="head_category">        
										<a class="cat-dropdown-toggle" href="#" role="button" id="dropdownMenuLink-cat" data-toggle="dropdown-cat" aria-haspopup="true" aria-expanded="false"><?php echo esc_html( __('ALl Categories', 'green-farm') ); ?></a>
										<div class="cat-dropdown-menu" aria-labelledby="dropdownMenuLink-cat">
									        <ul class="cat-list">
									            <?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="cat-inn">
									                            <a href="<?php echo esc_url($cat_link); ?>"><?php echo esc_html($product_category->name); ?></a>
									                        </li>
									            <?php
									                    }
									                }
									            }
									            ?>
									        </ul>
										</div>
									</div>
								<?php }?>
					</div>
				</div>
			</div>
		</div>
	</div>
