<?php
 
add_filter( 'ppt_blocks_args', 	array('block_listings200', 'data') );
add_action( 'listings200',  	array('block_listings200', 'output' ) );
add_action( 'listings200-css',  array('block_listings200', 'css' ) );
add_action( 'listings200-js',  	array('block_listings200', 'js' ) );

class block_listings200 {

	function __construct(){}		

	public static function data($a){ global $CORE; 
  
		$a['listings200'] = array(
			"name" 	=> "Coupon Display 200",
			"image"	=> "listings200.jpg",
			"cat"	=> "listings",
			"order" => 101,
			"desc" 	=> "", 
			"widget"	=> "ppt-listings",
			"data" 	=> array( ),	
			
			"defaults" => array( ),
			
					
		);		
		
		return $a;
	
	} public static function output(){ global $CORE, $listing_settings, $settings; 
		
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
 
		$settings =  $CORE->LAYOUT("get_block_settings_defaults_new", array("listings", "listings200"  ) );
		   
		 $df = array(
		 	
			"image1" => DEMO_IMGS."?fw=listings100&t=".THEME_KEY,
			 
			"btn1" => 0,
			"btn2" => 0,
           // "card" => "list", 

            "title" => "Featured Coupons",
			"custom" => "featured",

            //"show" => 9
             
		 );
		
		 if(is_array($listing_settings) && !empty($listing_settings)){
		
			 foreach($settings as $h => $j){
				if(isset($listing_settings[$h]) && $listing_settings[$h] != ""){
					$settings[$h] = $listing_settings[$h];
				}
			 }			 
	 
		}else{	 

            foreach($df as $h => $j){
               if(isset($df[$h]) && $df[$h] != ""){
                    $settings[$h] = $df[$h];
               }
            } 
       }
		
		
		if(isset($settings['image1']) && strlen($settings['image1']) > 1){
			 $df['image1'] = $settings['image1'];			
		}
		if(isset($settings['image2']) && strlen($settings['image2']) > 1){
			 $df['image2'] = $settings['image2'];			
		}
		if($settings['perrow'] == ""){ $settings['perrow'] = 3; }
		  

        
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
 
$data = do_shortcode('[LISTINGS nav=0 small=1 show="'.$settings['show'].'" order="'.$settings['order'].'" custom="'.$settings['custom'].'" orderby="'.$settings['orderby'].'" card="'.$settings['card'].'" perrow="'.$settings['perrow'].'"  ]');		

$data1 = do_shortcode('[LISTINGS nav=0 small=1 show="'.$settings['show'].'" order="" custom="new" orderby="" card="'.$settings['card'].'" perrow="'.$settings['perrow'].'"  ]');		
 
$data2 = do_shortcode('[LISTINGS nav=0 small=1 show="'.$settings['show'].'" order="asc" custom="popular" orderby="" card="'.$settings['card'].'" perrow="'.$settings['perrow'].'"  ]');		
 
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
 
	ob_start(); 
	?>
<section class="section-60">
  <div class="container">
    <div class="row d-flex flex-row-reverse">
      <div class="col-md-4 ">
      
      
<a href="<?php echo home_url(); ?>/?s=" data-ppt-image1-link>
       
<div class="grid rounded overflow-hidden position-relative mb-4"> 

<figure class="effect-2 textpos-bleft">
	<img src="<?php echo $df['image1'];  ?>" alt="img" class="lazy" data-ppt-image1>
    <figcaption>
    <div class="wrapper">
        <div class="caption">
        	
            <h4 class="text-light mb-4" data-ppt-image1-txt1><?php echo $CORE->LAYOUT("get_placeholder_text_new", array("short", "search" ) ); ?></h4>
        
            <div class="btn btn-primary btn-rounded-25 text-600" data-ppt-image1-txt><?php echo $CORE->LAYOUT("get_placeholder_text_new", array("button", "start_search" ) ); ?></div>
            
            	
        </div>
    </div>
    </figcaption>
</figure>

</div>
</a>


<hr />


<div class="row mt-n2">
<?php
$taxme = "listing";
$shownum = 12;
if(in_array(THEME_KEY, array("cp","es"))){
	$taxme = "store";
	$shownum = 28;
}

$args =  array('taxonomy' => $taxme, 'orderby'  => 'term_order', 'order' => 'asc', 'hide_empty' => true, 'parent' => 0, 'number' => $shownum ); 
$term_query = new WP_Term_Query( $args );

					
					$categories = array();
					if ( ! empty( $term_query->terms ) ) {
						foreach ( $term_query ->terms as $term ) {
							$categories[] = $term;
						}
					}
 
				     
                     $i=1;
                     foreach ($categories as $category) { 
                     
                             // HIDE PARENT
                             if($category->parent != 0){ continue; } 
                              
                             if(isset($category->term_id) && isset($GLOBALS['CORE_THEME']['category_icon_small_'.$category->term_id]) && $GLOBALS['CORE_THEME']['category_icon_small_'.$category->term_id] != ""   ){
                             $caticon = "fa ".str_replace("&", "&amp;",$GLOBALS['CORE_THEME']['category_icon_small_'.$category->term_id]);
                             }else{
                             $caticon = "fa fa-check";
                             }
							    
                             // LINK 
                             $link = get_term_link($category,$taxme);
							 
							 // ICON
							$image = do_shortcode('[CATEGORYIMAGE term_id="'.$category->term_id.'" pathonly=1 placeholder=1 tax="store"]');
							
							// TITLE
							$title = $CORE->GEO("translation_tax_with_termdata", $category);
                             
                     ?>
                     

<div class="col-6 <?php if($i > 2){ ?> hide-mobile<?php } ?> text-center">
<a href="<?php echo $link; ?>" class="text-dark">
	<div class="image bg-white mt-4 rounded shadow-sm border p-2">
		<div class="position-relative overflow-hidden"  style="<?php if($taxme =="listing"){ ?>height:48px; margin:15px 0px;<?php }else{ ?>height:80px;<?php } ?>">
			<div class="bg-image" data-bg="<?php echo $image; ?>" style="background-size: contain!important;background-repeat: no-repeat;"> </div>
		</div>
	</div>
</a>
<?php if($taxme =="listing"){ ?>
<div class="small opacity-5 mt-2 text-600"><?php echo $title; ?></div>
<?php } ?>
</div>         
                     
 
      
      <?php $i++; } ?>

<?php /* if($taxme =="listing" && $i > 10){ ?>
		<div class="col-12">
<a href="<?php echo _ppt(array('links','categories')); ?>" data-ppt-btn class="btn-lg btn-block my-3"><?php echo __("View More","premiumpress"); ?></a>
	  </div>
<?php } */ ?>
  
 
    </div>

	<hr class="show-mobile">
 
        
        
   
      </div>
      <div class="col-md-8">

<div class="tab-content">
<ul  role="tablist" class="nav nav-tabs nav-pills flex-column flex-sm-row text-center bg-light border-0 rounded-nav mb-3 hide-mobile">

	<li class="nav-item flex-sm-fill m-0">

	<a id="t1-tab" data-toggle="tab" href="#t1" role="tab" aria-controls="t1" aria-selected="true" class="custom nav-link border-0 font-weight-bold active hide-mobile">
			<?php echo __("Featured","premiumpress"); ?>
	</a>
			
	</li>
	<li class="nav-item flex-sm-fill m-0">
	<a id="t2-tab" data-toggle="tab" href="#t2" role="tab" aria-controls="t2" aria-selected="false" class="custom nav-link border-0 hide-mobile">
	<?php echo __("Newly Added","premiumpress"); ?>
	</a>

	</li>
	<li class="nav-item flex-sm-fill m-0">

	<a id="t3-tab" data-toggle="tab" href="#t3" role="tab" aria-controls="t3" aria-selected="false" class="custom nav-link border-0 hide-mobile">
	<?php echo __("Popular","premiumpress"); ?>
	</a>

	</li>  
</ul>

<div id="t1" role="tabpanel" aria-labelledby="t1-tab" class="tab-pane fade active show">
 %data%
</div>
<div id="t2" role="tabpanel" aria-labelledby="t2-tab" class="tab-pane fade">
%data1%
</div>
<div id="t3" role="tabpanel" aria-labelledby="t3-tab" class="tab-pane fade">
%data2%
</div>
</div>
      </div>
    </div>
  </div>
</section>


<?php
$output = ob_get_contents();
ob_end_clean();
echo str_replace("%data1%", $data1, str_replace("%data2%", $data2, str_replace("%data%", $data, ppt_theme_block_output($output, $listing_settings, array("listings", "listings200")))));
	
	}
	
		public static function js(){
		return "";
		}	
		 
		public static function css(){
		ob_start();
		?>
<style>

figure.effect-2 figcaption::before {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: 10px;
    left: 10px;
    border: 1px solid #fff;
    content: '';
    -webkit-transition: opacity .35s,-webkit-transform .35s;
    transition: opacity .35s,transform .35s;
}

.nav-pills .nav-link.active, .nav-pills .show>.nav-link {
    color: #000;
    background-color: #fff !important;
	border: 1px solid var(--ppt-border-grey)!important;
	box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .035) !important;
}
.nav-pills .nav-link {
    border-radius: .25rem;
    color: #808080;
    font-weight: 600;
}
</style>
<?php	
		$output = ob_get_contents();
		ob_end_clean();
		echo $output;
		}	
  
}

?>