<?php

/**
 * The file for header all actions
 *
 *
 * @package Blog Grow
 */

function BLOG_GROW_header_top_output()
{
	$BLOG_GROW_latest_news = get_theme_mod('BLOG_GROW_latest_news', 1);
	$BLOG_GROW_date_show = get_theme_mod('BLOG_GROW_date_show', 1);
?>
	<div class="header-top">
		<div class="container">
			<div class="header-top-all-items">
				<div class="ht-row">
					<?php if ($BLOG_GROW_date_show) : ?>
						<div class="web-date ht-date">
							<i class="far fa-calendar-check"></i>
							<p><?php echo date(get_option('date_format')); ?></p>
						</div>
					<?php endif; ?>
					<?php if ($BLOG_GROW_latest_news) : ?>
						<div class="breaking-news ht-news">
							<div class="breaking-news-title">
								<i class="fas fa-wifi"></i>
								<h5 class="breaking-title"><?php esc_html_e('Breaking News', 'blog-grow'); ?></h5>
							</div>
							<div class="news-update ticker news-noload">
								<?php
								$news_update_args = array(
									'post_type'  		=>	'post',
									'post_status'  		=>	'publish',
									'posts_per_page' 	=> 5,
									'ignore_sticky_posts' 	    =>	1,
								);
								$news_update_loop = new WP_Query($news_update_args);
								while ($news_update_loop->have_posts()) :  $news_update_loop->the_post(); ?>
									<div> <?php the_title(); ?>&nbsp; | &nbsp;</div>
								<?php endwhile;
								wp_reset_postdata(); ?>
							</div>
						</div>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>

<?php
}
add_action('BLOG_GROW_header_top', 'BLOG_GROW_header_top_output');

function BLOG_GROW_header_logo_output()
{
	$BLOG_GROW_mlogo_show = get_theme_mod('BLOG_GROW_mlogo_show', 1);
	$BLOG_GROW_search_show = get_theme_mod('BLOG_GROW_search_show', 1);
	$BLOG_GROW_header_social_show = get_theme_mod('BLOG_GROW_header_social_show', 1);
	$BLOG_GROW_hfacebook_link = get_theme_mod('BLOG_GROW_hfacebook_link');
	$BLOG_GROW_htwitter_link = get_theme_mod('BLOG_GROW_htwitter_link');
	$BLOG_GROW_hlinkedin_link = get_theme_mod('BLOG_GROW_hlinkedin_link');
	$BLOG_GROW_hyoutube_link = get_theme_mod('BLOG_GROW_hyoutube_link');
	$BLOG_GROW_hpinterest_link = get_theme_mod('BLOG_GROW_hpinterest_link');
	$BLOG_GROW_hinstagram_link = get_theme_mod('BLOG_GROW_hinstagram_link');

	if ($BLOG_GROW_search_show && $BLOG_GROW_header_social_show) {
		$BLOG_GROW_logo_col = '4';
		$BLOG_GROW_search_col = '5';
		$BLOG_GROW_social_col = '3';
	} elseif ($BLOG_GROW_header_social_show) {
		$BLOG_GROW_logo_col = '8';
		$BLOG_GROW_search_col = ' ';
		$BLOG_GROW_social_col = '4';
	} elseif ($BLOG_GROW_search_show) {
		$BLOG_GROW_logo_col = '7';
		$BLOG_GROW_search_col = '5';
		$BLOG_GROW_social_col = ' ';
	} else {
		$BLOG_GROW_logo_col = '12';
		$BLOG_GROW_search_col = ' ';
		$BLOG_GROW_social_col = ' ';
	}

?>
	<div class="header-middle">
		<div class="container">
			<div class="header-middle-all-content">
				<div class="row">
					<div class="col-lg-<?php echo esc_attr($BLOG_GROW_logo_col); ?>">
						<?php
						if ($BLOG_GROW_mlogo_show) {
							BLOG_GROW_logo_output();
						}
						?>
					</div>
					<?php if ($BLOG_GROW_search_show) : ?>
						<div class="col-lg-<?php echo esc_attr($BLOG_GROW_search_col); ?>">
							<div class="npaper search-box">
								<?php echo get_search_form(); ?>

							</div>
						</div>
					<?php endif; ?>
					<?php if ($BLOG_GROW_header_social_show) : ?>
						<div class="col-lg-<?php echo esc_attr($BLOG_GROW_social_col); ?>">
							<div class="header-links">
								<div class="social-links">
									<?php if ($BLOG_GROW_hfacebook_link) : ?>
										<a href="<?php echo esc_url($BLOG_GROW_hfacebook_link); ?>"><i class="fab fa-facebook-f"></i></a>
									<?php endif; ?>
									<?php if ($BLOG_GROW_htwitter_link) : ?>
										<a href="<?php echo esc_url($BLOG_GROW_htwitter_link); ?>"><i class="fab fa-twitter"></i></a>
									<?php endif; ?>
									<?php if ($BLOG_GROW_hlinkedin_link) : ?>
										<a href="<?php echo esc_url($BLOG_GROW_hlinkedin_link); ?>"><i class="fab fa-linkedin-in"></i></a>
									<?php endif; ?>
									<?php if ($BLOG_GROW_hyoutube_link) : ?>
										<a href="<?php echo esc_url($BLOG_GROW_hyoutube_link); ?>"><i class="fab fa-youtube"></i></a>
									<?php endif; ?>
									<?php if ($BLOG_GROW_hpinterest_link) : ?>
										<a href="<?php echo esc_url($BLOG_GROW_hpinterest_link); ?>"><i class="fab fa-pinterest"></i></a>
									<?php endif; ?>
									<?php if ($BLOG_GROW_hinstagram_link) : ?>
										<a href="<?php echo esc_url($BLOG_GROW_hinstagram_link); ?>"><i class="fab fa-instagram"></i></a>
									<?php endif; ?>
								</div>
							</div>
						</div>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>
<?php
}
add_action('BLOG_GROW_header_logo', 'BLOG_GROW_header_logo_output');

