<?php
/************** PORTFOLIO LISTING ***************/
function alc_portlisting($atts, $content=NULL){
    extract(shortcode_atts(array(
		"limit" => 6,
		"featured" => 0,
		'anim'=>'',
		'class'=>'',
		'automatic' => 'false',
		), $atts));
 	global $post;
    $anim = empty($anim) ? '' : "animation $anim";
	$return = '';
    $counter = 0; 
	$isActive = '';
	$args = array('post_type' => 'portfolio', 'taxonomy'=> 'portfolio_category', 'showposts' => $limit, 'posts_per_page' => $limit, 'orderby' => 'date','order' => 'DESC');
	
	if ($featured)
	{
		$args['meta_query'] = array(array('key'=>'_portfolio_featured'));
	}
	
   	$query = new WP_Query($args);
	$return.='
	<div class="caroursel-work '.$anim.' '.$class.' carshort">
			<ul class="latest-work ">';
				if ($query->have_posts()):  
					while ($query->have_posts()) : 							
					$query->the_post();
					$custom = get_post_custom($post->ID);
					$link = ''; $thumbnail = get_the_post_thumbnail($post->ID, 'portfolio-3-col'); 
					$return.='
					<li>
						<div class="project-post">';
							if (!empty($thumbnail)): 
								$return.=$thumbnail; 
							else :
								 $return.='<img src="http://placehold.it/300x225" alt="'.__ ('No preview image', 'unik').'" />';
							endif;	
							$return.='<div class="hover-box">';
									if( !empty ( $custom['_portfolio_video'][0] ) ) : $link = $custom['_portfolio_video'][0]; 
									$return.='<a href="'.$link.'" class="zoom video" title="'.get_the_title().'">
										<i class="fa fa-film"></i>
									</a>';
								elseif( isset($custom['_portfolio_link'][0]) && $custom['_portfolio_link'][0] != '' ) : 
									$return.='<a href="'.$custom['_portfolio_link'][0].'" class="link" title="'.get_the_title().'">
										<i class="fa fa-external-link "></i>
									</a>';
								elseif(isset( $custom['_portfolio_no_lightbox'][0] )  &&  $custom['_portfolio_no_lightbox'][0] !='' ) : $link = get_permalink(get_the_ID()); 
									$return.='<a href="'.$link.'" class="link" title="'.get_the_title().'">
										<i class="fa fa-file-o "></i>
									</a>';
								else : 
									$full_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', false); 
									$link = $full_image[0];
									$return.='<a href="'.$link.'" class="zoomshort"  title="'.get_the_title().'">
										<i class="fa fa-search"></i>
									</a>';
								endif;
							$return.='</div>';
							$return.='
						</div>
					</li>';		
					$counter ++; endwhile; 
				endif;
				$return.='
			</ul>
	</div>
	<script>
		jQuery(document).ready(function(){
			 jQuery(".latest-work").bxSlider({ 
				maxSlides: '.$limit.',
				auto: '.$automatic.',
				pager:false,
				slideWidth:180,
				slideMargin:30,
				nextText: "",
				prevText:""
			});
		});
	</script>';
	
	return $return;
}

add_shortcode('portlist', 'alc_portlisting');
/*********************************************/
vc_map( array(
   "name" => __("Unik Portfolio listing", "unik"),
   "base" => "portlist",
   "class" => "",
   "icon" => "icon-wpb-my_portlist",
   'admin_enqueue_css' => array(get_template_directory_uri().'/vc_templates/shortcodes.css'),
   "category" => __('Content', "unik"),
   "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" => __("items limit", "unik"),
         "param_name" => "limit",
          "value"=>"6"
      ),
      array(
         "type" => "dropdown",
         
         "class" => "",
         "heading" => __("Type of items to show", "unik"),
         "param_name" => "featured",
          "value"=>array("All Itmes"=>"0", "Only featured items"=>"1")
      ),
	   array(
         "type" => "dropdown",
         
         "class" => "",
         "heading" => __("Automatic sliding", "unik"),
         "param_name" => "automatic",
          "value"=>array("No"=>"false", "Yes"=>"true")
      ),
        array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Extra class", "unik"),
         "param_name" => "class",
         "description" => __(' Extra class name', "unik")
      )
   )
) );
/*************************************************/
?>