<?php

class WPBakeryShortCode_Av_Testimonial extends WPBakeryShortCodesContainer {
	protected function content ( $atts, $content = null){
		extract(shortcode_atts(array(
        'anim'=>'',
        'class'=>'',
		
	), $atts));
	$GLOBALS['testimonial_count'] = 0;
	$counter = 0;
	$randomId = mt_rand(0, 100000);
	do_shortcode( $content );
	$anim = empty($anim) ? '' : "animation $anim";
	$return = '
		<div class="testimonial-section '.$anim.' '.$class.'" >';
				if( is_array( $GLOBALS['testimonials'] ) ){
					foreach( $GLOBALS['testimonials'] as $testimonial ){
						$userimage = wp_get_attachment_image_src($testimonial['photo'], 'full');
						$company = empty($testimonial['company']) ? '' : ' at <span>'.$testimonial['company'].'</span>';
						$testimonials[] = '
						<li>';
							$testimonials[].='
							<a href="'.$testimonial['website'].'"><img alt="'.$testimonial['title'].'" src="'.$userimage[0].'"></a>
							<div class="message-content">
								<p>'.do_shortcode($testimonial['content']).'</p>
								<h6>'.$testimonial['title'].' '.$testimonial['position'].$company.'</h6>
							</div>				
						</li>';	
						$counter++;
					}
					$return.= '<ul class="bxslider testimonialshort'.$randomId.'">'.implode( "\n", $testimonials ).'</ul>';
					unset($GLOBALS['testimonials']);
				}
				$return.='
		</div>
		<script>
		jQuery(window).load(function(){
			jQuery(".testimonialshort'.$randomId.'").bxSlider({
			mode: "vertical"
		});
		});
		</script>';
	return $return;
	}

}
add_shortcode( 'av_testimonial', 'av_testimonial' );

/*******************************/
class WPBakeryShortCode_Av_Testimonial_Item extends WPBakeryShortCode {
	protected function content( $atts, $content = null){
		extract(shortcode_atts(array(
		'title' => '',
		'position' => '',
        'photo'=>'',
		'company' => '',
		'website'=>'#'
	), $atts));
	
	$x = $GLOBALS['testimonial_count'];
	$GLOBALS['testimonials'][$x] = array( 'title' => sprintf( $title, $GLOBALS['testimonial_count'] ), 'position' => $position, 'website' => $website,  'company' => $company, 'photo'=>$photo, 'content' =>  $content );
	
	$GLOBALS['testimonial_count']++;
	}
}
add_shortcode( 'av_testimonial_item', 'av_testimonial_item' );
vc_map( array(
    "name" => __("Unik Testimonial", "unik"),
    "base" => "av_testimonial",
    "as_parent" => array('only' => 'av_testimonial_item'), // Use only|except attributes to limit child shortcodes (separate multiple values with comma)
   	'show_settings_on_create' 	=> true,
	'category'=> 'Content',
    "icon" => "icon-wpb-my_testimonial",
    'admin_enqueue_css' => array(get_template_directory_uri().'/vc_templates/shortcodes.css'),
	"content_element" => true,
	'is_container'=> true,
    "params" => array(
        array(
         "type" => "dropdown",
         "class" => "",
         "heading" => __("Animation", "unik"),
         "param_name" => "anim",
         "value" => array( "None"=>"", "bounce"=>"bounce", "flash"=>"flash", "pulse"=>"pulse", "shake"=>"shake", "swing"=>"swing", "tada"=>"tada", "wobble"=>"wobble", "bounceIn"=>"bounceIn", "bounceInDown"=>"bounceInDown", "bounceInLeft"=>"bounceInLeft", "bounceInRight"=>"bounceInRight", "bounceInUp"=>"bounceInUp", "bounceOut"=>"bounceOut", "bounceOutDown"=>"bounceOutDown", "bounceOutLeft"=>"bounceOutLeft", "bounceOutRight"=>"bounceOutRight", "bounceOutUp"=>"bounceOutUp", "fadeIn"=>"fadeIn", "fadeInDown"=>"fadeInDown", "fadeInDownBig"=>"fadeInDownBig", "fadeInLeft"=>"fadeInLeft", "fadeInLeftBig"=>"fadeInLeftBig", "fadeInRight"=>"fadeInRight", "fadeInRightBig"=>"fadeInRightBig", "fadeInUp"=>"fadeInUp", "fadeInUpBig"=>"fadeInUpBig", "fadeOut"=>"fadeOut", "fadeOutDown"=>"fadeOutDown", "fadeOutDownBig"=>"fadeOutDownBig", "fadeOutLeft"=>"fadeOutLeft", "fadeOutLeftBig"=>"fadeOutLeftBig", "fadeOutRight"=>"fadeOutRight", "fadeOutRightBig"=>"fadeOutRightBig", "fadeOutUp"=>"fadeOutUp", "fadeOutUpBig"=>"fadeOutUpBig", "flip"=>"flip", "flipInX"=>"flipInX", "flipInY"=>"flipInY", "flipOutX"=>"flipOutX", "flipOutY"=>"flipOutY", "lightSpeedIn"=>"lightSpeedIn", "lightSpeedOut"=>"lightSpeedOut", "rotateIn"=>"rotateIn", "rotateInDownLeft"=>"rotateInDownLeft", "rotateInDownRight"=>"rotateInDownRight", "rotateInUpLeft"=>"rotateInUpLeft", "rotateInUpRight"=>"rotateInUpRight", "rotateOut"=>"rotateOut", "rotateOutDownLeft"=>"rotateOutDownLeft", "rotateOutDownRight"=>"rotateOutDownRight", "rotateOutUpLeft"=>"rotateOutUpLeft", "rotateOutUpRight"=>"rotateOutUpRight",  "hinge"=>"hinge", "rollIn"=>"rollIn", "rollOut"=>"rollOut", "zoomIn"=>"zoomIn","zoomInDown"=>"zoomInDown", "zoomInLeft"=>"zoomInLeft","zoomInRight"=>"zoomInRight","zoomInUp"=>"zoomInUp","zoomOut"=>"zoomOut", "zoomOutLeft"=>"zoomOutLeft", "zoomOutRight"=>"zoomOutRight","zoomOutUp"=>"zoomOutUp"),
         "description" => __(" Animation.", "unik")
      ),
		
        array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Extra class", "unik"),
         "param_name" => "class",
         "description" => __(' Extra class name', "unik")
      ),
    ),
    "js_view" => 'VcColumnView'
) );

/************************************************/
vc_map( array(
	"name" => __("Unik Testimonial Item", "unik"),
	"base" => "av_testimonial_item",
	"class" => "",
	"content_element" => true,
	"icon" => "icon-wpb-ui-accordion",
	"category" => __('Content', "unik"),
	"as_child" => array('only' => 'av_testimonial'),
	"params" => array(
      array(
         "type" => "textfield",
		 'holder'=>'div',
         "class" => "",
         "heading" => __("Name", "unik"),
         "param_name" => "title"
      ),
       array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Position", "unik"),
         "param_name" => "position"
      ),
		array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Company", "unik"),
         "param_name" => "company"
      ),
		array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Company website", "unik"),
         "param_name" => "website"
      ),
       array(
         "type" => "attach_image",
         "class" => "",
         "heading" => __("Photo ", "unik"),
         "param_name" => "photo"
      ),
        array(
         "type" => "textarea",        
         "class" => "",
         "heading" => __("Testimonial text", "unik"),
         "param_name" => "content"
      ),
       
	 // 'js_view'=> 'VcColumnView'
   )
) );
/*********************************************/
?>