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

class block_listings_carousel_buttons {

	function __construct(){}		

	public static function data($a){ global $CORE; 
  
		$a['listings_carousel_buttons'] = array(
			"name" 	=> "Carousel Buttons",
			"image"	=> "listings_carousel_buttons.jpg",
			"cat"	=> "listings",
			"order" => 1.3,
			"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_carousel_buttons"  ) );
		 
		 	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>

	<div> <a class="btn bg-white btn-sm text-muted prev px-2 mt-2 border"><span class="fa fa-angle-left px-1"></span></a> <a class="btn bg-white btn-sm text-muted next px-2 mt-2 border"><span class="fa fa-angle-right px-1"></span></a> </div>
        
</div>
</div>
<?php } ?>
	
 

<div class="col-12">
<div  class="owl-carousel owl-theme " data-1000="4" data-600="4" data-1200="4">%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_carousel_buttons")));
	
	}
	
		public static function js(){
		return "";
		}	
		 
		public static function css(){
		return "";
		 }	
}

?>