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

/**
 * Shortcode attributes
 * @var $atts
 * @var $order
 * @var $offset
 * @var $cat
 * @var $title
 * @var $thumb
 * @var $thumbsize
 * @var $pagination
 * @var $class
 * @var $content - shortcode content
 * Shortcode class
 * @var $this WPBakeryShortCode_qk_team
 */
$order =  $cat = $offset = $title = $thumb = $thumbsize = $pagination = $class = '';
$output = $after_output = '';
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );

if($thumb!=''){
    $thumb_col = $thumb;
    $content_col = 12- $thumb;
}else{
    $thumb_col = '6';
    $content_col = '6';
}

?>
<?php 
if ( get_query_var('paged') ) {
    $paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
    $paged = get_query_var('page');
} else {
    $paged = 1;
}
$args = array(
    'post_type' => 'post',
    'posts_per_page' =>$order,
);
if($pagination!='off'){
    $args['paged'] = $paged;
}
if($cat!='all'){
  if ( is_rtl() ) {
    $args['cat'] = $cat;
  }else{
    $args['category_name'] = $cat;
  }
}
if($offset!=''){
  $args['offset'] = $offset;
}
$portfolio = new WP_Query($args);
$custom  = photofolio_custom();
if($cat!='all' and !is_rtl()){
$category = get_term_by('slug', $cat, 'category');
$cat = $category->term_id;
}
?>

<section class="blog-section full-img <?php echo esc_attr($class); ?>">

    <div class="blog-box">

            <?php 
            if($portfolio->have_posts()) :
                            while($portfolio->have_posts()) : $portfolio->the_post(); 
            ?>
            <?php get_template_part( 'content', ( post_type_supports( get_post_type(), 'post-formats' ) ? get_post_format() : get_post_type() ) ); ?>

            <?php endwhile; ?>
            <?php else: ?>
            <div class="not-found">
                    <h1><?php esc_html_e('Nothing Found Here!','photofolio'); ?></h1>
                    <h3><?php esc_html_e('Search with other string:', 'photofolio') ?></h3>
                    <div class="search-form">
                            <?php get_search_form(); ?>
                    </div>
            </div>
            <?php endif; ?>
            <?php if($pagination!='off'){ ?>
            <?php photofolio_pagination($pages=$portfolio->max_num_pages); ?>
            <?php } ?>
            <?php wp_reset_postdata(); ?>
        </div>

</section>
