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

?>
<?php
$hclass = array();
$custom_change_page_header = $custom_page_header_trans =  '';
if (true == get_theme_mod('sparta_header_fixed_fullwidth', true)) :
    $hclass[] = ' vk-header-fixed';
endif;

if (is_page()) :
    global $post;
    $meta_page_header_fixed = get_post_meta($post->ID, 'univer_page_header_fixed', true);
    $meta_page_header_trans = get_post_meta($post->ID, 'univer_page_header_trans', true);

    if ($meta_page_header_trans !== '' && $meta_page_header_trans === 'yes') :
        $hclass[] = ' vk-header-transparent';
    endif;

    if ($meta_page_header_fixed !== '' && $meta_page_header_fixed === 'yes') :
        $hclass[] = ' vk-header-fixed';
    endif;
endif;

$sparta_logo = get_theme_mod('sparta_header_fullwidthtrans_logo', '');

/*Render page loader*/
echo wp_kses_post(Sparta_Helper::sparta_page_loader());
?>
    <header class="vk-header header-fullwidth trans <?php if (!empty($hclass)) : echo esc_attr(implode(' ', $hclass)); endif; ?>">
        <?php if (is_page('homepage') || is_front_page() || is_home()) : ?>
            <h1 class="homepage-title"><?php the_title(); ?></h1>
        <?php endif; ?>
        <div class="logo-header">
            <a href="<?php echo esc_url(home_url('/')); ?>" title="<?php echo esc_attr(get_bloginfo('name', 'display')); ?>">
                <?php
                    if ($sparta_logo) :
                        echo '<img src="' . esc_url($sparta_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 class="vk-menu-box">
            <div class="container vk-container">
                <?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' => 'collapse navbar-collapse vk-navbar-collapse',
                                'container_id' => 'myNavbar',
                                'menu_class' => 'nav navbar-nav 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>
        <div class="vk-function-header">
                <ul class="vk-list vk-list-inline vk-list-function-header">
                    <?php if(class_exists( 'HotelBookingPlugin' )): ?>
                    <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>
                    <?php endif; ?>
                    <li>
                        <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>
                    </li>
                    <?php if (class_exists('WooCommerce')) : ?>
                        <li>
                            <div id="site-header-cart" class="site-header-cart menu">
                                <div class="uni-shopping-cart">
                                    <a class="cart-contents" href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php esc_attr_e('View your shopping cart', 'sparta'); ?>">
                                        <span class="amount"><?php echo wp_kses_data(WC()->cart->get_cart_subtotal()); ?></span>
                                        <span class="count"><?php echo wp_kses_data(sprintf(_n('%d', '%d ', WC()->cart->get_cart_contents_count(), 'sparta'), WC()->cart->get_cart_contents_count())); ?></span>
                                    </a>
                                    <div class="uni-icon-font"><i class="vk-icon ti-shopping-cart"></i></div>
                                </div>
                                <div class="widget_shopping_cart_content text-left"></div>
                            </div>
                        </li>
                    <?php endif; ?>
                </ul>
        </div>
        <div class="vk-bar-search vk-box collapse" 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>
    </header>

