<?php
/**
 * Header Layout
 * @package Business Classified Ads
 */

$business_classified_ads_default = business_classified_ads_get_default_theme_options();


$business_classified_ads_header_layout_wishlist_url = esc_url( get_theme_mod( 'business_classified_ads_header_layout_wishlist_url',
$business_classified_ads_default['business_classified_ads_header_layout_wishlist_url'] ) );

$business_classified_ads_header_layout_button_text = esc_html( get_theme_mod( 'business_classified_ads_header_layout_button_text',
$business_classified_ads_default['business_classified_ads_header_layout_button_text'] ) );

$business_classified_ads_header_layout_button_link = esc_url( get_theme_mod( 'business_classified_ads_header_layout_button_link',
$business_classified_ads_default['business_classified_ads_header_layout_button_link'] ) );

$business_classified_ads_sticky = get_theme_mod('business_classified_ads_sticky');
$business_classified_ads_data_sticky = "false";
if ($business_classified_ads_sticky) {
$business_classified_ads_data_sticky = "true";
}
global $wp_customize;

?>
<div class="main-header">
    <section id="center-header" class="header-navbar <?php if( is_user_logged_in() && !isset( $wp_customize ) ){ echo "login-user";} ?>" data-sticky="<?php echo esc_attr($business_classified_ads_data_sticky); ?>">
        <div class="wrapper header-wrapper header-box">
            <div class="header-titles">
                <?php
                    business_classified_ads_site_logo();
                    business_classified_ads_site_description();
                ?>
            </div>
            <div class="theme-header-areas header-areas-right menu-box">
                <div class="site-navigation">
                    <nav class="primary-menu-wrapper" aria-label="<?php esc_attr_e('Horizontal', 'business-classified-ads'); ?>" role="navigation">
                        <ul class="primary-menu theme-menu">
                            <?php
                            if (has_nav_menu('business-classified-ads-primary-menu')) {
                                wp_nav_menu(
                                    array(
                                        'container' => '',
                                        'items_wrap' => '%3$s',
                                        'theme_location' => 'business-classified-ads-primary-menu',
                                    )
                                );
                            } else {
                                wp_list_pages(
                                    array(
                                        'match_menu_classes' => true,
                                        'show_sub_menu_icons' => true,
                                        'title_li' => false,
                                        'walker' => new Business_Classified_Ads_Walker_Page(),
                                    )
                                );
                            } ?>
                        </ul>
                    </nav>
                </div>
                <div class="navbar-controls twp-hide-js">
                    <button type="button" class="navbar-control navbar-control-offcanvas">
                        <span class="navbar-control-trigger" tabindex="-1">
                            <?php business_classified_ads_the_theme_svg('menu'); ?>
                        </span>
                    </button>
                </div>
            </div>
            <div class="theme-header-areas header-areas-right header-meta">
                <?php if ( $business_classified_ads_header_layout_wishlist_url ) : ?>
                    <span class="tbr-wishlist text-end">
                        <a href="<?php echo esc_url( $business_classified_ads_header_layout_wishlist_url ); ?>">
                          <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M458.4 64.3C400.6 15.7 311.3 23 256 79.3 200.7 23 111.4 15.6 53.6 64.3-21.6 127.6-10.6 230.8 43 285.5l175.4 178.7c10 10.2 23.4 15.9 37.6 15.9 14.3 0 27.6-5.6 37.6-15.8L469 285.6c53.5-54.7 64.7-157.9-10.6-221.3zm-23.6 187.5L259.4 430.5c-2.4 2.4-4.4 2.4-6.8 0L77.2 251.8c-36.5-37.2-43.9-107.6 7.3-150.7 38.9-32.7 98.9-27.8 136.5 10.5l35 35.7 35-35.7c37.8-38.5 97.8-43.2 136.5-10.6 51.1 43.1 43.5 113.9 7.3 150.8z"/></svg>
                        </a>           
                    </span>
                <?php endif; ?>
                <?php if(class_exists('woocommerce')){ ?>
                    <?php if ( is_user_logged_in() ) { ?>
                        <a class="account-area" href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_attr_e('My Account','business-classified-ads'); ?>"><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"/></svg><?php esc_html_e('Login / Register','business-classified-ads'); ?></a>
                    <?php }
                    else { ?>
                        <a class="account-area" href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_attr_e('Login / Register','business-classified-ads'); ?>"><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"/></svg><?php esc_html_e('Login / Register','business-classified-ads'); ?></a>
                    <?php } ?>
                <?php }?>
                <?php if( $business_classified_ads_header_layout_button_text || $business_classified_ads_header_layout_button_link ){ ?>
                    <a href="<?php echo esc_url( $business_classified_ads_header_layout_button_link ); ?>" class="btn-fancy btn-fancy-primary header-button"><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M416 208H272V64c0-17.7-14.3-32-32-32h-32c-17.7 0-32 14.3-32 32v144H32c-17.7 0-32 14.3-32 32v32c0 17.7 14.3 32 32 32h144v144c0 17.7 14.3 32 32 32h32c17.7 0 32-14.3 32-32V304h144c17.7 0 32-14.3 32-32v-32c0-17.7-14.3-32-32-32z"/></svg><?php echo esc_html( $business_classified_ads_header_layout_button_text ); ?></a>
                <?php } ?>
            </div>
        </div>
    </section>
</div>