<?php
/* 
* Theme: PREMIUMPRESS CORE FRAMEWORK FILE
* Url: www.premiumpress.com
* Author: Mark Fail
*
* THIS FILE WILL BE UPDATED WITH EVERY UPDATE
* IF YOU WANT TO MODIFY THIS FILE, CREATE A CHILD THEME
*
* http://codex.wordpress.org/Child_Themes
*/
if (!defined('THEME_VERSION')) {	header('HTTP/1.0 403 Forbidden'); exit; }

global $CORE;

// GET HOME PAGE CUSTOM DATA
$HDATA = $GLOBALS['CORE_THEME']['hdata'];
 
// HEADER
get_header($CORE->pageswitch()); 

?>
<?php if(!isset($GLOBALS['CORE_THEME']['home_section1']) || (isset($GLOBALS['CORE_THEME']['home_section1']) && $GLOBALS['CORE_THEME']['home_section1'] == '1' ) ){  ?>

<?php if(isset($GLOBALS['CORE_THEME']['homesliderid']) && $GLOBALS['CORE_THEME']['homesliderid'] != "" && $GLOBALS['CORE_THEME']['homeslider'] == 1 ){  

echo do_shortcode(stripslashes("[rev_slider ".$GLOBALS['CORE_THEME']['homesliderid']."]")); 

}else{ ?>

<div class="jumbostyle1 cols<?php echo $GLOBALS['CORE_THEME']['layout_columns']['homepage']; ?>" <?php if(isset($HDATA['j1']['img']) && $HDATA['j1']['img'] != ""){ echo 'style="background-image: url(\''.$HDATA['j1']['img'].'\'); background-size: cover;"'; } ?>>

    <div class="jumbotron"  style="margin-bottom:0px;">
    
    <div class="inner text-center">
        
            <h1><?php echo stripslashes($HDATA['j1']['title1']); ?></h1>
            
            <h2><?php echo stripslashes($HDATA['j1']['title2']); ?></h2>
            
            <?php echo wpautop(stripslashes($HDATA['j1']['title3'])); ?> 
        
          
          
<form action="<?php echo get_home_url(); ?>/" method="get" class="searchform">
<div class="wrap clearfix">
	<div class="inner">
    <div class="sb" onclick="jQuery('.searchform').submit();"><i class="glyphicon glyphicon-search"></i></div>
    <input type="search" name="s" placeholder="<?php echo $CORE->_e(array('button','11','flag_noedit')); ?>">
    
    <div class="popular"><?php echo $CORE->_e(array('homepage','13')); ?>: <?php echo $CORE->POPULARSEARCHES(6); ?></div>
    </div>
    
</div>
</form>	
		 
		 
    </div>
     
    </div>

</div>

<?php } ?>

<?php } ?>


 



