<?php
/**
 * Template part for displaying header menu
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package crater-free
 */

?>

<?php
	$page_val = is_front_page() ? 'home' : 'page' ;
?>
<header id="<?php echo esc_attr($page_val); ?>-inner" class="elementor-menu-anchor crater-menu-wrapper full-width-menu style2 page">
	<a class="skip-link screen-reader-text" href="#main"><?php esc_html_e( 'Skip to content', 'crater-free' ); ?></a>
	<?php crater_free_topmenu(); ?>
	<div class="header-wrapper">
		<div class="container">
			<div class="clearfix">      
    			<div class="logo">
           			<?php 
           				if( is_front_page()) {
           					if (has_custom_logo()){
		                		crater_free_the_custom_logo();
		                	}
           				}
           				else{
           					$inner_page_logo=esc_url(get_theme_mod( 'cr_inner_page_logo' ));
           					if(!empty($inner_page_logo)) {
           						?>
			                		<a id="logo-inner-page" class="logo-inner-page" href="<?php echo esc_url(home_url()); ?>"><img src="<?php echo esc_url( get_theme_mod( 'cr_inner_page_logo' ) ); ?>" alt="logo"></a>
			                	<?php
           					}
           					else{
           						if (has_custom_logo()){
			                		crater_free_the_custom_logo();
			                	}
           					}
           				}	                		                	
	                ?>
	                <?php 
	                    $alt_logo=esc_url(get_theme_mod( 'cr_sticky_logo' ));
	                	if(!empty($alt_logo)) {
		                	?>
		                		<a id="logo-alt" class="logo-alt" href="<?php echo esc_url(home_url()); ?>"><img src="<?php echo esc_url( get_theme_mod( 'cr_sticky_logo' ) ); ?>" alt="logo"></a>
		                	<?php
		                }		                
		            ?>
	                <?php
		                $show_title   = ( true === get_theme_mod( 'cr_site_title_tagline', false ) );
						$header_class = $show_title ? 'site-title' : 'screen-reader-text';
						if(!empty(get_bloginfo( 'name' ))) {
							if ( is_front_page() ) {
						        ?>
		                			<h1 class="<?php echo esc_attr( $header_class ); ?>">
								        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php esc_html(bloginfo( 'name' )); ?></a>
								    </h1>

								<?php

								if(true === get_theme_mod( 'cr_site_title_tagline', false )) {
									$description = esc_html(get_bloginfo( 'description', 'display' ));
							        if ( $description || is_customize_preview() ) { 
							            ?>
							                <p class="site-description"><?php echo $description; ?></p>
							            <?php 
							        }
								}
							}
							else {
								?>
									<p class="<?php echo esc_attr( $header_class ); ?>">
								        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php esc_html(bloginfo( 'name' )); ?></a>
								    </p>
								<?php

								if(true === get_theme_mod( 'cr_site_title_tagline', false )) {
									$description = esc_html(get_bloginfo( 'description', 'display' ));
							        if ( $description || is_customize_preview() ) { 
							            ?>
							                <p class="site-description"><?php echo $description; ?></p>
							            <?php 
							        }
								}
							}
						}
	                ?>
				</div>
				<nav class="crater-main-menu navbar page" id="crater-main-menu-wrapper">
					<div class="navbar-header">
				     	<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false">
					       	<span class="sr-only"><?php esc_html_e( 'Toggle navigation', 'crater-free' ); ?></span>
					      	<span class="icon-bar"></span>
					       	<span class="icon-bar"></span>
					       	<span class="icon-bar"></span>
				     	</button>
				   	</div>
				   	
					<div class="collapse navbar-collapse page" id="navbar-collapse-1">
				   		<?php
			                wp_nav_menu( array(			                  	
			                  	'theme_location'    => 'primary',
			                  	'depth'             => 3,
			                  	'container'         => 'ul',
			                  	'container_class'   => '',
			                  	'container_id'      => 'menu-primary',
			                  	'menu_class'        => 'nav primary',
			                  	'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
			                  	'walker'            => new wp_bootstrap_navwalker())
			                );
		             	?>	
		             	<?php crater_free_shop_menu(); ?>		
				   	</div>
				</nav>
			</div>
        </div>
    </div>
</header>
<?php 
	if(!is_front_page() && get_theme_mod( 'cr_enable_breadcrumbs',false)) { ?>
		<div class="breadcrumb-wrapper">
			<div class="container">
				<?php 
					if(get_theme_mod( 'cr_enable_breadcrumbs',false)) :
						$breadcrumb_from = esc_html(get_theme_mod( 'cr_breadcrumbs_types','default'));
						if (function_exists('yoast_breadcrumb') && $breadcrumb_from == 'yoast') :
							yoast_breadcrumb('<p id="breadcrumbs">','</p>');
						elseif (function_exists('bcn_display') && $breadcrumb_from == 'navxt'): 
							bcn_display();
						else:
							require get_template_directory() . '/inc/breadcrumbs.php';
							$breadcrumb_args = array(
								'container' => 'div',
								'show_browse' => false
							);        
							breadcrumb_trail($breadcrumb_args);
						endif;
					endif;
				?>
			</div>
		</div>
	<?php }
?>
<div id="home" class="elementor-menu-anchor"></div>
