codice:
<?php
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Portfolio Grid Shortcode
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function vntd_portfolio_grid($atts, $content = null) {
extract(shortcode_atts(array(
"filter" => '',
"filter_style" => '',
"grid_title" => '',
"thumb_style" => 'simple',
"hover_style" => 'simple',
"animation" => 'rotateSides',
"posts_nr" => '',
"cats" => '',
"thumb_style" => '',
"thumb_size" => 'square',
"order" => '',
"el_position" => '',
"width" => '',
"composer" => '',
"paged_posts" => '',
"more_url" => '',
"thumb_space" => '',
"cols" => '',
"thumb_size" => '',
"ajax" => ''
), $atts));
wp_enqueue_script('cubePortfolio');
wp_enqueue_script('cubeConfig');
wp_enqueue_style('cubePortfolio');
wp_enqueue_script('magnific-popup', '', '', '', true);
wp_enqueue_style('magnific-popup');
// Define container and item span value
global $post;
if(!$posts_nr) $posts_nr = "-1";
$block_id = rand(5,5000);
$layout_class = '';
$item_class = 'boxed-item col-xs-4';
if($thumb_space == 'no') {
$layout_class = 'fullwidth relative';
$item_class = 'five';
if($cols == "4") {
$item_class = 'four';
}
}
$thumb_gap = 30;
if($thumb_space == "no") $thumb_gap = 0;
ob_start();
echo '<div class="portfolio vntd-portfolio-grid portfolio-style '.$layout_class.' portfolio-'.$hover_style.' portfolio-'.$thumb_style.' portfolio-cols-'.$cols.'">';
if($filter == "yes") vntd_filters('project-type',$cats,$filter_style,$grid_title);
echo '<div class="portfolio-items grid-items" data-cols="'.$cols.'" data-animation="'.$animation.'" data-gap="'.$thumb_gap.'">';
wp_reset_postdata();
$paged = '';
//if($paged_posts == 'yes') {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
//}
//echo $cats_arr."ECHO TEST | | ".$cats;
$cats_arr = explode(" ", $cats);
$args = array(
'posts_per_page' => $posts_nr,
'paged' => $paged,
'post_type' => 'portfolio'
);
$the_query = new WP_Query($args);
// Default Thumbnail Sizes
$size = "portfolio-square";
if($thumb_size == "auto") $size = "portfolio-auto";
if($cols == 1) $size = "sidebar-landscape";
$data_content = $ajax_class = '';
if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post();
$img_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), $size);
$thumb_url = $img_url[0];
// For lightbox zoom
$img_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
$big_thumb_url = $img_url[0];
$post_link = get_permalink();
$post_link_type = get_post_meta($post->ID,'link_type',TRUE);
if($post_link_type == 'external' && get_post_meta($post->ID,'portfolio_external_url',TRUE)) {
$data_content = '';
$ajax_class = '';
$post_link = get_post_meta($post->ID,'portfolio_external_url',TRUE);
}
$excerpt = $excerpt_class = ' no-excerpt';
if(get_post_meta($post->ID,'portfolio_post_excerpt',TRUE)) {
$excerpt = get_post_meta($post->ID,'portfolio_post_excerpt',TRUE);
$excerpt_class = ' has-excerpt';
}
?>
<div class="item cbp-item <?php echo $item_class.$excerpt_class; ?> <?php echo vntd_portfolio_item_class(); ?>"<?php echo $data_content; ?>>
<div class="item-inner">
<?php echo $cats; ?><a href="<?php echo $post_link; ?>" class="work-image">
<img src="<?php echo $thumb_url ?>" alt="<?php the_title(); ?>">
<div class="portfolio-item-overlay">
<?php if($hover_style != "bottom") { ?>
<div class="portfolio-overlay-icons">
<span class="overlay-icon overlay-icon-link" href="<?php echo $post_link; ?>"><i class="fa fa-link"></i></span>
<span class="overlay-icon overlay-icon-zoom" href="<?php echo $big_thumb_url ?>"><i class="fa fa-search"></i></span>
</div>
<?php } ?>
<h3 class="portfolio-overlay-title">
<?php the_title(); ?>
</h3>
<div class="portfolio-overlay-cats"><?php vntd_portfolio_overlay_categories(); ?></div>
<?php if(get_post_meta($post->ID,'portfolio_post_excerpt',TRUE)) { ?>
<p class="portfolio-overlay-excerpt">
<?php echo get_post_meta($post->ID,'portfolio_post_excerpt',TRUE); ?>
</p>
<?php } ?>
</div>
</a>
</div>
<?php if($thumb_style && $thumb_style != "simple") { ?>
<div class="item-outer">
<h3 class="portfolio-outer-title">
<a href="<?php echo $post_link; ?>"><?php the_title(); ?></a>
</h3>
<div class="portfolio-outer-cats"><?php vntd_portfolio_overlay_categories(); ?></div>
<?php if(get_post_meta($post->ID,'portfolio_post_excerpt',TRUE)) { ?>
<p class="portfolio-outer-excerpt">
<?php echo get_post_meta($post->ID,'portfolio_post_excerpt',TRUE); ?>
</p>
<?php }
if($thumb_style == "title_excerpt_more") { ?>
<div class="portfolio-view-more btn btn-dark"><a href="<?php echo $post_link; ?>"><?php _e('View More', 'vntd_qaro'); ?></a></div>
<?php } ?>
</div>
<?php } ?>
</div>
<?php
endwhile; endif; ?>
<?php
//if($paged_posts == 'yes')
echo '</div>';
if($ajax == 'yes') {
vntd_ajax_pagination($the_query);
echo '<div id="portfolio-load-posts" class="pagination-wrap"><a href="#"class="btn btn-style-default btn-accent">'.__('Load More','vntd_qaro').'</a></div>';
}
echo '</div>';
wp_reset_postdata();
$content = ob_get_contents();
ob_end_clean();
return $content;
}
remove_shortcode('portfolio_grid');
add_shortcode('portfolio_grid', 'vntd_portfolio_grid');