<?php if(!isset($GLOBALS['CORE_THEME']['home_section3']) || (isset($GLOBALS['CORE_THEME']['home_section3']) && $GLOBALS['CORE_THEME']['home_section3'] == '1' ) ){  ?>
 
<div class="tabstyle1"> 

  <ul class="nav nav-tabs hidden-xs" role="tablist">
  
    <li role="presentation" class="active"><a href="#t1" aria-controls="t1" role="tab" data-toggle="tab"><?php echo $CORE->_e(array('homepage','2')); ?></a></li>
    
    <li role="presentation"><a href="#t2" aria-controls="t2" role="tab" data-toggle="tab"><?php echo $CORE->_e(array('homepage','16')); ?></a></li>
    
    <li role="presentation"><a href="#t3" aria-controls="t3" role="tab" data-toggle="tab"><?php echo $CORE->_e(array('homepage','17')); ?></a></li>

   <li role="presentation"><a href="#t4" aria-controls="t4" role="tab" data-toggle="tab"><?php echo $CORE->_e(array('homepage','18')); ?></a></li>

  </ul>

</div>

<?php $GLOBALS['item_class_size'] = "col-md-3 col-sm-4 col-xs-6 "; ?> 
<div class="tab-content" style="margin-top:20px;">
  
    <div role="tabpanel" class="tab-pane active" id="t1">   
	
        <div class="row wlt_search_results grid_style" >
        <?php echo do_shortcode('[LISTINGS dataonly=1 show=8 custom="new"]'); ?> 
        </div>
    
    </div>
    <div role="tabpanel" class="tab-pane" id="t2">   
	
        <div class="row wlt_search_results grid_style">
        <?php echo do_shortcode('[LISTINGS dataonly=1 show=8 custom="random"]'); ?> 
        </div>
    
    </div>
    <div role="tabpanel" class="tab-pane" id="t3">   
	
        <div class="row wlt_search_results grid_style">
        <?php echo do_shortcode('[LISTINGS dataonly=1 show=8 custom="popular"]'); ?> 
        </div>
    
    </div>
    <div role="tabpanel" class="tab-pane" id="t4">   
	
        <div class="row wlt_search_results grid_style">
        <?php echo do_shortcode('[LISTINGS dataonly=1 show=8 custom="featured"]'); ?> 
        </div>
    
    </div>

</div>
<?php unset($GLOBALS['item_class_size']); ?>
<script>
jQuery(document).ready(function() { 
 
	setTimeout(function(){equalheight('.grid_style .thumbnail');  }, 2000); 

	jQuery('.nav-tabs a').on( "click", function() {
	setTimeout(function(){equalheight('.grid_style .thumbnail');  }, 1000); 
	});

});
 </script>
<?php } ?> 
 

<?php if(!isset($GLOBALS['CORE_THEME']['home_section4']) || (isset($GLOBALS['CORE_THEME']['home_section4']) && $GLOBALS['CORE_THEME']['home_section4'] == '1' ) ){  ?>

<div class="catstyle4 clearfix">
 
<?php
		$i = 0; $n = 1;
		$args = array(
			  'taxonomy'     => THEME_TAXONOMY,
			  'orderby'      => 'count',
			  'order'		=> 'desc',
			  'show_count'   => 0,
			  'pad_counts'   => 1,
			  'hierarchical' => 0,
			  'title_li'     => '',
			  'hide_empty'   => 0,
			 
		);
$categories = get_categories($args);

foreach ($categories as $category) { 

		// HIDE PARENT
		if($category->parent != 0){ continue; }
		
		// IMAGE
		if(isset($category->term_id) && isset($GLOBALS['CORE_THEME']['category_icon_'.$category->term_id])   ){
		$image = $GLOBALS['CORE_THEME']['category_icon_'.$category->term_id];
		}else{
		$image = get_template_directory_uri()."/framework/img/demo/noimage.png";
		}
		$image = str_replace("&","&nbsp;",$image);
		
		// LINK 
		$link = get_term_link($category);

?>

 
<div class="col-md-3 list-group">

  <a href="<?php echo $link; ?>" class="list-group-item active">
    <?php echo $category->name; ?>
    <span class="pull-right">(<?php echo $category->count; ?>)</span>
  </a> 
    
  <?php
	
	// CHECK FOR SUB CATEGORIES
	$subcats = 4;
	$s = wp_list_categories("echo=0&taxonomy=".THEME_TAXONOMY."&title_li=&hierarchical=0&hide_empty=0&child_of=".$category->term_id);
	$showf = explode("</li>",$s);
	if(strlen($s) > 25 && strpos($s, "No categories") === false){
		$ss = 0;
		foreach($showf as $subcat){ 
			if($ss > $subcats){ continue; }
			
			$subcat = preg_replace('%<li class=".*">|</?ul>%U', '', $subcat);
			echo str_replace("<a", "<a class='list-group-item'", $subcat );
			//echo str_replace("/li>","/a>",str_replace("<li", "<a class='list-group-item'", trim($subcat)));
			$ss++;
		}  
	}	
	?>
    
</div>
 
<?php } ?> 
 
</div>

<?php } ?>

<?php get_footer($CORE->pageswitch()); ?>