<?php

/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Nextpage
 */

// logo from theme option
$nextpage_logo = nextpage_get_option('logo_nav_one');  //desktop logo

$nextpage_mobile_logo = nextpage_get_option('logo_nav_one_mobile');  //mobile logo

$nextpage_top_social_icon =  nextpage_get_option('topbar-social-icon'); //check social icon

$nextpage_ads = nextpage_get_option('add_image');

?>
<div class="navbar-area navone">

    <!-- adbar end-->
    <div class="adbar-area d-none d-lg-block">
        <div class="container">
            <div class="row">
                <div class="col-xl-6 col-lg-5 align-self-center">
                    <div class="logo text-md-left text-center">
                        <?php
                        if (has_custom_logo() || !empty($nextpage_logo['url'])) {

                            if (isset($nextpage_logo['url']) && !empty($nextpage_logo['url'])) {
                        ?>
                                <a href="<?php echo esc_url(site_url('/')) ?>" class="main-logo">
                                    <img src="<?php echo esc_url($nextpage_logo['url']); ?>" alt="<?php echo esc_attr($nextpage_logo['alt']); ?>">
                                </a>
                        <?php
                            } else {
                                the_custom_logo();
                            }
                        } else {
                            printf('<div class="site-title"><a href="%1$s">%2$s</a></div>', esc_url(site_url('/')), esc_html(get_bloginfo('name')));
                        }
                        ?>
                    </div>
                </div>
                <?php if (!empty($nextpage_ads['url'])) : ?>
                    <div class="col-xl-6 col-lg-7 text-md-right text-center">
                        <a target="_blank" href="<?php echo esc_url(nextpage_get_option('add_link')); ?>" class="adbar-right">
                            <img src="<?php echo esc_url($nextpage_ads['url']); ?>" alt="<?php echo esc_url($nextpage_ads['alt']); ?>">
                        </a>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
    <!-- adbar end-->

    <!-- navbar start -->
    <nav class="navbar navbar-expand-lg">
        <div class="container nav-container">
            <div class="responsive-mobile-menu">
                <div class="logo d-lg-none d-block">
                    <?php
                    if (has_custom_logo() || !empty($nextpage_mobile_logo['url'])) {

                        if (isset($nextpage_mobile_logo['url']) && !empty($nextpage_mobile_logo['url'])) {
                    ?>
                            <a href="<?php echo esc_url(site_url('/')) ?>" class="main-logo">
                                <img src="<?php echo esc_url($nextpage_mobile_logo['url']); ?>" alt="<?php echo esc_attr($nextpage_mobile_logo['alt']); ?>">
                            </a>
                    <?php
                        } else {
                            the_custom_logo();
                        }
                    } else {
                        printf('<div class="site-title"><a href="%1$s">%2$s</a></div>', esc_url(site_url('/')), esc_html(get_bloginfo('name')));
                    }
                    ?>
                </div>
                <button class="menu toggle-btn d-block d-lg-none" data-target="#nextpage_main_menu" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="icon-left"></span>
                    <span class="icon-right"></span>
                </button>
            </div>
            <div class="nav-right-part nav-right-part-mobile">
                <a class="search header-search" href="#"><i class="fa fa-search"></i></a>
            </div>
            <div class="collapse navbar-collapse" id="nextpage_main_menu">
                <?php
                if (has_nav_menu('main-menu')) {
                    wp_nav_menu(array(
                        'theme_location'  => 'main-menu',
                        'items_wrap'      => '<ul class="navbar-nav menu-open">%3$s</ul>',
                        'container'      => '',
                        'container_class' => '',
                        'menu_class'      => 'menu',
                    ));
                } else {
                    wp_nav_menu(array(
                        'menu_id'        => 'primary-menu',
                        'menu_class'        => 'navbar-nav',
                        'container'        => false,
                    ));
                } ?>
            </div>
            <?php if (nextpage_get_option('search_enable_menu_one', 0)) : ?>
                <div class="nav-right-part nav-right-part-desktop">
                    <form action="<?php echo esc_url(home_url('/')); ?>" method="get">
                        <div class="menu-search-inner">
                            <input type="text" name="s" placeholder="<?php echo esc_attr__('Search For', 'nextpage'); ?>" value="<?php get_search_query() ?>">
                            <button type="submit" class="submit-btn"><i class="fa fa-search"></i></button>
                        </div>
                    </form>
                </div>
            <?php endif; ?>
        </div>
    </nav>
</div>