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; }
public function content($atts, $content = null) { $el_class = $width = $image_size = $animation = $frame = $lightbox = $hover_style = $image_link = $link_target = $caption = $fullwidth = $el_position = $el_class = $image = ''; extract(shortcode_atts(array('title' => '', 'width' => '1/1', 'image' => $image, 'image_size' => '', 'image_width' => '', 'intro_animation' => 'none', 'animation_delay' => '200', 'frame' => '', 'lightbox' => '', 'image_link' => '', 'link_target' => '', 'hover_style' => 'default', 'overflow_mode' => '', 'caption' => '', 'caption_pos' => 'hover', 'fullwidth' => 'no', 'remove_rounded' => '', 'el_position' => '', 'el_class' => ''), $atts)); $link_icon = apply_filters('sf_link_icon', '<i class="ss-link"></i>'); $view_icon = apply_filters('sf_view_icon', '<i class="ss-view"></i>'); $link_icon_svg = apply_filters('sf_link_icon_svg', ''); $view_icon_svg = apply_filters('sf_view_icon_svg', ''); $caption = html_entity_decode($caption); if ($image_size == "") { $image_size = "large"; } $output = ''; if ($fullwidth == "yes" && $width == "1/1") { $fullwidth = true; } else { $fullwidth = false; } // $img = spb_getImageBySize( array( // 'attach_id' => preg_replace( '/[^\d]/', '', $image ), // 'thumb_size' => $image_size // ) ); $img_id = preg_replace('/[^\\d]/', '', $image); $img = wp_get_attachment_image($img_id, $image_size, false); $img_url = wp_get_attachment_image_src($image, 'large'); $el_class = $this->getExtraClass($el_class); $width = spb_translateColumnWidthToSpan($width); // $content = !empty($image) ? '<img src="'..'" alt="">' : ''; $content = ''; if ($image_width != "") { $image_width = 'style="width:' . $image_width . 'px;margin:0 auto;"'; } // Thumb Type if ($hover_style == "default" && function_exists('sf_get_thumb_type')) { $el_class .= ' ' . sf_get_thumb_type(); } else { $el_class .= ' thumbnail-' . $hover_style; } if ($caption_pos == "hover" && $caption != "") { $el_class .= ' gallery-item'; } if ($remove_rounded == "yes") { $el_class .= ' square-corners'; } if ($overflow_mode == "left") { $el_class .= ' image-overflow-left'; } if ($overflow_mode == "right") { $el_class .= ' image-overflow-right'; } if ($intro_animation != "none") { $output .= "\n\t" . '<div class="spb_content_element spb_image sf-animation ' . $frame . ' ' . $width . $el_class . '" data-animation="' . $intro_animation . '" data-delay="' . $animation_delay . '">'; } else { $output .= "\n\t" . '<div class="spb_content_element spb_image ' . $frame . ' ' . $width . $el_class . '">'; } $output .= "\n\t\t" . '<div class="spb-asset-content">'; $output .= $title != '' ? "\n\t\t\t" . $this->spb_title($title, '', $fullwidth) : ''; if ($caption_pos == "hover" && $caption != "") { $output .= '<figure class="animated-overlay overlay-style caption-hover clearfix" ' . $image_width . '>'; } else { if ($lightbox == "yes" || $image_link != "") { $output .= '<figure class="animated-overlay overlay-alt clearfix" ' . $image_width . '>'; } else { $output .= '<figure class="clearfix" ' . $image_width . '>'; } } if ($image_link != "") { $output .= "\n\t\t" . '<a class="img-link" href="' . $image_link . '" target="' . $link_target . '"></a>'; $output .= '<div class="img-wrap">' . $img . '</div>'; $output .= '<div class="figcaption-wrap"></div>'; $output .= '<figcaption>'; if ($caption_pos == "hover") { $output .= '<div class="thumb-info">'; if ($view_icon_svg != "") { $output .= $view_icon_svg; } $output .= '<h4>' . $caption . '</h4>'; } else { $output .= '<div class="thumb-info thumb-info-alt">'; if ($link_icon_svg != "") { $output .= $link_icon_svg; } else { $output .= $link_icon; } } $output .= '</div></figcaption>'; } else { if ($lightbox == "yes") { $output .= '<div class="img-wrap">' . $img . '</div>'; if ($img_url[0] != "") { $output .= '<a class="lightbox" href="' . $img_url[0] . '" data-rel="ilightbox[' . $image . '-' . rand(0, 1000) . ']" data-caption="' . $caption . '"></a>'; } $output .= '<div class="figcaption-wrap"></div>'; $output .= '<figcaption>'; if ($caption_pos == "hover") { if ($caption != "") { $output .= '<div class="thumb-info">'; if ($view_icon_svg != "") { $output .= $view_icon_svg; } $output .= '<h4>' . $caption . '</h4>'; } else { $output .= '<div class="thumb-info thumb-info-alt">'; if ($view_icon_svg != "") { $output .= $view_icon_svg; } else { $output .= $view_icon; } } } else { $output .= '<div class="thumb-info thumb-info-alt">'; if ($view_icon_svg != "") { $output .= $view_icon_svg; } else { $output .= $view_icon; } } $output .= '</div></figcaption>'; } else { $output .= "\n\t\t" . '<div class="img-wrap">' . $img . '</div>'; $output .= '<div class="figcaption-wrap"></div>'; if ($caption_pos == "hover" && $caption != "") { $output .= '<figcaption>'; $output .= '<div class="thumb-info">'; if ($link_icon_svg != "") { $output .= $link_icon_svg; } $output .= '<h4>' . $caption . '</h4>'; $output .= '</div></figcaption>'; } } } $output .= '</figure>'; if ($caption_pos == "below" && $caption != "") { $output .= '<div class="image-caption">'; $output .= '<h4>' . $caption . '</h4>'; $output .= '</div>'; } $output .= "\n\t\t" . '</div>'; $output .= "\n\t" . '</div> ' . $this->endBlockComment($width); if ($fullwidth == "yes") { $output = $this->startRow($el_position, '', true) . $output . $this->endRow($el_position, '', true); } else { $output = $this->startRow($el_position) . $output . $this->endRow($el_position); } return $output; }
function sf_portfolio_related_projects() { global $post, $sf_options; $fullwidth = $sf_options['related_projects_fullwidth']; $item_count = $sf_options['related_projects_columns']; $related = sf_portfolio_related_posts($post->ID, $item_count); $item_class = "col-sm-4"; $wrap_class = $heading_class = ""; if ($fullwidth) { $heading_class = "container"; } else { $wrap_class = "container"; } $hover_style = "default"; // Thumb Type if ($hover_style == "default" && function_exists('sf_get_thumb_type')) { $wrap_class .= ' ' . sf_get_thumb_type(); } else { $wrap_class .= ' thumbnail-' . $hover_style; } if ($item_count == "4") { $item_class = "col-sm-3"; } if ($related->have_posts()) { ?> <section class="related-projects <?php echo esc_attr($wrap_class); ?> clearfix"> <h2 class="<?php echo esc_attr($heading_class); ?> "><?php apply_filters('sf_related_projects_heading', _e("Related Projects", "swiftframework")); ?> </h2> <div class="clearfix"> <?php while ($related->have_posts()) { $related->the_post(); ?> <?php $item_title = get_the_title(); $item_subtitle = sf_get_post_meta($post->ID, 'sf_portfolio_subtitle', true); $thumb_image = $port_hover_style = $port_hover_text_style = ""; $thumb_image = sf_get_post_meta($post->ID, 'sf_thumbnail_image', true); if (!$thumb_image) { $thumb_image = get_post_thumbnail_id(); } $thumb_img_url = wp_get_attachment_url($thumb_image, 'full'); if ($thumb_img_url == "") { $thumb_img_url = "default"; } $image = sf_aq_resize($thumb_img_url, 500, 375, true, false); $image_alt = esc_attr(sf_get_post_meta($thumb_image, '_wp_attachment_image_alt', true)); $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 . ';"'; } ?> <article class="<?php echo esc_attr($item_class); ?> "> <figure class="animated-overlay overlay-style"> <img src="<?php echo esc_url($image[0]); ?> " width="<?php echo esc_attr($image[1]); ?> " height="<?php echo esc_attr($image[2]); ?> " alt="<?php echo esc_attr($image_alt); ?> "/> <a href="<?php the_permalink(); ?> "></a> <figcaption <?php echo esc_attr($port_hover_style); ?> > <div class="thumb-info"> <h4 <?php echo esc_attr($port_hover_text_style); ?> ><?php echo esc_attr($item_title); ?> </h4> <div class="name-divide"></div> <h5 <?php echo esc_attr($port_hover_text_style); ?> ><?php echo esc_attr($item_subtitle); ?> </h5> </div> </figcaption> </figure> </article> <?php } ?> </div> </section> <?php } }
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; }
function sf_galleries($display_type, $link_type, $fullwidth, $gutters, $columns, $show_title, $show_subtitle, $show_excerpt, $excerpt_length, $item_count, $category, $pagination, $sidebars, $hover_style) { /* OUTPUT VARIABLE ================================================== */ $gallery_items_output = ""; $count = 0; /* CATEGORY SLUG MODIFICATION ================================================== */ if ($category == "All") { $category = "all"; } if ($category == "all") { $category = ''; } $category_slug = str_replace('_', '-', $category); /* GALLERIES 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; } $galleries_args = array('post_type' => 'galleries', 'post_status' => 'publish', 'paged' => $paged, 'gallery-category' => $category_slug, 'posts_per_page' => $item_count); $galleries_items = new WP_Query($galleries_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-galleries filterable-items col-' . $columns . ' row clearfix'; } else { $list_class .= 'standard-galleries filterable-items col-' . $columns . ' row clearfix'; } } // Full width if ($fullwidth == "yes") { $list_class .= ' galleries-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; } /* ITEMS OUTPUT ================================================== */ global $sf_options; $gallery_items_output .= '<ul class="gallery-items ' . $list_class . '">' . "\n"; while ($galleries_items->have_posts()) { $galleries_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_gallery_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); } $post_terms = get_the_terms($post->ID, 'gallery-category'); $term_slug = " "; if (!empty($post_terms)) { foreach ($post_terms as $post_term) { $term_slug = $term_slug . $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 "; } } } } } /* 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 { $item_class .= "standard "; } } /* LINK TYPE CONFIG ================================================== */ $gallery_id = rand(0, 10000); $item_link = sf_gallery_item_link($link_type, $gallery_id); /* ITEM OUTPUT ================================================== */ $gallery_items_output .= '<li itemscope itemtype="http://schema.org/CreativeWork" data-id="id-' . $count . '" class="clearfix gallery-item ' . $item_class . ' ' . $term_slug . '">' . "\n"; /* THUMBNAIL CONFIG ================================================== */ if ($thumb_type != "none") { $gallery_items_output .= sf_gallery_thumbnail($display_type, $link_type, $columns, $gutters, $count, $gallery_id); } if ($display_type != "gallery" && $display_type != "masonry-gallery") { $gallery_items_output .= '<div class="gallery-item-details">' . "\n"; if ($show_title == "yes") { $gallery_items_output .= '<div class="comments-likes">'; if (function_exists('lip_love_it_link')) { $gallery_items_output .= lip_love_it_link(get_the_ID(), false); } $gallery_items_output .= '</div>'; $gallery_items_output .= '<h3 class="gallery-item-title" itemprop="name headline"><a href="' . get_permalink() . '">' . $item_title . '</a></h3>' . "\n"; } if ($show_subtitle == "yes" && $item_subtitle) { $gallery_items_output .= '<h5 class="gallery-subtitle" itemprop="name alternativeHeadline">' . $item_subtitle . '</h5>' . "\n"; } if ($show_excerpt == "yes") { $gallery_items_output .= '<div class="gallery-item-excerpt" itemprop="description">' . $post_excerpt . '</div>' . "\n"; } $gallery_items_output .= '</div>' . "\n"; } if ($item_link["script"] != "") { $gallery_items_output .= $item_link["script"]; } $gallery_items_output .= '</li>' . "\n"; $count++; } wp_reset_query(); wp_reset_postdata(); $gallery_items_output .= '</ul>' . "\n"; /* PAGINATION OUTPUT ================================================== */ if ($pagination == "yes") { if ($display_type == "masonry" || $display_type == "masonry-gallery") { $gallery_items_output .= '<div class="pagination-wrap masonry-pagination">'; } else { $gallery_items_output .= '<div class="pagination-wrap">'; } $gallery_items_output .= pagenavi($galleries_items); $gallery_items_output .= '</div>'; } /* FUNCTION OUTPUT ================================================== */ return $gallery_items_output; }
protected function content($atts, $content = null) { $title = $width = $el_class = $gallery_id = $output = $items = $hover_style = $masonry_gallery = $main_slider = $thumb_slider = $el_position = $gallery_images = $thumb_images = ''; extract(shortcode_atts(array('title' => '', 'gallery_id' => '', 'display_type' => '', 'columns' => '', 'fullwidth' => '', 'gutters' => '', 'image_size' => '', 'show_thumbs' => '', 'show_captions' => '', 'autoplay' => 'no', 'hover_style' => 'default', 'enable_lightbox' => 'yes', 'slider_transition' => 'slide', 'el_position' => '', 'width' => '1/1', 'el_class' => ''), $atts)); $search_icon = apply_filters('sf_search_icon', '<i class="ss-search"></i>'); $view_icon_svg = apply_filters('sf_view_icon_svg', ''); /* SIDEBAR CONFIG ================================================== */ $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'; } } /* GALLERY ================================================== */ $gallery_args = array('post_type' => 'galleries', 'post_status' => 'publish', 'p' => $gallery_id); $gallery_query = new WP_Query($gallery_args); while ($gallery_query->have_posts()) { $gallery_query->the_post(); if ($display_type == "masonry") { /* WRAP VARIABLE CONFIG ================================================== */ $list_class = ""; if ($fullwidth == "yes") { $list_class .= ' portfolio-full-width'; } 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; } /* COLUMN VARIABLE CONFIG ================================================== */ $item_class = ""; $gallery_image_size = "gallery-image"; if ($columns == "1") { $item_class = "col-sm-12 "; $gallery_image_size = "full"; } else { if ($columns == "2") { $item_class = "col-sm-6 "; $gallery_image_size = "gallery-image"; } else { if ($columns == "3") { $item_class = "col-sm-4 "; $gallery_image_size = "gallery-image"; } else { if ($columns == "4") { $item_class = "col-sm-3 "; $gallery_image_size = "thumb-image"; } else { if ($columns == "5") { $item_class = "col-sm-sf-5 "; $gallery_image_size = "thumb-image"; } } } } } if ($columns == "5" && $width != "1/1") { $gallery_image_size = "thumb-square"; } if ($image_size != "") { $gallery_image_size = $image_size; } $gallery_images = rwmb_meta('sf_gallery_images', 'type=image&size=' . $gallery_image_size); $masonry_gallery .= '<div class="masonry-gallery filterable-items ' . $list_class . '">' . "\n"; $lightbox_id = $gallery_id . '-' . rand(); foreach ($gallery_images as $image) { $masonry_gallery .= '<div class="gallery-image ' . $item_class . '">'; $masonry_gallery .= '<figure class="animated-overlay overlay-style">'; if ($enable_lightbox == "yes") { $masonry_gallery .= '<a href="' . $image['full_url'] . '" class="lightbox" data-rel="ilightbox[' . $lightbox_id . ']" data-caption="' . $image['caption'] . '"></a>'; } $masonry_gallery .= '<img src="' . $image['url'] . '" width="' . $image['width'] . '" height="' . $image['height'] . '" alt="' . $image['alt'] . '" /></a>'; if ($show_captions == "yes") { $masonry_gallery .= '<figcaption><div class="thumb-info">'; if ($image['caption'] != "") { $masonry_gallery .= '<h3>' . $image['caption'] . '</h3>'; } else { $masonry_gallery .= '<h3>' . $image['title'] . '</h3>'; } $masonry_gallery .= '</figcaption>' . "\n"; } else { if ($enable_lightbox == "yes") { $masonry_gallery .= '<figcaption><div class="thumb-info thumb-info-alt">'; if ($view_icon_svg != "") { $masonry_gallery .= $view_icon_svg; } else { $masonry_gallery .= $search_icon; } $masonry_gallery .= '</figcaption>' . "\n"; } } $masonry_gallery .= '</figure>' . "\n"; $masonry_gallery .= '</div>' . "\n"; } $masonry_gallery .= '</div>' . "\n"; $items .= $masonry_gallery; } else { if (spb_get_theme_name() == "atelier" || spb_get_theme_name() == "uplift" || spb_get_theme_name() == "nota") { $gallery_images = rwmb_meta('sf_gallery_images', 'type=image&size=thumb-square'); $main_slider .= '<div class="flexslider gallery-slider" data-transition="' . $slider_transition . '" data-autoplay="' . $autoplay . '" data-thumbs="' . $show_thumbs . '"><ul class="slides">' . "\n"; $lightbox_id = $gallery_id . '-' . rand(); foreach ($gallery_images as $image) { if ($show_thumbs == "yes") { $main_slider .= '<li data-thumb="' . $image["url"] . '">'; } else { $main_slider .= '<li>'; } if ($enable_lightbox == "yes") { $main_slider .= "<a href='{$image['full_url']}' class='lightbox zoom' data-rel='ilightbox[galleryid-" . $lightbox_id . "]' data-caption='{$image['caption']}'><i class='fa-search-plus'></i></a>"; } if (isset($image['image_srcset'])) { $main_slider .= $image['image_srcset']; } else { $main_slider .= "<img src='{$image['full_url']}' alt='{$image['alt']}' />"; } if ($show_captions == "yes" && $image['caption'] != "") { $main_slider .= '<p class="flex-caption">' . $image['caption'] . '</p>'; } $main_slider .= "</li>" . "\n"; } $main_slider .= '</ul></div>' . "\n"; $items .= $main_slider; } else { $gallery_images = rwmb_meta('sf_gallery_images', 'type=image&size=blog-image'); $thumb_images = rwmb_meta('sf_gallery_images', 'type=image&size=thumb-square'); $main_slider .= '<div class="flexslider gallery-slider" data-transition="' . $slider_transition . '" data-autoplay="' . $autoplay . '"><ul class="slides">' . "\n"; $lightbox_id = $gallery_id . '-' . rand(); foreach ($gallery_images as $image) { $main_slider .= "<li>"; if ($enable_lightbox == "yes") { $main_slider .= "<a href='{$image['full_url']}' class='lightbox' data-rel='ilightbox[galleryid-" . $lightbox_id . "]' data-caption='{$image['caption']}'>"; } if (isset($image['image_srcset'])) { $main_slider .= $image['image_srcset']; } else { $main_slider .= "<img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' />"; } if ($enable_lightbox == "yes") { $main_slider .= "</a>"; } if ($show_captions == "yes" && $image['caption'] != "") { $main_slider .= '<p class="flex-caption">' . $image['caption'] . '</p>'; } $main_slider .= "</li>" . "\n"; } $main_slider .= '</ul></div>' . "\n"; if ($show_thumbs == "yes") { $thumb_slider .= '<div class="flexslider gallery-nav"><ul class="slides">' . "\n"; foreach ($thumb_images as $image) { $thumb_slider .= "<li><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></li>" . "\n"; } $thumb_slider .= '</ul></div>' . "\n"; } $items .= $main_slider; $items .= $thumb_slider; } } } wp_reset_postdata(); /* PAGE BUILDER OUTPUT ================================================== */ if ($fullwidth == "yes" && $sidebars == "no-sidebars") { $fullwidth = true; } else { $fullwidth = false; } $width = spb_translateColumnWidthToSpan($width); $el_class = $this->getExtraClass($el_class); $output .= "\n\t" . '<div class="spb_gallery_widget gallery-' . $display_type . ' spb_content_element ' . $width . $el_class . '">'; $output .= "\n\t\t" . '<div class="spb-asset-content">'; $output .= $title != '' ? "\n\t\t\t" . $this->spb_title($title, '', $fullwidth) : ''; $output .= "\n\t\t" . $items; $output .= "\n\t\t" . '</div>'; $output .= "\n\t" . '</div> ' . $this->endBlockComment($width); if ($fullwidth) { $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_has_gallery; $sf_has_gallery = true; return $output; }
function sf_gallery($attr) { $post = get_post(); static $instance = 0; $instance++; if (!empty($attr['ids'])) { // 'ids' is explicitly ordered, unless you specify otherwise. if (empty($attr['orderby'])) { $attr['orderby'] = 'post__in'; $attr['include'] = $attr['ids']; } } // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ($output != '') { return $output; } // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'large', 'include' => '', 'exclude' => ''), $attr, 'gallery')); $id = intval($id); if ('RAND' == $order) { $orderby = 'none'; } if (!empty($include)) { $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) { return ''; } if (is_feed()) { $output = "\n"; foreach ($attachments as $att_id => $attachment) { $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; } return $output; } $itemtag = tag_escape($itemtag); $captiontag = tag_escape($captiontag); $icontag = tag_escape($icontag); $valid_tags = wp_kses_allowed_html('post'); if (!isset($valid_tags[$itemtag])) { $itemtag = 'dl'; } if (!isset($valid_tags[$captiontag])) { $captiontag = 'dd'; } if (!isset($valid_tags[$icontag])) { $icontag = 'dt'; } $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100 / $columns) : 100; $float = is_rtl() ? 'right' : 'left'; $selector = "gallery-{$instance}"; $gallery_style = $list_class = ''; $size_class = sanitize_html_class($size); $hover_style = "default"; // Thumb Type if ($hover_style == "default" && function_exists('sf_get_thumb_type')) { $list_class = sf_get_thumb_type(); } else { $list_class = 'thumbnail-' . $hover_style; } $output = "<div id='{$selector}' class='gallery-shortcode galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class} {$list_class}'>"; $i = 0; foreach ($attachments as $id => $attachment) { $image_output = '<figure class="animated-overlay overlay-style">'; $image_file_url = wp_get_attachment_image_src($id, $size); $image_file_lightbox_url = wp_get_attachment_url($id, "full"); $image_caption = wptexturize($attachment->post_excerpt); $image_meta = wp_get_attachment_metadata($id); $image_alt = sf_get_post_meta($id, '_wp_attachment_image_alt', true); $image_title = get_the_title($id); $image_output .= '<img src="' . $image_file_url[0] . '" alt="' . $image_alt . '" />'; if (!empty($attr['link']) && 'file' === $attr['link']) { $image_output .= '<a href="' . $image_file_lightbox_url . '" class="lightbox" data-rel="ilightbox[galleryid-' . $instance . ']" title="' . $image_alt . '" data-title="' . $image_alt . '" data-caption="' . $image_caption . '"></a>'; } elseif (!empty($attr['link']) && 'none' === $attr['link']) { } else { $image_output .= '<a href="' . get_attachment_link($id) . '"></a>'; } if ($image_title != "") { $image_output .= '<figcaption><div class="thumb-info">'; $image_output .= '<h4 itemprop="name headline">' . $image_title . '</h4>'; } else { $image_output .= '<figcaption><div class="thumb-info thumb-info-alt">'; $image_output .= apply_filters('sf_search_icon', '<i class="ss-search"></i>'); } $image_output .= '</div></figcaption>'; $image_output .= '</figure>'; if ($captiontag && trim($attachment->post_excerpt)) { $image_output .= '<div class="gallery-item-caption">' . wptexturize($attachment->post_excerpt) . '</div>'; } $orientation = ''; if (isset($image_meta['height'], $image_meta['width'])) { $orientation = $image_meta['height'] > $image_meta['width'] ? 'portrait' : 'landscape'; } $output .= "<{$itemtag} class='gallery-item'>"; $output .= "\n \t\t\t\t<{$icontag} class='{$orientation}'>\n \t\t\t\t{$image_output}\n \t\t\t\t</{$icontag}>"; $output .= "</{$itemtag}>"; } $output .= "\n \t\t\t<br style='clear: both;' />\n \t\t\t</div>\n"; return $output; }
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; }
function sf_blog_items($atts) { extract(shortcode_atts(array('blog_type' => '', 'gutters' => '', 'columns' => '', 'fullwidth' => '', 'show_title' => '', 'show_excerpt' => '', 'show_details' => '', 'offset' => '', 'order_by' => 'date', 'order' => 'DESC', 'excerpt_length' => '', 'show_read_more' => '', 'item_count' => '', 'category' => '', 'exclude_categories' => '', 'pagination' => '', 'social_integration' => '', 'twitter_username' => '', 'instagram_id' => '', 'instagram_token' => '', 'insta_item_count' => '', 'tweet_item_count' => '', 'blog_filter' => '', 'alt_styling' => '', 'hover_style' => '', 'content_output' => '', 'post_type' => '', 'width' => ''), $atts)); $blog_items_output = ""; global $sf_options, $sf_sidebar_config; /* CATEGORY SLUG MODIFICATION ================================================== */ if ($category == "All") { $category = "all"; } if ($category == "all") { $category = ''; } $category_slug = str_replace('_', '-', $category); /* BLOG QUERY SETUP ================================================== */ global $post, $wp_query; if (get_query_var('paged')) { $paged = get_query_var('paged'); $offset = $offset + $item_count * ($paged - 1); } elseif (get_query_var('page')) { $paged = get_query_var('page'); $offset = $offset + $item_count * ($paged - 1); } else { $paged = 1; } if ($post_type == "") { $post_type = "post"; } $blog_args = array(); $category_array = explode(",", $category_slug); if (isset($category_array) && $category_array[0] != "") { $blog_args = array('post_type' => $post_type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => $item_count, 'offset' => $offset, 'order' => $order, 'orderby' => $order_by, 'tax_query' => array(array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $category_array))); } else { $blog_args = array('post_type' => $post_type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => $item_count, 'offset' => $offset, 'order' => $order, 'orderby' => $order_by); } $blog_items = new WP_Query($blog_args); /* LIST CLASS CONFIG ================================================== */ $list_class = $wrap_class = ''; if ($blog_type == "masonry") { $list_class .= 'masonry-items'; 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; } } else { if ($blog_type == "bold") { $list_class .= 'bold-items'; } else { if ($blog_type == "mini") { $list_class .= 'mini-items'; } else { if ($blog_type == "timeline") { $list_class .= 'timeline-items'; if ($sf_sidebar_config == "no-sidebars") { $wrap_class .= apply_filters('sf_timeline_blog_nosidebars_wrap_class', 'col-sm-8 col-sm-offset-2'); } } else { $list_class .= 'standard-items row'; } } } } if ($alt_styling == "yes") { $list_class .= ' alt-styling'; } if ($pagination == "infinite-scroll") { $list_class .= ' blog-inf-scroll'; } /* BLOG ITEMS OUTPUT ================================================== */ $blog_items_output .= '<div class="blog-items-wrap blog-' . $blog_type . ' ' . $wrap_class . '">'; if ($blog_type == "timeline") { $blog_items_output .= '<div class="timeline"></div>'; } if ($social_integration == "yes" && $pagination == "none" && ($twitter_username != "" || $instagram_id != "")) { $blog_items_output .= '<ul class="blog-items ' . $list_class . ' social-blog clearfix" data-blog-type="' . $blog_type . '">'; } else { $blog_items_output .= '<ul class="blog-items ' . $list_class . ' clearfix" data-blog-type="' . $blog_type . '">'; } while ($blog_items->have_posts()) { $blog_items->the_post(); $post_format = get_post_format($post->ID); if ($post_format == "") { $post_format = 'standard'; } if ($blog_type == "mini" || $blog_type == "standard" || $blog_type == "timeline") { $item_class = "col-sm-12"; } else { if ($blog_type == "masonry" && $fullwidth == "yes") { $item_class = "col-sm-3"; } else { if ($blog_type == "masonry") { if ($columns == "5") { $item_class = "col-sm-sf-5"; } else { if ($columns == "4") { $item_class = "col-sm-3"; } else { if ($columns == "3") { $item_class = "col-sm-4"; } else { if ($columns == "2") { $item_class = "col-sm-6"; } else { if ($columns == "1") { $item_class = "col-sm-12"; } } } } } } else { $item_class = "col-sm-12"; } } } $taxonomy_name = 'category'; if ($post_type != "post") { $taxonomy_name = $post_type . '-category'; } $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 . $post_term->slug . ' '; } } /* BLOG ITEM OUTPUT ================================================== */ $blog_items_output .= '<li itemscope itemtype="http://schema.org/BlogPosting" class="blog-item ' . $item_class . ' ' . $term_slug . ' ' . implode(' ', get_post_class()) . '" id="' . get_the_ID() . '" data-date="' . get_the_time('U') . '">'; $blog_items_output .= sf_get_post_item($post->ID, $blog_type, $show_title, $show_excerpt, $show_details, $excerpt_length, $content_output, $show_read_more, $fullwidth); $blog_items_output .= '</li>'; } wp_reset_query(); wp_reset_postdata(); $blog_items_output .= '</ul>'; /* SOCIAL INTEGRATION ================================================== */ if ($social_integration == "yes" && $pagination == "none") { $tweet_count = $instagram_count = floor($item_count / 4); $item_count = $item_count - $tweet_count - $instagram_count; if ($instagram_id == "") { $tweet_count = $tweet_count * 2; } else { if ($twitter_username == "") { $instagram_count = $instagram_count * 2; } } if ($insta_item_count != "") { $instagram_count = $insta_item_count; } if ($tweet_item_count != "") { $tweet_count = $tweet_item_count; } /* TWEETS ================================================== */ if ($twitter_username != "") { if ($fullwidth == "yes") { $blog_items_output .= '<ul class="blog-tweets">' . sf_get_tweets($twitter_username, $tweet_count, 'blog-fw', $item_class) . '</ul>'; } else { $blog_items_output .= '<ul class="blog-tweets">' . sf_get_tweets($twitter_username, $tweet_count, 'blog', $item_class) . '</ul>'; } } /* INSTAGRAMS ================================================== */ if ($instagram_id != "" && $instagram_token != "") { $blog_items_output .= '<ul class="blog-instagrams" data-title="' . __("Instagram", "swiftframework") . '" data-count="' . $instagram_count . '" data-userid="' . $instagram_id . '" data-token="' . $instagram_token . '" data-itemclass="' . $item_class . '"></ul>'; } } /* PAGINATION OUTPUT ================================================== */ if ($pagination == "infinite-scroll") { global $sf_include_infscroll; $sf_include_infscroll = true; $blog_items_output .= '<div class="pagination-wrap hidden">'; $blog_items_output .= pagenavi($blog_items); $blog_items_output .= '</div>'; } else { if ($pagination == "load-more") { global $sf_include_infscroll; $sf_include_infscroll = true; $blog_items_output .= '<a href="#" class="load-more-btn">' . __('Load More', 'swiftframework') . '</a>'; $blog_items_output .= '<div class="pagination-wrap load-more hidden">'; $blog_items_output .= pagenavi($blog_items); $blog_items_output .= '</div>'; } else { if ($pagination == "standard") { if ($blog_type == "masonry") { $blog_items_output .= '<div class="pagination-wrap masonry-pagination">'; } else { $blog_items_output .= '<div class="pagination-wrap">'; } $blog_items_output .= pagenavi($blog_items); $blog_items_output .= '</div>'; } } } $blog_items_output .= '</div>'; /* FUNCTION OUTPUT ================================================== */ return $blog_items_output; }
function sf_portfolio_related_projects() { global $post, $sf_options; $fullwidth = $sf_options['related_projects_fullwidth']; $gutters = false; if (isset($sf_options['related_projects_gutters'])) { $gutters = $sf_options['related_projects_gutters']; } $item_count = $sf_options['related_projects_columns']; $related = sf_portfolio_related_posts($post->ID, $item_count); $item_class = "col-sm-4"; $wrap_class = $heading_class = ""; if ($fullwidth) { $heading_class = "container"; } else { $wrap_class = "container"; } $hover_style = "default"; if ($gutters) { $wrap_class .= " gutters"; } else { $wrap_class .= " no-gutters"; } // Thumb Type if (function_exists('sf_get_thumb_type') && sf_theme_opts_name() == "sf_atelier_options") { $wrap_class .= ' ' . sf_get_thumb_type(); } else { if (function_exists('sf_get_thumb_type') && $hover_style == "default") { $wrap_class .= ' ' . sf_get_thumb_type(); } else { $wrap_class .= ' thumbnail-' . $hover_style; } } if ($item_count == "4") { $item_class = "col-sm-3"; } if (sf_theme_supports('alt-gallery-hover')) { $item_class .= " portfolio-item gallery-item"; } if ($related->have_posts()) { ?> <section class="related-projects <?php echo esc_attr($wrap_class); ?> clearfix"> <h2 class="<?php echo esc_attr($heading_class); ?> "><?php echo apply_filters('sf_related_projects_heading', __("Related Projects", "swiftframework")); ?> </h2> <div class="row clearfix"> <?php while ($related->have_posts()) { $related->the_post(); ?> <?php $item_title = get_the_title(); $item_subtitle = sf_get_post_meta($post->ID, 'sf_portfolio_subtitle', true); $thumb_image = $port_hover_style = $port_hover_text_style = ""; $thumb_image = sf_get_post_meta($post->ID, 'sf_thumbnail_image', true); if (!$thumb_image) { $thumb_image = get_post_thumbnail_id(); } $thumb_img_url = wp_get_attachment_url($thumb_image, 'full'); if ($thumb_img_url == "") { $thumb_img_url = "default"; } $image = sf_aq_resize($thumb_img_url, 500, 375, true, false); $image_alt = esc_attr(sf_get_post_meta($thumb_image, '_wp_attachment_image_alt', true)); $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 != "") { if (isset($sf_options['overlay_opacity'])) { $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 . ');"'; } else { if (isset($sf_options['overlay_opacity_top'])) { $overlay_opacity_top = $sf_options['overlay_opacity_top']; $overlay_opacity_bottom = $sf_options['overlay_opacity_bottom']; $port_hover_bg_rgb = sf_hex2rgb($port_hover_bg_color); if ($overlay_opacity_top < 100 || $overlay_opacity_bottom < 100) { $overlay_opacity_top = $overlay_opacity_top < 100 ? '0.' . $overlay_opacity_top : '1.0'; $overlay_opacity_bottom = $overlay_opacity_bottom < 100 ? '0.' . $overlay_opacity_bottom : '1.0'; $port_hover_style = 'style="background: -webkit-gradient(linear,left top,left bottom,color-stop(25%,rgba(' . $port_hover_bg_rgb["red"] . ',' . $port_hover_bg_rgb["green"] . ',' . $port_hover_bg_rgb["blue"] . ', ' . $overlay_opacity_top . ')),to(rgba(' . $port_hover_bg_rgb["red"] . ',' . $port_hover_bg_rgb["green"] . ',' . $port_hover_bg_rgb["blue"] . ', ' . $overlay_opacity_bottom . '))); background: -webkit-linear-gradient(top, rgba(' . $port_hover_bg_rgb["red"] . ',' . $port_hover_bg_rgb["green"] . ',' . $port_hover_bg_rgb["blue"] . ', ' . $overlay_opacity_top . ') 25%,rgba(' . $port_hover_bg_rgb["red"] . ',' . $port_hover_bg_rgb["green"] . ',' . $port_hover_bg_rgb["blue"] . ', ' . $overlay_opacity_bottom . ') 100%); background: linear-gradient(to bottom, rgba(' . $port_hover_bg_rgb["red"] . ',' . $port_hover_bg_rgb["green"] . ',' . $port_hover_bg_rgb["blue"] . ', ' . $overlay_opacity_top . ') 25%, rgba(' . $port_hover_bg_rgb["red"] . ',' . $port_hover_bg_rgb["green"] . ',' . $port_hover_bg_rgb["blue"] . ', ' . $overlay_opacity_bottom . ') 100%);"'; } } } } if ($port_hover_text_color != "") { $port_hover_text_style = 'style="color: ' . $port_hover_text_color . ';"'; } ?> <article class="<?php echo esc_attr($item_class); ?> "> <figure class="animated-overlay overlay-style"> <img src="<?php echo esc_url($image[0]); ?> " width="<?php echo esc_attr($image[1]); ?> " height="<?php echo esc_attr($image[2]); ?> " alt="<?php echo esc_attr($image_alt); ?> "/> <a href="<?php the_permalink(); ?> "></a> <figcaption <?php echo esc_attr($port_hover_style); ?> > <div class="thumb-info"> <h4 <?php echo esc_attr($port_hover_text_style); ?> ><?php echo esc_attr($item_title); ?> </h4> <div class="name-divide"></div> <h5 <?php echo esc_attr($port_hover_text_style); ?> ><?php echo esc_attr($item_subtitle); ?> </h5> </div> </figcaption> </figure> </article> <?php } ?> </div> </section> <?php } }