
<?php $options = get_option('kaveh_frame'); ?>

<nav class="nav-header">
              <div class="container d-flex align-items-center justify-content-lg-between position-relative">
              <div class="mb-4 mt-4"></div>
              <p>جهت فعال شدن هدر قالب حتما افزونه boostify header footer builder را نصب و فعال کنید همچنین شما میتوانید هدر خود را با استفاده از المنتور پرو چینش کنید</p>
              <div class="mb-4 mt-4"></div>
              </div>
            </nav>
            <?php if (wp_is_mobile()): ?>
              <div class="nav-responsive position-fixed top-0 end-0 w-100 h-100">
                <div class="nav-responsive-backdrop position-fixed top-0 end-0 w-100 h-100"></div>
                <div class="nav-responsive-content position-absolute top-0 right-0 w-100 h-100">
                  <div class="nav-responsive-content-wrapper bg-white">
                    <button type="button"
                      class="nav-responsive-close rounded-circle d-flex align-items-center justify-content-center text-white">
                      <i class="icon-close"></i>
                    </button>
                    <ul class="nav-responsive-content-menu">
                      <?php
                      function has_sub_menu(array $menu_items, int $id)
                      {
                        foreach ($menu_items as $menu_item) {
                          if ((int) $menu_item->menu_item_parent === $id) {
                            return true;
                          }
                        }
                        return false;
                      }
                      // wordpress does not group child menu items with parent menu items
                      $menus = get_terms('nav_menu', array('hide_empty' => true));
                      if (!empty($options['kaveh_mobile_select'])):
                        $menuop = $options['kaveh_mobile_select'];
                        $navbar_items = wp_get_nav_menu_items($menuop);
                      else:
                        $navbar_items = wp_get_nav_menu_items('primary');
                      endif;

                      foreach ($navbar_items as $navbar_item) {
                        $nav_meta = get_post_meta($navbar_item->ID);
                        $icon_class = $nav_meta['_menu_item_desc'];
                        if ($navbar_item->menu_item_parent == 0):
                          ?>
                          <li <?php if (has_sub_menu($navbar_items, $navbar_item->ID)): ?> class="has-child" <?php endif; ?>>
                            <a href="<?php echo $navbar_item->url; ?>" class="d-block rounded-pill">
                              <i class="<?php echo $icon_class[0]; ?>"></i>
                              <?php echo $navbar_item->title; ?>
                              <?php if (has_sub_menu($navbar_items, $navbar_item->ID)): ?>
                                <i class="icon-angle-left position-absolute top-50 translate-middle-y m-0"></i>
                              <?php endif; ?>
                            </a>
                            <?php if (has_sub_menu($navbar_items, $navbar_item->ID)): ?>
                              <div class="children position-fixed top-0 start-0 w-100 h-100 bg-white">
                                <div class="heading px-3 py-4 d-flex align-items-center justify-content-between">
                                  <?php echo $navbar_item->title; ?>
                                  <button type="button"
                                    class="nav-responsive-back rounded-circle d-flex align-items-center justify-content-center text-white mb-0">
                                    <i class="icon-arrow-left-2"></i>
                                  </button>
                                </div>
                                <ul>
                                  <?php
                                  foreach ($navbar_items as $menu_item) {
                                    if ((int) $menu_item->menu_item_parent === $navbar_item->ID) {
                                      ?>
                                      <li <?php if (has_sub_menu($navbar_items, $menu_item->ID)): ?>class="has-child" <?php endif; ?>>
                                        <a href="<?php echo $menu_item->url; ?>" class="d-block rounded-pill">
                                          <?php echo $menu_item->title; ?>
                                          <?php if (has_sub_menu($navbar_items, $menu_item->ID)): ?>
                                            <i class="icon-angle-left position-absolute top-50 translate-middle-y m-0"></i>
                                          <?php endif; ?>
                                        </a>
                                        <?php if (has_sub_menu($navbar_items, $menu_item->ID)): ?>
                                          <div class="children position-fixed top-0 start-0 w-100 h-100 bg-white">
                                            <div class="heading px-3 py-4 d-flex align-items-center justify-content-between">
                                              <?php echo $menu_item->title; ?>
                                              <button type="button"
                                                class="nav-responsive-back rounded-circle d-flex align-items-center justify-content-center text-white mb-0">
                                                <i class="icon-arrow-left-2"></i>
                                              </button>
                                            </div>
                                            <ul>
                                              <?php foreach ($navbar_items as $submenu_item): ?>
                                                <?php if ((int) $submenu_item->menu_item_parent === $menu_item->ID): ?>
                                                  <li <?php if (has_sub_menu($navbar_items, $submenu_item->ID)): ?>class="has-child" <?php endif; ?>>
                                                    <a href="<?php echo $submenu_item->url; ?>" class="d-block rounded-pill">
                                                      <?php echo $submenu_item->title; ?>
                                                      <?php if (has_sub_menu($navbar_items, $submenu_item->ID)): ?>
                                                        <i class="icon-angle-left position-absolute top-50 translate-middle-y m-0"></i>
                                                      <?php endif; ?>
                                                    </a>
                                                    <?php if (has_sub_menu($navbar_items, $submenu_item->ID)): ?>
                                                      <div class="children position-fixed top-0 start-0 w-100 h-100 bg-white">
                                                        <div class="heading px-3 py-4 d-flex align-items-center justify-content-between">
                                                          <?php echo $submenu_item->title; ?>
                                                          <button type="button"
                                                            class="nav-responsive-back rounded-circle d-flex align-items-center justify-content-center text-white mb-0">
                                                            <i class="icon-arrow-left-2"></i>
                                                          </button>
                                                        </div>
                                                        <ul>
                                                          <?php foreach ($navbar_items as $subsubmenu_item): ?>
                                                            <?php if ((int) $subsubmenu_item->menu_item_parent === $submenu_item->ID): ?>
                                                              <li <?php if (has_sub_menu($navbar_items, $subsubmenu_item->ID)): ?>class="has-child" <?php endif; ?>>
                                                                <a href="<?php echo $subsubmenu_item->url; ?>" class="d-block rounded-pill">
                                                                  <?php echo $subsubmenu_item->title; ?>
                                                                  <?php if (has_sub_menu($navbar_items, $subsubmenu_item->ID)): ?>
                                                                    <div class="children position-fixed top-0 start-0 w-100 h-100 bg-white">
                                                                      <div class="heading px-3 py-4 d-flex align-items-center justify-content-between">
                                                                        <?php echo $subsubmenu_item->title; ?>
                                                                        <button type="button"
                                                                          class="nav-responsive-back rounded-circle d-flex align-items-center justify-content-center text-white mb-0">
                                                                          <i class="icon-arrow-left-2"></i>
                                                                        </button>
                                                                      </div>
                                                                      <ul>
                                                                        <?php foreach ($navbar_items as $subsubsubmenu_item): ?>
                                                                          <?php if ((int) $subsubsubmenu_item->menu_item_parent === $subsubmenu_item->ID): ?>
                                                                            <li class="has-child">
                                                                              <a href="#" class="d-block rounded-pill"> ایتم 1 </a>
                                                                              <div class="children position-fixed top-0 start-0 w-100 h-100 bg-white">
                                                                                <div
                                                                                  class="heading px-3 py-4 d-flex align-items-center justify-content-between">
                                                                                  دسته بندی محصولات
                                                                                  <button type="button"
                                                                                    class="nav-responsive-back rounded-circle d-flex align-items-center justify-content-center text-white mb-0">
                                                                                    <i class="icon-arrow-left-2"></i>
                                                                                  </button>
                                                                                </div>
                                                                                <ul>
                                                                                  <li class="has-child">
                                                                                    <a href="#" class="d-block rounded-pill"> ایتم 1 </a>

                                                                                  </li>
                                                                                  <li class="has-child">
                                                                                    <a href="#" class="d-block rounded-pill"> ایتم 2 </a>

                                                                                  </li>
                                                                                  <li>
                                                                                    <a href="#" class="d-block rounded-pill"> ایتم 3 </a>
                                                                                  </li>
                                                                                </ul>
                                                                              </div>
                                                                            </li>
                                                                          <?php endif; ?>
                                                                        <?php endforeach; ?>
                                                                      </ul>
                                                                    </div>
                                                                  <?php endif; ?>
                                                                </a>
                                                              </li>
                                                            <?php endif; ?>
                                                          <?php endforeach; ?>
                                                        </ul>
                                                      </div>
                                                    <?php endif; ?>
                                                  </li>

                                                <?php endif; ?>
                                              <?php endforeach; ?>

                                            </ul>
                                          </div>
                                        <?php endif; ?>
                                      </li>
                                      <?php
                                    }
                                  }
                                  ?>
                                </ul>
                              </div>
                            <?php endif; ?>
                          </li>
                        <?php endif; ?>
                      <?php
                      }
                      ?>
                    </ul>
                  </div>
                  <div class="discounts-contact d-flex align-items-center justify-content-between position-relative">
                    <?php
                    if (!empty($options['kaveh_boxmenudown_mobile_on'])):
                      if ($options['kaveh_boxmenudown_mobile_on'] === '1'):
                        ?>
                        <a href="<?php echo $options['kaveh_boxmenudown_url']; ?>" class="discount rounded-pill">
                          <i class="<?php echo $options['kaveh_boxmenudown_iconclass']; ?>"></i>
                          <?php echo $options['kaveh_boxmenudown_text']; ?>
                        </a>
                        <ul class="d-flex align-items-center">
                          <li>
                            <a href="#">
                              <i class="icon-document"></i>
                            </a>
                          </li>
                          <li>
                            <a href="#">
                              <i class="icon-phone-4"></i>
                            </a>
                          </li>
                        </ul>
                        <?php
                      endif;
                    endif;
                    ?>
                  </div>
                  <?php if ($options['kaveh_icons_mobile_on'] == true): ?>
                    <div class="socials d-flex align-items-center justify-content-between position-relative">
                      <ul class="d-flex align-items-center">
                        <?php
                        if (!empty($options['kaveh_mobile_menu-repeater'])):
                          $iconh = $options['kaveh_mobile_menu-repeater'];
                          for ($i = 0; $i < count($iconh); $i++) {
                            ?>
                            <li>
                              <a href="<?php echo $iconh[$i]['kaveh_mobile_menu_text']['url']; ?>"
                                class="d-flex align-items-center justify-content-center rounded-pill">
                                <i class="<?php echo $iconh[$i]['kaveh_mobile_menu_icon']; ?>"></i>
                              </a>
                            </li>
                            <?php
                          }
                        endif;
                        ?>

                      </ul>
                      <span class="text-white"> شبکه های اجتماعی </span>
                    </div>
                  <?php endif; ?>

                </div>
              </div>
            <?php endif; ?>