<?php
/**
 * The file for header all actions
 *
 *
 * @package NewsBox Plus
 */

function newsbox_plus_header_menu_output(){
?>
			<div class="menu-bar text-center">
				<div class="container">
					<div class="newsbox-plus-container menu-inner">
						<nav id="site-navigation" class="main-navigation">
							<?php
								wp_nav_menu( array(
									'theme_location' => 'main-menu',
									'menu_id'        => 'newsbox-plus-menu',
									'menu_class'        => 'newsbox-plus-menu',
								) );
							?>
						</nav><!-- #site-navigation -->	
					</div>
				</div>
			</div>

<?php
}
add_action('newsbox_plus_header_menu','newsbox_plus_header_menu_output');

function newsbox_plus_header_logo_output(){
?>

	<div class="newsbox-plus-logo-section">
		<div class="container">
				<div class="head-logo-sec">
					<?php if(has_custom_logo()): ?>
						<div class="site-branding brand-logo">
							<?php
								the_custom_logo();
							?>
						</div>
					<?php endif; ?>
					<?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
								$newsbox_plus_description = get_bloginfo( 'description', 'display' );
								if ( $newsbox_plus_description || is_customize_preview() ) :
									?>
									<p class="site-description"><?php echo $newsbox_plus_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
								<?php endif; ?>	
							<?php endif; ?>	

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

<?php
}
add_action('newsbox_plus_header_logo','newsbox_plus_header_logo_output');

// News Ticker action
function newsbox_plus_news_ticker_output(){
	$newsbox_plus_latest_news = get_theme_mod( 'newsbox_plus_latest_news', 1 );
	if(is_page() || empty($newsbox_plus_latest_news) ){
		return;
	}
?>
	<div class="header-bottom latest-news-bar shadow">
			<div class="container">
				<div class="nbarmain">
						<div class="news-latest"> 
							<?php esc_html_e( 'Latest News','newsbox-plus' ); ?>
						</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>
			</div>
	</div>

<?php
}
add_action('newsbox_plus_news_ticker','newsbox_plus_news_ticker_output');
