<?php
/**
 * Szablon nawigacji
 *
 * @link https://krzysztof-turek.com
 *
 * @package tylkofotografia.pl
 * @version 0.2
 */

  $menu     = new Menus();
  $menuId = $menu->get_menu_id( 'tf-header-menu' );
  $headerMenu   = wp_get_nav_menu_items( $menuId );
  $main = '';
  $directory_uri = get_stylesheet_directory_uri();
  ?>

  <!-- Jumbotron -->
  <!---<div class="text-center ">
    <div class="container">
      <div class="row">
        <div class="col-md-4 d-flex justify-content-center justify-content-md-start mb-3 mb-md-0">
          <a class="navbar-brand" href="<?php echo site_url(); ?>">
			<?php if ( is_home() &&  is_front_page() ) { ?>
			<h1 class="logo" id="logo">Tylko<b>Fotografia</b></h1>
			<?php } else { ?>
		    <p class="logo" id="logo">Tylko<b>Fotografia</b></p>
			<?php } ?>
	    </a>

        </div>
		<div class="col-md-5">
			
		  </div>
        <div class="col-md-3">
			
          <form class="d-flex input-group w-auto my-auto mb-3 mb-md-0"  method="get" action="/index.php">
            <input autocomplete="off" type="search" name="s" class="form-control rounded" placeholder="Szukaj" />
            <button class="input-group-text border-0 d-none d-lg-flex" type="submit"><i class="fas fa-search"></i></button>
          </form>
        </div>

      </div>
    </div>
  </div>--->
  <!-- Jumbotron -->

	
<!-- navbar navbar-expand-md navbar-dark fixed-top rozszerza do góry -->
<nav class="navbar navbar-expand-lg fixed-top navbar-light ">
    <div class="container">
		<a class="navbar-brand" href="<?php echo site_url(); ?>">
			<img src="<?php echo $directory_uri; ?>/favicon/TylkoFotografia-logo-icon.png" style="display: inline-block; vertical-align: middle; max-height: 40px; margin-right: 5px;"/>
			<?php if ( is_home() &&  is_front_page() ) { ?>
			<h1 class="logo" id="logo" style="display: inline-block;
        vertical-align: middle;">Tylko<b>Fotografia</b></h1>
			<?php } else { ?>
		    <p class="logo" id="logo" style="display: inline-block;
        vertical-align: middle;">Tylko<b>Fotografia</b></p>
			<?php } ?>
	    </a>
       <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mx-auto mb-2 mb-lg-0 ml-2">

  <?php 
  if (is_array($headerMenu) || is_object($headerMenu))
  {
  foreach($headerMenu as $menuItem) 
  { 
    $childItems   = $menu->get_child_menu_items( $headerMenu, $menuItem->ID );
    if ($menuItem->menu_item_parent == 0 && empty($childItems)) {
      $main .= '<li class="nav-item">';
      $main .= '<a href="'.$menuItem->url.'" class="nav-link">'.$menuItem->title.'</a>';
      $main .= '</li>';
    } 
    if ($menuItem->menu_item_parent == 0 && !empty($childItems))
    {
      $main .= '<li class="nav-item dropdown">';
      $main .= '<a href="#" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">'.$menuItem->title.'</a>';
        
      if (!empty($childItems) && is_array($childItems) ) 
      {  
      
        $main .= '<ul class="dropdown-menu">';
        foreach ($childItems as $childItem) 
        {
          $main .= '<li>';
          $main .= '<a href="'.$childItem->url.'" class="dropdown-item ">'.$childItem->title.'</a>';
          $main .= '</li>';
        } 
        $main .= '</ul>';
      }
      $main .= '</li>';
    }
  }
} 
echo $main;
?>

    </ul>
		  <form class="d-flex input-group w-auto my-auto mb-3 mb-md-0"  method="get" action="/index.php">
            <input autocomplete="off" type="search" name="s" class="form-control rounded" placeholder="Szukaj" />
            <button class="input-group-text border-0 d-none d-lg-flex" type="submit"><i class="fas fa-search"></i></button>
          </form>
    </div>
		
  </div>
</nav>
  