protected function content($atts, $content = null)
 {
     $title = $category = $item_class = $width = $hover_style = $gutters = $fullwidth = $list_class = $el_class = $output = $filter = $items = $el_position = '';
     extract(shortcode_atts(array('title' => '', "item_count" => '12', 'item_columns' => '4', 'fullwidth' => 'no', 'gutters' => 'yes', "category" => 'all', 'hover_style' => 'default', 'el_position' => '', 'width' => '1/1', 'el_class' => ''), $atts));
     /* SIDEBAR CONFIG
        ================================================== */
     global $sf_sidebar_config, $sf_options;
     $sidebars = '';
     if ($sf_sidebar_config == "left-sidebar" || $sf_sidebar_config == "right-sidebar") {
         $sidebars = 'one-sidebar';
     } else {
         if ($sf_sidebar_config == "both-sidebars") {
             $sidebars = 'both-sidebars';
         } else {
             $sidebars = 'no-sidebars';
         }
     }
     if (is_singular('portfolio')) {
         $sidebars = "no-sidebars";
     }
     // CATEGORY SLUG MODIFICATION
     if ($category == "All") {
         $category = "all";
     }
     if ($category == "all") {
         $category = '';
     }
     $category_slug = str_replace('_', '-', $category);
     global $post, $wp_query, $sf_carouselID;
     if ($sf_carouselID == "") {
         $sf_carouselID = 1;
     } else {
         $sf_carouselID++;
     }
     $categories = explode(",", $category_slug);
     $translated_categories = '';
     foreach ($categories as $key => $category_slug) {
         $category_id_by_slug = get_term_by('slug', $category_slug, 'portfolio-category');
         if (isset($category_id_by_slug->term_id)) {
             $translated_slug_id = apply_filters('wpml_object_id', $category_id_by_slug->term_id, 'custom taxonomy', true);
             $translated_slug = get_term_by('id', $translated_slug_id, 'portfolio-category');
             $translated_categories = $translated_categories . ($key < count($categories) - 1 ? $translated_slug->slug . ',' : $translated_slug->slug);
         }
     }
     $portfolio_args = array('post_type' => 'portfolio', 'post_status' => 'publish', 'portfolio-category' => $translated_categories, 'posts_per_page' => $item_count, 'no_found_rows' => 1);
     $portfolio_items = new WP_Query($portfolio_args);
     $count = 0;
     $figure_width = 300;
     $figure_height = 225;
     if ($item_columns == "3") {
         $figure_width = 400;
         $figure_height = 300;
     }
     if ($item_columns == "2") {
         $figure_width = 600;
         $figure_height = 450;
     }
     // Thumb Type
     if ($hover_style == "default" && function_exists('sf_get_thumb_type')) {
         $list_class = sf_get_thumb_type();
     } else {
         $list_class = 'thumbnail-' . $hover_style;
     }
     if ($gutters == "no") {
         $list_class .= ' no-gutters';
     } else {
         $list_class .= ' gutters';
     }
     $portfolio_carousel_item_class = apply_filters('spb_portfolio_carousel_item_class', '');
     $items .= '<div id="carousel-' . $sf_carouselID . '" class="portfolio-items carousel-items clearfix ' . $list_class . '" data-columns="' . $item_columns . '" data-auto="false">';
     while ($portfolio_items->have_posts()) {
         $portfolio_items->the_post();
         $items .= '<div itemscope data-id="id-' . $count . '" class="clearfix carousel-item portfolio-item ' . $portfolio_carousel_item_class . '">';
         $items .= sf_portfolio_thumbnail("gallery", "", "1/1", $item_columns, "no", 0, $gutters, $fullwidth);
         $items .= '</div>';
         $count++;
     }
     wp_reset_postdata();
     $items .= '</div>';
     $width = spb_translateColumnWidthToSpan($width);
     $el_class = $this->getExtraClass($el_class);
     $output .= "\n\t" . '<div class="spb_portfolio_carousel_widget carousel-asset spb_content_element ' . $width . $el_class . '">';
     $output .= "\n\t\t" . '<div class="spb-asset-content">';
     if ($fullwidth == "yes") {
         $output .= "\n\t\t" . '<div class="title-wrap container clearfix">';
     } else {
         $output .= "\n\t\t" . '<div class="title-wrap clearfix">';
     }
     if ($title != '') {
         $output .= '<h3 class="spb-heading"><span>' . $title . '</span></h3>';
     }
     $output .= spb_carousel_arrows();
     $output .= '</div>';
     $output .= "\n\t\t" . $items;
     $output .= "\n\t\t" . '</div>';
     $output .= "\n\t" . '</div> ' . $this->endBlockComment($width);
     if ($fullwidth == "yes" && $sidebars == "no-sidebars") {
         $output = $this->startRow($el_position, '', true) . $output . $this->endRow($el_position, '', true);
     } else {
         $output = $this->startRow($el_position) . $output . $this->endRow($el_position);
     }
     global $sf_include_carousel, $sf_include_isotope;
     $sf_include_carousel = true;
     $sf_include_isotope = true;
     return $output;
 }
 protected function content($atts, $content = null)
 {
     global $sf_options;
     $title = $category = $wrap_class = $title_class = $item_class = $width = $el_class = $output = $filter = $items = $el_position = '';
     extract(shortcode_atts(array('title' => '', "item_count" => '5', "category" => 'all', 'pagination' => 'no', 'el_position' => '', 'width' => '1/1', 'el_class' => ''), $atts));
     $pagination_view_icon = apply_filters('sf_pagination_view_icon', '<i class="sf-icon-quickview"></i>');
     // TYPE CHECK
     $alt_display = false;
     if (sf_theme_supports('spb-port-showcase-alt')) {
         $alt_display = true;
     }
     // CATEGORY SLUG MODIFICATION
     if ($category == "All") {
         $category = "all";
     }
     if ($category == "all") {
         $category = '';
     }
     $category_slug = str_replace('_', '-', $category);
     global $post, $wp_query;
     $categories = explode(",", $category_slug);
     $translated_categories = '';
     foreach ($categories as $key => $category_slug) {
         $category_id_by_slug = get_term_by('slug', $category_slug, 'portfolio-category');
         if (isset($category_id_by_slug->term_id)) {
             $translated_slug_id = apply_filters('wpml_object_id', $category_id_by_slug->term_id, 'custom taxonomy', true);
             $translated_slug = get_term_by('id', $translated_slug_id, 'portfolio-category');
             $translated_categories = $translated_categories . ($key < count($categories) - 1 ? $translated_slug->slug . ',' : $translated_slug->slug);
         }
     }
     $portfolio_args = array('post_type' => 'portfolio', 'post_status' => 'publish', 'portfolio-category' => $translated_categories, 'posts_per_page' => $item_count, 'no_found_rows' => 1);
     $portfolio_items = new WP_Query($portfolio_args);
     // OUTPUT
     if ($alt_display == "yes") {
         if ($pagination == "yes") {
             $wrap_class = "has-pagination ";
         }
         $title_class = "center-title";
         global $sf_carouselID;
         if ($sf_carouselID == "") {
             $sf_carouselID = 1;
         } else {
             $sf_carouselID++;
         }
         $items .= '<div class="port-carousel carousel-wrap">';
         $items .= spb_carousel_arrows(true);
         $items .= '<div id="carousel-' . $sf_carouselID . '" class="portfolio-showcase carousel-items staged-carousel gutters clearfix" data-columns="5" data-auto="false" data-pagination="' . $pagination . '">';
     } else {
         $items .= '<div class="portfolio-showcase-wrap"><ul class="portfolio-showcase-items clearfix" data-columns="' . $item_count . '">';
     }
     while ($portfolio_items->have_posts()) {
         $portfolio_items->the_post();
         if ($alt_display) {
             $items .= '<div itemscope class="clearfix carousel-item portfolio-item gallery-item">';
             $items .= sf_portfolio_thumbnail("gallery", "", "1/1", '3', "no", 0, "yes", "yes");
             $items .= '</div>';
         } else {
             $thumb_img_url = "";
             $item_title = get_the_title();
             $item_subtitle = sf_get_post_meta($post->ID, 'sf_portfolio_subtitle', true);
             $thumb_image = rwmb_meta('sf_thumbnail_image', 'type=image&size=full');
             foreach ($thumb_image as $detail_image) {
                 $thumb_img_url = $detail_image['url'];
                 break;
             }
             if (!$thumb_image || $thumb_img_url == "") {
                 $thumb_image = get_post_thumbnail_id();
                 $thumb_img_url = wp_get_attachment_url($thumb_image, 'full');
             }
             $item_title = get_the_title();
             $permalink = get_permalink();
             $item_link = sf_portfolio_item_link();
             $items .= '<li itemscope class="clearfix portfolio-item deselected-item ' . $item_class . '">';
             // THUMBNAIL MEDIA TYPE SETUP
             $image_width = 700;
             $image_height = 350;
             if ($item_count == "5") {
                 $image_width = 500;
                 $image_height = 500;
             }
             if ($thumb_img_url == "") {
                 $thumb_img_url = "default";
             }
             $image = sf_aq_resize($thumb_img_url, $image_width, $image_height, true, false);
             if ($image) {
                 $items .= '<a ' . $item_link['config'] . '>';
                 $items .= '<img itemprop="image" class="main-image" src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[2] . '" alt="' . $item_title . '" />';
                 $items .= '</a>';
             }
             if ($item_subtitle == "") {
                 $items .= '<div class="item-info">';
                 $items .= '<span class="item-title"><a href="' . $permalink . '">' . $item_title . '</a></span>';
                 $items .= '</div>';
             } else {
                 $items .= '<div class="item-info has-subtitle">';
                 $items .= '<span class="item-title"><a href="' . $permalink . '">' . $item_title . '</a></span>';
                 $items .= '<span><a href="' . $permalink . '">' . $item_subtitle . '</a></span>';
                 $items .= '</div>';
             }
             $items .= '</li>';
         }
     }
     wp_reset_postdata();
     if ($alt_display == "yes") {
         $items .= '</div></div>';
     } else {
         $items .= '</div>';
     }
     $width = spb_translateColumnWidthToSpan($width);
     $el_class = $this->getExtraClass($el_class);
     $sidebar_config = sf_get_post_meta(get_the_ID(), 'sf_sidebar_config', true);
     $sidebars = '';
     if ($sidebar_config == "left-sidebar" || $sidebar_config == "right-sidebar") {
         $sidebars = 'one-sidebar';
     } else {
         if ($sidebar_config == "both-sidebars") {
             $sidebars = 'both-sidebars';
         } else {
             $sidebars = 'no-sidebars';
         }
     }
     $view_all = "";
     $portfolio_page = __($sf_options['portfolio_page'], 'swift-framework-plugin');
     if ($category_slug != "") {
         $has_button = true;
         $category_id = get_cat_ID($category_slug);
         $category_link = get_category_link($category_id);
         $view_all = '<a class="view-all hidden" href="' . esc_url($category_link) . '">' . $pagination_view_icon . '</a>';
     } else {
         if ($portfolio_page != "") {
             $view_all = '<a class="view-all hidden" href="' . get_permalink($portfolio_page) . '">' . $pagination_view_icon . '</a>';
         }
     }
     $output .= "\n\t" . '<div class="spb_portfolio_showcase_widget spb_content_element ' . $wrap_class . $width . $el_class . '">';
     if ($pagination == "yes") {
         $output .= "\n\t\t" . $view_all;
     }
     $output .= "\n\t\t" . '<div class="spb-asset-content">';
     $output .= $title != '' ? "\n\t\t\t" . $this->spb_title($title, $title_class, true) : '';
     $output .= "\n\t\t\t" . $items;
     $output .= "\n\t\t" . '</div>';
     $output .= "\n\t" . '</div> ' . $this->endBlockComment($width);
     $output = $this->startRow($el_position, '', true) . $output . $this->endRow($el_position, '', true);
     global $sf_has_portfolio_showcase, $sf_include_carousel;
     if ($alt_display) {
         $sf_include_carousel = true;
     } else {
         $sf_has_portfolio_showcase = true;
     }
     return $output;
 }
