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

class block_listings_carousel1 {

	function __construct(){}		

	public static function data($a){ global $CORE; 
  
		$a['listings_carousel1'] = array(
			"name" 	=> "Carousel",
			"image"	=> "listings_carousel1.jpg",
			"cat"	=> "listings",
			"order" => 1.2,
			"desc" 	=> "", 
			"widget"	=> "ppt-listings",
			"data" 	=> array( ), 
			"defaults" => array( ), 
 
					
		);		
		
		return $a;
	
	} public static function output(){ global $CORE, $listing_settings, $settings; 
	
		// ALL DEFAULT FIELDS
        $df = ppt_theme_blocks_defaults("listings"); 
		  
		// APPLY CUSTOM CHANGES 
		$cc = array(

            "tax" 		=> "listing",
            "btn_show" 	=> 0,

            "btn_txt" 	=> $CORE->LAYOUT("get_placeholder_text_new", array("short", "more" ) ),

            "title" 	=> $CORE->LAYOUT("get_placeholder_text_new", array("short", "featured_listings" ) ),         
			"subtitle" 		=> "Quidam officiis similique sea ei, vel tollit indoctum efficiendi.",


            "perrow" 	=> 4,
            "show" 		=> 4,
		 );
		 

		$df = array_merge($df, $cc);
		
		
		// 1. ELEMENTOR
		if(!empty($listing_settings)){
			foreach($df as $k => $v){				
				if(isset($listing_settings[$k]) && $listing_settings[$k] != "" ){
					$df[$k] = $listing_settings[$k];
				}
			}
			
		// 2. HOME DESIGNS		
		}else{	
			 
		 	$settings =   $CORE->LAYOUT("get_block_settings_defaults_new", array("listings", "listings_carousel1"  ) );
		 
		 	foreach($df as $h => $j){
				if(isset($settings[$h]) && $settings[$h] != ""){
					$df[$h] = $settings[$h];
				}
			 } 
		}
		 
		
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
 
 
$data = do_shortcode('[LISTINGS nav=0 carousel=1 small=1 show="'.$df['show'].'" order="'.$df['order'].'" custom="'.$df['custom'].'" orderby="'.$df['orderby'].'" card="'.$df['card'].'" perrow="'.$df['perrow'].'"  ]');	

if($df['show'] < 5){
$data = str_replace("mb-4","",$data);
}

 
ob_start(); ?>
<section class="section-20">
    
<div class="container"><div class="row">



<?php if(strlen($df['title']) > 2){ ?>
<div class="col-12 mb-3">
<div class="d-md-flex justify-content-between align-items-center">
	<div>	
		<h2 class="mb-1" data-ppt-title><?php echo $df['title']; ?></h2>
		<?php if(strlen($df['subtitle']) > 2){ ?><div class="mb-3" data-ppt-subtitle><?php echo $df['subtitle']; ?></div><?php } ?>
	</div>

	<?php if($df['btn_show'] == "1"){ ?>
	<div class="justify-content-center">
		<a href="<?php echo home_url(); ?>/?s=" data-ppt-btn data-ppt-btn-link class="btn-system btn-rounded-25 btn-lg hide-mobile"><?php echo $df['btn_txt']; ?></a>
	</div>
	<?php } ?>
</div>
</div>
<?php } ?>
	
 

<div class="col-12">
<div  class="owl-carousel owl-theme " data-1000="4" data-600="4" data-1200="4" <?php if(!in_array(THEME_KEY,array("es","da"))){ ?>data-0="2"<?php } ?>>%data%</div>
</div>

</div></div>

</section>
<?php $output = ob_get_contents();
ob_end_clean();
echo str_replace("%data%", $data, ppt_theme_block_output($output, $listing_settings, array("listings", "listings_carousel1")));
	
	}
	
		public static function js(){
		return "";
		}	
		 
		public static function css(){
		return "";
		 }	
}

?>