<?php

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


function colorful_blog_header_logo_output()
{
	$colorful_blog_mlogo_show = get_theme_mod('colorful_blog_mlogo_show', 1);
	$colorful_blog_search_show = get_theme_mod('colorful_blog_search_show', 1);
	$colorful_blog_header_social_show = get_theme_mod('colorful_blog_header_social_show', 1);
	$colorful_blog_hfacebook_link = get_theme_mod('colorful_blog_hfacebook_link');
	$colorful_blog_htwitter_link = get_theme_mod('colorful_blog_htwitter_link');
	$colorful_blog_hlinkedin_link = get_theme_mod('colorful_blog_hlinkedin_link');
	$colorful_blog_hyoutube_link = get_theme_mod('colorful_blog_hyoutube_link');
	$colorful_blog_hpinterest_link = get_theme_mod('colorful_blog_hpinterest_link');
	$colorful_blog_hinstagram_link = get_theme_mod('colorful_blog_hinstagram_link');


?>
	<div class="header-top">
		<div class="container">
			<div class="header-top-all-content">
				<div class="hm-row">
					<div class="hmr-logo">
						<?php
						if ($colorful_blog_mlogo_show) {
							colorful_blog_logo_output();
						}
						?>
					</div>
					<div class="hmr-ss">
						<?php if ($colorful_blog_search_show) : ?>
							<div class="hmr-ss1">
								<div class="npaper search-box">
									<?php echo get_search_form(); ?>

								</div>
							</div>
						<?php endif; ?>
						<?php if ($colorful_blog_header_social_show) : ?>
							<div class="hmr-ss2">
								<div class="header-links">
									<div class="social-links">
										<?php if ($colorful_blog_hfacebook_link) : ?>
											<a href="<?php echo esc_url($colorful_blog_hfacebook_link); ?>"><i class="fab fa-facebook-f"></i></a>
										<?php endif; ?>
										<?php if ($colorful_blog_htwitter_link) : ?>
											<a href="<?php echo esc_url($colorful_blog_htwitter_link); ?>"><i class="fab fa-twitter"></i></a>
										<?php endif; ?>
										<?php if ($colorful_blog_hlinkedin_link) : ?>
											<a href="<?php echo esc_url($colorful_blog_hlinkedin_link); ?>"><i class="fab fa-linkedin-in"></i></a>
										<?php endif; ?>
										<?php if ($colorful_blog_hyoutube_link) : ?>
											<a href="<?php echo esc_url($colorful_blog_hyoutube_link); ?>"><i class="fab fa-youtube"></i></a>
										<?php endif; ?>
										<?php if ($colorful_blog_hpinterest_link) : ?>
											<a href="<?php echo esc_url($colorful_blog_hpinterest_link); ?>"><i class="fab fa-pinterest"></i></a>
										<?php endif; ?>
										<?php if ($colorful_blog_hinstagram_link) : ?>
											<a href="<?php echo esc_url($colorful_blog_hinstagram_link); ?>"><i class="fab fa-instagram"></i></a>
										<?php endif; ?>
									</div>
								</div>
							</div>
						<?php endif; ?>

					</div>
				</div>
			</div>
		</div>
	</div>
<?php
}
add_action('colorful_blog_header_logo', 'colorful_blog_header_logo_output');