Example #3
0
 function sf_portfolio_items($atts)
 {
     extract(shortcode_atts(array('title' => '', 'display_type' => '', 'multi_size_ratio' => '', 'fullwidth' => '', 'gutters' => '', 'columns' => '', 'show_title' => '', 'show_subtitle' => '', 'show_excerpt' => '', 'hover_show_excerpt' => '', 'excerpt_length' => '', 'item_count' => '', 'category' => '', 'order' => '', 'order_by' => '', 'portfolio_filter' => '', 'pagination' => '', 'button_enabled' => '', 'hover_style' => '', 'post_type' => 'portfolio', 'el_position' => '', 'width' => '', 'el_class' => ''), $atts));
     /* OUTPUT VARIABLE
        ================================================== */
     $portfolio_items_output = $grid_size = "";
     $count = 0;
     /* CATEGORY SLUG MODIFICATION
        ================================================== */
     if ($category == "All") {
         $category = "all";
     }
     if ($category == "all") {
         $category = '';
     }
     $category_slug = str_replace('_', '-', $category);
     /* PORTFOLIO QUERY SETUP
        ================================================== */
     global $post, $wp_query;
     if (get_query_var('paged')) {
         $paged = get_query_var('paged');
     } elseif (get_query_var('page')) {
         $paged = get_query_var('page');
     } else {
         $paged = 1;
     }
     $portfolio_args = array('post_type' => $post_type, 'post_status' => 'publish', 'paged' => $paged, 'portfolio-category' => $category_slug, 'posts_per_page' => $item_count, 'order' => $order, 'orderby' => $order_by);
     $portfolio_items = new WP_Query($portfolio_args);
     /* LIST CLASS CONFIG
        ================================================== */
     $list_class = '';
     if ($display_type == "masonry" || $display_type == "masonry-gallery") {
         $list_class .= 'masonry-items filterable-items col-' . $columns . ' row clearfix';
     } else {
         if ($display_type == "gallery") {
             $list_class .= 'gallery-portfolio filterable-items col-' . $columns . ' row clearfix';
         } else {
             if ($display_type == "multi-size-masonry") {
                 $columns = 3;
                 $list_class .= 'multi-masonry-items filterable-items col-' . $columns . ' row clearfix';
             } else {
                 $list_class .= 'standard-portfolio filterable-items col-' . $columns . ' row clearfix';
             }
         }
     }
     // Full width
     if ($fullwidth == "yes") {
         $list_class .= ' portfolio-full-width';
     }
     // Gutters
     if ($gutters == "no") {
         $list_class .= ' no-gutters';
     } else {
         $list_class .= ' gutters';
     }
     // Thumb Type
     if ($hover_style == "default" && function_exists('sf_get_thumb_type')) {
         $list_class .= ' ' . sf_get_thumb_type();
     } else {
         $list_class .= ' thumbnail-' . $hover_style;
     }
     if ($display_type == "multi-size-masonry") {
         if ($fullwidth == "yes") {
             $grid_size = 'col-sm-3';
         } else {
             $grid_size = 'col-sm-4';
         }
     }
     /* ITEMS OUTPUT
        ================================================== */
     global $sf_options;
     $portfolio_items_output .= '<ul class="portfolio-items ' . $list_class . '">' . "\n";
     if ($display_type == "multi-size-masonry") {
         $portfolio_items_output .= '<li class="clearfix portfolio-item ' . $grid_size . ' grid-sizer">' . "\n";
     }
     while ($portfolio_items->have_posts()) {
         $portfolio_items->the_post();
         /* META VARIABLES
            ================================================== */
         $thumb_type = sf_get_post_meta($post->ID, 'sf_thumbnail_type', true);
         $item_title = get_the_title();
         $item_subtitle = sf_get_post_meta($post->ID, 'sf_portfolio_subtitle', true);
         $permalink = get_permalink();
         $custom_excerpt = sf_get_post_meta($post->ID, 'sf_custom_excerpt', true);
         $post_excerpt = '';
         if ($custom_excerpt != '') {
             $post_excerpt = sf_custom_excerpt($custom_excerpt, $excerpt_length);
         } else {
             $post_excerpt = sf_excerpt($excerpt_length);
         }
         $taxonomy_name = 'category';
         if ($post_type != "post") {
             $taxonomy_name = $post_type . '-category';
         }
         if ($taxonomy_name == "product-category") {
             $taxonomy_name = "product_cat";
         }
         $post_terms = get_the_terms($post->ID, $taxonomy_name);
         $term_slug = " ";
         if (!empty($post_terms)) {
             foreach ($post_terms as $post_term) {
                 $term_slug = $term_slug . strtolower($post_term->slug) . ' ';
             }
         }
         /* COLUMN VARIABLE CONFIG
            ================================================== */
         $item_class = "";
         if ($columns == "1") {
             $item_class = "col-sm-12 ";
         } else {
             if ($columns == "2") {
                 $item_class = "col-sm-6 ";
             } else {
                 if ($columns == "3") {
                     $item_class = "col-sm-4 ";
                 } else {
                     if ($columns == "4") {
                         $item_class = "col-sm-3 ";
                     } else {
                         if ($columns == "5") {
                             $item_class = "col-sm-sf-5 ";
                         }
                     }
                 }
             }
         }
         $masonry_thumb_size = sf_get_post_meta(get_the_ID(), 'sf_masonry_thumb_size', true);
         if ($display_type == "multi-size-masonry") {
             if ($fullwidth == "yes") {
                 if ($masonry_thumb_size == "") {
                     $masonry_thumb_size = "standard";
                 }
                 if ($masonry_thumb_size == "wide") {
                     $item_class = 'col-sm-6 size-wide ';
                 } else {
                     if ($masonry_thumb_size == "tall") {
                         $item_class = 'col-sm-3 size-tall ';
                     } else {
                         if ($masonry_thumb_size == "wide-tall") {
                             $item_class = 'col-sm-6 size-wide-tall ';
                         } else {
                             $item_class = 'col-sm-3 size-standard ';
                         }
                     }
                 }
             } else {
                 if ($masonry_thumb_size == "") {
                     $masonry_thumb_size = "standard";
                 }
                 if ($masonry_thumb_size == "wide") {
                     $item_class = 'col-sm-8 size-wide ';
                 } else {
                     if ($masonry_thumb_size == "tall") {
                         $item_class = 'col-sm-4 size-tall ';
                     } else {
                         if ($masonry_thumb_size == "wide-tall") {
                             $item_class = 'col-sm-8 size-wide-tall ';
                         } else {
                             $item_class = 'col-sm-4 size-standard ';
                         }
                     }
                 }
             }
         }
         /* DISPLAY TYPE CONFIG
            ================================================== */
         if ($display_type == "masonry" || $display_type == "masonry-gallery") {
             $item_class .= "masonry-item masonry-gallery-item";
         } else {
             if ($display_type == "gallery") {
                 $item_class .= "gallery-item ";
             } else {
                 if ($display_type == "multi-size-masonry") {
                     $item_class .= "multi-masonry-item ";
                 } else {
                     $item_class .= "standard ";
                 }
             }
         }
         /* LINK TYPE CONFIG
            ================================================== */
         $item_link = sf_portfolio_item_link();
         /* ITEM OUTPUT
            ================================================== */
         $portfolio_items_output .= '<li itemscope itemtype="http://schema.org/CreativeWork" data-id="id-' . $count . '" class="clearfix portfolio-item ' . $item_class . ' ' . $term_slug . '">' . "\n";
         $portfolio_items_output .= apply_filters('sf_before_portfolio_item_thumb', '');
         /* THUMBNAIL CONFIG
            ================================================== */
         if ($thumb_type != "none") {
             $portfolio_items_output .= sf_portfolio_thumbnail($display_type, $masonry_thumb_size, $multi_size_ratio, $columns, $hover_show_excerpt, $excerpt_length, $gutters, $fullwidth);
         }
         $portfolio_items_output .= apply_filters('sf_after_portfolio_item_thumb', '');
         if ($display_type != "gallery" && $display_type != "masonry-gallery" && $display_type != "multi-size-masonry") {
             $portfolio_items_output .= '<div class="portfolio-item-details">' . "\n";
             if ($show_title == "yes") {
                 $portfolio_items_output .= '<div class="comments-likes">';
                 if (function_exists('lip_love_it_link')) {
                     $portfolio_items_output .= lip_love_it_link(get_the_ID(), false);
                 }
                 $portfolio_items_output .= '</div>';
                 $portfolio_items_output .= '<h3 class="portfolio-item-title" itemprop="name headline"><a ' . $item_link['config'] . '>' . $item_title . '</a></h3>' . "\n";
             }
             if ($show_subtitle == "yes" && $item_subtitle) {
                 $portfolio_items_output .= '<h5 class="portfolio-subtitle" itemprop="name alternativeHeadline">' . $item_subtitle . '</h5>' . "\n";
             }
             if ($show_excerpt == "yes") {
                 $portfolio_items_output .= '<div class="portfolio-item-excerpt" itemprop="description">' . $post_excerpt . '</div>' . "\n";
             }
             $portfolio_items_output .= '</div>' . "\n";
         }
         $portfolio_items_output .= '</li>' . "\n";
         $count++;
     }
     wp_reset_query();
     wp_reset_postdata();
     $portfolio_items_output .= '</ul>' . "\n";
     /* PAGINATION OUTPUT
        ================================================== */
     if ($pagination == "yes") {
         if ($display_type == "masonry" || $display_type == "masonry-gallery") {
             $portfolio_items_output .= '<div class="pagination-wrap masonry-pagination">';
         } else {
             $portfolio_items_output .= '<div class="pagination-wrap">';
         }
         $portfolio_items_output .= pagenavi($portfolio_items);
         $portfolio_items_output .= '</div>';
     }
     /* FUNCTION OUTPUT
        ================================================== */
     return $portfolio_items_output;
 }
<?php

echo sf_portfolio_thumbnail();