<?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 OMag
 */

?>
<!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 $theme_options = omag_theme_options();

		if( 'boxed' == $theme_options['site_layout'] ){
			?>

			<div class="box-cover">
				<div class="boxed">

		<?php } ?>

		<header class="site-header">

			<?php
              	if( 1 === $theme_options['enable_top_header'] ){
          	?>

			<div class="news-head">
				<div class="container">

					<?php if( 1 === $theme_options['enable_date'] ){ ?>

						<div class="head-time-icon"><i class="far fa-clock"></i></div> <div class="header-date" id="datepicker"></div>

					<?php }

						if( 1 === $theme_options['enable_top_nav'] ){ ?>

						<?php
                    if ( has_nav_menu( 'top-nav' ) ) {

                      wp_nav_menu( array(
                        'theme_location'  => 'top-nav',
                        'depth'       => 1,
                        'container'     => 'div',
                        'container_class' => 'header-nav',
                    ) );

                    }
                }

						if( 1 === $theme_options['enable_social_top'] ){ ?>


					<div class="header-social float-right">

						<?php do_action( 'omag_social_media' ); ?>

					</div>

					<?php } ?>

					<div class="clearfix"></div>
				</div>
			</div>

			<?php } ?>

			<?php
				if ( get_header_image() ) {   
	        	$header_bg_image = get_header_image();
	        ?>
	        	<div class="adv-sec header-bg-image" style="background-position: center; background-size: cover; background-image: url(<?php echo esc_url( $header_bg_image ); ?>)">
	        <?php } else { ?>
	        	<div class="adv-sec">
	        <?php } ?>

				<div class="container">

					<?php if ( has_custom_logo() ) { ?>

						<div class="site-branding logo logo float-left">

							<?php the_custom_logo(); ?>

						</div>

						<?php } else { ?>

						<div class="site-branding logo logo float-left">

				        <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
				        <?php

				        $description = get_bloginfo( 'description', 'display' );
				        if ( $description || is_customize_preview() ) : ?>
				        <p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p>
				        <?php
				        endif; ?>

				      	</div><!-- .site-branding -->


						<?php } ?>

				      <?php 
		                if ( is_active_sidebar( 'advertisement-1' ) ) { ?>

		                    <div class="adv float-right">

		                        <?php dynamic_sidebar( 'advertisement-1' ); ?>

		                    </div><!-- .header-advertisement -->

		                    <?php 
		                } ?>

					<div class="clearfix"></div>
				</div>
			</div>

			<div class="nav-bar-holder">
				
			<nav class="mean-menu bg-dark" data-toggle="affix">

				<div class="container">

				<div class="home-icon-wrap">

					<?php
						if ( 1 === $theme_options['enable_home_icon'] ) {

							if ( is_front_page() ) {

                                $home_icon = 'home-icon active-true';

                            } else {

                                $home_icon = 'home-icon';

                            } 
					?>
					
					<a class="<?php echo esc_attr( $home_icon ); ?>" href="<?php echo esc_url( home_url( '/' ) ); ?>"> <i class="fas fa-home"></i> </a>

					<?php } ?>

				</div>
			    
                <?php
                    if ( has_nav_menu( 'primary' ) ) {

                      wp_nav_menu( array(
                        'theme_location'  => 'primary',
                        'depth'       => 2,
                        'container' 	=> 'ul',
                        'menu_class'    => 'nav navbar-nav mr-auto float-md-none',
                        'fallback_cb' => 'wp_page_menu',
                    ) );

                    } else {

                      wp_nav_menu( array(
                        'theme_location'  => 'primary',
                        'depth'          => 1,
                        'container' 	=> 'ul',
                        'menu_class'    => 'nav navbar-nav mr-auto float-md-none',
                        'fallback_cb' => 'wp_page_menu',
                      ) );

                    }
                ?>
            </div>
			</nav>
		</div>
		</header>
