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; }
function sf_portfolio_thumbnail($display_type = "gallery", $multi_size = "", $multi_size_ratio = "1/1", $columns = "2", $hover_show_excerpt = "no", $excerpt_length = 20, $gutters = "yes", $fullwidth = "no") { global $post, $sf_options; $portfolio_thumb = $thumb_image_id = $thumb_image = $thumb_gallery = $video = $item_class = $link_config = $port_hover_style = $port_hover_text_style = ''; $thumb_width = 400; $thumb_height = 300; $video_height = 300; if ($columns == "1") { $thumb_width = 1200; $thumb_height = 900; $video_height = 900; } else { if ($columns == "2") { $thumb_width = 800; $thumb_height = 600; $video_height = 600; } else { if ($columns == "3" || $columns == "4") { if ($fullwidth == "yes") { $thumb_width = 500; $thumb_height = 375; $video_height = 375; } else { $thumb_width = 400; $thumb_height = 300; $video_height = 300; } } } } if ($display_type == "multi-size-masonry") { if ($multi_size_ratio == "4/3") { if ($multi_size == "wide-tall") { $thumb_width = 1000; $thumb_height = 750; } else { if ($multi_size == "tall") { $thumb_width = 500; $thumb_height = 750; } else { if ($multi_size == "wide") { $thumb_width = 1000; $thumb_height = 375; } else { if ($multi_size == "standard") { $thumb_width = 500; $thumb_height = 375; $video_height = 375; } } } } } else { if ($multi_size == "wide-tall") { $thumb_width = 900; $thumb_height = 900; } else { if ($multi_size == "tall") { $thumb_width = 450; $thumb_height = 900; } else { if ($multi_size == "wide") { $thumb_width = 900; $thumb_height = 450; } else { if ($multi_size == "standard") { $thumb_width = 450; $thumb_height = 450; $video_height = 450; } } } } } if ($gutters == "yes" && $multi_size == "tall") { $thumb_height = $thumb_height + 50; } if ($gutters == "yes" && $multi_size == "wide-tall") { $thumb_height = $thumb_height + 15; } } if ($display_type == "masonry" || $display_type == "masonry-gallery") { $thumb_height = null; } $thumb_type = sf_get_post_meta($post->ID, 'sf_thumbnail_type', true); $thumb_image = rwmb_meta('sf_thumbnail_image', 'type=image&size=full'); $thumb_video = sf_get_post_meta($post->ID, 'sf_thumbnail_video_url', true); if ($display_type == "multi-size-masonry" && $multi_size != "") { $thumb_gallery = rwmb_meta('sf_thumbnail_gallery', 'type=image&size=large-square'); } else { if ($columns == "2") { $thumb_gallery = rwmb_meta('sf_thumbnail_gallery', 'type=image&size=thumb-image-twocol'); } else { $thumb_gallery = rwmb_meta('sf_thumbnail_gallery', 'type=image&size=thumb-image'); } } $thumb_link_type = sf_get_post_meta($post->ID, 'sf_thumbnail_link_type', true); $thumb_link_url = sf_get_post_meta($post->ID, 'sf_thumbnail_link_url', true); $thumb_lightbox_thumb = rwmb_meta('sf_thumbnail_image', 'type=image&size=large'); $thumb_lightbox_image = rwmb_meta('sf_thumbnail_link_image', 'type=image&size=large'); $thumb_lightbox_video_url = sf_get_post_meta($post->ID, 'sf_thumbnail_link_video_url', true); $thumb_lightbox_video_url = sf_get_embed_src($thumb_lightbox_video_url); $port_hover_bg_color = sf_get_post_meta($post->ID, 'sf_port_hover_bg_color', true); $port_hover_text_color = sf_get_post_meta($post->ID, 'sf_port_hover_text_color', true); if ($port_hover_bg_color != "") { $overlay_opacity = $sf_options['overlay_opacity']; if ($overlay_opacity == 100) { $overlay_opacity = '1'; } else { $overlay_opacity = '0.' . $overlay_opacity; } $port_hover_bg_rgb = sf_hex2rgb($port_hover_bg_color); $port_hover_style = 'style="background-color:rgba(' . $port_hover_bg_rgb['red'] . ',' . $port_hover_bg_rgb['green'] . ',' . $port_hover_bg_rgb['blue'] . ',' . $overlay_opacity . ');"'; } if ($port_hover_text_color != "") { $port_hover_text_style = 'style="color: ' . $port_hover_text_color . ';"'; } foreach ($thumb_image as $detail_image) { $thumb_image_id = $detail_image['ID']; $thumb_img_url = $detail_image['url']; break; } if (!$thumb_image) { $thumb_image = get_post_thumbnail_id(); $thumb_image_id = $thumb_image; $thumb_img_url = wp_get_attachment_url($thumb_image, 'full'); } $thumb_lightbox_img_url = wp_get_attachment_url($thumb_lightbox_image, 'full'); $image_alt = esc_attr(sf_get_post_meta($thumb_image_id, '_wp_attachment_image_alt', true)); $item_title = get_the_title(); $item_subtitle = sf_get_post_meta($post->ID, 'sf_portfolio_subtitle', true); $permalink = get_permalink(); $item_link = sf_portfolio_item_link(); $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); } if ($display_type == "gallery" || $display_type == "masonry-gallery" || $display_type == "multi-size-masonry") { $portfolio_thumb .= '<figure class="animated-overlay overlay-style">' . "\n"; } else { $portfolio_thumb .= '<figure class="animated-overlay overlay-alt">' . "\n"; } if ($thumb_type == "video") { $video = sf_video_embed($thumb_video, $thumb_width, $video_height); $portfolio_thumb .= '<div class="video-thumb">' . $video . '</div>'; } else { if ($thumb_type == "slider") { $portfolio_thumb .= '<div class="flexslider thumb-slider"><ul class="slides">' . "\n"; foreach ($thumb_gallery as $image) { $portfolio_thumb .= "<li><a " . $item_link['config'] . "><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></a></li>" . "\n"; } $portfolio_thumb .= '</ul></div>' . "\n"; } else { if ($thumb_type == "image" && $thumb_img_url == "") { $thumb_img_url = "default"; } $image = sf_aq_resize($thumb_img_url, $thumb_width, $thumb_height, true, false); if ($image) { $portfolio_thumb .= '<a ' . $item_link['config'] . '></a>'; if ($display_type == "multi-size-masonry") { $portfolio_thumb .= '<div class="multi-masonry-img-wrap"><img itemprop="image" src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[2] . '" alt="' . $image_alt . '" /></div>' . "\n"; } else { $portfolio_thumb .= '<img itemprop="image" src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[2] . '" alt="' . $image_alt . '" />' . "\n"; } $portfolio_thumb .= '<div class="figcaption-wrap"></div>'; if ($item_subtitle != "" && $hover_show_excerpt == "no" && ($display_type == "gallery" || $display_type == "masonry-gallery" || $display_type == "multi-size-masonry")) { $portfolio_thumb .= '<figcaption ' . $port_hover_style . '><div class="thumb-info">'; } else { if ($display_type == "standard" || $display_type == "masonry") { $portfolio_thumb .= '<figcaption ' . $port_hover_style . '><div class="thumb-info thumb-info-alt">'; } else { if ($hover_show_excerpt == "yes" && ($display_type == "gallery" || $display_type == "masonry-gallery")) { $portfolio_thumb .= '<figcaption ' . $port_hover_style . '><div class="thumb-info thumb-info-excerpt">'; } else { $portfolio_thumb .= '<figcaption ' . $port_hover_style . '><div class="thumb-info">'; } } } if ($display_type == "gallery" || $display_type == "masonry-gallery" || $display_type == "multi-size-masonry") { if ($hover_show_excerpt == "yes") { $portfolio_thumb .= '<h4 itemprop="name headline" ' . $port_hover_text_style . '>' . $item_title . '</h4>'; if ($post_excerpt != "") { $portfolio_thumb .= '<div class="name-divide"></div>'; $portfolio_thumb .= '<div itemprop="description" ' . $port_hover_text_style . '>' . $post_excerpt . '</div>'; } } else { $portfolio_thumb .= '<h4 itemprop="name headline" ' . $port_hover_text_style . '>' . $item_title . '</h4>'; if ($item_subtitle != "") { $portfolio_thumb .= '<div class="name-divide"></div>'; $portfolio_thumb .= '<h5 itemprop="name alternativeHeadline" ' . $port_hover_text_style . '>' . $item_subtitle . '</h5>'; } } } else { $portfolio_thumb .= '<i class="' . $item_link['icon'] . '"></i>'; } $portfolio_thumb .= '</div></figcaption>'; } } } $portfolio_thumb .= '</figure>' . "\n"; return $portfolio_thumb; }
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++; } $portfolio_args = array('post_type' => 'portfolio', 'post_status' => 'publish', 'portfolio-category' => $category_slug, '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'; } $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(); $port_hover_style = $port_hover_text_style = ''; $item_title = get_the_title(); $thumb_type = sf_get_post_meta($post->ID, 'sf_thumbnail_type', true); $thumb_image = rwmb_meta('sf_thumbnail_image', 'type=image&size=full'); $thumb_video = sf_get_post_meta($post->ID, 'sf_thumbnail_video_url', true); $thumb_gallery = rwmb_meta('sf_thumbnail_gallery', 'type=image&size=thumb-image'); $thumb_link_type = sf_get_post_meta($post->ID, 'sf_thumbnail_link_type', true); $thumb_link_url = sf_get_post_meta($post->ID, 'sf_thumbnail_link_url', true); $thumb_lightbox_thumb = rwmb_meta('sf_thumbnail_image', 'type=image&size=large'); $thumb_lightbox_image = rwmb_meta('sf_thumbnail_link_image', 'type=image&size=large'); $thumb_lightbox_video_url = sf_get_post_meta($post->ID, 'sf_thumbnail_link_video_url', true); $thumb_lightbox_video_url = sf_get_embed_src($thumb_lightbox_video_url); $port_hover_bg_color = sf_get_post_meta($post->ID, 'sf_port_hover_bg_color', true); $port_hover_text_color = sf_get_post_meta($post->ID, 'sf_port_hover_text_color', true); foreach ($thumb_image as $detail_image) { $thumb_img_url = $detail_image['url']; break; } if (!$thumb_image) { $thumb_image = get_post_thumbnail_id(); $thumb_img_url = wp_get_attachment_url($thumb_image, 'full'); } $thumb_lightbox_img_url = wp_get_attachment_url($thumb_lightbox_image, 'full'); $item_title = get_the_title(); $item_subtitle = sf_get_post_meta($post->ID, 'sf_portfolio_subtitle', true); $permalink = get_permalink(); $item_link = sf_portfolio_item_link(); if ($port_hover_bg_color != "") { $overlay_opacity = $sf_options['overlay_opacity']; if ($overlay_opacity == 100) { $overlay_opacity = '1'; } else { $overlay_opacity = '0.' . $overlay_opacity; } $port_hover_bg_rgb = sf_hex2rgb($port_hover_bg_color); $port_hover_style = 'style="background-color:rgba(' . $port_hover_bg_rgb['red'] . ',' . $port_hover_bg_rgb['green'] . ',' . $port_hover_bg_rgb['blue'] . ',' . $overlay_opacity . ');"'; } if ($port_hover_text_color != "") { $port_hover_text_style = 'style="color: ' . $port_hover_text_color . ';"'; } $items .= '<div itemscope data-id="id-' . $count . '" class="clearfix carousel-item portfolio-item">'; $items .= '<figure class="animated-overlay overlay-style">'; // THUMBNAIL MEDIA TYPE SETUP if ($thumb_type == "video") { $video = sf_video_embed($thumb_video, $figure_width, $figure_height); $items .= $video; } else { if ($thumb_type == "slider") { $items .= '<div class="flexslider thumb-slider"><ul class="slides">'; foreach ($thumb_gallery as $image) { $alt = $image['alt']; if (!$alt) { $alt = $image['title']; } $items .= "<li><a " . $item_link['config'] . "><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$alt}' /></a></li>"; } $items .= '</ul></div>'; } else { if ($thumb_type == "image" && $thumb_img_url == "") { $thumb_img_url = "default"; } $image = sf_aq_resize($thumb_img_url, $figure_width, $figure_height, true, false); if ($image) { $items .= '<img itemprop="image" src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[2] . '" alt="' . $item_title . '" />'; $items .= '<a ' . $item_link['config'] . '></a>'; $items .= '<figcaption ' . $port_hover_style . '><div class="thumb-info">'; $items .= '<h4 ' . $port_hover_text_style . '>' . $item_title . '</h4>'; if ($item_subtitle != "") { $items .= '<div class="name-divide"></div>'; $items .= '<h5 ' . $port_hover_text_style . '>' . $item_subtitle . '</h5>'; } $items .= '</div></figcaption>'; } } } $items .= '</figure>'; $items .= '</div>'; $count++; } wp_reset_query(); 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">'; $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; }