<?php
/**
* The header for our theme
*
* This is the template that displays all of the header section
*
* @package mediapulse
* @since 0.1
*/ ?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
	<?php if ( is_singular() && pings_open() ) { ?>
		<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
	<?php }
    wp_head(); ?>
</head>

<body <?php  $mediapulse_theme_layout = get_theme_mod('theme_layout', 'wide') ; if (  $mediapulse_theme_layout == 'boxed' ) { body_class('boxed'); } else body_class(); ?>>
<?php   
if ( function_exists( 'wp_body_open' ) )
wp_body_open();
?>
    <!-- Topbar Start -->
    <div class="container-fluid" <?php if ( has_header_image() ) { ?> style="background-image:url(<?php echo esc_url( get_header_image() ); ?>)" <?php } ?>>
        <div class="row align-items-center bg-light px-lg-5">
		<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'mediapulse' ); ?></a>
		<?php $hide_show_trending = get_theme_mod( 'hide_show_trending', true ); 
			if ( $hide_show_trending == true ) { ?>
            <div class="col-12 col-md-8">
                <div class="d-flex justify-content-between">
                    <div class="bg-primary text-white text-center py-2" style="width: 100px;"><?php echo esc_html('Tranding','mediapulse'); ?></div>
                    <div class="owl-carousel owl-carousel-1 tranding-carousel position-relative d-inline-flex align-items-center ml-3" style="width: calc(100% - 100px); padding-left: 90px;">
					<?php $mediapulse_args = array(
					'post_type'=> 'post',
					'orderby'    => 'ID',
					'post_status' => 'publish',
					'order'    => 'DESC',
					'posts_per_page' => -1 // this will retrive all the post that is published 
					);
					$result = new WP_Query( $mediapulse_args ); 
					if ( $result->have_posts()): 
					while ( $result->have_posts() ): $result->the_post(); ?>
						<div class="text-truncate">
						<a class="text-secondary" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>  	
					<?php
					endwhile; 
					endif; 
					?>
                    </div>
                </div>
            </div>
			<?php } 
			$mediapulse_hide_show_date = get_theme_mod( 'hide_show_date', true ); 
			if ( $mediapulse_hide_show_date == true ) { ?>
            <div class="col-md-4 text-right d-none d-md-block">
			<?php echo date("l, F j, Y"); ?>
            </div>
			<?php } ?>
        </div>
        <div class="row align-items-center py-2 px-lg-5">
            <div class="col-lg-4">
			<?php 
			$mediapulse_custom_logo_id = get_theme_mod( 'custom_logo' );
			$mediapulse_image = wp_get_attachment_image_src( $mediapulse_custom_logo_id , 'full' ); ?>
			<a href="<?php echo esc_url( home_url() ); ?>" class="navbar-brand d-none d-lg-block">
			<?php if ( has_custom_logo() ) { ?>
                <img src="<?php echo $mediapulse_image[0] ?>" class="logo-size" alt="logo">
			<?php } else { ?>
				<?php $mediapulse_site_title = get_bloginfo( 'name' );
				$mediapulse_site_description = get_bloginfo( 'description' ); ?>
				<h3 class="logo-title"><?php echo esc_html($mediapulse_site_title); ?></h3>
				<p class="description"><?php echo esc_html($mediapulse_site_description); ?></p>
			<?php } ?>
			</a>
            </div>
			<?php if(get_theme_mod( 'sale_header_image' )) : ?>
            <div class="col-lg-8 text-center text-lg-right">
                <img class="img-fluid" src="<?php echo esc_url( get_theme_mod( 'sale_header_image' ) ); ?>">
            </div>
			<?php endif; ?>
        </div>
    </div>
    <!-- Topbar End -->


    <!-- Navbar Start -->
    <div class="container-fluid p-0 mb-3">
        <nav class="navbar navbar-expand-lg bg-light navbar-light py-2 py-lg-0 px-lg-5">
            <a href="<?php the_permalink(); ?>" class="navbar-brand d-block d-lg-none">
                <h1 class="m-0 display-5 text-uppercase">
				<?php 
			$mediapulse_custom_logo_id = get_theme_mod( 'custom_logo' );
			$mediapulse_image = wp_get_attachment_image_src( $mediapulse_custom_logo_id , 'full' ); ?>
			<?php if ( has_custom_logo() ) { ?>
                <img src="<?php echo $mediapulse_image[0] ?>" class="logo-size" alt="logo">
			<?php } else { ?>
				<?php $mediapulse_site_title = get_bloginfo( 'name' ); ?>
				<h3><?php echo esc_html($mediapulse_site_title); ?></h3>
			<?php } ?></h1>
            </a>
            <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse justify-content-between px-0 px-lg-3" id="navbarCollapse">
                
                    <?php
	                    wp_nav_menu( array(
	                        'theme_location' => 'primary',
							'depth'           => 4, // 1 = no dropdowns, 2 = with dropdowns.
							'container'       => 'div',
							'container_class' => 'navbar-collapse collapse',
							'container_id'    => 'navbarCollapse',
							'menu_class'      => 'navbar-nav nav-item',
	                        'fallback_cb'     => 'WP_Bootstrap_Navwalker::fallback',
							'walker'          => new WP_Bootstrap_Navwalker(),
	                    ) );
	                ?>
                
				<?php 
				$mediapulse_hide_show_search_icon = get_theme_mod( 'hide_show_search_icon', true ); 
				if ( $mediapulse_hide_show_search_icon == true ) { ?>
                <div class="input-group ml-auto" style="width: 100%; max-width: 300px;">
                    <?php get_search_form(); ?>
                </div>
				<?php } ?>
            </div>
        </nav>
    </div>