<?php
if(is_admin()){
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

															Blog Carousel
																		
*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
add_filter('sao_element_item', 'sao_element_item_blog_slider');
function sao_element_item_blog_slider( $element ) {
 	
 	$element[]=array(
 		'name'			=> 	esc_html__('Blog Slider','reza'),
 		'id'			=> 'blog_slider',
		'group'			=> esc_html__('rabonews','reza'),
		'img'			=>  REZA_DIR.'/admin/assets/images/element-blog-slider.jpg',
  	);  
	
	return $element;
}  
 /*****************************************************************************************************************************************************
******************************************************************************************************************************************************

															Blog Carousel Options
																		
*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
add_filter('sao_element_options_blog_slider', 'reza_blog_slider_options');
function reza_blog_slider_options( $option =false) {
 
	$element='blog_slider';
			
	$option[]= array( 
 		"group"			=>  esc_html__('General','reza'),		  
	);	
	$option[]= array( 
 		"group"			=>  esc_html__('Slider','reza'),		  
	);
	$option[]= array( 
 		"group"			=>  esc_html__('Layout','reza'),		  
	);		
	 $option[]= array( 
 		"group"			=>  esc_html__('Title Box','reza'),		  
	);	
 
	$option[]= array( 
 		"group"			=>  esc_html__('Post Style','reza'),		  
	);	
	
	$option[]= array( 
 		"group"			=>  esc_html__('Typography','reza'),		  
	);	
 
	$option[]= array( 
 		"group"			=>  esc_html__('Attribute','reza'),		  
	);							
	
	 
  	$between =true;	
	$meta=true;		
 	$alignment =true;
   	$caption_layout =true;
  	$image =true;
  	$pager =true;
  	$effect =true;
	$layout_2_fold='';	 	
   	include REZA_PATH . '/sao-builder/blog/sao-blog-general.php'; 
	
	 
	 
	include REZA_PATH . '/sao-builder/general/sao-slider.php'; 
	$height = array(
		'50'				=>	'50px',
		'100'				=>	'100px',
		'150'				=>	'150px',
		'200'				=>	'200px',
		'300'				=>	'300px',
		'400'				=>	'400px',
		'500'				=>	'500px', 
		'600'				=>	'600px',
		'700'				=>	'700px',
		'800'				=>	'800px',
		'900'				=>	'900px',
		'1000'				=>	'1000px',
 		
	);
	$option[]= array( 
		"name"			=>esc_html__('Height','reza'),
 		"id"			=> "height",
		"default"		=>  '700',
 		"group"			=> esc_html__('Layout','reza'),
		"type"			=> "select",
   		"options"		=>  $height,						
   	); 
	
 	
  	include REZA_PATH . '/sao-builder/blog/sao-blog-layout.php'; 
	include REZA_PATH . '/sao-builder/general/sao-title-box.php'; 
 	include REZA_PATH . '/sao-builder/blog/sao-blog-post-style.php'; 
 	include REZA_PATH . '/sao-builder/blog/sao-blog-typography.php'; 
   	include REZA_PATH . '/sao-builder/general/sao-element.php';
	   
  	 
    return $option;

} 

add_filter('sao_builder_perview_blog_slider', 'reza_builder_perview_blog_slider');
function reza_builder_perview_blog_slider( $args ) {
	 
	
  		$key = $args['key'];
 		$option = $args['option'];
		$output='';
		$css='';
	 if(!empty($option['title'])){
			$output.='<h4 class="rd-perview-header">'.$option['title'] .'</h4>'; 
		}
 				$output.='<img src="'.REZA_DIR.'/admin/assets/images/slider/slider_1.jpg">'; 
 			  
	$css.= '.sao-element-'.$key.' {text-align: center;width: 100%;}'; 
  	$return['css']= $css;
	$return['output']= $output;
		return $return;
}
}
 /*****************************************************************************************************************************************************
******************************************************************************************************************************************************

															Blog Carousel config
																		
*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
add_filter('sao_builder_blog_slider', 'reza_blog_slider_config');
function reza_blog_slider_config( $args,$out = false ) {
 	wp_reset_query();
	wp_reset_postdata();
	$option = $args['option'];
	$key = $args['key']; 
	if(reza_element_show($option)=='show'){
	
 		$option['post_type']='post';
		$layout ='featured';
		$pager =  !empty($option['pager'])?'rd-pager':'';		
 		$ratio_class =!empty($option['height'])?'rd-ratio-h'.$option['height']:'rd-ratio-h50';
		$alignment_class =!empty($option['alignment'])?$option['alignment']:reza_option('blog_alignment');
		$image_width =!empty($option['image_width'])? $option['image_width']:reza_option('blog_image_width');
		$box_layout =!empty($option['box_layout'])? $option['box_layout']:reza_option('blog_box_layout');
		$caption_layout =!empty($option['caption_layout'])? $option['caption_layout']: reza_option('blog_caption_layout');
		$custom_class = !empty( $option['custom_class']) ? $option['custom_class'] : '';			 
	
  	 
	
		$layout_class='';
 
			$layout_class='rd-cap-'.$caption_layout;
 		
		$classes = array(
			'rd-el-'.$key,
			 'rd-el-slider',
			 'rd-slider',
			'rd-ajax-tab',
			$ratio_class,
 			'rd-gap-0px',
			$ratio_class,
 		$pager,
		
			'rd-align-'.reza_alignment($alignment_class),
			$layout_class,
			reza_image_caption_effect($option),	
			reza_element_show($option,true),
			$custom_class,
		);
		
		ob_start(); 
		?>
		
			<aside <?php  reza_el_id($option);?> class="<?php echo esc_attr(join( ' ', $classes ));?> " <?php echo reza_el_cssanime($option);?> >
			
				<?php reza_post_title_tabs($option,'reza_post_'.$layout.'_main');?>
            <div class="rd-gap-slider">
                 <div class="rd-gap-content">
                <div class="rd-gap-warp rd-aw rd-slider-list-warp">
                <div class="rd-item-list ">
                   
                    <?php 
                          reza_post_featured_main($option);
                     ?>
                    
                </div>
				</div>
            
				<?php if(!empty($option['arrows'])){?>
					<div class="rd-arrow-warp"><a class="rd-arrow-prev"></a><a class="rd-arrow-next"></a></div>
				<?php }?>
                 
                 
			</div>
			</div>
			<?php
            $slider_options = array(); 	
		 	$slider_options['mode']= !empty($option['effect']) ? $option['effect'] : 'slide';
            $slider_options['speed']=  !empty($option['speed']) ? $option['speed'] : '1000';
            $slider_options['pause']= !empty($option['pause']) ? $option['pause'] : '5000';
            $slider_options['between']=   '0';	
            $slider_options['pager']= true;
            $slider_options['timer']= false;	
            $slider_options['controls']=!empty($option['arrows']) ? true : '';
            $slider_options['auto']=  !empty($option['auto']) ? true : '';
            reza_lightslider('1',$slider_options);
             ?>    
		  
		</aside> 
	
	 
		<?php
		$item = '.rd-el-'.$key.'';
		$item_css = reza_title_box_css($option,$item);
		$item_css.= reza_post_css($option,$item);
		$item_css.= reza_caption_css($option,$item);
		$item_css.= reza_arrow_layout_css($option);
		$item_css.= reza_element_padding($option);
		$item_css.= reza_pager_css($option);
		$css =reza_item_css($item_css,$item);
		
		$return['output']=  ob_get_clean();
		$return['css']= $css;
		$return['emptybefore']= true;
		$return['emptyafter']= true;
		
		if( !empty($out)){
			$output = $return['output'];
			$output.=!empty($return['css'])?'<style>'.$return['css'].'</style>':'';
			return $output;
		}else{
			return $return;	
		}
	}
}
 