<?php 
get_header(); 

global $opt_themes, $wp_query, $category;
$category	= get_category( get_query_var( 'cat' ) );
$paged				= (get_query_var('paged')) ? get_query_var('paged') : 1;
$current_cat_id  	= get_query_var('cat');
$cat_ID				= $current_cat_id;
$limited			= $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));

$current_cats 		= get_queried_object();
//echo $current_cats->name; 
$subcategories 		= get_categories(array( 'parent' => $current_cats->term_id ) );
$subcat_noparent	= get_categories(array( 'parent' => '' )); 
if ( $subcategories === FALSE or $subcategories == '' ) $subcategories = $subcat_noparent;
?>

<div id="content" class="site-content">

	
	<div class="container">
	 
	<ul id="breadcrumb" class="
	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	pt-1 pb-3 breadcrumb
	<?php
	break; 	
	case 'modyolo':
	?>
	pt-1 pb-3 breadcrumb
	<?php
	break; 	
	case 'reborn':
	?>
	pt-1 pb-3 breadcrumb
	<?php
	break; 	
	case 'liteapks':
	?>
	 breadcrumb
	<?php	
	break; 
	default:
	?>
	pt-1 pb-3 breadcrumb
	<?php
	break; 
	}
	?>"  itemscope='itemscope' itemtype='https://schema.org/BreadcrumbList'  <?php
	if ($opt_themes['ex_themes_breadcrumbs_activate_']) { ?>style="display:none"<?php } ?>>
	<li class="breadcrumb-item home" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem">
	<a href="<?php echo get_bloginfo("home"); ?>" title="<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>"> <?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>
	<meta itemprop='item' content='<?php echo get_bloginfo("home"); ?>' />
	<meta itemprop='name' content='<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>' />
	<meta itemprop='position' content='1' />
	</a>
	</li>
	<li class="breadcrumb-item active">
	<?php single_cat_title(); ?>
	</li>
	</ul>
 
	
	
	<?php switch ($opt_themes['themes_styles']) { case 'liteapks': ?>
	<h1 class="h2 font-weight-bold mb-4"><?php single_cat_title(); ?></h1>
	<?php if($category->category_description){?>
	<div class="p-2 text-body bg-white mb-4">
	<?php echo $category->category_description; ?>
	</div>
	<?php } ?>
	<?php break; } ?>

	<div class="row">
	
	
	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>	
	<?php 
	do_action('main_home');
	do_action('section_arch');
	?> 
	<div class="mb-4">
	<?php ex_themes_banner_header_ads_(); ?>
	</div>
	<div class="row">	
	<?php
	break; 	
	case 'modyolo':
	?>
	<?php 
	do_action('main_home');
	do_action('section_arch');
	?>
	<?php if($category->category_description){?>
	<div class="p-2 text-body bg-white mb-4">
	<?php echo $category->category_description; ?>
	</div>
	<?php } ?>
	<div class="mb-4">
	<?php ex_themes_banner_header_ads_(); ?>
	</div>
	<div class="row">	
	
	<?php
	break; 	
	case 'reborn':
	?>
	<?php 
	do_action('main_home');
	do_action('section_arch');
	?>
	<div class="mb-4">
	<?php ex_themes_banner_header_ads_(); ?>
	</div>
	<div class="row">	
	
	<?php
	break; 	
	case 'liteapks':
	?>
	
	<?php	
	break; 
	default:
	?>
	<?php 
	do_action('main_home');
	do_action('section_arch');
	?>
	<div class="mb-4">
	<?php ex_themes_banner_header_ads_(); ?>
	</div>
	
	<div class="row">	
	
	<?php
	break; 
	}
	?> 
	<?php
	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;
	?>
	
	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	</div>
	<?php
	sp_close_section();
	get_template_part('include/nav'); 
	sp_close_main();
	?> 	 

	<!--sidebar-->	
	<?php do_action('sidebar'); ?> 
	<!--sidebar-->
	<?php
	break; 	
	case 'modyolo':
	?>
	</div>
	<?php
	sp_close_section();
	get_template_part('include/nav'); 
	sp_close_main();
	?> 	 

	<!--sidebar-->	
	<?php do_action('sidebar'); ?> 
	<!--sidebar-->
	<?php
	break; 	
	case 'reborn':
	?>
	</div>
	<?php
	sp_close_section();
	get_template_part('include/nav'); 
	sp_close_main();
	?> 	 

	<!--sidebar-->	
	<?php do_action('sidebar'); ?> 
	<!--sidebar-->
	<?php
	break; 	
	case 'liteapks':
	?> 
	<?php	
	break; 
	default:
	?>
	</div>
	<?php
	sp_close_section();
	get_template_part('include/nav'); 
	sp_close_main();
	?> 	 

	<!--sidebar-->	
	<?php do_action('sidebar'); ?> 
	<!--sidebar-->
	<?php
	break; 
	}
	?>
	
	</div>
	<?php switch ($opt_themes['themes_styles']) { case 'liteapks': ?>
	<?php get_template_part('include/nav'); ?>
	<?php break; } ?>
	 
	
	<?php 
	if($subcategories){	
	?>	
	<main id="primary" class="content-area">
	<section class="py-4">
	<div class="row mb-4">	
	<?php foreach($subcategories as $cat){
	$catLink 		= get_term_link($cat->term_id);  
	?>
	<div class="col-4 col-md-3 col-lg-2 col-xl-2 mb-3">
	<a class="h6 font-weight-semibold text-truncate text-center text-body bg-white border rounded shadow-sm d-block p-2 mb-0" href="<?php echo $catLink; ?>" title="<?php echo $cat->name; ?>"><?php echo $cat->name; ?></a>
	</div>	
	<?php } ?>	
	</div>
	</section>
	</main>
	<?php } ?>    
	
	</div>
	
	
</div> 

<?php
get_footer(); 