<?php
if(is_admin()){

/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

															Contact Form 7
																		
*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
add_filter('sao_element_item', 'sao_element_item_contactform');
function sao_element_item_contactform( $element ) {
 	
 	$element[]=  array(
 		'name'			=> 	esc_html__('Contact Form 7','reza'),
 		'id'			=> 'contactform',
		'group'			=> esc_html__('rabonews','reza'),
		'img'			=>  REZA_DIR.'/admin/assets/images/element-contact-form.jpg',
		
   	); 
  
	return $element;
}  
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

															Contact Form 7 Options
																		
*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
add_filter('sao_element_options_contactform', 'reza_contactform_options');
function reza_contactform_options( $option ) {
  
	$option[]= array( 
		"name"			=> esc_html__('Contact Form','reza'),
 		"id"			=> "contactform_id",
  		"type"			=> "select",
 		"options"		=>  reza_category_array_options('contactform'),						
 	);	

  
 	$option[]= array( 
		"name"			=> __('Field Height','reza'),
 		"id"			=> "height",
  		"group"			=>  __('Layout','reza'),
 		"type"			=> "number",
  	);	
	
	$option[]= array( 
		"name"			=> __('Textarea Height','reza'),
 		"id"			=> "textarea_height",
  		"group"			=>  __('Layout','reza'),
 		"type"			=> "number",
  	);		
	
	$option[]= array( 
		"name"			=> esc_html__('Between Field','reza'),
 		"id"			=> "between",
 		"group"			=>  esc_html__('Layout','reza'),
		"type"			=> "select",
  		"default"		=>  '',
		"options" 		=> reza_array_options('between',true), 

  	);
 
	 
  
	
	
$option[]= array( 
		"name"			=> __('Text Color','reza'),
 		"id"			=> "text_color",
		"group"			=>  esc_html__('Style','reza'),
 		"type"			=> "color",
	); 		
	
	$option[]= array( 
		"name"			=> __('Field Background Color','reza'),
 		"id"			=> "field_background_color",
		"group"			=>  esc_html__('Style','reza'),
 		"type"			=> "color_rgba",
	); 	
	$option[]= array( 
		"name"			=> __('Field Text Color','reza'),
 		"id"			=> "field_text_color",
		"group"			=>  esc_html__('Style','reza'),
 		"type"			=> "color",
	); 		 
 	 
	$option[]= array( 
		"name"			=> __('Field Border Color','reza'),
 		"id"			=> "field_border_color",
		"group"			=>  esc_html__('Style','reza'),
 		"type"			=> "color_rgba",
	); 	 
	
 							
 
	
	$option[]= array( 
		"name"			=> __('Button color','reza'),
 		"id"			=> "button_color",
		"group"			=>  esc_html__('Style','reza'),
		"type"			=> "multi_options",
		"options"			=>	array( 	
							array( 
								"name"			=> 	__('Background Color','reza'),
								"id"			=> "background",
								"type"			=> "color_rgba",
							),	
							array( 
								"name"			=> __('Text Color','reza'),			
								"id"			=> "text",
								"type"			=> "color_rgba",
							), 
					),						
	); 	 
	$option[]= array(
		"name"			=> esc_html__('Border Radius','reza'),
		"id"			=> "border_radius", 
		"type"		=> "select",
		"group"			=>  esc_html__('Style','reza'),
		"options"	=>  reza_array_options('radius',true),
	);
	$option[] = array(
		"name" 		=> esc_html__('Textarea Border Radius' , 'reza'),
		"id" 		=> "textarea_radius",
		"type"		=> "select",
		"group"			=>  esc_html__('Style','reza'),
		"options"	=>  reza_array_options('radius_mini',true),
	);   		
				
  	
	
	$option[]= array( 
		"name"			=> esc_html__('Text Typography','reza'),
 		"id"			=> "text_typo",
  		"group"			=>  esc_html__('Typography','reza'),
   		"type"			=> "multi_options",
		"options"		=>	reza_multi_array_options('typo')
		 
	);
 	   	include REZA_PATH . '/sao-builder/general/sao-element.php';

    return $option;
} 
}
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

															Contact Form 7 Config
																		
*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
add_filter('sao_builder_contactform', 'reza_contactform_config');
function reza_contactform_config( $args , $out = false ) {
	wp_reset_query();
	wp_reset_postdata();
 
 	$option = $args['option'];
	$key = $args['key'];
	if(reza_element_show($option)=='show'){
		$output='';
		$css ='';
		$between_class= !empty($option['between']) ?$option['between']:'20px';
		if(!empty($option['contactform_id'])){
		$contactform_id = get_page_by_path($option['contactform_id'],OBJECT, 'wpcf7_contact_form');
		}
		$custom_class = !empty( $option['custom_class']) ? $option['custom_class'] : '';
	
		$classes = array(
			'rd-el-'.$key,
			'rd-contactform',
			'rd-gap-'.$between_class.'',
			'rd-aw',
			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);?>>
						<div class="rd-gap-content">

            <div class="rd-gap-warp">
                <div class="rd-item-list">
                
                    <?php 
                     if( !empty($contactform_id) && !empty($contactform_id->ID)){
                    echo do_shortcode('[contact-form-7 id="'.esc_attr($contactform_id->ID).'" title=""]');
                    }
                     ?>
                </div>
                </div>
			</div>
		</aside>
        
		<?php
 		$item = '.rd-el-'.$key.'';
 		$item_css=
 			reza_var_unit('--rd-input-ht',$option,'height').
			reza_var_unit('--rd-textarea-ht',$option,'textarea_height').
			reza_var('--rd-main-lk',$option,'text_color').
			reza_var('--rd-form-bg',$option,'field_background_color').
			reza_var('--rd-form-txt',$option,'field_text_color').
			reza_var('--rd-main-br-cr',$option,'field_border_color').
			reza_var_2('--rd-primary-bg',$option,'button_color','background').
			reza_var_2('--rd-primary-txt',$option,'button_color','text').
			reza_var('--rd-btn-rd',$option,'border_radius').
			reza_var('--rd-main-rd',$option,'textarea_radius').
			reza_var_font_typo('--rd-form',$option,'text_typo');
			
		$item_css.= reza_element_padding($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;	
		}
	}
}
 