<?php
/**
 * The header for our theme
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Wacko
 */

?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
  <meta charset="<?php bloginfo( 'charset' ); ?>">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="profile" href="http://gmpg.org/xfn/11">

  <?php wp_head(); ?>
</head>

<?php

$theme_options  = wacko_theme_options();
$body_class = '';
if ( 'page' == get_option( 'show_on_front' ) && is_front_page() ) {
  if( 1 != $theme_options['slider_enable'] ) {
    $body_class = 'homepage';
  }
}
if ( has_header_image() ) {
  $body_class .= ' header-bg-image';
}
?>

<body <?php body_class($body_class); ?>>

  <nav class="navbar navbar-inverse">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>

        <?php if ( has_custom_logo() ) { ?>

        <div class="site-branding">
          <?php
          the_custom_logo();
        ?>
      
      </div><!-- .site-branding -->


      <?php } else { ?>

        <div class="site-branding">
          
          <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
       
        <?php

        $description = get_bloginfo( 'description', 'display' );
        if ( $description || is_customize_preview() ) : ?>
        <p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p>
        <?php
        endif; ?>
      </div><!-- .site-branding -->

      <?php } ?>

    </div>

    <div class="collapse navbar-collapse">

      <?php
      if ( has_nav_menu( 'primary' ) ) {

        wp_nav_menu( array(
          'theme_location' 	=> 'primary',
          'container' 		=> 'ul',
          'menu_class' 		=> 'nav navbar-nav pull-right',
          'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
          'walker'            => new WP_Bootstrap_Navwalker(),
        ) );

      } else {

        wp_nav_menu( array(
          'theme_location'  => 'primary',
          'depth'          => 1,
          'container'     => 'ul',
          'menu_class'    => 'nav navbar-nav pull-right',
          'fallback_cb' => 'wp_page_menu',
        ) );

      }
      ?>

    </div><!--/.nav-collapse -->
  </div>
</nav>

<main>

  <?php

  $theme_options  = wacko_theme_options();

  if ( 'page' == get_option( 'show_on_front' ) && is_front_page() ) {
    do_action( 'wacko_action_home_content' );
  }
  $bg_image_url = get_header_image();

  if ( 'page' == get_option( 'show_on_front' ) && is_front_page() ) {

    if ( 1 === $theme_options['home_content'] ) {

      do_action( 'wacko_page_header' );

    }
  } else { 
    do_action( 'wacko_page_header' );
}
