<?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 elina-lite-portfolio-gallery
 */

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

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

<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
	<a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'elina-lite-portfolio-gallery' ); ?></a>

	<nav id="site-navigation" class="light navbar navbar-expand-lg">
				  <div class="container">

				  
		<!-- Logo -->
			<?php
			$custom_logo_id = get_theme_mod('custom_logo');
			$logo = wp_get_attachment_image_src($custom_logo_id, 'full');

			if ($logo && !empty($logo[0])) { // Ensuring $logo is not null and has a value
				echo '<a class="logo" href="' . esc_url(home_url('/')) . '">';
				echo '<img src="' . esc_url($logo[0]) . '" alt="' . esc_attr(get_bloginfo('name')) . '">';
				echo '</a>';
			} else {
				echo '<a class="logo" href="' . esc_url(home_url('/')) . '">';
				echo '<h3 class="test-logo">' . esc_html(get_bloginfo('name')) . '</h3>'; // Use esc_html for text content
				echo '</a>';
			}
				?>

			 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="<?php echo esc_attr__( 'Toggle navigation', 'elina-lite-portfolio-gallery' ); ?>">
                <span class="icon-bar"><i class="fas fa-bars"></i></span>
            </button>
			 <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">Primary Menu</button>
			<!--main navigation-->
			<div class="collapse navbar-collapse" id="navbarSupportedContent">
			<?php 
				wp_nav_menu(
					array(
						'theme_location' => 'menu-1',
						'container'      => 'ul',
						'menu_id'        => 'primary-menu',
						'menu_class'     => 'navbar-nav ml-auto',
						'fallback_cb'    => 'custom_menu_fallback',
						//'walker'         => new Custom_Walker_Nav_Menu(),
					)
				);
			?>

            <?php
			function custom_menu_fallback() {
				if (current_user_can('manage_options')) {
					echo '<ul class="navbar-nav ml-auto">';
					echo '<li><a href="' . esc_url(admin_url('nav-menus.php')) . '">' . esc_html__('Click here to add a menu', 'elina-lite-portfolio-gallery') . '</a></li>';
					echo '</ul>';
				}
			}
			 ?>
			
			<?php do_action( 'elinalite_social_top' ); ?>
		    	</div><!-- #end-main navigation -->
			</div><!-- #end-container -->
		</nav><!-- #site-navigation -->

	
