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

$sparta_header_default_logo = get_theme_mod('sparta_header_default_logo', '');
$sparta_header_flyout_logo = get_theme_mod('sparta_header_flyout_logo', '');
$sparta_header_trans_logo = get_theme_mod('sparta_header_trans_logo', '');
$general_info_address = get_theme_mod('general_info_address', '');
$general_info_phone = get_theme_mod('general_info_phone', '');

/*Render page loader*/
echo wp_kses_post(Sparta_Helper::sparta_page_loader());
?>
<header class="vk-header header-boxed">
    <?php if ($general_info_address !== '' || $general_info_phone !== '' || class_exists('HotelBookingPlugin')): ?>
        <div class="vk-top-header">
            <div class="container">
                <div class="row">
                    <div class="col-lg-8 col-md-8 col-sm-8 col-7 vk-top-header-left">
                            <?php
                            if ($general_info_address !== ''):
                                echo '<span class="txt-address">' . esc_html($general_info_address) . '</span>';
                            endif;
                            if ($general_info_phone !== ''):
                                echo '<span class="hsp">-</span>';
                                echo '<span>' . esc_html__('Reservation ', 'sparta') . '' . esc_html($general_info_phone) . '</span>';
                            endif;
                            ?>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4 col-5 vk-top-header-right">
                            <?php if (class_exists('HotelBookingPlugin')): ?>
                                <ul>
                                    <li>
                                        <a href="<?php echo esc_url(sparta_get_link_page_booking()); ?>" class="btn book-now">
                                            <?php echo esc_html__('BOOK NOW', 'sparta'); ?>
                                        </a>
                                    </li>
                                </ul>
                            <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?>
    <?php if (is_page('homepage') || is_front_page() || is_home()) : ?>
        <h1 class="homepage-title"><?php the_title(); ?></h1>
    <?php endif; ?>
    <div id="sticky-wrapper" class="sticky-wrapper">
        <div class="vk-main-menu animated uni-sticky">
            <div class="container">
                <div class="row">
                    <div class="col-lg-2 col-md-3 col-sm-4 col-4">
                        <div class="wrapper-logo">
                            <a href="<?php echo esc_url(home_url('/')); ?>"
                               title="<?php echo esc_attr(get_bloginfo('name', 'display')); ?>">
                                <?php
                                if ($sparta_header_default_logo) :
                                    echo '<img src="' . esc_url($sparta_header_default_logo) . '" alt="' . esc_attr(get_bloginfo('description')) . '">';
                                else : ?>
                                    <img src="<?php echo get_template_directory_uri() . '/assets/images/logo.png'; ?>" alt="<?php echo esc_attr(get_bloginfo('description')); ?>" class="logo-df">
                                <?php endif;
                                ?>
                            </a>
                        </div>
                    </div>
                    <div class="col-lg-9 col-sm-12 col-12 sparta-menu-main">
                        <?php
                        if (has_nav_menu('main-menu')) : ?>
                            <nav class="vk-navbar navbar">
                                <div class="navbar-header">
                                    <button type="button" class="navbar-toggle vk-btn-navbar-toggle"
                                            data-toggle="collapse" data-target="#myNavbar">
                                        <i class="vk-icon ti-menu"></i>
                                        <i class="vk-icon ti-close"></i>
                                    </button>
                                </div>
                                <?php
                                wp_nav_menu(
                                    array(
                                        'container_class' => 'vk-navbar-collapse collapse',
                                        'container_id' => 'myNavbar',
                                        'menu_class' => 'vk-nav vk-navbar-nav',
                                        'theme_location' => 'main-menu'
                                    )
                                );
                                ?>
                            </nav>
                        <?php else :
                            $admin_url = get_admin_url() . 'customize.php?url=' . esc_url(get_permalink()) . '&autofocus%5Bsection%5D=menu_locations';
                            echo '<div class="txt-assign-menu"><a href="' . esc_url($admin_url) . '">' . esc_html__('Assign a menu here', 'sparta') . '</a></div>';
                        endif; ?>
                    </div>
                    <div class="col-lg-1 d-none d-lg-block text-right">
                        <div data-toggle="collapse" data-target="#collapseSearch" aria-expanded="false" aria-controls="collapseSearch" class="h-search" role="button">
                            <i class="vk-icon ti-search"></i>
                        </div>
                        <div id="click_trigger" class="row_flex open">
                            <div class="box_sticks">
                                <div id="stick1" class="stick"></div>
                                <div id="stick2" class="stick"></div>
                                <div id="stick3" class="stick"></div>
                            </div>
                        </div>
                    </div>
                    <div class="vk-bar-search vk-box collapse col-lg-12" id="collapseSearch">
                        <form role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>">
                            <div class="search-form">
                                <input type="search" class="form-control" placeholder="<?php echo esc_attr_x('Search &hellip;', 'placeholder', 'sparta'); ?>" value="<?php echo get_search_query(); ?>" name="s"/>
                                <button type="submit" class="vk-btn-search vk-btn"><i class="fa fa-search"></i></button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>
<div class="menu_overlay">
    <div class="menu_content">
        <div class="site-flyout">
            <div class="brand-name-wrapper">
                <a href="<?php echo esc_url(home_url('/')); ?>"
                   title="<?php echo esc_attr(get_bloginfo('name', 'display')); ?>">
                    <?php
                    if ($sparta_header_flyout_logo && $sparta_header_flyout_logo !== '') :
                        echo '<img src="' . esc_url($sparta_header_flyout_logo) . '" alt="' . esc_attr(get_bloginfo('description')) . '">';
                    else : ?>
                        <img src="<?php echo get_template_directory_uri() . '/assets/images/logo-site-flyout.png'; ?>"
                             alt="<?php echo esc_attr(get_bloginfo('description')); ?>" class="logo-df">
                    <?php endif;

                    ?>
                </a>
            </div>

            <?php
            if (is_active_sidebar('site-flyout')):
                dynamic_sidebar('site-flyout');
            endif;
            ?>
            <div class="flyout-f text-center">
                <?php if (class_exists('HotelBookingPlugin')): ?>
                    <div class="flyout-booknow">
                        <a href="<?php echo esc_url(sparta_get_link_page_booking()); ?>" class="btn book-now">
                            <?php echo esc_html__('BOOK NOW', 'sparta'); ?>
                        </a>
                    </div>
                <?php endif; ?>
                <?php
                if ($general_info_address !== '' || $general_info_phone !== ''):
                    echo '<div class="flyout-info">';
                    if ($general_info_address !== ''):
                        echo '<span>' . esc_html($general_info_address) . '</span>';
                    endif;
                    if ($general_info_phone !== ''):
                        echo '<span class="hsp">-</span>';
                        echo '<span>' . esc_html__('Reservation: ', 'sparta') . '' . esc_html($general_info_phone) . '</span>';
                    endif;
                    echo '</div>';
                endif;

                $show_social = get_theme_mod('sparta_social_on', array('facebook', 'twitter', 'google'));

                if (!empty($show_social) && is_array($show_social)) :
                    echo '<div class="social-link-widget">';
                    foreach ($show_social as $part) : ?>
                        <?php if (get_theme_mod('sparta_acc_' . $part) != ''): ?>

                            <a href="<?php echo esc_attr(get_theme_mod('sparta_acc_' . $part)); ?>">
                                <i class="fa fa-<?php echo esc_html($part); ?>"></i>
                            </a>
                        <?php
                        endif;
                    endforeach;
                    echo '</div>';
                endif;
                ?>
            </div>

        </div>
    </div>
    <div class="menu-opacity">
    </div>
</div>

