<?php 
if ( ! defined( 'ABSPATH' ) ) {
  die( '-1' );
}

/**
 * Shortcode attributes
 * @var $atts
 * @var $order
 * @var $orderby
 * @var $cat
 * @var $col
 * @var $thumbsize
 * @var $content - shortcode content
 * Shortcode class
 * @var $this WPBakeryShortCode_qk_team
 */
$order =  $cat =  $thumbsize = $orderby = '';

$output = $after_output = '';
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
if(isset($cat) and $cat!='all'){
	$args = array('post_type' => 'portfolio', 'posts_per_page' => $order, 'tax_query' => array(
	array(
		'taxonomy' => 'portfolio_category',
		'field'    => 'slug',
		'terms'    => $cat,
	),
));
}else{
	$args = array('post_type' => 'portfolio', 'posts_per_page' => $order);
}	
$portfolio = new WP_Query($args);
?>
<!-- Portfolio section -->
<section class="portfolio-section float-style grid-ajax">
	<div class="container">
		<ul class="filter">
			<li><a class="active" href="#" data-filter="*"><?php esc_html_e('all','photofolio'); ?></a></li>
			<?php $portfolio_skills = get_terms('portfolio_tag'); ?>
			<?php foreach($portfolio_skills as $portfolio_skill) { ?>
			<li><a href="#" data-filter=".<?php echo esc_attr($portfolio_skill->slug); ?>"><?php echo esc_attr($portfolio_skill->name); ?></a></li>
			<?php } ?>
		</ul>
	</div>
	<div class="portfolio-box iso-call col-<?php if($col==null){ echo "2"; }else{  echo esc_attr($col); }?>">
		<?php  while($portfolio->have_posts()) : $portfolio->the_post(); ?>
			<?php
				$item_classes = '';
				$item_skill = '';
				$item_cats = get_the_terms(get_the_ID(), 'portfolio_tag');
				$i=1; foreach((array)$item_cats as $item_cat){
					if(count($item_cat)>0){
						$item_classes .= $item_cat->slug . ' ';
						
					}

					if($i=1){
						$item_skill .= $item_cat->name;
					}else{
						$item_skill .= ', '. $item_cat->name;
					}

				$i++; }
			?>
		<div class="project-post <?php echo esc_attr($item_classes); ?>">
			<div class="post-gallery">
				<?php the_post_thumbnail($thumbsize); ?>
				
			<div class="title-post">
				<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
				<?php echo get_the_term_list( get_the_ID(), 'portfolio_tag', '<ul class="project-tags"><li>', ',</li><li>', '</li></ul>' );?>
			</div>
			</div>
		</div>
		<?php endwhile; ?>

	</div>
	<div class="center-button">
		<a href="#" class="load-post-container" data-cat="<?php echo esc_attr($cat); ?>" data-found="<?php echo esc_attr($portfolio->found_posts); ?>" data-load="<?php echo esc_attr($order); ?>"><?php esc_html_e('show me more','photofolio');?></a>
	</div>
</section>
<!-- End Portfolio section -->