<?php
/**
 * The header for our theme
 *
 * @package News Current Affair
 */
?>
<!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(); ?>
<div id="page" class="site">
    <a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'news-current-affair' ); ?></a>

    <?php
    $news_current_affair_preloader_wrap = absint( get_theme_mod( 'news_current_affair_enable_preloader', 0 ) );
    if ( $news_current_affair_preloader_wrap === 1 ) : ?>
        <div id="loader">
            <div class="loader-container">
                <div id="preloader" class="loader-2">
                    <div class="dot"></div>
                </div>
            </div>
        </div>
    <?php endif; ?>
    

    <header id="masthead" class="site-header">
        <?php 
            $news_current_affair_has_header_image = has_header_image();

            if ( $news_current_affair_has_header_image ) {
                $news_current_affair_header_image_url = esc_url( get_header_image() );
            } else {
                $news_current_affair_header_image_url = '';
            }
        ?>
        <div class="headermain">
            <div class="header-info-box">
                <div class="header-menu-box <?php echo esc_attr( get_theme_mod( 'news_current_affair_enable_sticky_header', false ) ? 'sticky-header' : '' ); ?>" style="background-image: url('<?php echo $news_current_affair_header_image_url; ?>'); background-repeat: no-repeat; background-size: cover;">
                    <div class="container">
                        <div class="middle-box">
                            <div class="flex-row">
                                <div class="middle-left">
                                    <div class="site-branding">
                                        <?php
                                        if ( function_exists( 'the_custom_logo' ) ) {
                                            the_custom_logo();
                                        }
                                        if ( is_front_page() && is_home() ) :
                                            if ( get_theme_mod( 'news_current_affair_site_title_text', true ) ) : ?>
                                                <h1 class="site-title">
                                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                                                </h1>
                                            <?php endif;
                                        else :
                                            if ( get_theme_mod( 'news_current_affair_site_title_text', true ) ) : ?>
                                                <p class="site-title">
                                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                                                </p>
                                            <?php endif;
                                        endif;
                                        $news_current_affair_description = get_bloginfo( 'description', 'display' );
                                        if ( $news_current_affair_description || is_customize_preview() ) :
                                            if ( get_theme_mod( 'news_current_affair_site_tagline_text', false ) ) : ?>
                                                <p class="site-description"><?php echo esc_html( $news_current_affair_description ); ?></p>
                                            <?php endif;
                                        endif; ?>
                                    </div>
                                </div>
                                <div class="middle-center">
                                    <div class="menucontent">
                                        <div class="nav-menu-header">
                                            <nav id="site-navigation" class="main-navigation">
                                                <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                                    <span class="screen-reader-text"><?php esc_html_e( 'Primary Menu', 'news-current-affair' ); ?></span>
                                                    <i class="fas fa-bars"></i>
                                                </button>
                                                <?php
                                                wp_nav_menu( array(
                                                    'theme_location' => 'menu-1',
                                                    'menu_id'        => 'primary-menu',
                                                ) );
                                                ?>
                                            </nav>
                                        </div>
                                    </div>
                                </div>
                                <div class="middle-right">
                                    <?php if ( get_theme_mod( 'news_current_affair_header_search', true ) == 1 ) : ?>
                                        <span class="search-bar">
                                            <button type="button" class="open-search"><i class="fas fa-search"></i></button>
                                        </span>
                                    <?php endif; ?>
                                    <div class="share-icon">
                                        <i class="fas fa-share-alt share-box" tabindex="0" role="button" aria-haspopup="true" aria-expanded="false" aria-controls="share-options"></i>
                                        <div class="share-options" id="share-options">
                                            <a href="<?php echo esc_url( get_theme_mod('news_current_affair_product_social_link1', 'https://facebook.com') ); ?>" target="_blank"><i class="fab fa-facebook-f"></i></a>
                                            <a href="<?php echo esc_url( get_theme_mod('news_current_affair_product_social_link2','https://twitter.com') ); ?>" target="_blank"><i class="fab fa-twitter"></i></a>
                                            <a href="<?php echo esc_url( get_theme_mod('news_current_affair_product_social_link3','https://instagram.com') ); ?>" target="_blank"><i class="fab fa-instagram"></i></a>
                                            <a href="<?php echo esc_url( get_theme_mod('news_current_affair_product_social_link4', 'https://linkedin.com') ); ?>" target="_blank">
                                                <i class="fab fa-linkedin"></i>
                                            </a>
                                            <a href="<?php echo esc_url( get_theme_mod('news_current_affair_product_social_link5', 'https://pinterest.com') ); ?>" target="_blank">
                                                <i class="fab fa-pinterest"></i>
                                            </a>
                                        </div>
                                    </div>
                                    <div class="topbar-menu">
                                        <span class="top-toggle" id="account-toggle" role="button" tabindex="0" aria-haspopup="true" aria-expanded="false"
                                        >
                                            <i class="fa fa-chevron-down" aria-hidden="true"></i>
                                            <span class="screen-reader-text">
                                                <?php esc_html_e( 'Account menu toggle', 'news-current-affair' ); ?>
                                            </span>
                                        </span>
                                        <ul class="dropdown" id="account-dropdown" hidden>
                                            <?php if ( is_user_logged_in() ) : ?>
                                                <li><a href="<?php echo esc_url( home_url( '/profile' ) ); ?>">
                                                    <?php esc_html_e( 'My Profile', 'news-current-affair' ); ?>
                                                </a></li>
                                                <li><a href="<?php echo esc_url( wp_logout_url() ); ?>">
                                                    <?php esc_html_e( 'Logout', 'news-current-affair' ); ?>
                                                </a></li>
                                            <?php else : ?>
                                                <li><a href="<?php echo esc_url( wp_login_url() ); ?>">
                                                    <?php esc_html_e( 'Login', 'news-current-affair' ); ?>
                                                </a></li>
                                                <li><a href="<?php echo esc_url( wp_registration_url() ); ?>">
                                                    <?php esc_html_e( 'Register', 'news-current-affair' ); ?>
                                                </a></li>
                                            <?php endif; ?>
                                        </ul>
                                    </div>
                                    <div class="search-outer">
                                        <div class="inner_searchbox">
                                            <?php get_search_form(); ?>
                                        </div>
                                        <button type="button" class="search-close"><i class="fas fa-window-close"></i></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div> 
            </div>
        </div>
    </header>
</div>