<?php
/* 
Template Name: Template - Popular Apps
*/
global $opt_themes;
$paged_categorie_apps		= (get_query_var('paged')) ? get_query_var('paged') : 1;
$cat_ID_categorie_apps		= $opt_themes['categorie_tops_apps'];
$limited_categorie_apps		= $opt_themes['limit_categorie'];
$today						= date('Y-m-d'); 				
$popular_ranges				= $opt_themes['popular_ranges']; 
$one_week_ago				= date('Y-m-d', strtotime($today.' - '.$popular_ranges));
get_header();
?>


	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	<div id="content" class="site-content">
	<div class="container py-1">
	<div class=" mb-3" style="max-width:850px;"> 
	<ul id="breadcrumb" class="breadcrumb">
	<li class="breadcrumb-item home"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>"><?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?></a></li>
	<?php printf( __( '%s', THEMES_NAMES ), '<li class="breadcrumb-item">' . get_the_title() . '</li>' ); ?> 
	</ul>
	</div>
	</div>
	<div class="container">	
	<div class="row">
	<?php 
	do_action('main_home');
	do_action('section_cust');
	?>
	<div class="row">
	<?php
	break; 	
	case 'modyolo':
	?>
	
	<div id="content" class="site-content">
	<div class="container py-1 ">
	<div class=" mb-3" > 	
	<ul id="breadcrumb" class="breadcrumb">
	<li class="breadcrumb-item home"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>"><?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?></a></li>
	<?php printf( __( '%s', THEMES_NAMES ), '<li class="breadcrumb-item">' . get_the_title() . '</li>' ); ?> 
	</ul>
	</div>
	</div>
	<div class="container">	
	<div class="row">
	<?php 
	do_action('main_home');
	do_action('section_cust');
	?>
	<div class="row">
	
	<?php
	break; 	
	case 'reborn':
	?>
	<div id="content" class="site-content">
	<div class="container py-1">
	<div class=" mb-3" style="max-width:850px;"> 
	<ul id="breadcrumb" class="breadcrumb">
	<li class="breadcrumb-item home"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>"><?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?></a></li>
	<?php printf( __( '%s', THEMES_NAMES ), '<li class="breadcrumb-item">' . get_the_title() . '</li>' ); ?> 
	</ul>
	</div>
	</div>
	<div class="container">	
	<div class="row">
	<?php 
	do_action('main_home');
	do_action('section_cust');
	?>
	<div class="row">
	
	<?php
	break; 	
	case 'liteapks':
	?>
	<div class="py-2"> 
	
	<div class="container py-1">
	<div class=" mb-3" style="max-width:850px;"> 
	<ul id="breadcrumb" class="breadcrumb">
	<li class="breadcrumb-item home"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>"><?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?></a></li>
	<?php printf( __( '%s', THEMES_NAMES ), '<li class="breadcrumb-item">' . get_the_title() . '</li>' ); ?> 
	</ul>
	</div>
	</div>
	 
	</div>
	<div class="container"> 
	<h2 class="font-weight-bold mb-4"><?php the_title(); ?></h2> 
	<div class="row">
	
	<?php	
	break; 
	default:
	?>
	<div id="content" class="site-content">
	<div class="container py-1">
	<div class=" mb-3" style="max-width:850px;"> 
	<ul id="breadcrumb" class="breadcrumb">
	<li class="breadcrumb-item home"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>"><?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?></a></li>
	<?php printf( __( '%s', THEMES_NAMES ), '<li class="breadcrumb-item">' . get_the_title() . '</li>' ); ?> 
	</ul>
	</div>
	<div class="container">	
	<div class="row">
	<?php 
	do_action('main_home');
	do_action('section_cust');
	?>
	<div class="row">
	
	<?php
	break; 
	}
	?>
	
	<?php
	query_posts( array(	
	'date_query'	=> array(
	 array(
	 'before'	=> $today,
	 'after'	=> $one_week_ago,
	 'inclusive'	=> true
	 ),
	),
	'paged'	=> $paged_categorie_apps, 	
	'cat'	=> $cat_ID_categorie_apps,
	'posts_per_page'	=> $limited_categorie_apps,
	'meta_key'	=> 'post_views_count', 
	'orderby'	=> 'meta_value_num', 
	'order'	=> 'DESC' 
	)
	);
	
	if (have_posts()) : while (have_posts()) : the_post();	
	
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	get_template_part('loop/item.mdr'); 
	break; 
	
	case 'modyolo':
	get_template_part('loop/item.mdy'); 
	break; 
	
	case 'reborn':
	get_template_part('loop/item.reborn');
	break; 
	
	case 'liteapks':
	get_template_part('loop/item.liteapks');
	break; 
	
	default:
	get_template_part('loop/item.mdr'); 
	break;
	}	
	endwhile; 
	wp_reset_postdata();
	endif; ?>
	
	
	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	</div>
	</section>
	<?php 
	get_template_part('include/nav'); 
	?>
	</main>
	<?php do_action('sidebar'); ?>
	</div>
	</div>
	</div>
	<?php
	break; 	
	case 'modyolo':
	?>
	</div>
	</section>
	<?php 
	get_template_part('include/nav'); 
	?>
	</main>
	<?php do_action('sidebar'); ?>
	
	</div>
	</div>
	<?php
	break; 	
	case 'reborn':
	?>
	</div>
	</section>
	<?php 
	get_template_part('include/nav'); 
	?>
	</main>
	<?php do_action('sidebar'); ?>
	
	</div>
	</div>
	<?php
	break; 	
	case 'liteapks':
	?>
	</div>
	</section>
	<?php get_template_part('include/nav'); ?>
	</div>
	<?php	
	break; 
	default:
	?>
	</div>
	</section>
	<?php 
	get_template_part('include/nav'); 
	?>
	</main>
	<?php do_action('sidebar'); ?>
	
	</div>
	</div>
	<?php
	break; 
	}
	?>
	
<?php
get_footer(); 