<?php
/**
 * The header for our theme
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package GrShop
 */

$topbar_welcome_message = get_theme_mod( 'topbar_welcome_message','Welcome to GRShop. Grocery & Food Store' );
$topbar_register_text = get_theme_mod( 'topbar_register_text','Register' );
$topbar_register_url = get_theme_mod( 'topbar_register_url','#' );
$topbar_login_text = get_theme_mod( 'topbar_login_text','Sign in' );
$topbar_login_url = get_theme_mod( 'topbar_login_url','#' );
$header_search_form = get_theme_mod( 'header_search_form','on' );
$header_my_accounts = get_theme_mod( 'header_my_accounts','on' );
$header_my_accounts_login = get_theme_mod( 'header_my_accounts_login','#' );
$header_my_accounts_register = get_theme_mod( 'header_my_accounts_register','#' );
$header_my_accounts_dashboard = get_theme_mod( 'header_my_accounts_dashboard','#' );
$header_contact_number = get_theme_mod( 'header_contact_number','+8801304-43-545' );



?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="profile" href="https://gmpg.org/xfn/11">
	
	<?php wp_head(); ?>
</head>

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

<!-- Start Page -->
<div id="page" class="site">

	<a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'grshop-grocery' ); ?></a>


		<!-- Header -->
		<header id="masthead" class="grshop-grocery-header grshop-grocery-header site-header">

			<!-- Topbar -->
			<div class="grshop-grocery-header__topbar">
				<div class="container">
					<div class="row">
						<div class="col-lg-6 col-md-6 col-12">
							<div class="grshop-grocery-header__welcome">
								<p><?php echo $topbar_welcome_message;?></p>
							</div>
						</div>
						
						<?php 
						// Default values for repeater_setting theme mod.
						$defaults = [
							[
								'link_text' => esc_html__( 'About Us', 'grshop-grocery' ),
								'link_url' => '#',
								'link_target' => '_self',
							],
							[
								'link_text' => esc_html__( 'Contact Us', 'grshop-grocery' ),
								'link_url' => '#',
								'link_target' => '_self',
							],
						];
						// Retrieve the repeater field settings
						$topbar_pages = get_theme_mod( 'topbar_pages', $defaults );
						?>

						<div class="col-lg-6 col-md-6 col-12">
							<!-- Top Right -->
							<ul class="grshop-grocery-header__list list-none">
								<?php foreach ($topbar_pages as $topbar_page) : ?>
								<li>
									<a href="<?php echo esc_url( $topbar_page['link_url'] ); ?>"  target="<?php echo esc_attr( $topbar_page['link_target'] ); ?>" >
										<?php echo esc_html( $topbar_page['link_text'] ); ?>
									</a>
								</li>
								<?php endforeach;?>
							</ul>
							<!-- End Top Right -->
						</div>
					</div>
				</div>
			</div>
			<!-- End Topbar -->
			
			<div class="grshop-grocery-header__middle">
				<?php if ( get_header_image() ) : ?>
				<div class="header-image">
					<img src="<?php header_image(); ?>" width="<?php echo absint( get_custom_header()->width ); ?>" height="<?php echo absint( get_custom_header()->height ); ?>">
				</div>
				<?php endif; ?>
				<div class="container">
					<div class="row">
						<div class="col-12">
							<div class="grshop-grocery-header__middle">
								
								<!-- Logo -->
								<div class="grshop-grocery-logo">
									<?php if( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
										the_custom_logo();
									}else { ?>
										<div class="normal-text">
											<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html(get_bloginfo('name'));?></a>
											<?php $grshop_grocery_title_description = get_bloginfo( 'description', 'display' ); ?>
											<p class="site-description"><?php echo esc_html($grshop_grocery_title_description); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
										</div>
									<?php } ?>
									
									<div class="grshop-grocery-header__menu">
										<!-- Main Nav -->
										<nav id="site-navigation" class="grshop-grocery-header__nav navbar navbar-expand-lg" style="display: none;">
											<div class="navbar-collapse">
												<?php
												wp_nav_menu( array(
													'theme_location' => 'menu-1',
													'menu_id'        => 'primary-menu',
													'menu_class'        => 'nav grshop-grocery-menu navbar-nav',
												) );
												?>
											</div>
										</nav>
										<!--/ End Main Nav -->
									</div>	

								</div>
								<?php if ( true == get_theme_mod( 'header_search_form', 'on' ) ) : ?>
								<div class="grshop-grocery-search-form">
									<?php if ( class_exists( 'WooCommerce' ) ):?>
										<div class="search-bar">
											<form role="search" method="get" class="woocommerce-product-search" action="<?php echo esc_url( home_url( '/' ) ); ?>">
												<input name="s" placeholder="Search Products Here.." type="search" value="<?php echo get_search_query(); ?>">
												<button type="submit"><i class="fas fa-search"></i></button>
												<input type="hidden" name="post_type" value="product">
											</form>
										</div>
									<?php endif;?>
								</div>
								<?php endif;?>

								<div class="grshop-grocery-header__info">
									<?php if ( true == get_theme_mod( 'header_my_accounts', 'on' ) ) : ?>
									<div class="grshop-grocery-header-account">
										<div class="grshop-grocery-header-account__icon">
											<i class="fas fa-user"></i>
										</div>
										<div class="grshop-grocery-header-account__content">
											<h4 class="grshop-grocery-header-account__label"><?php esc_html_e('My Accounts','grshop-grocery');?></h4> 
											<div class="grshop-grocery-header-account__info">
												<?php if  ( is_user_logged_in() ):?>
													<a href="<?php echo esc_url($header_my_accounts_dashboard);?>"><?php esc_html_e('Welcome! Go to Dashboard','grshop-grocery');?></a>
												<?php else :?>	
													<a href="<?php echo esc_url($header_my_accounts_login);?>"><?php esc_html_e('Login','grshop-grocery');?></a>
													<span><?php esc_html_e('Or','grshop-grocery');?></span>
													<a href="<?php echo esc_url($header_my_accounts_register);?>"><?php esc_html_e('Signup','grshop-grocery');?></a>
												<?php endif;?>
											</div>
										</div>
									</div>
									<?php endif;?>
									<div class="grshop-grocery-header-account__contact">
										<a class="grshop-grocery-btn" href="tel:<?php echo esc_attr($header_contact_number)?>"><i class="fas fa-phone-alt"></i><?php echo $header_contact_number;?></a>
									</div>
								</div>

							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="grshop-grocery-header__main">
				<div class="container">
					<div class="row">
						<div class="col-12">
							<div class="grshop-grocery-header__main-inside">
								<nav class="grshop-grocery-header__nav">
									<?php
										wp_nav_menu( array(
											'theme_location' => 'menu-1',
											'menu_id'        => 'primary-menu',
											'menu_class'        => 'main-menu',
										) );
									?>
								</nav>
								<?php if (class_exists('WooCommerce')) : ?>
								<!-- Header cart -->
								<a href="<?php echo esc_url( wc_get_cart_url() ); ?>" class="grshop-grocery-header-cart">
									<div class="grshop-grocery-header-cart__icon">
										<i class="fas fa-shopping-cart"></i>
										<?php if (class_exists('WooCommerce')) : ?>
											<span class="total-count"><?php echo WC()->cart->get_cart_contents_count(); ?></span>
										<?php else : ?>
											<span class="total-count"><?php esc_html_e('0','grshop-grocery');?></span>
										<?php endif; ?>
									</div>
									<div class="grshop-grocery-header-cart__content">
										<h4 class="grshop-grocery-header-cart__title"><?php _e('Cart', 'grshop-grocery'); ?></h4>
										<p class="grshop-grocery-header-cart__amount">
											<?php if (class_exists('WooCommerce')) : ?>
												<?php echo WC()->cart->get_cart_total(); ?>
											<?php else : ?>
												<?php _e('0.00', 'grshop-grocery'); ?>
											<?php endif; ?>
										</p>
									</div>
								</a>
								<!-- End Header cart -->
								<?php endif;?>

								<div class="grshop-grocery-header__right">
									<div class="grshop-grocery-header__button grshop-grocery-header__search">
										<div class="menu-click"><a href="#" class="grshop-grocery-header__button--icon"><i class="fa fa-bars"></i><?php esc_html_e('Menu','grshop-grocery');?></a></div>
									</div>
								</div>

							</div>
						</div>
					</div>
				</div>
				
			</div>
			
		
			<!-- Sidebar Menu -->
			<div class="grshop-grocery-mobile-menu">
				<div class="menu-inner">
					<h4 class="oe-menu-title"><?php esc_html_e('Navigation','grshop-grocery');?></h4>
					<?php
						wp_nav_menu( array(
							'theme_location' => 'menu-1',
							'menu_id'        => 'side-menu',
							'menu_class'        => 'side-nav',
						) );
					?>
					<div class="close-menu"><a href="#"><i class="fa fa-remove"></i><?php esc_html_e('Close Menu','grshop-grocery');?></a></div>
				</div>
			</div>
			<!-- End Sidebar Menu -->
			
		</header>
		<!-- End Header -->
		
	<div id="primary" class="grshop-grocery-section-main">