<?php
defined('ABSPATH') || exit('No Access!');

global $user_id, $options, $labels;

$src_shortcode = $options->get_option('src-shortcode');
$header_page = $options->get_option('header-page');
$faqs_page = $options->get_option('faqs-page');
?>
    <div class="overlay"></div>
<?php
if ($options->get_option('top-ads')) {
    $top_target = $options->get_option('top-target');
    $top_target = $top_target ? 'target="_blank"' : null;
    $top_xfn = $options->get_option('top-xfn');
    $top_xfn = $top_xfn ? ' rel="' . esc_attr($top_xfn) . '"' : null;
    $top_image = wp_get_attachment_url($options->get_option('top-image'));
    echo '<a href="' . esc_attr($options->get_option('top-url')) . '" class="top-ads" ' . $top_target . $top_xfn . ' style="background-image: url(' . $top_image . ')"></a>';
}
?>
<?php if (intval($header_page) && get_post($header_page)): ?>
    <header class="main-header">
        <?php
        echo (Elementor\Plugin::instance())->frontend->get_builder_content_for_display($header_page);
        if ($options->get_option('cat-menu')) {
            include(IRK_PATH . 'partials/cat-menu.php');
        }
        ?>
    </header>
<?php else: ?>
    <header class="main-header">
        <?php
        if ($options->get_option('header-contact-bar')) {
            $container_class = 'container';
            include(IRK_PATH . 'partials/contact-bar.php');
        }
        ?>
        <?php include(IRK_PATH . 'partials/top-menu.php'); ?>
        <div class="container">
            <div class="header-row row">
                <div class="col-lg-2">
                    <?php include(IRK_PATH . 'partials/cat-toggle.php'); ?>
                    <?php include(IRK_PATH . 'partials/header-logo.php'); ?>
                    <?php
                    if (is_home() || is_front_page()) {
                        echo '<h1 class="site-name">' . get_bloginfo('name') . '</h1>';
                    } else {
                        echo '<div class="site-name">' . get_bloginfo('name') . '</div>';
                    }

                    echo $faqs_page ? '<a href="' . get_permalink($faqs_page) . '" class="faqs"></a>' : null;
                    ?>
                </div>
                <div class="col-lg-6">
                    <?php
                    if ($src_shortcode) {
                        echo do_shortcode($src_shortcode);
                    } else {
                        include(IRK_PATH . 'partials/search.php');
                    }
                    ?>
                </div>
                <div class="col-lg-4">
                    <div class="header-action">
                        <?php include(IRK_PATH . 'partials/account-btn.php'); ?>
                        <?php irk_is_woo_active() ? include(IRK_PATH . 'partials/mini-cart.php') : null; ?>
                    </div>
                </div>
            </div>
        </div>
    </header>
    <?php include(IRK_PATH . 'partials/cat-menu.php'); ?>
<?php endif; ?>