// Colorful Blog mene style
function colorful_blog_main_menu_output()
{
	$colorful_blog_menubar_show = get_theme_mod('colorful_blog_menubar_show', 1);
	if (empty($colorful_blog_menubar_show)) {
		return;
	}

	$colorful_blog_menubarlogo_show = get_theme_mod('colorful_blog_menubarlogo_show', 1);
	$colorful_blog_mainmenu_show = get_theme_mod('colorful_blog_mainmenu_show', 1);
	$colorful_blog_menusearch_show = get_theme_mod('colorful_blog_menusearch_show', 1);

?>
	<div class="menu-bar ">
		<div class="container">
			<div class="menubar-content">
				<?php
				if ($colorful_blog_menubarlogo_show) {
					colorful_blog_logo_output();
				}
				?>
				<div class="Colorful-mmenu menu-inner">
					<?php if ($colorful_blog_mainmenu_show) : ?>
						<nav id="site-navigation" class="main-navigation">
							<?php
							wp_nav_menu(array(
								'theme_location' => 'main-menu',
								'menu_id'        => 'colorful-blog-menu',
								'menu_class'        => 'colorful-blog-menu',
								'fallback_cb'    => 'colorful_blog_fallback_menu',
							));
							?>
						</nav><!-- #site-navigation -->
					<?php endif; ?>
					<?php if ($colorful_blog_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">
									<?php get_search_form(); ?>
									<small class="beshop-cradit"><?php esc_html_e('Colorful Blog Theme By', 'colorful-blog') ?> <a target="_blank" title="<?php esc_attr_e('Colorful Blog Theme', 'colorful-blog') ?>" href="<?php echo esc_url('https://wpthemespace.com/product/beshop/'); ?>"><?php esc_html_e('Wp Theme Space', 'colorful-blog') ?></a></small>
									<button data-widget="remove" id="removeClass" class="sclose" type="button">×</button>

								</div>
							</div>
						</div>
				</div>
			<?php endif; ?>

			</div>

		</div>
	</div>

<?php
}
add_action('colorful_blog_main_menu', 'colorful_blog_main_menu_output');



// Colorful Blog mene style
function colorful_blog_mobile_menu_output()
{
?>
	<div id="wsm-menu" class="mobile-menu-bar wsm-menu">
		<div class="container">
			<button id="mmenu-btn" class="menu-btn" aria-expanded="false" aria-controls="mobile-navigation" aria-label="<?php esc_attr_e('Toggle mobile menu', 'colorful-blog'); ?>">
				<span class="menu-icon"></span>
				<span class="mopen"><?php esc_html_e('Menu', 'colorful-blog'); ?></span>
				<span class="mclose"><?php esc_html_e('Close', 'colorful-blog'); ?></span>
			</button>
			<nav id="mobile-navigation" class="mobile-navigation" aria-label="<?php esc_attr_e('Mobile Navigation', 'colorful-blog'); ?>">
				<div class="mobile-menu-header">
					<span class="menu-title"><?php esc_html_e('Menu', 'colorful-blog'); ?></span>
					<button type="button" class="mobile-menu-close" id="mobile-menu-close" aria-label="<?php esc_attr_e('Close menu', 'colorful-blog'); ?>">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<?php
				wp_nav_menu(array(
					'theme_location' => 'main-menu',
					'menu_id'        => 'wsm-menu-ul',
					'menu_class'        => 'wsm-menu-has',
					'fallback_cb'    => 'colorful_blog_fallback_mobile_menu',
				));
				?>
			</nav><!-- #site-navigation -->
		</div>
	</div>
	<div class="mobile-menu-overlay" aria-hidden="true"></div>

<?php
}
add_action('colorful_blog_mobile_menu', 'colorful_blog_mobile_menu_output');


function colorful_blog_logo_output()
{
	$colorful_blog_hide_tagline = get_theme_mod('colorful_blog_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: ?>
			<?php
			if (display_header_text() == true || (display_header_text() == true && is_customize_preview())) : ?>
				<div class="site-branding brand-text">
					<?php if (display_header_text() == true || (display_header_text() == true && is_customize_preview())) : ?>
						<h1 class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a></h1>
						<?php
						$colorful_blog_description = get_bloginfo('description', 'display');
						if (($colorful_blog_description || is_customize_preview()) && empty($colorful_blog_hide_tagline)) :
						?>
							<p class="site-description"><?php echo $colorful_blog_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 
														?></p>
						<?php endif; ?>
					<?php endif; ?>

				</div><!-- .site-branding -->
			<?php endif; ?>
		<?php endif; ?>
	</div>
<?php
}