// Blog Grow mene style
function BLOG_GROW_main_menu_output()
{
	$BLOG_GROW_menubar_show = get_theme_mod('BLOG_GROW_menubar_show', 1);
	if (empty($BLOG_GROW_menubar_show)) {
		return;
	}

	$BLOG_GROW_menubarlogo_show = get_theme_mod('BLOG_GROW_menubarlogo_show', 1);
	$BLOG_GROW_mainmenu_show = get_theme_mod('BLOG_GROW_mainmenu_show', 1);
	$BLOG_GROW_menusearch_show = get_theme_mod('BLOG_GROW_menusearch_show', 1);

?>
	<div class="menu-bar ">
		<div class="container">
			<div class="menubar-content">
				<?php
				if ($BLOG_GROW_menubarlogo_show) {
					BLOG_GROW_logo_output();
				}
				?>
				<div class="blog-grow-container menu-inner">
					<?php if ($BLOG_GROW_mainmenu_show) : ?>
						<nav id="site-navigation" class="main-navigation">
							<?php
							wp_nav_menu(array(
								'theme_location' => 'main-menu',
								'menu_id'        => 'blog-grow-menu',
								'menu_class'        => 'blog-grow-menu',
							));
							?>
						</nav><!-- #site-navigation -->
					<?php endif; ?>
					<?php if ($BLOG_GROW_menusearch_show) : ?>
						<div class="serach-show">
							<div class="besearch-icon">
								<a href="#" id="besearch"><i class="fas fa-search"></i></a>
							</div>
							<div id="bspopup" class="soff">
								<div id="affsearch" class="sopen">
									<button data-widget="remove" id="removeClass" class="sclose" type="button">×</button>
									<?php get_search_form(); ?>
									<small class="beshop-cradit"><?php esc_html_e('Blog Grow Theme By', 'blog-grow') ?> <a target="_blank" title="<?php esc_attr_e('Blog Grow Theme', 'blog-grow') ?>" href="<?php echo esc_url('https://in.linkedin.com/in/dhrumil-kumbhani-707b7b179'); ?>"><?php esc_html_e('Dhrumil Kumbhani', 'blog-grow') ?></a></small>
								</div>
							</div>
						</div>
				</div>
			<?php endif; ?>

			</div>

		</div>
	</div>

<?php
}
add_action('BLOG_GROW_main_menu', 'BLOG_GROW_main_menu_output');



// Blog Grow mene style
function BLOG_GROW_mobile_menu_output()
{
?>
	<div id="wsm-menu" class="mobile-menu-bar wsm-menu">
		<div class="container">
			<nav id="mobile-navigation" class="mobile-navigation">
				<button id="mmenu-btn" class="menu-btn" aria-expanded="false">
					<span class="mopen"><?php esc_html_e('Menu', 'blog-grow'); ?></span>
					<span class="mclose"><?php esc_html_e('Close', 'blog-grow'); ?></span>
				</button>
				<?php
				wp_nav_menu(array(
					'theme_location' => 'main-menu',
					'menu_id'        => 'wsm-menu-ul',
					'menu_class'        => 'wsm-menu-has',
				));
				?>
			</nav><!-- #site-navigation -->
		</div>
	</div>

<?php
}
add_action('BLOG_GROW_mobile_menu', 'BLOG_GROW_mobile_menu_output');


function BLOG_GROW_logo_output()
{
	$BLOG_GROW_hide_tagline = get_theme_mod('BLOG_GROW_hide_tagline');
?>
	<div class="head-logo-sec">
		<?php if (has_custom_logo()) : ?>
			<div class="site-branding brand-logo">
				<?php the_custom_logo(); ?>
			</div>
		<?php else : ?>
			<div class="site-branding brand-text">
				<h1 class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a></h1>
				<?php
				$BLOG_GROW_description = get_bloginfo('description', 'display');
				if (($BLOG_GROW_description || is_customize_preview()) && empty($BLOG_GROW_hide_tagline)) :
				?>
					<p class="site-description"><?php echo $BLOG_GROW_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 
												?></p>
				<?php endif; ?>
			</div><!-- .site-branding -->
		<?php endif; ?>
	</div>
<?php
}

function BLOG_GROW_catmenubar_output()
{
?>
	<div class="blgrow-catmenu">
		<ul id="blgrow-catmenu" class="blgrow-catlist">
			<?php wp_list_categories(array(
				'title_li' => __return_false()
			)); ?>
		</ul>
	</div>
<?php
}
add_action('BLOG_GROW_catmenubar', 'BLOG_GROW_catmenubar_output');
