<?php
/*Template Name: Home*/


get_header();

$theme_options = omag_theme_options();

$sidebar_class = '';

if( 'left' == $theme_options['sidebar'] ) {
  $sidebar_class = 'left-sidebar';
} else {
  $sidebar_class = '';
}

$grid_class= '';

if( 'grid' == $theme_options['post_view'] ){
	$grid_class= 'grid-view';	
}

?>


<div class="container mb-view-container">

 	<?php
 	$theme_options = omag_theme_options();
 	if( 1 === $theme_options['enable_hot_news'] ){

 		$heading = $theme_options['hot_news_title'];
 		$hot_news = $theme_options['hot_news_cat'];
 		$hot_news_count = $theme_options['hot_news_count'];
 		?>
 		<div class="row">
 			<div class="hot-news">
 				<div class="hot-title float-left"> <?php echo esc_html( $heading ); ?> </div>

 				<?php
 				if(!empty( $hot_news )){

 					$hot_news_args = array( 
 						'cat'             => absint( $hot_news ), 
 						'post_status'     => 'publish', 
 						'posts_per_page'  => absint( $hot_news_count ),
 						'ignore_sticky_posts' => 1,
 					);

 				} else{

 					$hot_news_args = array( 'post_status' => 'publish', 'posts_per_page' => absint( $hot_news_count ), 'ignore_sticky_posts' => 1, );

 				} 

 				$hot_news_query = new WP_Query( $hot_news_args ); 

 				if ( $hot_news_query->have_posts() ) {

 					?>
 					<div id="spcl-news" class="owl-carousel owl-theme float-right">

 						<?php
 						while ( $hot_news_query->have_posts() ) : $hot_news_query->the_post();

 							?>

 							<div class="item">
 								<a href="<?php the_permalink(); ?>">
 									<?php the_title(); ?>
 								</a>
 							</div>

 							<?php 
 						endwhile;
 						wp_reset_postdata(); 
 						?>

 					</div>

 					<?php } ?>

 					<div class="clearfix"></div>
 				</div>
 			</div>

 			<?php } ?>

 			<!-- Banner -->

 			<div class="banner">
 				<div class="row">

 					<?php 
 					if( 1 === $theme_options['slider_enable']) {
 						do_action( 'omag_slideshow' );
 					}

 					if( 1 === $theme_options['featured_news_enable']) {
 						if( 'secondary' == $theme_options['featured_news_layout']) {
 							do_action( 'omag_featured_news_secondary' );
 						} else {
 							do_action( 'omag_featured_news_primary' );
 						}
 					}
 					?>

 				</div>
 			</div>

 			<!-- Banner End -->

 			<!-- News start -->

 			<div class="row news-cover">

 				<div class="col-lg-9 <?php echo esc_attr( $sidebar_class ); ?> <?php echo esc_attr( $grid_class ); ?>" id="right">

 					<div class="site">
 						<div class="site-inner">

 							<?php 

 							if ( is_active_sidebar( 'omag-home-page-widget-area' ) ) :

 								dynamic_sidebar( 'omag-home-page-widget-area' ); 

 							else:

 								if ( current_user_can( 'edit_theme_options' ) ) : ?>
 								<div class="site-content">
 									<p>
 										<?php echo esc_html__( 'Widgets of Home Page Widget Area will be displayed here. Go to Appearance =>Widgets in admin panel to add widgets. All these widgets will be replaced when you start adding widgets.', 'omag' ); ?>
 									</p>
 								</div>

 								<?php 

 							endif;

 							endif; ?>

 						</div>
 					</div>
 				</div>

 				<div class="col-lg-3" id="left">
 					<div class="sidebar">
 						<section>
 							<?php get_sidebar(); ?>
 						</section>
 					</div>
 				</div>

 			</div>

 		<!-- News end -->
 	</div>
 	<!-- Content end -->

<?php get_footer(); ?>
