/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ function widget($args, $instance) { $title = isset($instance['title']) ? $instance['title'] : __('Recent Posts', 'wpex'); $title = apply_filters('widget_title', $title); $post_type = isset($instance['post_type']) ? $instance['post_type'] : ''; $number = isset($instance['number']) ? $instance['number'] : ''; $order = isset($instance['order']) ? $instance['order'] : ''; echo $args['before_widget']; if ($title) { echo $args['before_title'] . $title . $args['after_title']; } ?> <ul class="wpex-recent-posts-thumb-grid clearfix"> <?php global $post; // Get current post ID to exclude it if ($post) { $current_post = $post->ID; } else { $current_post = ''; } // Get posts $myposts = get_posts(array('post_type' => $post_type, 'numberposts' => $number, 'orderby' => $order, 'no_found_rows' => true, 'meta_key' => '_thumbnail_id', 'suppress_filters' => false, 'exclude' => $current_post)); $count = 0; foreach ($myposts as $post) { setup_postdata($post); $count++; if (has_post_thumbnail()) { ?> <li><a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><img src="<?php echo wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), '65', '65', true); ?> " alt="<?php the_title(); ?> " /></a></li> <?php } if ($count == 3) { $count = '0'; } } wp_reset_postdata(); ?> </ul> <?php echo $args['after_widget']; }
function vcex_testimonials_grid_shortcode($atts) { extract(shortcode_atts(array('unique_id' => '', 'term_slug' => 'all', 'include_categories' => '', 'exclude_categories' => '', 'posts_per_page' => '12', 'grid_style' => 'fit_columns', 'masonry_layout_mode' => '', 'filter_speed' => '', 'columns' => '4', 'order' => 'DESC', 'orderby' => 'date', 'orderby_meta_key' => '', 'filter' => 'true', 'center_filter' => '', 'title' => 'true', 'excerpt' => 'false', 'excerpt_length' => '20', 'read_more' => 'true', 'read_more_text' => __('read more', 'wpex'), 'pagination' => 'false', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'all_text' => __('All', 'wpex'), 'img_border_radius' => '50%', 'img_width' => '45', 'img_height' => '45', 'custom_excerpt_trim' => ''), $atts)); // Turn output buffer on ob_start(); // Get global $post var global $post; // Trim custom Excerpts? if ('false' == $custom_excerpt_trim) { $custom_excerpt_trim = false; } else { $custom_excerpt_trim = true; } // Border Radius $img_border_radius = $img_border_radius ? $img_border_radius : '50%'; $img_border_radius = 'style="border-radius:' . $img_border_radius . ';"'; // Include categories $include_categories = '' != $include_categories ? $include_categories : $term_slug; $include_categories = 'all' == $include_categories ? '' : $include_categories; $filter_cats_include = ''; if ($include_categories) { $include_categories = explode(',', $include_categories); $filter_cats_include = array(); foreach ($include_categories as $key) { $key = get_term_by('slug', $key, 'testimonials_category'); $filter_cats_include[] = $key->term_id; } } // Exclude categories $filter_cats_exclude = ''; if ($exclude_categories) { $exclude_categories = explode(',', $exclude_categories); if (!empty($exclude_categories) && is_array($exclude_categories)) { $filter_cats_exclude = array(); foreach ($exclude_categories as $key) { $key = get_term_by('slug', $key, 'testimonials_category'); $filter_cats_exclude[] = $key->term_id; } $exclude_categories = array('taxonomy' => 'testimonials_category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN'); } else { $exclude_categories = ''; } } // Start Tax Query if (!empty($include_categories) && is_array($include_categories)) { $include_categories = array('taxonomy' => 'testimonials_category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN'); } else { $include_categories = ''; } // Meta key for orderby if ($orderby_meta_key && ('meta_value_num' == $orderby || 'meta_value' == $orderby)) { $meta_key = $orderby_meta_key; } else { $meta_key = NULL; } // Pagination var $paged = NULL; $no_found_rows = true; if ('true' == $pagination) { global $paged; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $no_found_rows = false; } // The Query $wpex_query = new WP_Query(array('post_type' => 'testimonials', 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key, 'filter_content' => $filter_content, 'paged' => $paged, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories), 'no_found_rows' => $no_found_rows)); //Output posts if ($wpex_query->posts) { // Main Vars $unique_id = $unique_id ? $unique_id : 'testimonials-' . rand(1, 100); // Is Isotope var if ('true' == $filter || 'masonry' == $grid_style) { $is_isotope = true; } else { $is_isotope = false; } // No need for masonry if not enough columns and filter is disabled if ('true' != $filter && 'masonry' == $grid_style) { $post_count = count($wpex_query->posts); if ($post_count <= $columns) { $is_isotope = false; } } // Output script for inline JS for the Visual composer front-end builder if (function_exists('vcex_front_end_grid_js')) { if ($is_isotope) { vcex_front_end_grid_js('isotope'); } } // Display filter links if ($filter == 'true' && taxonomy_exists('testimonials_category')) { $terms = get_terms('testimonials_category', array('include' => $filter_cats_include, 'exclude' => $filter_cats_exclude)); $terms = apply_filters('vcex_testimonials_grid_get_terms', $terms); if ($terms && count($terms) > '1') { $center_filter = 'yes' == $center_filter ? 'center' : ''; ?> <ul class="vcex-testimonials-filter filter-<?php echo $unique_id; ?> vcex-filter-links <?php echo $center_filter; ?> clr"> <li class="active"><a href="#" data-filter="*"><span><?php echo $all_text; ?> </span></a></li> <?php foreach ($terms as $term) { ?> <li><a href="#" data-filter=".cat-<?php echo $term->term_id; ?> "><?php echo $term->name; ?> </a></li> <?php } ?> </ul><!-- .vcex-testimonials-filter --> <?php } } // Wrap Classes $wrap_classes = 'wpex-row vcex-testimonials-grid clr'; if ($is_isotope) { $wrap_classes .= ' vcex-isotope-grid'; } // Data $data = ''; if ($is_isotope && 'true' == $filter) { if ('no_margins' != $grid_style && $masonry_layout_mode) { $data .= ' data-layout-mode="' . $masonry_layout_mode . '"'; } if ($filter_speed) { $data .= ' data-transition-duration="' . $filter_speed . '"'; } } ?> <div class="<?php echo $wrap_classes; ?> " id="<?php echo $unique_id; ?> "<?php echo $data; ?> > <?php $count = ''; foreach ($wpex_query->posts as $post) { setup_postdata($post); $count++; // Get post data $post_id = get_the_ID(); $wpex_testimonial_author = get_post_meta(get_the_ID(), 'wpex_testimonial_author', true); $wpex_testimonial_company = get_post_meta(get_the_ID(), 'wpex_testimonial_company', true); $wpex_testimonial_url = get_post_meta(get_the_ID(), 'wpex_testimonial_url', true); // Get featured image and resize it $post_thumb_id = get_post_thumbnail_id(); $attachment_url = wp_get_attachment_url($post_thumb_id); $img_crop = '9999' == $img_height ? false : true; $cropped_img = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop, 'array'); $img_url = $cropped_img['url']; // Add classes to the entries $entry_classes = 'testimonial-entry col'; $entry_classes .= ' span_1_of_' . $columns; $entry_classes .= ' col-' . $count; if ($is_isotope) { $entry_classes .= ' vcex-isotope-entry'; } if (taxonomy_exists('testimonials_category')) { $post_terms = get_the_terms($post, 'testimonials_category'); if ($post_terms) { foreach ($post_terms as $post_term) { $entry_classes .= ' cat-' . $post_term->term_id; } } } ?> <div id="#post-<?php the_ID(); ?> " class="<?php echo $entry_classes; ?> "> <div class="testimonial-entry-content clr"> <span class="testimonial-caret"></span> <?php // Custom Excerpt if ('true' == $excerpt) { $read_more = $read_more == 'true' ? true : false; if ('true' == $read_more) { if (is_rtl()) { $read_more_link = '...<a href="' . get_permalink() . '" title="' . $read_more_text . '">' . $read_more_text . '</a>'; } else { $read_more_link = '...<a href="' . get_permalink() . '" title="' . $read_more_text . '">' . $read_more_text . '<span>→</span></a>'; } } else { $read_more_link = '...'; } // Custom Excerpt function if (function_exists('wpex_excerpt')) { $args = array('post_id' => $post_id, 'length' => intval($excerpt_length), 'trim_custom_excerpts' => $custom_excerpt_trim, 'readmore' => false, 'more' => $read_more_link); wpex_excerpt($args); } else { the_excerpt(); } } else { the_content(); } ?> </div><!-- .home-testimonial-entry-content--> <div class="testimonial-entry-bottom"> <?php if (has_post_thumbnail()) { ?> <div class="testimonial-entry-thumb"> <img src="<?php echo $img_url; ?> " alt="<?php echo the_title(); ?> " <?php echo $img_border_radius; ?> /> </div><!-- /testimonial-thumb --> <?php } ?> <div class="testimonial-entry-meta"> <?php if ($wpex_testimonial_author) { ?> <span class="testimonial-entry-author"><?php echo $wpex_testimonial_author; ?> </span> <?php } ?> <?php if ($wpex_testimonial_company) { ?> <?php if ($wpex_testimonial_url) { ?> <a href="<?php echo esc_url($wpex_testimonial_url); ?> " class="testimonial-entry-company" title="<?php echo $wpex_testimonial_company; ?> " target="_blank"><?php echo $wpex_testimonial_company; ?> </a> <?php } else { ?> <span class="testimonial-entry-company"><?php echo $wpex_testimonial_company; ?> </span> <?php } ?> <?php } ?> </div><!-- .testimonial-entry-meta --> </div><!-- .home-testimonial-entry-bottom --> </div><!-- .testimonials-entry --> <?php // Reset counter if ($count == $columns) { $count = ''; } } ?> </div><!-- .vcex-testimonials-grid --> <?php // Paginate Posts if ('true' == $pagination) { wpex_pagination($wpex_query); } // End has posts check } // Reset the WP query wp_reset_postdata(); // Return outbut buffer return ob_get_clean(); }
if (!defined('ABSPATH')) { exit; } // Return if no featured image if (!has_post_thumbnail()) { return; } //Globals global $product; // Main vars $output = ''; $enable_woo_entry_sliders = get_theme_mod('enable_woo_entry_sliders', 'on'); // Get first image $attachment_id = get_post_thumbnail_id(); $attachment_url = wp_get_attachment_url($attachment_id); $alt = strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true)); $width = get_theme_mod('woo_entry_width', '9999'); $height = get_theme_mod('woo_entry_height', '9999'); $crop = $height == '9999' ? false : true; $cropped_image = wpex_image_resize($attachment_url, $width, $height, $crop); if ($cropped_image) { ?> <img src="<?php echo $cropped_image; ?> " alt="<?php echo $alt; ?> " class="woo-entry-image-main" /> <?php }
function wpex_image($return = 'url', $custom_id = '', $custom_query = false) { /*-----------------------------------------------------------------------------------*/ /* - Main Vars /*-----------------------------------------------------------------------------------*/ global $post; $post_id = $post->ID; $post_type = get_post_type($post_id); if ($custom_id) { $attachment_id = $custom_id; } else { $attachment_id = get_post_thumbnail_id($post_id); } $attachment_url = wp_get_attachment_url($attachment_id); $post_layout = get_post_meta($post_id, 'wpex_post_layout', true); $post_media_position = get_post_meta($post_id, 'wpex_post_media_position', true); $width = 9999; $height = 9999; $crop = false; /*-----------------------------------------------------------------------------------*/ /* - Get correct dimensions based on customizer/meta options /*-----------------------------------------------------------------------------------*/ // Only run the following code if image resizing isn't disabled if (get_option('wpex_image_resizing', '1')) { // Pages if (is_singular('page')) { $width = get_theme_mod('page_image_width', '9999'); $height = get_theme_mod('page_image_height', '9999'); } // Standard Post Type if ('post' == $post_type) { // Singular if (is_singular('post')) { // Related if ($custom_query) { $width = get_theme_mod('blog_related_image_width', '9999'); $height = get_theme_mod('blog_related_image_height', '9999'); } else { if ($post_layout == 'full-width' || $post_media_position || 'full-width' == get_theme_mod('blog_single_layout')) { $width = get_theme_mod('blog_post_full_image_width', '9999'); } else { $width = get_theme_mod('blog_post_image_width', '9999'); } if ('full-width' == get_theme_mod('blog_single_layout') || 'full-width' == $post_layout || $post_media_position) { $height = get_theme_mod('blog_post_full_image_height', '9999'); } else { $height = get_theme_mod('blog_post_image_height', '9999'); } } // Entries } else { // Categories if (is_category()) { // Get term data $term = get_query_var('cat'); $term_data = get_option("category_{$term}"); // Width if (isset($term_data['wpex_term_image_width'])) { if ('' != $term_data['wpex_term_image_width']) { $width = $term_data['wpex_term_image_width']; } else { $width = get_theme_mod('blog_entry_image_width', '9999'); } } else { $width = get_theme_mod('blog_entry_image_width', '9999'); } // height if (isset($term_data['wpex_term_image_height'])) { if ($term_data['wpex_term_image_height'] !== '') { $height = $term_data['wpex_term_image_height']; } else { $height = get_theme_mod('blog_entry_image_height', '9999'); } } else { $height = get_theme_mod('blog_entry_image_height', '9999'); } // Blog Posts } else { $width = get_theme_mod('blog_entry_image_width', '9999'); $height = get_theme_mod('blog_entry_image_height', '9999'); } } } elseif ('staff' == $post_type) { $width = get_theme_mod('staff_entry_image_width', '9999'); $height = get_theme_mod('staff_entry_image_height', '9999'); } elseif ('portfolio' == $post_type) { if (is_singular() && $custom_query) { $width = get_theme_mod('portfolio_post_image_width', '9999'); $height = get_theme_mod('portfolio_post_image_height', '9999'); } else { $width = get_theme_mod('portfolio_entry_image_width', '9999'); $height = get_theme_mod('portfolio_entry_image_height', '9999'); } } elseif ('testimonials' == $post_type) { $width = get_theme_mod('testimonials_entry_image_width', '50'); $height = get_theme_mod('testimonials_entry_image_height', '50'); } // Search if (is_search()) { if ('default' == wpex_search_results_style()) { $width = '100'; $height = '100'; } else { $width = get_theme_mod('blog_entry_image_width', '9999'); $height = get_theme_mod('blog_entry_image_height', '9999'); } } } /*-----------------------------------------------------------------------------------*/ /* - Return /*-----------------------------------------------------------------------------------*/ // Width if ($width) { $width = intval($width); } else { $width = '9999'; } $width = apply_filters('wpex_image_width', $width); // Height if ($height) { $height = intval($height); } else { $height = '9999'; } $height = apply_filters('wpex_image_height', $height); // Crop if ($height == '9999') { $crop = false; } else { $crop = true; } // Run aq function $resized_array = wpex_image_resize($attachment_url, $width, $height, $crop, 'array'); // Return data if ('url' == $return) { return $resized_array['url']; } elseif ('array' == $return) { return $resized_array; } }
function vcex_testimonials_slider_shortcode($atts, $content = null) { extract(shortcode_atts(array('count' => '3', 'term_slug' => '', 'include_categories' => '', 'exclude_categories' => '', 'category' => 'all', 'order' => 'DESC', 'orderby' => 'date', 'skin' => 'light', 'font_size' => '', 'font_weight' => '', 'background' => '', 'background_image' => '', 'background_style' => 'stretch', 'css_animation' => '', 'filter_content' => 'false', 'excerpt' => 'false', 'excerpt_length' => '20', 'read_more' => 'true', 'read_more_text' => __('read more', 'wpex'), 'offset' => 0, 'unique_id' => '', 'slideshow' => 'true', 'slideshow_speed' => '7000', 'animation_speed' => '600', 'display_author_name' => 'false', 'display_author_avatar' => 'false', 'display_author_company' => 'false', 'padding_bottom' => '', 'padding_top' => '', 'custom_excerpt_trim' => ''), $atts)); // Turn output buffer on ob_start(); // Trim custom excerpts? if ('false' == $custom_excerpt_trim) { $custom_excerpt_trim = false; } else { $custom_excerpt_trim = true; } // Add Style $add_style = ''; if ($background) { $add_style .= 'background-color:' . $background . ';'; } if ($background_image) { $add_style .= 'background-image:url(' . wp_get_attachment_url($background_image) . ');'; } if ($padding_top) { $add_style .= 'padding-top:' . intval($padding_top) . 'px;'; } if ($padding_bottom) { $add_style .= 'padding-bottom:' . intval($padding_bottom) . 'px;'; } if ($add_style) { $add_style = ' style="' . $add_style . '"'; } // Slide Style $slide_style = array(); if ($font_size) { $slide_style[] = 'font-size: ' . $font_size . ';'; } if ($font_weight) { $slide_style[] = 'font-weight: ' . $font_weight . ';'; } $slide_style = implode('', $slide_style); if ($slide_style) { $slide_style = wp_kses($slide_style, array()); $slide_style = ' style="' . esc_attr($slide_style) . '"'; } // Get post meta to check page layout global $post; if ('full-screen' == get_post_meta($post->ID, 'wpex_post_layout', true)) { $inner_slide_container = 'container'; } else { $inner_slide_container = ''; } // Include categories $include_categories = '' != $include_categories ? $include_categories : $term_slug; $include_categories = 'all' == $include_categories ? '' : $include_categories; $filter_cats_include = ''; if ($include_categories) { $include_categories = explode(',', $include_categories); $filter_cats_include = array(); foreach ($include_categories as $key) { $key = get_term_by('slug', $key, 'testimonials_category'); $filter_cats_include[] = $key->term_id; } } // Exclude categories $filter_cats_exclude = ''; if ($exclude_categories) { $exclude_categories = explode(',', $exclude_categories); if (!empty($exclude_categories) && is_array($exclude_categories)) { $filter_cats_exclude = array(); foreach ($exclude_categories as $key) { $key = get_term_by('slug', $key, 'testimonials_category'); $filter_cats_exclude[] = $key->term_id; } $exclude_categories = array('taxonomy' => 'testimonials_category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN'); } else { $exclude_categories = ''; } } // Start Tax Query if (!empty($include_categories) && is_array($include_categories)) { $include_categories = array('taxonomy' => 'testimonials_category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN'); } else { $include_categories = ''; } // The Query $wpex_query = new WP_Query(array('post_type' => 'testimonials', 'posts_per_page' => $count, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'no_found_rows' => true, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories), 'no_found_rows' => true)); //Output posts if ($wpex_query->posts) { // Unique ID if ($unique_id) { $unique_id = 'id="' . $unique_id . '"'; } else { $unique_id = ''; } // Give flexslider a unique name $rand_num = rand(1, 100); $unique_flexslider_id = 'flexslider-' . $rand_num; ?> <script type="text/javascript"> jQuery(function($){ if ( $.fn.imagesLoaded != undefined && $.fn.flexslider != undefined ) { $(".vcex-flexslider-wrap").removeClass("flexslider-loader"); var $slider = $("#<?php echo $unique_flexslider_id; ?> "); $slider.imagesLoaded(function() { $slider.flexslider({ animation: "fade", slideshow : <?php echo $slideshow; ?> , slideshowSpeed: <?php echo $slideshow_speed; ?> , animationSpeed: <?php echo $animation_speed; ?> , controlNav : true, directionNav: false, pauseOnHover: true, smoothHeight: true, prevText : '<i class=icon-angle-left"></i>', nextText : '<i class="icon-angle-right"></i>', controlsContainer: ".vcex-slider-container-<?php echo $rand_num; ?> " }); }); } }); </script> <?php // Wrap classes $classes = 'vcex-testimonials-fullslider vcex-flexslider-wrap'; $classes .= ' vcex-slider-container-' . $rand_num; if ($skin) { $classes .= ' ' . $skin . '-skin'; } if ($background_style && $background_image) { $classes .= ' vcex-background-' . $background_style; } if ('' != $css_animation) { $classes .= ' wpb_animate_when_almost_visible wpb_' . $css_animation; } ?> <div class="<?php echo $classes; ?> "<?php echo $unique_id; echo $add_style; ?> > <div id="<?php echo $unique_flexslider_id; ?> " class="flexslider"> <ul class="slides"> <?php // Loop through posts foreach ($wpex_query->posts as $post) { setup_postdata($post); // Post VARS $post_id = $post->ID; $post_title = get_the_title($post_id); $post_content = $post->post_content; $author_name = get_post_meta($post_id, 'wpex_testimonial_author', true); // Testimonial start if ('' != $post_content) { ?> <li class="slide"> <div id="post-<?php echo $post_id; ?> " class="vcex-testimonials-fullslider-entry <?php echo $inner_slide_container; ?> " <?php echo $slide_style; ?> > <?php // Author avatar if ('yes' == $display_author_avatar && has_post_thumbnail($post_id)) { $post_thumb_id = get_post_thumbnail_id($post_id); $attachment_url = wp_get_attachment_url($post_thumb_id); if (function_exists('wpex_image_resize')) { $img_url = wpex_image_resize($attachment_url, '70', '70', true); } else { $img_url = $attachment_url; } ?> <div class="vcex-testimonials-fullslider-avatar"> <img src="<?php echo $img_url; ?> " alt="<?php echo $author_name; ?> " height="70" width="70" /> </div> <?php } // Custom Excerpt if ('true' == $excerpt) { if ('true' == $read_more) { $read_more_link = '...<a href="' . get_permalink() . '" title="' . $read_more_text . '">' . $read_more_text . '<span>→</span></a>'; } else { $read_more_link = '...'; } $excerpt_array = array('length' => intval($excerpt_length), 'trim_custom_excerpts' => $custom_excerpt_trim, 'post_id' => $post_id, 'more' => $read_more_link); vcex_excerpt($excerpt_array); } else { echo apply_filters('the_content', $post_content); } // Author name if ($author_name && 'yes' == $display_author_name) { $company = get_post_meta(get_the_ID(), 'wpex_testimonial_company', true); ?> <div class="vcex-testimonials-fullslider-author"> <?php echo $author_name; ?> <?php if ($company && 'true' == $display_author_company) { $company_url = get_post_meta(get_the_ID(), 'wpex_testimonial_url', true); if ($company_url) { ?> <a href="<?php echo esc_url($company_url); ?> " class="vcex-testimonials-fullslider-company" title="<?php echo $company; ?> " target="_blank"><?php echo $company; ?> </a> <?php } else { ?> <span class="vcex-testimonials-fullslider-company"><?php echo $company; ?> </span> <?php } } ?> </div> <?php } ?> </div><!-- .vcex-testimonials-fullslider-entry --> </li> <?php } ?> <?php } ?> </ul> </div> </div><!-- .vcex-testimonials-fullslider --><div class="vcex-clear-floats"></div> <?php } // End has posts check // Reset the WP query postdata wp_reset_postdata(); // Return outbut buffer return ob_get_clean(); }
function vcex_image_grid_shortcode($atts) { extract(shortcode_atts(array('unique_id' => '', 'columns' => '4', 'image_ids' => '', 'img_filter' => '', 'grid_style' => '', 'rounded_image' => '', 'thumbnail_link' => 'lightbox', 'custom_links' => '', 'custom_links_target' => '_self', 'img_width' => '9999', 'img_height' => '9999', 'title' => 'true', 'title_type' => 'title', 'img_hover_style' => '', 'img_rendering' => '', 'lightbox_title' => '', 'lightbox_caption' => ''), $atts)); // Start output buffer ob_start(); // Define output var $output = ''; // Get Attachments $images = explode(",", $image_ids); $images = array_combine($images, $images); // Dummy Images $dummy_images = NULL; if (empty($image_ids)) { $dummy_images = true; $images = array(WPEX_VCEX_DIR_URI . 'assets/images/dummy1.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy2.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy3.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy4.jpg'); } //Output posts if ($images) { // Custom Links if ('custom_link' == $thumbnail_link) { $custom_links = explode(',', $custom_links); } // Is Isotope var if ('masonry' == $grid_style) { $is_isotope = true; } else { $is_isotope = false; } // No margins style if ('no-margins' == $grid_style) { $is_isotope = false; } // Output script for inline JS for the Visual composer front-end builder if (function_exists('vcex_front_end_grid_js')) { if ($is_isotope) { vcex_front_end_grid_js('isotope'); } elseif ('no-margins' == $grid_style) { vcex_front_end_grid_js('masonry'); } } // Set correct grid class $col_class = ''; if ($grid_style == 'no-margins') { if ($columns == '1') { $columns_class = 'full-width'; } if ($columns == '2') { $columns_class = 'one-half'; } if ($columns == '3') { $columns_class = 'one-third'; } if ($columns == '4') { $columns_class = 'one-fourth'; } if ($columns == '5') { $columns_class = 'one-fifth'; } if ($columns == '6') { $columns_class = 'one-sixth'; } } else { if ($columns == '1') { $columns_class = 'span_1_of_1'; } if ($columns == '2') { $columns_class = 'span_1_of_2'; } if ($columns == '3') { $columns_class = 'span_1_of_3'; } if ($columns == '4') { $columns_class = 'span_1_of_4'; } if ($columns == '5') { $columns_class = 'span_1_of_5'; } if ($columns == '6') { $columns_class = 'span_1_of_6'; } } // Unique ID $unique_id = !empty($unique_id) ? $unique_id : 'vcex-image-grid-' . rand(1, 100); // Wrap Classes $wrap_classes = 'vcex-image-grid wpex-row clr'; $wrap_classes .= ' grid-style-' . $grid_style; if ($is_isotope) { $wrap_classes .= ' vcex-isotope-grid no-transition'; } if ('no-margins' == $grid_style) { $wrap_classes .= ' vcex-no-margin-grid'; } if ($img_rendering) { $wrap_classes .= ' vcex-image-rendering-' . $img_rendering; } if ('lightbox' == $thumbnail_link) { $wrap_classes .= ' lightbox-group'; } if ('yes' == $rounded_image) { $wrap_classes .= ' vcex-rounded-images'; } // Entry Classes $entry_classes = 'vcex-image-grid-entry col'; if ($is_isotope) { $entry_classes .= ' vcex-isotope-entry'; } if ('no-margins' == $grid_style) { $entry_classes .= ' vcex-no-margin-entry'; } if ($columns_class) { $entry_classes .= ' ' . $columns_class; } ?> <div class="<?php echo $wrap_classes; ?> " id="<?php echo $unique_id; ?> "> <?php $count = 0; // Loop through images $count2 = -1; foreach ($images as $attachment) { $count++; $count2++; // Attachment VARS $attachment_link = get_post_meta($attachment, '_wp_attachment_url', true); $attachment_alt = strip_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true)); // Title data if ('false' != $lightbox_title) { if ('title' == $lightbox_title) { $data_title = 'data-title="' . strip_tags(get_the_title($attachment)) . '"'; } else { $data_title = 'data-title="' . $attachment_alt . '"'; } } else { $data_title = ''; } // Caption data $data_caption = ''; if ('false' != $lightbox_caption) { $attachment_caption = get_post_field('post_excerpt', $attachment); if ($attachment_caption) { $data_caption = 'data-caption="' . str_replace('"', "'", $attachment_caption) . '"'; } } // Get and crop image if needed if ($dummy_images) { $cropped_image_url = $attachment_img_url = $attachment; $cropped_image_width = ''; $cropped_image_height = ''; } else { $attachment_img_url = wp_get_attachment_url($attachment); $img_width = intval($img_width); $img_height = intval($img_height); $crop = $img_height == '9999' ? false : true; $cropped_image = wpex_image_resize($attachment_img_url, $img_width, $img_height, $crop, 'array'); $cropped_image_url = $cropped_image['url']; $cropped_image_width = $cropped_image['width']; $cropped_image_height = $cropped_image['height']; } // Hover Classes $hover_classes = ''; if ($img_filter) { $hover_classes = 'vcex-' . $img_filter; } if ($img_hover_style || $img_filter) { $hover_classes .= ' vcex-img-hover-parent vcex-img-hover-' . $img_hover_style; } ?> <div class="<?php echo $entry_classes; ?> col-<?php echo $count; ?> "> <figure class="vcex-image-grid-entry-img"> <?php if ($img_hover_style || $img_filter) { ?> <div class="<?php echo $hover_classes; ?> "> <?php } ?> <?php // Lightbox if ('lightbox' == $thumbnail_link) { // Define lightbox url $lightbox_url = $attachment_img_url; $video_url = get_post_meta($attachment, "_video_url", true); $data_attributes = 'data-type="image"'; if ($video_url) { $data_attributes = 'data-type="iframe"'; $data_attributes .= 'data-options="thumbnail:\'' . $lightbox_url . '\',width:1920,height:1080"'; $lightbox_url = $video_url; } ?> <a href="<?php echo $lightbox_url; ?> " title="<?php echo $attachment_alt; ?> " <?php echo $data_title; ?> <?php echo $data_caption; ?> class="vcex-image-grid-entry-img lightbox-group-item" <?php echo $data_attributes; ?> > <img src="<?php echo $cropped_image_url; ?> " alt="<?php echo $attachment_alt; ?> " width="<?php echo $cropped_image_width; ?> " height="<?php echo $cropped_image_height; ?> " /> <?php // Video icon overlay if ($video_url) { ?> <div class="vcex-image-grid-video-overlay rounded"><span class="fa fa-play"></span></div> <?php } ?> </a><!-- .vcex-image-grid-entry-img --> <?php } elseif ('custom_link' == $thumbnail_link) { $custom_link = !empty($custom_links[$count2]) ? $custom_links[$count2] : '#'; if ('#' == $custom_link) { ?> <img src="<?php echo $cropped_image_url; ?> " alt="<?php echo $attachment_alt; ?> " width="<?php echo $cropped_image_width; ?> " height="<?php echo $cropped_image_height; ?> " /> <?php } else { ?> <a href="<?php echo esc_url($custom_link); ?> " title="<?php echo $attachment_alt; ?> " class="vcex-image-grid-entry-img" target="<?php echo $custom_links_target; ?> "> <img src="<?php echo $cropped_image_url; ?> " alt="<?php echo $attachment_alt; ?> " width="<?php echo $cropped_image_width; ?> " height="<?php echo $cropped_image_height; ?> " /> </a> <?php } } else { ?> <img src="<?php echo $cropped_image_url; ?> " alt="<?php echo $attachment_alt; ?> " width="<?php echo $cropped_image_width; ?> " height="<?php echo $cropped_image_height; ?> " /> <?php } ?> <?php if ($img_hover_style) { ?> </div><!-- .<?php echo $hover_classes; ?> --> <?php } ?> <?php // Display title if ('yes' == $title) { // Title if ('title' == $title_type) { $attachment_title = get_the_title($attachment); if ($attachment_title) { echo '<figcaption class="vcex-image-grid-entry-title">' . $attachment_title . '</figcaption>'; } } elseif ('alt' == $title_type && $attachment_alt) { echo '<figcaption class="vcex-image-grid-entry-title">' . $attachment_alt . '</figcaption>'; } elseif ('caption' == $title_type) { $attachment_caption = get_post_field('post_excerpt', $attachment); if ($attachment_caption) { echo '<figcaption class="vcex-image-grid-entry-title">' . $attachment_caption . '</figcaption>'; } } elseif ('description' == $title_type) { $attachment_description = get_post_field('post_content', $attachment); if ($attachment_description) { echo '<figcaption class="vcex-image-grid-entry-title">' . apply_filters('the_content', $attachment_description) . '</figcaption>'; } } } ?> </figure> </div> <?php // Clear counter if ($count == $columns) { $count = 0; } // End foreach loop } ?> </div> <?php // End has posts check } // Reset query wp_reset_postdata(); // Return data return ob_get_clean(); }
function vcex_portfolio_carousel_shortcode($atts) { extract(shortcode_atts(array('unique_id' => '', 'classes' => '', 'style' => 'default', 'term_slug' => '', 'include_categories' => '', 'exclude_categories' => '', 'count' => '8', 'center' => 'false', 'timeout_duration' => '5000', 'items' => '4', 'items_margin' => '15', 'infinite_loop' => 'true', 'items_scroll' => '1', 'auto_play' => 'false', 'arrows' => 'true', 'order' => 'DESC', 'orderby' => 'date', 'orderby_meta_key' => '', 'thumbnail_link' => '', 'img_width' => '9999', 'img_height' => '9999', 'title' => 'true', 'excerpt' => 'true', 'excerpt_length' => '30', 'custom_excerpt_trim' => 'true', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'img_hover_style' => '', 'img_rendering' => '', 'overlay_style' => '', 'content_background' => '', 'content_heading_margin' => '', 'content_heading_weight' => '', 'content_heading_transform' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'tablet_items' => '3', 'mobile_landscape_items' => '2', 'mobile_portrait_items' => '1'), $atts)); // Turn output buffer on ob_start(); // Global post global $post; // Include categories $include_categories = '' != $include_categories ? $include_categories : $term_slug; $include_categories = 'all' == $include_categories ? '' : $include_categories; $filter_cats_include = ''; if ($include_categories) { $include_categories = explode(',', $include_categories); $filter_cats_include = array(); foreach ($include_categories as $key) { $key = get_term_by('slug', $key, 'portfolio_category'); $filter_cats_include[] = $key->term_id; } } // Exclude categories $filter_cats_exclude = ''; if ($exclude_categories) { $exclude_categories = explode(',', $exclude_categories); if (!empty($exclude_categories) && is_array($exclude_categories)) { $filter_cats_exclude = array(); foreach ($exclude_categories as $key) { $key = get_term_by('slug', $key, 'portfolio_category'); $filter_cats_exclude[] = $key->term_id; } $exclude_categories = array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN'); } else { $exclude_categories = ''; } } // Start Tax Query if (!empty($include_categories) && is_array($include_categories)) { $include_categories = array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN'); } else { $include_categories = ''; } // Meta key for orderby if ($orderby_meta_key && ('meta_value_num' == $orderby || 'meta_value' == $orderby)) { $meta_key = $orderby_meta_key; } else { $meta_key = NULL; } // The Query $wpex_query = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $count, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'no_found_rows' => true, 'meta_key' => $meta_key, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories))); //Output posts if ($wpex_query->posts) { // Output js for front-end editor vcex_front_end_carousel_js(); // Give caroufredsel a unique name $rand_num = rand(1, 100); $unique_carousel_id = 'carousel-' . $rand_num; // Prevent auto play in visual composer if (wpex_is_front_end_composer()) { $auto_play = 'false'; } // Overlay Style if (empty($overlay_style)) { $overlay_style = 'none'; } else { $overlay_style = $overlay_style; } // Item Margin if ('no-margins' == $style) { $items_margin = '0'; } // Items to scroll fallback for old setting if ('page' == $items_scroll) { $items_scroll = $items; } // Unique ID if ($unique_id) { $unique_id = ' id="' . $unique_id . '"'; } // Main Classes $main_classes = 'wpex-carousel wpex-carousel-portfolio clr owl-carousel'; if ($style) { $main_classes .= ' wpex-carousel-' . $style; } if ($classes) { $main_classes .= ' ' . $classes; } // Entry media classes $media_classes = 'wpex-carousel-entry-media clr'; if ($img_hover_style) { $media_classes .= ' vcex-img-hover-parent vcex-img-hover-' . $img_hover_style; } if ($img_rendering) { $media_classes .= ' vcex-image-rendering-' . $img_rendering; } if ($overlay_style) { $media_classes .= ' ' . wpex_overlay_classname($overlay_style); } // Content Design $content_style = ''; if ($content_background) { $content_style .= 'background:' . $content_background . ';'; } if ($content_padding) { $content_style .= 'padding:' . $content_padding . ';'; } if ($content_margin) { $content_style .= 'margin:' . $content_margin . ';'; } if ($content_border) { $content_style .= 'border:' . $content_border . ';'; } if ($content_font_size) { $content_style .= 'font-size:' . $content_font_size . ';'; } if ($content_color) { $content_style .= 'color:' . $content_color . ';'; } if ($content_opacity) { $content_style .= 'opacity:' . $content_opacity . ';'; } if ($content_alignment) { $content_style .= 'text-align:' . $content_alignment . ';'; } if ($content_style) { $content_style = ' style="' . $content_style . '"'; } // Title design $heading_style = ''; if ($content_heading_margin) { $heading_style .= 'margin: ' . $content_heading_margin . ';'; } if ($content_heading_transform) { $heading_style .= 'text-transform: ' . $content_heading_transform . ';'; } if ($content_heading_weight) { $heading_style .= 'font-weight: ' . $content_heading_weight . ';'; } if ($content_heading_size) { $heading_style .= 'font-size: ' . $content_heading_size . ';'; } if ($heading_style) { $heading_style = ' style="' . $heading_style . '"'; } // Heading color if ($content_heading_color) { $content_heading_color = ' style="color: ' . $content_heading_color . ';"'; } ?> <div class="<?php echo $main_classes; ?> "<?php echo $unique_id; ?> data-items="<?php echo $items; ?> " data-slideby="<?php echo $items_scroll; ?> " data-nav="<?php echo $arrows; ?> " data-autoplay="<?php echo $auto_play; ?> " data-loop="<?php echo $infinite_loop; ?> " data-autoplay-timeout="<?php echo $timeout_duration; ?> " data-center="<?php echo $center; ?> " data-margin="<?php echo intval($items_margin); ?> " data-items-tablet="<?php echo $tablet_items; ?> " data-items-mobile-landscape="<?php echo $mobile_landscape_items; ?> " data-items-mobile-portrait="<?php echo $mobile_portrait_items; ?> "> <?php // Loop through posts foreach ($wpex_query->posts as $post) { setup_postdata($post); // Post VARS $postid = $post->ID; $featured_img_url = wp_get_attachment_url(get_post_thumbnail_id($postid)); $permalink = get_permalink($postid); $post_title = esc_attr(the_title_attribute('echo=0')); // Crop featured images if necessary if ('9999' == $img_height) { $img_crop = false; } else { $img_crop = true; } $featured_img = wpex_image_resize($featured_img_url, $img_width, $img_height, $img_crop, 'array'); ?> <div class="wpex-carousel-slide"> <?php // Media Wrap if (has_post_thumbnail()) { ?> <div class="<?php echo $media_classes; ?> "> <?php // No links if ('none' == $thumbnail_link) { ?> <img src="<?php echo $featured_img['url']; ?> " alt="<?php echo $post_title; ?> " width="<?php echo $featured_img['width']; ?> " height="<?php echo $featured_img['height']; ?> " /> <?php } elseif ('lightbox' == $thumbnail_link) { ?> <a href="<?php echo $featured_img_url; ?> " title="<?php echo $post_title; ?> " class="wpex-carousel-entry-img wpex-lightbox"> <img src="<?php echo $featured_img['url']; ?> " alt="<?php echo $post_title; ?> " width="<?php echo $featured_img['width']; ?> " height="<?php echo $featured_img['height']; ?> " /> <?php } else { ?> <a href="<?php echo $permalink; ?> " title="<?php echo $post_title; ?> " class="wpex-carousel-entry-img"> <img src="<?php echo $featured_img['url']; ?> " alt="<?php echo $post_title; ?> " width="<?php echo $featured_img['width']; ?> " height="<?php echo $featured_img['height']; ?> " /> <?php } ?> <?php // Overlay & close link if ('none' != $thumbnail_link) { // Inner Overlay if ($overlay_style) { wpex_overlay('inside_link', $overlay_style); } // Close link echo '</a><!-- .wpex-carousel-entry-img -->'; // Outside Overlay if ($overlay_style) { wpex_overlay('outside_link', $overlay_style); } } ?> </div><!-- .wpex-carousel-entry-media --> <?php } ?> <?php // Title if ('true' == $title || 'true' == $excerpt) { ?> <div class="wpex-carousel-entry-details clr"<?php echo $content_style; ?> > <?php // Title if ('true' == $title && $post_title) { ?> <div class="wpex-carousel-entry-title"<?php echo $heading_style; ?> > <a href="<?php echo $permalink; ?> " title="<?php echo $post_title; ?> "<?php echo $content_heading_color; ?> ><?php echo $post_title; ?> </a> </div> <?php } // Excerpt if ('true' == $excerpt) { if ('true' == $custom_excerpt_trim) { $custom_excerpt_trim = true; } else { $custom_excerpt_trim = false; } $excerpt_array = array('length' => intval($excerpt_length), 'readmore' => false, 'trim_custom_excerpts' => $custom_excerpt_trim); // Generate excerpt $get_excerpt = vcex_get_excerpt($excerpt_array); if ($get_excerpt) { ?> <div class="wpex-carousel-entry-excerpt clr"> <?php echo $get_excerpt; ?> </div><!-- .wpex-carousel-entry-excerpt --> <?php } ?> <?php } ?> </div><!-- .wpex-carousel-entry-details --> <?php } ?> </div><!-- .wpex-carousel-slide --> <?php // End foreach loop } ?> </div><!-- .wpex-carousel --> <?php } // End has posts check // Set things back to normal wp_reset_postdata(); // Return outbut buffer return ob_get_clean(); }
function vcex_portfolio_grid_shortcode($atts) { extract(shortcode_atts(array('unique_id' => '', 'term_slug' => '', 'include_categories' => '', 'exclude_categories' => '', 'posts_per_page' => '8', 'grid_style' => 'fit_columns', 'masonry_layout_mode' => '', 'filter_speed' => '', 'columns' => '4', 'order' => 'DESC', 'orderby' => 'date', 'orderby_meta_key' => '', 'filter' => '', 'center_filter' => 'no', 'thumb_link' => 'post', 'thumb_lightbox_gallery' => '', 'thumb_lightbox_title' => '', 'img_crop' => 'true', 'img_width' => '9999', 'img_height' => '9999', 'img_filter' => '', 'title' => 'true', 'title_link' => 'post', 'excerpt' => 'true', 'excerpt_length' => 30, 'custom_excerpt_trim' => '', 'read_more' => '', 'read_more_text' => __('read more', 'wpex'), 'pagination' => '', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'img_hover_style' => '', 'img_overlay_disable' => '', 'img_rendering' => '', 'all_text' => '', 'overlay_style' => '', 'content_heading_margin' => '', 'content_background' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'readmore_background' => '', 'readmore_color' => '', 'equal_heights_grid' => '', 'single_column_style' => '', 'entry_media' => ''), $atts)); // Turn output buffer on ob_start(); // Global $post global $post; // Don't create custom tax if tax doesn't exist if (taxonomy_exists('portfolio_category')) { // Include categories $include_categories = '' != $include_categories ? $include_categories : $term_slug; $include_categories = 'all' == $include_categories ? '' : $include_categories; $filter_cats_include = ''; if ($include_categories) { $include_categories = explode(',', $include_categories); $filter_cats_include = array(); foreach ($include_categories as $key) { $key = get_term_by('slug', $key, 'portfolio_category'); $filter_cats_include[] = $key->term_id; } } // Exclude categories $filter_cats_exclude = ''; if ($exclude_categories) { $exclude_categories = explode(',', $exclude_categories); if (!empty($exclude_categories) && is_array($exclude_categories)) { $filter_cats_exclude = array(); foreach ($exclude_categories as $key) { $key = get_term_by('slug', $key, 'portfolio_category'); $filter_cats_exclude[] = $key->term_id; } $exclude_categories = array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN'); } else { $exclude_categories = ''; } } // Start Tax Query if (!empty($include_categories) && is_array($include_categories)) { $include_categories = array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN'); } else { $include_categories = ''; } } // Meta key for orderby if ($orderby_meta_key && ('meta_value_num' == $orderby || 'meta_value' == $orderby)) { $meta_key = $orderby_meta_key; } else { $meta_key = NULL; } // Pagination variables $paged = NULL; $no_found_rows = true; if ('true' == $pagination) { global $paged; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $no_found_rows = false; } // The Query $wpex_query = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key, 'filter_content' => $filter_content, 'paged' => $paged, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories), 'no_found_rows' => $no_found_rows)); //Output posts if ($wpex_query->posts) { // Set unique ID $unique_id = $unique_id ? $unique_id : 'portfolio-' . rand(1, 100); // Image hard crop if ('9999' == $img_height) { $img_crop = false; } else { $img_crop = true; } // Is Isotope var if ('true' == $filter || 'masonry' == $grid_style || 'no_margins' == $grid_style) { $is_isotope = true; } else { $is_isotope = false; } // No need for masonry if not enough columns and filter is disabled if ('true' != $filter && 'masonry' == $grid_style) { $post_count = count($wpex_query->posts); if ($post_count <= $columns) { $is_isotope = false; } } // Output script for inline JS for the Visual composer front-end builder if ($is_isotope) { vcex_front_end_grid_js('isotope'); } // Display filter links if ('true' == $filter && taxonomy_exists('portfolio_category')) { // Get the terms for the filter $terms = get_terms('portfolio_category', array('include' => $filter_cats_include, 'exclude' => $filter_cats_exclude)); // Display filter only if terms exist and there is more then 1 if ($terms && count($terms) > '1') { // Center filter links $center_filter = 'yes' == $center_filter ? 'center' : ''; // All text if ($all_text) { $all_text = $all_text; } else { $all_text = __('All', 'wpex'); } ?> <ul class="vcex-portfolio-filter filter-<?php echo $unique_id; ?> vcex-filter-links <?php echo $center_filter; ?> clr"> <li class="active"><a href="#" data-filter="*"><span><?php echo $all_text; ?> </span></a></li> <?php foreach ($terms as $term) { ?> <li><a href="#" data-filter=".cat-<?php echo $term->term_id; ?> "><?php echo $term->name; ?> </a></li> <?php } ?> </ul><!-- .vcex-portfolio-filter --> <?php } ?> <?php } // Content Design $content_style = ''; if ($content_background) { $content_style .= 'background:' . $content_background . ';'; } if ($content_padding) { $content_style .= 'padding:' . $content_padding . ';'; } if ($content_margin) { $content_style .= 'margin:' . $content_margin . ';'; } if ($content_border) { $content_style .= 'border:' . $content_border . ';'; } if ($content_font_size) { $content_style .= 'font-size:' . $content_font_size . ';'; } if ($content_color) { $content_style .= 'color:' . $content_color . ';'; } if ($content_opacity) { $content_style .= 'opacity:' . $content_opacity . ';'; } if ($content_alignment) { $content_style .= 'text-align:' . $content_alignment . ';'; } if ($content_style) { $content_style = 'style="' . $content_style . '"'; } // Heading Design $heading_style = ''; if ($content_heading_margin) { $heading_style .= 'margin: ' . $content_heading_margin . ';'; } if ($content_heading_size) { $heading_style .= 'font-size: ' . $content_heading_size . ';'; } if ($content_heading_color) { $heading_style .= 'color: ' . $content_heading_color . ';'; } if ($heading_style) { $heading_style = 'style="' . $heading_style . '"'; } // Readmore design if ('false' != $read_more) { $read_more = 'true'; // Set readmore to true $readmore_style = ''; if ($readmore_background) { $readmore_style .= 'background: ' . $readmore_background . ';'; } if ($readmore_color) { $readmore_style .= 'color: ' . $readmore_color . ';'; } if ($readmore_style) { $readmore_style = 'style="' . $readmore_style . '"'; } } // Set title to true if not false if ('false' != $title) { $title = 'true'; } // Set excerpt to true if not false if ('false' != $excerpt) { $excerpt = 'true'; } // Default excerpt length if ('' == $excerpt_length) { $excerpt_length = '30'; } elseif ('false' == $excerpt) { $excerpt_length = '0'; } // Trim custom Excerpts? if ('false' == $custom_excerpt_trim) { $custom_excerpt_trim = false; } else { $custom_excerpt_trim = true; } // Only use articles if title is enabled for HTML5 validity if ($title == 'true') { $main_element_type = 'article'; } else { $main_element_type = 'div'; } // Main wrap classes $wrap_classes = 'wpex-row vcex-portfolio-grid clr'; // Equal heights class if ('1' != $columns && ('fit_columns' == $grid_style && 'true' == $equal_heights_grid)) { $equal_heights_grid = true; } else { $equal_heights_grid = false; } // Isotope classes if ($is_isotope) { $wrap_classes .= ' vcex-isotope-grid'; } // No margins grid if ('no_margins' == $grid_style) { $wrap_classes .= ' vcex-no-margin-grid'; } // Left thumbnail 1 column style if ('left_thumbs' == $single_column_style) { $wrap_classes .= ' left-thumbs'; } // Lightbox classes if ('true' == $thumb_lightbox_gallery) { $wrap_classes .= ' lightbox-group'; $lightbox_single_class = ' lightbox-group-item'; } else { $lightbox_single_class = ' wpex-lightbox'; } // Data $data = ''; if ($is_isotope && 'true' == $filter) { if ('no_margins' != $grid_style && $masonry_layout_mode) { $data .= ' data-layout-mode="' . $masonry_layout_mode . '"'; } if ($filter_speed) { $data .= ' data-transition-duration="' . $filter_speed . '"'; } } if ('no_margins' == $grid_style && 'true' != $filter) { $data .= ' data-transition-duration="0.0"'; } ?> <div class="<?php echo $wrap_classes; ?> " id="<?php echo $unique_id; ?> "<?php echo $data; ?> > <?php // Define counter var to clear floats $count = $count_all = ''; // Start loop foreach ($wpex_query->posts as $post) { setup_postdata($post); // Open match-height-row div for equal heights if ($equal_heights_grid && !$is_isotope) { if (0 == $count) { ?> <div class="match-height-row clr"> <?php } $count_all++; } // Post Data $post_id = $post->ID; $post_title = get_the_title(); $post_title_esc = esc_attr(the_title_attribute('echo=0')); $post_permalink = get_permalink($post_id); // Add to the counter var $count++; // Add classes to the entries $entry_classes = 'portfolio-entry col'; $entry_classes .= ' span_1_of_' . $columns; $entry_classes .= ' col-' . $count; if ($is_isotope) { $entry_classes .= ' vcex-isotope-entry'; } if ('no_margins' == $grid_style) { $entry_classes .= ' vcex-no-margin-entry'; } if (taxonomy_exists('portfolio_category')) { $post_terms = get_the_terms($post, 'portfolio_category'); if ($post_terms) { foreach ($post_terms as $post_term) { $entry_classes .= ' cat-' . $post_term->term_id; } } } ?> <<?php echo $main_element_type; ?> class="<?php echo $entry_classes; ?> "> <?php // Entry Media if ('false' != $entry_media) { // Video if (function_exists('wpex_get_portfolio_featured_video_url') && wpex_get_portfolio_featured_video_url()) { ?> <div class="portfolio-entry-media clr"> <?php wpex_portfolio_post_video(); ?> </div> <?php } elseif (has_post_thumbnail()) { // Get cropped image $cropped_img = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop, 'array'); // Filter style $img_filter_class = $img_filter ? 'vcex-' . $img_filter : ''; // Media classes $media_classes = $img_filter_class; if ($img_hover_style) { $media_classes .= ' vcex-img-hover-parent vcex-img-hover-' . $img_hover_style; } if ($img_rendering) { $media_classes .= ' vcex-image-rendering-' . $img_rendering; } if ($overlay_style) { $media_classes .= ' ' . wpex_overlay_classname($overlay_style); } ?> <div class="portfolio-entry-media <?php echo $media_classes; ?> "> <?php // No link if ('nowhere' == $thumb_link) { ?> <img src="<?php echo $cropped_img['url']; ?> " alt="<?php echo $post_title; ?> " class="portfolio-entry-img" height="<?php echo $cropped_img['height']; ?> " width="<?php echo $cropped_img['width']; ?> " /> <?php // Lightbox } elseif ('lightbox' == $thumb_link) { // Display lightbox title $data = ''; if ('true' == $thumb_lightbox_title) { $data = ' data-title="' . $post_title_esc . '"'; } ?> <a href="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?> " title="<?php echo $post_title_esc; ?> " class="portfolio-entry-media-link<?php echo $lightbox_single_class; ?> "<?php echo $data; ?> > <img src="<?php echo $cropped_img['url']; ?> " alt="<?php echo $post_title_esc; ?> " class="portfolio-entry-img" height="<?php echo $cropped_img['height']; ?> " width="<?php echo $cropped_img['width']; ?> " /> <?php // Standarad post link } else { ?> <a href="<?php echo $post_permalink; ?> " title="<?php echo $post_title_esc; ?> " class="portfolio-entry-media-link"> <img src="<?php echo $cropped_img['url']; ?> " alt="<?php echo $post_title_esc; ?> " class="portfolio-entry-img" height="<?php echo $cropped_img['height']; ?> " width="<?php echo $cropped_img['width']; ?> " /> <?php } ?> <?php // Close link and output overlay code if ('nowhere' != $thumb_link) { // Inner Overlay if ($overlay_style) { wpex_overlay('inside_link', $overlay_style); } // Close links echo '</a>'; // Outside Overlay if ($overlay_style) { wpex_overlay('outside_link', $overlay_style); } } ?> </div><!-- .portfolio-entry-media --> <?php } ?> <?php } ?> <?php // Display content if there is either a title or excerpt if ('true' == $title || 'true' == $excerpt) { ?> <div class="portfolio-entry-details clr" <?php echo $content_style; ?> > <?php // Equal height div if ($equal_heights_grid && !$is_isotope) { ?> <div class="match-height-content"> <?php } // Display the title if ('false' != $title) { ?> <h2 class="portfolio-entry-title" <?php echo $heading_style; ?> > <?php // Link title to post if ('post' == $title_link) { ?> <a href="<?php echo $post_permalink; ?> " title="<?php echo $post_title_esc; ?> " <?php echo $heading_style; ?> ><?php echo $post_title; ?> </a> <?php } elseif ('lightbox' == $title_link) { ?> <a href="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?> " title="<?php echo $post_title_esc; ?> " class="wpex-lightbox" <?php echo $heading_style; ?> ><?php echo $post_title; ?> </a> <?php } else { echo $post_title; } ?> </h2> <?php } // Display excerpt and readmore if ('true' == $excerpt || 'true' == $read_more) { ?> <div class="portfolio-entry-excerpt clr"> <?php // Display full content if ('9999' == $excerpt_length) { the_content(); } elseif (function_exists('wpex_excerpt')) { $args = array('post_id' => $post_id, 'length' => intval($excerpt_length), 'trim_custom_excerpts' => $custom_excerpt_trim); wpex_excerpt($args); } else { the_excerpt(); } // Display Readmore if ('false' != $read_more) { // Read more string fallback if ('' == $read_more_text) { $read_more_text = __('read more', 'wpex'); } ?> <a href="<?php echo $post_permalink; ?> " title="<?php echo $read_more_text; ?> " rel="bookmark" class="vcex-readmore theme-button" <?php echo $readmore_style; ?> > <?php echo $read_more_text; ?> <span class="vcex-readmore-rarr"><?php echo wpex_element('rarr'); ?> </span> </a> <?php } ?> </div> <?php } // Close Equal height div if ($equal_heights_grid && !$is_isotope) { ?> </div> <?php } ?> </div><!-- .portfolio-entry-details --> <?php } ?> </<?php echo $main_element_type; ?> ><!-- .portfolio-entry --> <?php // Check if counter equal columns if ($count == $columns) { // Close equal height row if ($equal_heights_grid && !$is_isotope) { echo '</div><!-- .match-height-row -->'; } // Reset counter $count = ''; } // End foreach } // Make sure match-height-row is closed if ($equal_heights_grid && !$is_isotope) { if ('4' == $columns && $count_all % 4 != 0) { echo '</div><!-- .match-height-row -->'; } if ('3' == $columns && $count_all % 3 != 0) { echo '</div><!-- .match-height-row -->'; } if ('2' == $columns && $count_all % 2 != 0) { echo '</div><!-- .match-height-row -->'; } } ?> </div><!-- .vcex-portfolio-grid --> <?php // Paginate Posts if ('true' == $pagination) { wpex_pagination($wpex_query); } // Reset the WP query wp_reset_postdata(); // End has posts check } // Return outbut buffer return ob_get_clean(); }
} ?> "> <?php foreach ($attachments as $attachment) { // Get image alt tag $attachment_alt = strip_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true)); ?> <li class="slide" data-thumb="<?php echo wpex_image_resize(wp_get_attachment_url($attachment), '100', '100', true); ?> "> <?php // Display image with lightbox if (wpex_gallery_is_lightbox_enabled() == 'on') { $lightbox_url = wpex_image_resize(wp_get_attachment_url($attachment), 1500, 9999, false); ?> <a href="<?php echo $lightbox_url; ?> " title="<?php echo $attachment_alt; ?> " data-title="<?php echo $attachment_alt; ?> " data-type="image" class="lightbox-group-item"> <img src="<?php echo wpex_image('url', $attachment); ?> " alt="<?php
function vcex_image_flexslider_shortcode($atts) { // Define shortcode params extract(shortcode_atts(array('unique_id' => '', 'image_ids' => '', 'animation' => 'slide', 'slideshow' => 'true', 'randomize' => 'false', 'direction' => 'horizontal', 'slideshow_speed' => '7000', 'animation_speed' => '600', 'control_nav' => 'true', 'direction_nav' => 'true', 'pause_on_hover' => 'true', 'smooth_height' => 'false', 'thumbnail_link' => 'lightbox', 'custom_links' => '', 'custom_links_target' => '_self', 'img_width' => '9999', 'img_height' => '9999', 'caption' => 'true', 'img_rendering' => '', 'control_thumbs' => 'false'), $atts)); // Turn output buffer on ob_start(); // Get Attachments $attachments = explode(",", $image_ids); $attachments = array_combine($attachments, $attachments); // Dummy images when no images are defined $dummy_images = NULL; if (empty($image_ids)) { $dummy_images = true; $attachments = array(WPEX_VCEX_DIR_URI . 'assets/images/dummy2.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy3.jpg'); } //Output images if ($attachments) { // Output script for inline JS for the Visual composer front-end builder if (function_exists('vcex_front_end_slider_js')) { vcex_front_end_slider_js(); } // Set output var $output = ''; // Control Thumbnails if ('true' == $control_thumbs) { $control_nav = 'thumbnails'; } else { $control_nav = $control_nav; } // Flexslider Data $flexslider_data = 'data-animation="' . $animation . '"'; $flexslider_data .= ' data-slideshow="' . $slideshow . '"'; $flexslider_data .= ' data-randomize="' . $randomize . '"'; $flexslider_data .= ' data-direction="' . $direction . '"'; $flexslider_data .= ' data-slideshow-speed="' . $slideshow_speed . '"'; $flexslider_data .= ' data-animation-speed="' . $animation_speed . '"'; $flexslider_data .= ' data-direction-nav="' . $direction_nav . '"'; $flexslider_data .= ' data-pause="' . $pause_on_hover . '"'; $flexslider_data .= ' data-smooth-height="' . $smooth_height . '"'; $flexslider_data .= ' data-control-nav="' . $control_nav . '"'; // Custom Links if ($thumbnail_link == 'custom_link') { $custom_links = explode(',', $custom_links); } // Main Classes $classes = 'vcex-flexslider-wrap vcex-img-flexslider flexslider-container clr'; if ('lightbox' == $thumbnail_link) { $classes .= ' lightbox-group'; } // Unique ID $unique_id = $unique_id ? ' id="' . $unique_id . '"' : NULL; ?> <div class="<?php echo $classes; ?> "<?php echo $unique_id; ?> > <div class="vcex-flexslider flexslider" <?php echo $flexslider_data; ?> > <ul class="slides"> <?php // Loop through attachments $count = -1; foreach ($attachments as $attachment) { $count++; // Attachment VARS $attachment_link = get_post_meta($attachment, '_wp_attachment_url', true); $attachment_img_url = wp_get_attachment_url($attachment); $attachment_alt = strip_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true)); $attachment_caption = esc_attr(get_post_field('post_excerpt', $attachment)); // Get and crop image if needed if ($dummy_images) { $attachment_img = $attachment; } else { $attachment_img = wp_get_attachment_url($attachment); $img_width = intval($img_width); $img_height = intval($img_height); $crop = $img_height == '9999' ? false : true; $attachment_img = wpex_image_resize($attachment_img, $img_width, $img_height, $crop); } // Image rendering if ($img_rendering) { $img_rendering = ' vcex-image-rendering-' . $img_rendering; } // Image output $image_output = '<img src="' . $attachment_img . '" alt="' . $attachment_alt . '" />'; // Thumb Data attr if ('true' == $control_thumbs) { $data_thumb = 'data-thumb="' . wpex_image_resize($attachment_img_url, 100, 100, true) . '"'; } else { $data_thumb = ''; } ?> <li class="vcex-flexslider-slide slide <?php echo $img_rendering; ?> " <?php echo $data_thumb; ?> > <div class="vcex-flexslider-entry-media"> <?php // Lightbox links if ('lightbox' == $thumbnail_link) { ?> <a href="<?php echo $attachment_img_url; ?> " title="<?php echo $attachment_caption; ?> " class="vcex-flexslider-entry-img lightbox-group-item"> <?php echo $image_output; ?> </a> <?php // Custom links } elseif ('custom_link' == $thumbnail_link) { $custom_link = !empty($custom_links[$count]) ? $custom_links[$count] : '#'; if ('#' == $custom_link) { ?> <?php echo $image_output; ?> <?php } else { ?> <a href="<?php echo esc_url($custom_link); ?> " title="<?php echo $attachment_caption; ?> " class="vcex-flexslider-entry-img" target="<?php echo $custom_links_target; ?> "> <?php echo $image_output; ?> </a> <?php } } else { // Plain Image echo $image_output; } // Image Caption if ('true' == $caption && $attachment_caption) { ?> <div class="vcex-img-flexslider-caption clr"> <?php echo $attachment_caption; ?> </div><!-- .vcex-flexslider-entry-caption --> <?php } ?> </div><!-- .vcex-flexslider-entry-media --> </li> <?php } ?> </ul> </div> </div> <div class="vcex-clear-floats"></div> <?php } // End has posts check // Return outbut buffer return ob_get_clean(); }
function vcex_post_type_grid_shortcode($atts) { extract(shortcode_atts(array('unique_id' => '', 'post_types' => '', 'tax_query' => '', 'tax_query_taxonomy' => '', 'tax_query_terms' => '', 'posts_per_page' => '12', 'grid_style' => 'fit_columns', 'columns' => '3', 'order' => 'DESC', 'orderby' => 'date', 'orderby_meta_key' => '', 'filter' => '', 'masonry_layout_mode' => '', 'filter_speed' => '', 'center_filter' => '', 'thumbnail_link' => 'post', 'entry_media' => "true", 'img_width' => '9999', 'img_height' => '9999', 'thumb_link' => 'post', 'img_filter' => '', 'title' => 'true', 'date' => 'true', 'excerpt' => 'true', 'excerpt_length' => '15', 'custom_excerpt_trim' => 'true', 'read_more' => 'false', 'read_more_text' => __('read more', 'wpex'), 'pagination' => 'false', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'all_text' => __('All', 'wpex'), 'featured_video' => 'true', 'url_target' => '_self', 'thumbnail_query' => 'no', 'overlay_style' => '', 'img_hover_style' => '', 'date_color' => '', 'content_heading_margin' => '', 'content_background' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'readmore_background' => '', 'readmore_color' => '', 'equal_heights_grid' => ''), $atts)); // Turn output buffer on ob_start(); // Get global $post var global $post; // Meta key for orderby if ($orderby_meta_key && ('meta_value_num' == $orderby || 'meta_value' == $orderby)) { $meta_key = $orderby_meta_key; } else { $meta_key = NULL; } // Pagination var $paged = NULL; $no_found_rows = true; if ('true' == $pagination) { global $paged; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $paged = NULL; $no_found_rows = false; } // Post types $post_types = $post_types ? $post_types : 'post'; $post_types = explode(',', $post_types); $post_types_count = count($post_types); // Thumbnail meta query if ('true' == $thumbnail_query) { $meta_query = array(array('key' => '_thumbnail_id')); } else { $meta_query = NULL; } // Tax Query if ('' != $tax_query && '' != $tax_query_taxonomy && '' != $tax_query_terms) { $tax_query_terms = explode(',', $tax_query_terms); $tax_query = array(array('taxonomy' => $tax_query_taxonomy, 'field' => 'slug', 'terms' => $tax_query_terms)); } else { $tax_query = ''; } // Query args $args = array('post_type' => $post_types, 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'tax_query' => $tax_query, 'meta_key' => $meta_key, 'filter_content' => $filter_content, 'paged' => $paged, 'meta_query' => $meta_query, 'no_found_rows' => $no_found_rows); // Build new query $wpex_query = new WP_Query($args); //Output posts if ($wpex_query->posts) { // Main Vars $unique_id = $unique_id ? $unique_id : 'post-type-' . rand(1, 100); $img_crop = $img_height == '9999' ? false : true; $read_more = $read_more == 'true' ? true : false; // Is Isotope var if ('true' == $filter && $post_types_count > '1' || 'masonry' == $grid_style || 'no_margins' == $grid_style) { $is_isotope = true; } else { $is_isotope = false; } // No need for masonry if not enough columns and filter is disabled if ('true' != $filter && 'masonry' == $grid_style) { $post_count = count($wpex_query->posts); if ($post_count <= $columns) { $is_isotope = false; } } // Main wrap classes $wrap_classes = 'wpex-row vcex-post-type-grid vcex-clearfix'; // Equal heights class if ('1' != $columns && ('fit_columns' == $grid_style && 'true' == $equal_heights_grid)) { $equal_heights_grid = true; } else { $equal_heights_grid = false; } // Isotope classes if ($is_isotope) { $wrap_classes .= ' vcex-isotope-grid'; } // No margins grid if ('no_margins' == $grid_style) { $wrap_classes .= ' vcex-no-margin-grid'; } // Output script for inline JS for the Visual composer front-end builder if ($is_isotope) { vcex_front_end_grid_js('isotope'); } // Content Design $content_style = ''; if ($content_background) { $content_style .= 'background:' . $content_background . ';'; } if ($content_padding) { $content_style .= 'padding:' . $content_padding . ';'; } if ($content_margin) { $content_style .= 'margin:' . $content_margin . ';'; } if ($content_border) { $content_style .= 'border:' . $content_border . ';'; } if ($content_font_size) { $content_style .= 'font-size:' . $content_font_size . ';'; } if ($content_color) { $content_style .= 'color:' . $content_color . ';'; } if ($content_opacity) { $content_style .= 'opacity:' . $content_opacity . ';'; } if ($content_alignment) { $content_style .= 'text-align:' . $content_alignment . ';'; } if ($content_style) { $content_style = 'style="' . $content_style . '"'; } // Heading Design $heading_style = ''; if ($content_heading_margin) { $heading_style .= 'margin:' . $content_heading_margin . ';'; } if ($content_heading_size) { $heading_style .= 'font-size:' . $content_heading_size . ';'; } if ($content_heading_color) { $heading_style .= 'color:' . $content_heading_color . ';'; } if ($heading_style) { $heading_style = 'style="' . $heading_style . '"'; } // Readmore design if ('true' == $read_more) { $readmore_style = ''; if ($readmore_background) { $readmore_style .= 'background:' . $readmore_background . ';'; } if ($readmore_color) { $readmore_style .= 'color:' . $readmore_color . ';'; } if ($readmore_style) { $readmore_style = 'style="' . $readmore_style . '"'; } } // Date design $date_style = ''; if ('true' == $date) { if ($date_color) { $date_style .= 'color:' . $date_color . ';'; } if ($date_style) { $date_style = 'style="' . $date_style . '"'; } } // Display filter links if ('true' == $filter && $post_types_count > '1') { $center_filter = 'yes' == $center_filter ? 'center' : ''; ?> <ul class="vcex-post-type-filter filter-<?php echo $unique_id; ?> vcex-filter-links <?php echo $center_filter; ?> clr"> <li class="active"><a href="#" data-filter="*"><span><?php echo $all_text; ?> </span></a></li> <?php foreach ($post_types as $post_type) { $obj = get_post_type_object($post_type); ?> <li><a href="#" data-filter=".post-type-<?php echo $post_type; ?> "><?php echo $obj->labels->name; ?> </a></li> <?php } ?> </ul><!-- .vcex-post-type-filter --> <?php } ?> <?php // Data $data = ''; if ($is_isotope && 'true' == $filter) { if ('no_margins' != $grid_style && $masonry_layout_mode) { $data .= ' data-layout-mode="' . $masonry_layout_mode . '"'; } if ($filter_speed) { $data .= ' data-transition-duration="' . $filter_speed . '"'; } } if ('no_margins' == $grid_style && 'true' != $filter) { $data .= ' data-transition-duration="0.0"'; } ?> <div class="<?php echo $wrap_classes; ?> " id="<?php echo $unique_id; ?> "<?php echo $data; ?> > <?php // Define counter var to clear floats $count = $count_all = ''; // Loop through posts foreach ($wpex_query->posts as $post) { setup_postdata($post); // Open match-height-row div for equal heights if ($equal_heights_grid && !$is_isotope) { if (0 == $count) { ?> <div class="match-height-row clr"> <?php } $count_all++; } // Post ID var $post_id = $post->ID; // Add to counter var $count++; // Get post format $format = get_post_format($post_id); // Get video if ('true' == $featured_video) { $video_url = get_post_meta($post_id, 'wpex_post_oembed', true); } // General Class $entry_classes = 'vcex-post-type-entry col'; // Counter class $entry_classes .= ' col-' . $count; // Column class $entry_classes .= ' span_1_of_' . $columns; // Post type class $entry_classes .= ' post-type-' . get_post_type($post_id); // Isotope if ($is_isotope) { $entry_classes .= ' vcex-isotope-entry'; } // No margins grid if ('no_margins' == $grid_style) { $entry_classes .= ' vcex-no-margin-entry'; } // No media entry class if ("false" == $entry_media) { $entry_classes .= ' vcex-post-type-no-media-entry'; } if ($title == 'true') { $main_element_type = 'article'; } else { $main_element_type = 'div'; } ?> <<?php echo $main_element_type; ?> id="#post-<?php the_ID(); ?> " class="<?php echo $entry_classes; ?> "> <?php if ("true" == $entry_media) { ?> <?php // Video Embed if ("video" == $format && 'true' == $featured_video && $video_url) { ?> <div class="vcex-post-type-entry-media"> <div class="vcex-video-wrap"> <?php echo wp_oembed_get($video_url); ?> </div> </div><!-- .vcex-post-type-entry-media --> <?php } elseif (has_post_thumbnail()) { // Filter style $img_filter_class = $img_filter ? 'vcex-' . $img_filter : ''; // Image hover styles $img_hover_style_class = $img_hover_style ? 'vcex-img-hover-parent vcex-img-hover-' . $img_hover_style : ''; // Media classes $media_classes = $img_filter_class; $media_classes .= ' ' . $img_hover_style_class; $overlay_classnames = wpex_overlay_classname($overlay_style); $media_classes .= ' ' . $overlay_classnames; ?> <div class="vcex-post-type-entry-media <?php echo $media_classes; ?> "> <?php if ($thumb_link == 'post' || $thumb_link == 'lightbox') { ?> <?php // Post links if ($thumb_link == 'post') { ?> <a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " target="<?php echo $url_target; ?> "> <?php } ?> <?php // Lightbox Links if ($thumb_link == 'lightbox') { ?> <?php // Video Lightbox if ($format == 'video') { ?> <a href="<?php echo $video_url; ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " class="wpex-lightbox-video"> <?php } else { ?> <a href="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " class="wpex-lightbox"> <?php } ?> <?php } ?> <?php } // Get cropped image array and display image $cropped_img = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop, 'array'); ?> <img src="<?php echo $cropped_img['url']; ?> " alt="<?php the_title(); ?> " class="vcex-post-type-entry-img" height="<?php echo $cropped_img['height']; ?> " width="<?php echo $cropped_img['width']; ?> " /> <?php if ($thumb_link == 'post' || $thumb_link == 'lightbox') { ?> <?php } ?> <?php // Overlay if ('post' == $thumb_link || 'lightbox' == $thumb_link) { // Inner Overlay wpex_overlay('inside_link', $overlay_style); ?> </a> <?php // Outside Overlay wpex_overlay('outside_link', $overlay_style); } ?> </div><!-- .post_type-entry-media --> <?php } ?> <?php } ?> <?php if ('true' == $title || 'true' == $excerpt || 'true' == $read_more) { ?> <div class="vcex-post-type-entry-details clr" <?php echo $content_style; ?> > <?php // Equal height div if ($equal_heights_grid && !$is_isotope) { ?> <div class="match-height-content"> <?php } // Post Title if ('false' != $title) { ?> <h2 class="vcex-post-type-entry-title" <?php echo $heading_style; ?> > <a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " target="<?php echo $url_target; ?> " <?php echo $heading_style; ?> ><?php the_title(); ?> </a> </h2> <?php } ?> <?php // Post Date if ($date == 'true') { ?> <div class="vcex-post-type-entry-date" <?php echo $date_style; ?> ><?php echo get_the_date(); ?> </div> <?php } ?> <?php // Excerpt if ('true' == $excerpt || 'true' == $read_more) { if ('true' != $excerpt) { $excerpt_length = '0'; } ?> <div class="vcex-post-type-entry-excerpt clr"> <?php // Show full content if ('9999' == $excerpt_length) { the_content(); } else { $trim_custom_excerpts = 'true' == $custom_excerpt_trim ? true : false; $excerpt_array = array('length' => intval($excerpt_length), 'trim_custom_excerpts' => $trim_custom_excerpts); vcex_excerpt($excerpt_array); } // Read more if ($read_more) { ?> <a href="<?php the_permalink(); ?> " title="<?php echo $read_more_text; ?> " rel="bookmark" class="vcex-readmore theme-button" target="<?php echo $url_target; ?> " <?php echo $readmore_style; ?> > <?php echo $read_more_text; ?> <span class="vcex-readmore-rarr"><?php echo wpex_element('rarr'); ?> </span> </a> <?php } ?> </div> <?php } // Close Equal height div if ($equal_heights_grid && !$is_isotope) { ?> </div> <?php } ?> </div><!-- .post_type-entry-details --> <?php } ?> </<?php echo $main_element_type; ?> ><!-- .post_type-entry --> <?php // Check if counter equal columns if ($count == $columns) { // Close equal height row if ($equal_heights_grid && !$is_isotope) { echo '</div><!-- .match-height-row -->'; } // Reset counter $count = ''; } // End foreach } // Make sure match-height-row is closed if ($equal_heights_grid && !$is_isotope) { if ('4' == $columns && $count_all % 4 != 0) { echo '</div><!-- .match-height-row -->'; } if ('3' == $columns && $count_all % 3 != 0) { echo '</div><!-- .match-height-row -->'; } if ('2' == $columns && $count_all % 2 != 0) { echo '</div><!-- .match-height-row -->'; } } ?> </div><!-- .vcex-post-type-grid --> <?php // Paginate Posts if ('true' == $pagination) { wpex_pagination($wpex_query); } // End has posts check } // Reset the WP query wp_reset_postdata(); // Return outbut buffer return ob_get_clean(); }
/** * Change products per row */ public function subcategory_thumbnail($category) { $title = get_the_title(); $thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true); $attachment_url = wp_get_attachment_url($thumbnail_id); $width = get_theme_mod('woo_cat_entry_width', '9999'); $height = get_theme_mod('woo_cat_entry_height', '9999'); $crop = $height == '9999' ? false : true; $attachment_url = wpex_image_resize($attachment_url, $width, $height, $crop); $attachment_url = $attachment_url ? $attachment_url : get_template_directory_uri() . '/images/dummy-image.jpg'; echo '<img src="' . $attachment_url . '" alt="' . $title . '" />'; }
function vcex_image_swap_shortcode($atts) { // Define shortcode params extract(shortcode_atts(array('unique_id' => '', 'primary_image' => 'true', 'secondary_image' => '', 'border_radius' => '', 'link' => '', 'link_title' => '', 'link_target' => '_self', 'link_tooltip' => '', 'img_width' => '9999', 'img_height' => '9999', 'img_rendering' => ''), $atts)); $img_crop = $img_width >= '9999' ? false : true; // Primary Image $primary_image = wp_get_attachment_url($primary_image); $primary_image_alt = strip_tags(get_post_meta($primary_image, '_wp_attachment_image_alt', true)); if (function_exists('wpex_image_resize')) { $primary_image = wpex_image_resize($primary_image, intval($img_width), intval($img_height), $img_crop); } // Secondary Image $secondary_image = wp_get_attachment_url($secondary_image); $secondary_image_alt = strip_tags(get_post_meta($secondary_image, '_wp_attachment_image_alt', true)); if (function_exists('wpex_image_resize')) { $secondary_image = wpex_image_resize($secondary_image, intval($img_width), intval($img_height), $img_crop); } // Extra classes $classes = 'vcex-image-swap clr'; if ('' != $border_radius) { $border_radius = 'style="border-radius:' . $border_radius . ';"'; } if ($img_rendering) { $classes .= ' vcex-image-rendering-' . $img_rendering; } // Output ob_start(); ?> <div class="<?php echo $classes; ?> "> <?php if ($link) { ?> <a href="<?php echo esc_url($link); ?> " title="<?php echo $link_title; ?> " target="<?php echo $link_target; ?> " class="vcex-image-swap-link <?php if ('yes' == $link_tooltip) { echo 'tooltip-up'; } ?> "> <?php } ?> <img src="<?php echo $primary_image; ?> " alt="<?php echo $primary_image_alt; ?> " class="vcex-image-swap-primary" <?php echo $border_radius; ?> /> <img src="<?php echo $secondary_image; ?> " alt="<?php echo $secondary_image_alt; ?> " class="vcex-image-swap-secondary" <?php echo $border_radius; ?> /> <?php if ($link) { ?> </a> <?php } ?> </div> <?php return ob_get_clean(); }
<div class="product-variation-thumbs clr lightbox-group"> <?php foreach ($attachments as $attachment) { $attachment_alt = strip_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true)); ?> <a href="<?php echo wp_get_attachment_url($attachment); ?> " title="<?php echo $attachment_alt; ?> " data-title="<?php echo $attachment_alt; ?> " data-type="image" class="lightbox-group-item"><img src="<?php echo wpex_image_resize(wp_get_attachment_url($attachment), '100', '100', true); ?> " alt="<?php echo $attachment_alt; ?> " /></a> <?php } ?> </div><!-- .product-variation-thumbs --> <?php } } else { // Display woocommerce placeholder image echo apply_filters('woocommerce_single_product_image_html', sprintf('<img src="%s" alt="Placeholder" />', woocommerce_placeholder_img_src()), $post->ID); }
/** * Returns correct HTMl for post thumbnails * * @since 2.0.0 */ function wpex_get_post_thumbnail($args = array()) { // Check if retina is enabled $retina_img = ''; $attr = array(); // Default args $defaults = array('attachment' => get_post_thumbnail_id(), 'size' => 'full', 'width' => '', 'height' => '', 'crop' => 'center-center', 'alt' => '', 'class' => '', 'return' => 'html', 'style' => '', 'retina' => wpex_global_obj('retina'), 'schema_markup' => false, 'placeholder' => false); // Parse args $args = wp_parse_args($args, $defaults); // Extract args extract($args); // Return dummy image if ('dummy' == $attachment || $placeholder) { return '<img src="' . wpex_placeholder_img_src() . '" />'; } // Return if there isn't any attachment if (!$attachment) { return; } // Sanitize variables $size = 'wpex-custom' == $size ? 'wpex_custom' : $size; $size = 'wpex_custom' == $size ? false : $size; $crop = !$crop ? 'center-center' : $crop; $crop = 'true' == $crop ? 'center-center' : $crop; // Image must have an alt if (empty($alt)) { $alt = get_post_meta($attachment, '_wp_attachment_image_alt', true); } if (empty($alt)) { $alt = trim(strip_tags(get_post_field('post_excerpt', $attachment))); } if (empty($alt)) { $alt = trim(strip_tags(get_the_title($attachment))); $alt = str_replace('_', ' ', $alt); $alt = str_replace('-', ' ', $alt); } // Prettify alt attribute if ($alt) { $alt = ucwords($alt); } // If image width and height equal '9999' return full image if ('9999' == $width && '9999' == $height) { $size = $size ? $size : 'full'; $width = $height = ''; } // Define crop locations $crop_locations = array_flip(wpex_image_crop_locations()); // Set crop location if defined in format 'left-top' and turn into array if ($crop && in_array($crop, $crop_locations)) { $crop = 'center-center' == $crop ? true : explode('-', $crop); } // Get attachment URl $attachment_url = wp_get_attachment_url($attachment); // Return if there isn't any attachment URL if (!$attachment_url) { return; } // Add classes if ($class) { $attr['class'] = $class; } // Add alt if ($alt) { $attr['alt'] = esc_attr($alt); } // Add style if ($style) { $attr['style'] = $style; } // Add schema markup if ($schema_markup) { $attr['itemprop'] = 'image'; } // If on the fly image resizing is enabled or a custom width/height is defined if (wpex_get_mod('image_resizing', true) || ($width || $height)) { // Add Classes if ($class) { $class = ' class="' . $class . '"'; } // If size is defined and not equal to wpex_custom if ($size && 'wpex_custom' != $size) { $dims = wpex_get_thumbnail_sizes($size); $width = $dims['width']; $height = $dims['height']; $crop = !empty($dims['crop']) ? $dims['crop'] : $crop; } // Crop standard image $image = wpex_image_resize(array('image' => $attachment_url, 'width' => $width, 'height' => $height, 'crop' => $crop)); // Generate retina version if ($retina) { $retina_img = wpex_generate_retina_image($attachment_url, $width, $height, $crop); if ($retina_img) { $attr['data-at2x'] = $retina_img; } else { $attr['data-no-retina'] = ''; } } // Return HTMl if ($image) { // Return image URL if ('url' == $return) { return $image['url']; } else { // Add attributes $attr = array_map('esc_attr', $attr); $html = ''; foreach ($attr as $name => $value) { $html .= ' ' . esc_attr($name) . '="' . esc_attr($value) . '"'; } // Return img return '<img src="' . esc_url($image['url']) . '" width="' . esc_attr($image['width']) . '" height="' . esc_attr($image['height']) . '"' . $html . ' />'; } } } else { // Sanitize size $size = $size ? $size : 'full'; // Create retina version if retina is enabled (not needed for full images) if ($retina) { // Retina not needed for full images if ('full' != $size) { $dims = wpex_get_thumbnail_sizes($size); $retina_img = wpex_generate_retina_image($attachment_url, $dims['width'], $dims['height'], $dims['crop']); } // Add retina tag if ($retina_img) { $attr['data-at2x'] = $retina_img; } else { $attr['data-no-retina'] = ''; } } // Return image URL if ('url' == $return) { $src = wp_get_attachment_image_src($attachment, $size, false); return $src[0]; } else { return wp_get_attachment_image($attachment, $size, false, $attr); } } }
function vcex_image_carousel_shortcode($atts) { // Define shortcode params extract(shortcode_atts(array('unique_id' => '', 'classes' => '', 'style' => '', 'image_ids' => '', 'center' => 'false', 'timeout_duration' => '5000', 'items' => '4', 'items_margin' => '15', 'infinite_loop' => 'true', 'items_scroll' => '1', 'auto_play' => 'false', 'arrows' => 'true', 'thumbnail_link' => '', 'custom_links' => '', 'custom_links_target' => '', 'img_width' => '9999', 'img_height' => '9999', 'title' => 'false', 'title_type' => '', 'img_filter' => '', 'rounded_image' => '', 'img_hover_style' => '', 'img_rendering' => '', 'caption' => 'false', 'content_background' => '', 'content_heading_margin' => '', 'content_heading_weight' => '', 'content_heading_transform' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'tablet_items' => '3', 'mobile_landscape_items' => '2', 'mobile_portrait_items' => '1'), $atts)); // Turn output buffer on ob_start(); // Get Attachments $images = explode(',', $image_ids); $images = array_combine($images, $images); // Dummy Images $dummy_images = NULL; if (empty($image_ids)) { $dummy_images = true; $images = array(WPEX_VCEX_DIR_URI . 'assets/images/dummy1.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy2.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy3.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy4.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy5.jpg', WPEX_VCEX_DIR_URI . 'assets/images/dummy6.jpg'); } // Classes $img_classes = array(); if ($rounded_image == 'yes') { $img_classes[] = 'vcex-rounded-images'; } if ($img_filter) { $img_classes[] = 'vcex-' . $img_filter; } if ($img_hover_style) { $img_classes[] = ' vcex-img-hover-parent vcex-img-hover-' . $img_hover_style; } $img_classes = implode(' ', $img_classes); // Custom Links if ($thumbnail_link == 'custom_link') { $custom_links = explode(',', $custom_links); } // Display carousel if there are images if ($images) { // Output js for front-end editor vcex_front_end_carousel_js(); // Give caroufredsel a unique name $rand_num = rand(1, 100); $unique_carousel_id = 'carousel-' . $rand_num; // Prevent auto play in visual composer if (wpex_is_front_end_composer()) { $auto_play = 'false'; } // Item Margin if ('no-margins' == $style) { $items_margin = '0'; } // Items to scroll fallback for old setting if ('page' == $items_scroll) { $items_scroll = $items; } // Unique ID if ($unique_id) { $unique_id = ' id="' . $unique_id . '"'; } // Main Classes $add_classes = 'wpex-carousel wpex-carousel-images clr owl-carousel'; if ($style) { $add_classes .= ' ' . $style; } if ($img_rendering) { $add_classes = ' vcex-image-rendering-' . $img_rendering; } if ($classes) { $add_classes .= ' ' . $classes; } ?> <div class="<?php echo $add_classes; ?> "<?php echo $unique_id; ?> data-items="<?php echo $items; ?> " data-slideby="<?php echo $items_scroll; ?> " data-nav="<?php echo $arrows; ?> " data-autoplay="<?php echo $auto_play; ?> " data-loop="<?php echo $infinite_loop; ?> " data-autoplay-timeout="<?php echo $timeout_duration; ?> " data-center="<?php echo $center; ?> " data-margin="<?php echo intval($items_margin); ?> " data-items-tablet="<?php echo $tablet_items; ?> " data-items-mobile-landscape="<?php echo $mobile_landscape_items; ?> " data-items-mobile-portrait="<?php echo $mobile_portrait_items; ?> "> <?php // Loop through images $count = -1; foreach ($images as $attachment) { $count++; // Attachment VARS $attachment_link = get_post_meta($attachment, '_wp_attachment_url', true); $attachment_img_url = wp_get_attachment_url($attachment); $attachment_alt = strip_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true)); $attachment_caption = get_post_field('post_excerpt', $attachment); $attachment_title = get_the_title($attachment); if ('alt' == $title_type) { $attachment_title = $attachment_alt; } // Get and crop image if needed if ($dummy_images) { $attachment_img = $attachment; } else { $attachment_img = wp_get_attachment_url($attachment); $img_width = intval($img_width); $img_height = intval($img_height); if ('9999' == $img_height) { $crop = false; } else { $crop = true; } $attachment_img = wpex_image_resize($attachment_img, $img_width, $img_height, $crop); } // Image output $image_output = '<img src="' . $attachment_img . '" alt="' . $attachment_alt . '" />'; ?> <div class="wpex-carousel-slide"> <div class="wpex-carousel-entry-media clr <?php echo $img_classes; ?> "> <?php // Lightbox if ('lightbox' == $thumbnail_link) { ?> <a href="<?php echo $attachment_img_url; ?> " title="<?php echo $attachment_alt; ?> " class="wpex-carousel-entry-img wpex-lightbox"> <?php echo $image_output; ?> </a><!-- .wpex-carousel-entry-img --> <?php } elseif ('custom_link' == $thumbnail_link) { $custom_link = !empty($custom_links[$count]) ? $custom_links[$count] : '#'; if ($custom_link == '#') { echo $image_output; } else { ?> <a href="<?php echo esc_url($custom_link); ?> " title="<?php echo $attachment_alt; ?> " class="wpex-carousel-entry-img" target="<?php echo $custom_links_target; ?> "> <?php echo $image_output; ?> </a> <?php } } else { echo $image_output; } ?> </div><!-- .wpex-carousel-entry-media --> <?php // Open details if ('yes' == $title || 'yes' == $caption) { if ($attachment_title || $attachment_caption) { // Content Design $content_style = ''; if ($content_background) { $content_style .= 'background:' . $content_background . ';'; } if ($content_padding) { $content_style .= 'padding:' . $content_padding . ';'; } if ($content_margin) { $content_style .= 'margin:' . $content_margin . ';'; } if ($content_border) { $content_style .= 'border:' . $content_border . ';'; } if ($content_font_size) { $content_style .= 'font-size:' . $content_font_size . ';'; } if ($content_color) { $content_style .= 'color:' . $content_color . ';'; } if ($content_opacity) { $content_style .= 'opacity:' . $content_opacity . ';'; } if ($content_alignment) { $content_style .= 'text-align:' . $content_alignment . ';'; } if ($content_style) { $content_style = ' style="' . $content_style . '"'; } ?> <div class="wpex-carousel-entry-details clr"<?php echo $content_style; ?> > <?php } // Display title if ('yes' == $title && $attachment_title) { // Title design $heading_style = ''; if ($content_heading_margin) { $heading_style .= 'margin: ' . $content_heading_margin . ';'; } if ($content_heading_transform) { $heading_style .= 'text-transform: ' . $content_heading_transform . ';'; } if ($content_heading_weight) { $heading_style .= 'font-weight: ' . $content_heading_weight . ';'; } if ($content_heading_size) { $heading_style .= 'font-size: ' . $content_heading_size . ';'; } if ($content_heading_color) { $heading_style .= 'color: ' . $content_heading_color . ';'; } if ($heading_style) { $heading_style = ' style="' . $heading_style . '"'; } ?> <div class="wpex-carousel-entry-title"<?php echo $heading_style; ?> ><?php echo $attachment_title; ?> </div> <?php } // Display caption if ('yes' == $caption && $attachment_caption) { ?> <div class="wpex-carousel-entry-excerpt"><?php echo $attachment_caption; ?> </div> <?php } // Close details if ('yes' == $title || 'yes' == $caption) { if ($attachment_title || $attachment_caption) { ?> </div> <?php } } } ?> </div><!-- .wpex-carousel-slide --> <?php // End foreach loop } ?> </div><!-- .wpex-carousel --> <?php } // End has images check // Return outbut buffer return ob_get_clean(); }
exit; } // Return if there isn't any thumbnail if (!has_post_thumbnail()) { return; } // Get cropped featured image $image = wpex_image('array'); ?> <div class="blog-entry-media clr"> <?php // Lightbox style entry if (get_theme_mod('blog_entry_image_lightbox')) { $lightbox_url = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), 9999, 9999, false); ?> <a href="<?php echo $lightbox_url; ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " rel="bookmark" class="blog-entry-media-link <?php wpex_img_animation_classes(); ?> wpex-lightbox" data-type="image"> <img src="<?php echo $image['url']; ?> " alt="<?php
function vcex_teaser_shortcode($atts, $content = NULL) { extract(shortcode_atts(array('unique_id' => '', 'heading' => '', 'heading_type' => 'h2', 'heading_color' => '', 'heading_size' => '', 'heading_margin' => '', 'heading_weight' => '', 'heading_letter_spacing' => '', 'heading_transform' => '', 'style' => 'one', 'text_align' => '', 'image' => '', 'img_width' => '9999', 'img_height' => '9999', 'video' => '', 'url' => '', 'content_background' => '', 'url_target' => '', 'url_rel' => '', 'css_animation' => '', 'img_filter' => '', 'img_hover_style' => '', 'img_rendering' => '', 'content_font_size' => '', 'content_margin' => '', 'content_padding' => '', 'content_color' => '', 'content_font_weight' => '', 'background' => '', 'border_color' => '', 'padding' => '', 'border_radius' => '', 'img_style' => ''), $atts)); // Turn output buffer on ob_start(); // Unique ID if ($unique_id) { $unique_id = 'id="' . $unique_id . '"'; } // Classes $add_classes = 'vcex-teaser'; if ('' != $css_animation) { $add_classes .= ' wpb_animate_when_almost_visible wpb_' . $css_animation . ''; } if ($style) { $add_classes .= ' vcex-teaser-' . $style; } if ($text_align) { $add_classes .= ' vcex-text-align-' . $text_align; } // Main style $inline_style = ''; if ($padding && 'two' == $style) { $inline_style .= 'padding:' . $padding . ';'; } if ($background && 'two' == $style) { $inline_style .= 'background:' . $background . ';'; } if ($border_color && 'two' == $style) { $inline_style .= 'border-color:' . $border_color . ';'; } if ($border_radius && 'two' == $style) { $inline_style .= 'border-radius:' . $border_radius . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } ?> <div class="<?php echo $add_classes; ?> " <?php echo $unique_id; ?> <?php echo $inline_style; ?> > <?php /*** Video ***/ if ($video) { ?> <div class="vcex-teaser-media vcex-video-wrap"> <?php echo wp_oembed_get($video); ?> </div><!-- .vcex-teaser-media --> <?php } /*** Link ***/ if ($url) { // Link classes $add_classes = 'vcex-teaser-link'; // Link Target if ('local' == $url_target) { $url_target = ''; $add_classes .= ' local-scroll-link'; } elseif ('blank' == $url_target) { $url_target = 'target="_blank"'; } else { $url_target = ''; } ?> <a href="<?php echo esc_url($url); ?> " title="<?php echo $heading; ?> " target="<?php echo $url_target; ?> " rel="<?php echo $url_rel; ?> " class="<?php echo $add_classes; ?> "> <?php } /*** Image ***/ if ($image) { $image_img_url = wp_get_attachment_url($image); $image_img = wp_get_attachment_url($image); $image_alt = strip_tags(get_post_meta($image, '_wp_attachment_image_alt', true)); $img_crop = $img_height >= '9999' ? false : true; $add_classes = 'vcex-teaser-media'; if ($img_filter) { $add_classes .= ' vcex-' . $img_filter; } if ($img_hover_style) { $add_classes .= ' vcex-img-hover-parent vcex-img-hover-' . $img_hover_style; } if ($img_rendering) { $add_classes .= ' vcex-image-rendering-' . $img_rendering; } if ('stretch' == $img_style) { $add_classes .= ' stretch-image'; } ?> <figure class="<?php echo $add_classes; ?> "> <img src="<?php echo wpex_image_resize($image_img_url, intval($img_width), intval($img_height), $img_crop); ?> " alt="<?php echo $image_alt; ?> " /> </figure> <?php } if ($content || $heading) { /*** Content Area ***/ $inline_style = ''; if ($content_margin) { $inline_style .= 'margin:' . $content_margin . ';'; } if ($content_padding) { $inline_style .= 'padding:' . $content_padding . ';'; } if ($background && 'three' == $style && '' == $content_background) { $inline_style .= 'background:' . $background . ';'; } if ($content_background) { $inline_style .= 'background:' . $content_background . ';'; } if ($border_color && ('three' == $style || 'four' == $style)) { $inline_style .= 'border-color:' . $border_color . ';'; } if ($border_radius && ('three' == $style || 'four' == $style)) { $inline_style .= 'border-radius:' . $border_radius . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } ?> <div class="vcex-teaser-content clr" <?php echo $inline_style; ?> > <?php /*** Heading ***/ if ($heading) { // Heading style $inline_style = ''; if ($heading_color) { $inline_style .= 'color:' . $heading_color . ';'; } if ($heading_size) { $inline_style .= 'font-size:' . $heading_size . ';'; } if ($heading_margin) { $inline_style .= 'margin:' . $heading_margin . ';'; } if ($heading_weight) { $inline_style .= 'font-weight:' . $heading_weight . ';'; } if ($heading_letter_spacing) { $inline_style .= 'letter-spacing:' . $heading_letter_spacing . ';'; } if ($heading_transform) { $inline_style .= 'text-transform:' . $heading_transform . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } ?> <<?php echo $heading_type; ?> class="vcex-teaser-heading" <?php echo $inline_style; ?> > <?php // Display heading echo $heading; ?> </<?php echo $heading_type; ?> > <?php } // Close URL tag if ($url) { ?> </a> <?php } /*** Text ***/ if ($content) { $inline_style = ''; if ($content_font_size) { $inline_style .= 'font-size:' . $content_font_size . ';'; } if ($content_color) { $inline_style .= 'color:' . $content_color . ';'; } if ($content_font_weight) { $inline_style .= 'font-weight:' . $content_font_weight . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } ?> <div class="vcex-teaser-text clr" <?php echo $inline_style; ?> > <?php echo do_shortcode($content); ?> </div><!-- .vcex-teaser-text --> <?php } ?> </div><!-- .vcex-teaser-content --> <?php } ?> </div><!-- .vcex-teaser --> <?php // Return outbut buffer return ob_get_clean(); }
function vcex_feature_box_shortcode($atts, $content = NULL) { extract(shortcode_atts(array('unique_id' => '', 'classes' => '', 'heading' => '', 'equal_heights' => '', 'padding' => '', 'border' => '', 'background' => '', 'heading_type' => 'h2', 'heading_color' => '', 'heading_size' => '', 'heading_margin' => '', 'heading_weight' => '', 'heading_letter_spacing' => '', 'heading_transform' => '', 'tablet_widths' => '', 'phone_widths' => '', 'style' => 'left-content-right-image', 'text_align' => '', 'image_lightbox' => '', 'image' => '', 'img_width' => '9999', 'img_height' => '9999', 'img_border_radius' => '', 'video' => '', 'heading_url' => '', 'content_background' => '', 'css_animation' => '', 'img_filter' => '', 'image_url' => '', 'img_hover_style' => '', 'img_rendering' => '', 'content_font_size' => '', 'content_padding' => '', 'content_color' => '', 'content_font_weight' => '', 'img_style' => '', 'content_width' => '', 'media_width' => ''), $atts)); // Turn output buffer on ob_start(); // Load equal height for the frontend if (function_exists('wpex_is_front_end_composer') && wpex_is_front_end_composer() && $equal_heights) { ?> <script> (function($) { "use strict"; if ($.fn.matchHeight != undefined) { $('.match-height-feature-row .match-height-feature').matchHeight(); } })(jQuery); </script> <?php } // If video url is set disable equal heights if ($video) { $equal_heights = false; } // ID if ($unique_id) { $unique_id = ' id="' . $unique_id . '"'; } // Add style $inline_style = ''; if ($padding) { $inline_style .= 'padding:' . $padding . ';'; } if ($background) { $inline_style .= 'background:' . $background . ';'; } if ($border) { $inline_style .= 'border:' . $border . ';'; } if ($inline_style) { $inline_style = ' style="' . $inline_style . '"'; } // Classes $add_classes = 'vcex-feature-box clr'; if ('' != $css_animation) { $add_classes .= ' wpb_animate_when_almost_visible wpb_' . $css_animation . ''; } if ($style) { $add_classes .= ' ' . $style; } if ($equal_heights) { $add_classes .= ' match-height-feature-row'; } if ($tablet_widths) { $add_classes .= ' tablet-fullwidth-columns'; } if ($phone_widths) { $add_classes .= ' phone-fullwidth-columns'; } if ($text_align) { $add_classes .= ' vcex-text-align-' . $text_align; } if ($classes) { $add_classes .= ' ' . $classes; } ?> <div class="<?php echo $add_classes; ?> "<?php echo $unique_id; echo $inline_style; ?> > <?php // Image/Video check if ($image || $video) { // Add classes $add_classes = 'vcex-feature-box-media clr'; if ($equal_heights) { $add_classes .= ' match-height-feature'; } // Media style $inline_style = ''; if ($media_width) { $inline_style .= 'width:' . $media_width . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } ?> <div class="<?php echo $add_classes; ?> " <?php echo $inline_style; ?> > <?php /*** Video ***/ if ($video) { ?> <div class="vcex-video-wrap"> <?php echo wp_oembed_get(esc_url($video)); ?> </div><!-- .vcex-feature-box-media --> <?php } elseif ($image) { // Get image $image_img_url = wp_get_attachment_url($image); $image_img = wp_get_attachment_url($image); $image_alt = strip_tags(get_post_meta($image, '_wp_attachment_image_alt', true)); $img_crop = $img_height >= '9999' ? false : true; // Image inline CSS $inline_style = ''; if ($img_border_radius) { $inline_style .= 'border-radius:' . $img_border_radius . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } // Image classes $add_classes = 'vcex-feature-box-image'; if ($equal_heights) { $add_classes .= ' fade-in-image'; } if ($img_filter) { $add_classes .= ' vcex-' . $img_filter; } if ($img_hover_style && 'true' != $equal_heights) { $add_classes .= ' vcex-img-hover-parent vcex-img-hover-' . $img_hover_style; } if ($img_rendering) { $add_classes .= ' vcex-image-rendering-' . $img_rendering; } // Image URL if ($image_url || 'image' == $image_lightbox) { // Standard URL $link = vc_build_link($image_url); $a_href = isset($link['url']) ? $link['url'] : ''; $a_title = isset($link['title']) ? $link['title'] : ''; $a_target = isset($link['target']) ? $link['target'] : ''; // Image lightbox $data_attributes = ''; if ($image_lightbox) { if ('image' == $image_lightbox) { $a_href = $image_img_url; $add_classes .= ' wpex-lightbox'; $data_attributes .= 'data-type="image"'; } elseif ('url' == $image_lightbox) { $add_classes .= ' wpex-lightbox'; $data_attributes .= 'data-type="iframe"'; $data_attributes .= 'data-options="width:1920,height:1080"'; } elseif ('auto-detect' == $image_lightbox) { $add_classes .= ' wpex-lightbox-autodetect'; } elseif ('video_embed' == $image_lightbox) { $add_classes .= ' wpex-lightbox'; $data_attributes .= 'data-type="iframe"'; $data_attributes .= 'data-options="width:1920,height:1080"'; } elseif ('html5' == $image_lightbox) { $poster = wp_get_attachment_image_src($img_id, 'large'); $poster = $poster[0]; $add_classes .= ' wpex-lightbox'; $data_attributes .= 'data-type="video"'; $data_attributes .= 'data-options="width:848, height:480, html5video: { webm: \'' . $lightbox_video_html5_webm . '\', poster: \'' . $poster . '\' }"'; } elseif ('quicktime' == $image_lightbox) { $add_classes .= ' wpex-lightbox'; $data_attributes .= 'data-type="video"'; $data_attributes .= 'data-options="width:1920,height:1080"'; } } } if (isset($a_href) && $a_href) { ?> <a href="<?php echo esc_url($a_href); ?> " title="<?php echo $a_title; ?> " target="<?php echo $a_target; ?> " class="vcex-feature-box-image-link <?php echo $add_classes; ?> " <?php echo $inline_style; ?> <?php echo $data_attributes; ?> > <?php } else { ?> <div class="<?php echo $add_classes; ?> " <?php echo $inline_style; ?> > <?php } ?> <img src="<?php echo wpex_image_resize($image_img_url, intval($img_width), intval($img_height), $img_crop); ?> " alt="<?php echo $image_alt; ?> " <?php echo $inline_style; ?> /> <?php if (isset($a_href) && $a_href) { ?> </a><!-- .vcex-feature-box-image --> <?php } else { ?> </div><!-- .vcex-feature-box-image --> <?php } ?> <?php } // End video check ?> </div><!-- .vcex-feature-box-media --> <?php } // $video or $image check ?> <?php // Content area if ($content || $heading) { /*** Content Area ***/ $add_classes = 'vcex-feature-box-content clr'; if ($equal_heights) { $add_classes .= ' match-height-feature'; } $inline_style = ''; if ($content_width) { $inline_style .= 'width:' . $content_width . ';'; } if ($content_background) { $inline_style .= 'background:' . $content_background . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } ?> <div class="<?php echo $add_classes; ?> " <?php echo $inline_style; ?> > <?php if ($content_padding) { ?> <div class="vcex-feature-box-padding-container clr" style="padding:<?php echo $content_padding; ?> ;"> <?php } ?> <?php /*** Heading ***/ if ($heading) { // Heading style $inline_style = ''; if ($heading_color) { $inline_style .= 'color:' . $heading_color . ';'; } if ($heading_size) { $inline_style .= 'font-size:' . $heading_size . ';'; } if ($heading_margin) { $inline_style .= 'margin:' . $heading_margin . ';'; } if ($heading_weight) { $inline_style .= 'font-weight:' . $heading_weight . ';'; } if ($heading_letter_spacing) { $inline_style .= 'letter-spacing:' . $heading_letter_spacing . ';'; } if ($heading_transform) { $inline_style .= 'text-transform:' . $heading_transform . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } // Heading URL $a_href = ''; if ($heading_url && '||' != $heading_url) { $link = vc_build_link($heading_url); $a_href = isset($link['url']) ? $link['url'] : ''; $a_title = isset($link['title']) ? $link['title'] : ''; $a_target = isset($link['target']) ? $link['target'] : ''; } if (isset($a_href) && $a_href) { ?> <a href="<?php echo esc_url($a_href); ?> " title="<?php echo $a_title; ?> " target="<?php echo $a_target; ?> " class="vcex-feature-box-heading-link"> <?php } ?> <<?php echo $heading_type; ?> class="vcex-feature-box-heading" <?php echo $inline_style; ?> > <?php // Display heading echo $heading; ?> </<?php echo $heading_type; ?> > <?php if (isset($a_href) && $a_href) { ?> </a> <?php } ?> <?php } /*** Text ***/ if ($content) { $inline_style = ''; if ($content_font_size) { $inline_style .= 'font-size:' . $content_font_size . ';'; } if ($content_color) { $inline_style .= 'color:' . $content_color . ';'; } if ($content_font_weight) { $inline_style .= 'font-weight:' . $content_font_weight . ';'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } ?> <div class="vcex-feature-box-text clr" <?php echo $inline_style; ?> > <?php echo apply_filters('the_content', $content); ?> </div><!-- .vcex-feature-box-text --> <?php } ?> <?php if ($content_padding) { ?> </div><!-- .vcex-feature-box-padding-container --> <?php } ?> </div><!-- .vcex-feature-box-content --> <?php } ?> </div><!-- .vcex-feature --> <?php // Return outbut buffer return ob_get_clean(); }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ function widget($args, $instance) { // Set vars $title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : __('Recent Posts', 'wpex'); $number = isset($instance['number']) ? $instance['number'] : '3'; $style = isset($instance['style']) ? $instance['style'] : 'default'; $order = isset($instance['order']) ? $instance['order'] : ''; $img_height = !empty($instance['img_height']) ? intval($instance['img_height']) : '65'; $img_width = !empty($instance['img_width']) ? intval($instance['img_width']) : '65'; $date = isset($instance['date']) ? $instance['date'] : ''; $post_type = isset($instance['post_type']) ? $instance['post_type'] : ''; // Important hook echo $args['before_widget']; // Display title if ($title) { echo $args['before_title'] . $title . $args['after_title']; } // The Query global $post; // Get current post ID to exclude it if (is_singular()) { $current_post = $post->ID; } else { $current_post = ''; } $myposts = get_posts(array('post_type' => $post_type, 'numberposts' => $number, 'orderby' => $order, 'no_found_rows' => true, 'suppress_filters' => false, 'meta_key' => '_thumbnail_id', 'exclude' => $current_post)); if ($myposts) { ?> <ul class="wpex-widget-recent-posts clr style-<?php echo $style; ?> "> <?php // Loop through posts foreach ($myposts as $post) { setup_postdata($post); // Set featured image dimensions and crop if (has_post_thumbnail()) { if ('9999' == $img_height) { $img_crop = false; } else { $img_crop = true; } $featured_image = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), $img_width, $img_height, $img_crop); // Output entry if a featured image exists and can be cropped if ($featured_image) { ?> <li class="clearfix wpex-widget-recent-posts-li"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> " class="wpex-widget-recent-posts-thumbnail"> <img src="<?php echo $featured_image; ?> " alt="<?php the_title(); ?> " /> </a> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> " class="wpex-widget-recent-posts-title"><?php the_title(); ?> </a> <?php // Display date if enabled if ($date !== '1') { ?> <div class="wpex-widget-recent-posts-date"><?php echo get_the_date(); ?> </div> <?php } ?> </li> <?php } } } ?> </ul> <?php } // Reset the query wp_reset_postdata(); // Important hook echo $args['after_widget']; }
function vcex_post_type_flexslider_shortcode($atts) { extract(shortcode_atts(array('unique_id' => '', 'post_types' => 'post', 'tax_query' => '', 'tax_query_taxonomy' => '', 'tax_query_terms' => '', 'posts_per_page' => '4', 'order' => 'DESC', 'orderby' => 'date', 'filter_content' => 'false', 'offset' => 0, 'animation' => 'slide', 'slideshow' => 'true', 'randomize' => 'false', 'direction' => 'horizontal', 'slideshow_speed' => '7000', 'animation_speed' => '600', 'control_nav' => 'true', 'direction_nav' => 'true', 'pause_on_hover' => 'true', 'smooth_height' => 'true', 'img_width' => '9999', 'img_height' => '9999', 'caption' => true, 'caption_location' => 'over-slider', 'control_thumbs' => 'false', 'title' => 'true', 'excerpt' => 'true', 'excerpt_length' => '40'), $atts)); // Turn output buffer on ob_start(); // Get global $post var global $post; // Post types $post_types = $post_types ? $post_types : 'post'; $post_types = explode(',', $post_types); // Tax Query if ('' != $tax_query && '' != $tax_query_taxonomy && '' != $tax_query_terms) { $tax_query_terms = explode(',', $tax_query_terms); $tax_query = array(array('taxonomy' => $tax_query_taxonomy, 'field' => 'slug', 'terms' => $tax_query_terms)); } else { $tax_query = ''; } // Build new query $vcex_query = new WP_Query(array('post_type' => $post_types, 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'meta_query' => array(array('key' => '_thumbnail_id')), 'no_found_rows' => true, 'tax_query' => $tax_query)); //Output posts if ($vcex_query->posts) { // Output script for inline JS for the Visual composer front-end builder if (function_exists('vcex_front_end_slider_js')) { vcex_front_end_slider_js(); } // Control Thumbnails if ('true' == $control_thumbs) { $control_nav = 'thumbnails'; } else { $control_nav = $control_nav; } // Flexslider Data $flexslider_data = 'data-animation="' . $animation . '"'; $flexslider_data .= ' data-slideshow="' . $slideshow . '"'; $flexslider_data .= ' data-randomize="' . $randomize . '"'; $flexslider_data .= ' data-direction="' . $direction . '"'; $flexslider_data .= ' data-slideshow-speed="' . $slideshow_speed . '"'; $flexslider_data .= ' data-animation-speed="' . $animation_speed . '"'; $flexslider_data .= ' data-direction-nav="' . $direction_nav . '"'; $flexslider_data .= ' data-pause="' . $pause_on_hover . '"'; $flexslider_data .= ' data-smooth-height="' . $smooth_height . '"'; $flexslider_data .= ' data-control-nav="' . $control_nav . '"'; // Main Vars $unique_id = $unique_id ? ' id="' . $unique_id . '"' : NULL; $img_crop = $img_height == '9999' ? false : true; ?> <div class="vcex-flexslider-wrap clr vcex-img-flexslider vcex-posttypes-flexslider"<?php echo $unique_id; ?> > <div class="vcex-flexslider flexslider" <?php echo $flexslider_data; ?> > <ul class="slides"> <?php // Loop through posts foreach ($vcex_query->posts as $post) { setup_postdata($post); $img_url = wp_get_attachment_url(get_post_thumbnail_id()); // Thumb Data attr if ('true' == $control_thumbs) { $data_thumb = 'data-thumb="' . wpex_image_resize($img_url, 100, 100, true) . '"'; } else { $data_thumb = ''; } ?> <li class="vcex-flexslider-slide slide" <?php echo $data_thumb; ?> > <div class="vcex-flexslider-entry-media"> <?php if (has_post_thumbnail()) { $cropped_img = wpex_image_resize($img_url, intval($img_width), intval($img_height), $img_crop, 'array'); if ($cropped_img && is_array($cropped_img)) { ?> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <img src="<?php echo $cropped_img['url']; ?> " alt="<?php the_title(); ?> " class="vcex-post-type-entry-img" height="<?php echo $cropped_img['height']; ?> " width="<?php echo $cropped_img['width']; ?> " /> </a> <?php } ?> <?php } // WooComerce Price if (class_exists('Woocommerce') && 'product' == get_post_type()) { ?> <div class="slider-woocommerce-price"> <?php $product = get_product(get_the_ID()); echo $product->get_price_html(); ?> </div><!-- .slider-woocommerce-price --> <?php } ?> <?php if ('true' == $caption) { ?> <div class="vcex-img-flexslider-caption clr <?php echo $caption_location; ?> "> <?php // Display title if ('true' == $title) { ?> <div class="title clr"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><?php the_title(); ?> </a> <?php if ('staff' == get_post_type() && get_post_meta(get_the_ID(), 'wpex_staff_position', true)) { ?> <div class="staff-position"> <?php echo get_post_meta(get_the_ID(), 'wpex_staff_position', true); ?> </div> <?php } ?> </div> <?php } // Display excerpt if ('true' == $excerpt) { ?> <div class="excerpt clr"> <?php $excerpt_array = array('length' => intval($excerpt_length)); vcex_excerpt($excerpt_array); ?> </div><!-- .excerpt --> <?php } ?> </div><!-- .vcex-img-flexslider-caption --> <?php } ?> </div><!-- .vcex-flexslider-entry-media --> </li><!-- .vcex-posttypes-slide --> <?php } ?> </ul><!-- .slides --> </div><!-- .flexslider --> </div><!-- .vcex-posttypes-flexslider --> <!-- Be safe and clear the floats --> <div class="vcex-clear-floats"></div> <?php // End has posts check } // Reset the WP query wp_reset_postdata(); // Return outbut buffer return ob_get_clean(); }
function vcex_blog_grid_shortcode($atts) { extract(shortcode_atts(array('unique_id' => '', 'term_slug' => '', 'include_categories' => '', 'exclude_categories' => '', 'posts_per_page' => '4', 'grid_style' => 'fit_columns', 'columns' => '3', 'order' => 'DESC', 'orderby' => 'date', 'filter' => 'false', 'masonry_layout_mode' => '', 'filter_speed' => '', 'center_filter' => '', 'thumbnail_link' => 'post', 'entry_media' => "true", 'img_width' => '9999', 'img_height' => '9999', 'thumb_link' => 'post', 'img_filter' => '', 'title' => 'true', 'date' => 'true', 'excerpt' => 'true', 'excerpt_length' => '15', 'custom_excerpt_trim' => 'true', 'read_more' => 'false', 'read_more_text' => __('read more', 'wpex'), 'pagination' => 'false', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'all_text' => __('All', 'wpex'), 'featured_video' => 'true', 'url_target' => '_self', 'date_color' => '', 'content_heading_margin' => '', 'content_background' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'readmore_background' => '', 'readmore_color' => '', 'equal_heights_grid' => '', 'single_column_style' => ''), $atts)); // Turn output buffer on ob_start(); // Get global $post var global $post; // Include categories $include_categories = '' != $include_categories ? $include_categories : $term_slug; $include_categories = 'all' == $include_categories ? '' : $include_categories; $filter_cats_include = ''; if ($include_categories) { $include_categories = explode(',', $include_categories); $filter_cats_include = array(); foreach ($include_categories as $key) { $key = get_term_by('slug', $key, 'category'); $filter_cats_include[] = $key->term_id; } } // Exclude categories $filter_cats_exclude = ''; if ($exclude_categories) { $exclude_categories = explode(',', $exclude_categories); if (!empty($exclude_categories) && is_array($exclude_categories)) { $filter_cats_exclude = array(); foreach ($exclude_categories as $key) { $key = get_term_by('slug', $key, 'category'); $filter_cats_exclude[] = $key->term_id; } $exclude_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN'); } else { $exclude_categories = ''; } } // Start Tax Query if (!empty($include_categories) && is_array($include_categories)) { $include_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN'); } else { $include_categories = ''; } // Pagination var $paged = NULL; $no_found_rows = true; if ('true' == $pagination) { global $paged; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $no_found_rows = false; } // The Query $wpex_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'paged' => $paged, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories), 'no_found_rows' => $no_found_rows)); //Output posts if ($wpex_query->posts) { // Custom excerpts trim $custom_excerpt_trim = 'true' == $custom_excerpt_trim ? true : false; // Image hard crop if ('9999' == $img_height) { $img_crop = false; } else { $img_crop = true; } // Equal heights class if ('1' != $columns && ('fit_columns' == $grid_style && 'true' == $equal_heights_grid)) { $equal_heights_grid = true; } else { $equal_heights_grid = false; } // Is Isotope var if ('true' == $filter || 'masonry' == $grid_style) { $is_isotope = true; } else { $is_isotope = false; } // No need for masonry if not enough columns and filter is disabled if ('true' != $filter && 'masonry' == $grid_style) { $post_count = count($wpex_query->posts); if ($post_count <= $columns) { $is_isotope = false; } } // Output script for inline JS for the Visual composer front-end builder if ($is_isotope) { vcex_front_end_grid_js('isotope'); } // Display filter links if ($filter == 'true') { $terms = get_terms('category', array('include' => $filter_cats_include, 'exclude' => $filter_cats_exclude)); if ($terms && count($terms) > '1') { $center_filter = 'yes' == $center_filter ? 'center' : ''; ?> <ul class="vcex-blog-filter vcex-filter-links <?php echo $center_filter; ?> clr"> <li class="active"><a href="#" data-filter="*"><span><?php echo $all_text; ?> </span></a></li> <?php foreach ($terms as $term) { ?> <li><a href="#" data-filter=".cat-<?php echo $term->term_id; ?> "><?php echo $term->name; ?> </a></li> <?php } ?> </ul><!-- .vcex-blog-filter --> <?php } ?> <?php } // Content Design $content_style = ''; if ($content_background) { $content_style .= 'background:' . $content_background . ';'; } if ($content_padding) { $content_style .= 'padding:' . $content_padding . ';'; } if ($content_margin) { $content_style .= 'margin:' . $content_margin . ';'; } if ($content_border) { $content_style .= 'border:' . $content_border . ';'; } if ($content_font_size) { $content_style .= 'font-size:' . $content_font_size . ';'; } if ($content_color) { $content_style .= 'color:' . $content_color . ';'; } if ($content_opacity) { $content_style .= 'opacity:' . $content_opacity . ';'; } if ($content_alignment) { $content_style .= 'text-align:' . $content_alignment . ';'; } if ($content_style) { $content_style = 'style="' . $content_style . '"'; } // Heading Design $heading_style = ''; if ($content_heading_margin) { $heading_style .= 'margin:' . $content_heading_margin . ';'; } if ($content_heading_size) { $heading_style .= 'font-size:' . $content_heading_size . ';'; } if ($content_heading_color) { $heading_style .= 'color:' . $content_heading_color . ';'; } if ($heading_style) { $heading_style = 'style="' . $heading_style . '"'; } // Readmore design if ('true' == $read_more) { $readmore_style = ''; if ($readmore_background) { $readmore_style .= 'background:' . $readmore_background . ';'; } if ($readmore_color) { $readmore_style .= 'color:' . $readmore_color . ';'; } if ($readmore_style) { $readmore_style = 'style="' . $readmore_style . '"'; } } // Date design $date_style = ''; if ('true' == $date) { if ($date_color) { $date_style .= 'color:' . $date_color . ';'; } if ($date_style) { $date_style = 'style="' . $date_style . '"'; } } // Wrap classes $wrap_classes = 'wpex-row vcex-blog-grid clr'; if ($is_isotope) { $wrap_classes .= ' vcex-isotope-grid'; } if ('left_thumbs' == $single_column_style) { $wrap_classes .= ' left-thumbs'; } // Unique ID if ($unique_id) { $unique_id = ' id="' . $unique_id . '"'; } // Data $data = ''; if ($is_isotope && 'true' == $filter) { if ($masonry_layout_mode) { $data .= ' data-layout-mode="' . $masonry_layout_mode . '"'; } if ($filter_speed) { $data .= ' data-transition-duration="' . $filter_speed . '"'; } } ?> <div class="<?php echo $wrap_classes; ?> "<?php echo $unique_id . $data; ?> > <?php // Define counter var to clear floats $count = $count_all = ''; // Loop through posts foreach ($wpex_query->posts as $post) { setup_postdata($post); // Open match-height-row div for equal heights if ($equal_heights_grid && !$is_isotope) { if (0 == $count) { ?> <div class="match-height-row clr"> <?php } $count_all++; } // Post Vars $post_id = $post->ID; $format = get_post_format($post_id); $post_title = get_the_title(); $post_title_esc = esc_attr(the_title_attribute('echo=0')); $link = get_permalink(); // Counter $count++; // Link format tweaks if ('link' == $format) { $link = wpex_permalink(); $url_target = '_blank'; } // Get video if ('video' == $format) { $video_url = get_post_meta($post_id, 'wpex_post_oembed', true); } // Entry Classes $entry_classes = 'vcex-blog-entry col'; $entry_classes .= ' col-' . $count; $entry_classes .= ' span_1_of_' . $columns; if ($is_isotope) { $entry_classes .= ' vcex-isotope-entry'; } // Create a list of terms to add as classes to the entry if ($post_terms = get_the_terms($post, 'category')) { foreach ($post_terms as $post_term) { $entry_classes .= ' cat-' . $post_term->term_id; } } if ("false" == $entry_media) { $entry_classes .= ' vcex-blog-no-media-entry'; } ?> <article id="#post-<?php the_ID(); ?> " class="<?php echo $entry_classes; ?> "> <?php if ("true" == $entry_media) { ?> <?php $img_filter_class = $img_filter ? 'vcex-' . $img_filter : ''; ?> <?php if ("video" == $format && 'true' == $featured_video && $video_url) { ?> <div class="vcex-blog-entry-media"> <div class="vcex-video-wrap"> <?php echo wp_oembed_get($video_url); ?> </div> </div><!-- .vcex-blog-entry-media --> <?php } elseif (has_post_thumbnail()) { ?> <div class="vcex-blog-entry-media <?php echo $img_filter_class; ?> "> <?php if ($thumb_link == 'post' || $thumb_link == 'lightbox') { ?> <?php // Post links if ($thumb_link == 'post') { ?> <a href="<?php echo $link; ?> " title="<?php echo $post_title_esc; ?> " target="<?php echo $url_target; ?> "> <?php } ?> <?php // Lightbox Links if ($thumb_link == 'lightbox') { ?> <?php // Video Lightbox if ('video' == $format) { ?> <a href="<?php echo $video_url; ?> " title="<?php echo $post_title_esc; ?> " class="wpex-lightbox-video"> <?php } else { ?> <a href="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?> " title="<?php echo $post_title_esc; ?> " class="wpex-lightbox"> <?php } ?> <?php } ?> <?php } // Get cropped image array and display image $cropped_img = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop, 'array'); ?> <img src="<?php echo $cropped_img['url']; ?> " alt="<?php the_title(); ?> " class="vcex-blog-entry-img" height="<?php echo $cropped_img['height']; ?> " width="<?php echo $cropped_img['width']; ?> " /> <?php if ($thumb_link == 'post' || $thumb_link == 'lightbox') { ?> </a> <?php } ?> </div><!-- .blog-entry-media --> <?php } ?> <?php } ?> <?php // Display entry details if the title or excerpt are enabled if ('true' == $title || 'true' == $excerpt) { ?> <div class="vcex-blog-entry-details clr" <?php echo $content_style; ?> > <?php // Equal height div if ($equal_heights_grid && !$is_isotope) { ?> <div class="match-height-content"> <?php } // Post Title if ($title == 'true') { ?> <h2 class="vcex-blog-entry-title" <?php echo $heading_style; ?> > <a href="<?php echo $link; ?> " title="<?php echo $post_title_esc; ?> " target="<?php echo $url_target; ?> " <?php echo $heading_style; ?> > <?php the_title(); ?> </a> </h2> <?php } // Post Date if ($date == 'true') { ?> <div class="vcex-blog-entry-date" <?php echo $date_style; ?> ><?php echo get_the_date(); ?> </div> <?php } // Excerpt if ('true' == $excerpt || 'true' == $read_more) { if ('true' != $excerpt) { $excerpt_length = '0'; } ?> <div class="vcex-blog-entry-excerpt clr"> <?php // Show full content if ('9999' == $excerpt_length) { the_content(); } else { // Custom Excerpt $excerpt_array = array('post_id' => $post_id, 'length' => intval($excerpt_length), 'trim_custom_excerpts' => $custom_excerpt_trim); vcex_excerpt($excerpt_array); } // Read more if ('true' == $read_more) { if ('link' == $format) { $read_more_text = __('Visit Website', 'wpex'); } ?> <a href="<?php echo $link; ?> " title="<?php echo $read_more_text; ?> " rel="bookmark" class="vcex-readmore theme-button" target="<?php echo $url_target; ?> " <?php echo $readmore_style; ?> > <?php echo $read_more_text; ?> <span class="vcex-readmore-rarr"><?php echo wpex_element('rarr'); ?> </span> </a> <?php } ?> </div> <?php } // Close Equal height div if ($equal_heights_grid && !$is_isotope) { ?> </div> <?php } ?> </div><!-- .blog-entry-details --> <?php } ?> </article><!-- .blog-entry --> <?php // Reset counter if ($count == $columns) { // Close equal height row if ($equal_heights_grid && !$is_isotope) { echo '</div><!-- .match-height-row -->'; } $count = '0'; } // End foreach } // Make sure match-height-row is closed if ($equal_heights_grid && !$is_isotope) { if ('4' == $columns && $count_all % 4 != 0) { echo '</div><!-- .match-height-row -->'; } if ('3' == $columns && $count_all % 3 != 0) { echo '</div><!-- .match-height-row -->'; } if ('2' == $columns && $count_all % 2 != 0) { echo '</div><!-- .match-height-row -->'; } } ?> </div><!-- .vcex-blog-grid --> <?php // Paginate Posts if ('true' == $pagination) { wpex_pagination($wpex_query); } // End has posts check } // Reset the WP query wp_reset_postdata(); // Return outbut buffer return ob_get_clean(); }
/** * Tweaks the default WP Gallery Output * * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/post_gallery * @since 1.0.0 */ function output($output, $attr) { // Main Variables global $post, $wp_locale; static $instance = 0; $instance++; $output = ''; // Sanitize orderby statement if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } // Get shortcode attributes extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'columns' => 3, 'include' => '', 'exclude' => '', 'img_height' => '', 'img_width' => '', 'size' => 'medium'), $attr)); // Get post ID $id = intval($id); if ('RAND' == $order) { $orderby = 'none'; } if (!empty($include)) { $include = preg_replace('/[^0-9,]+/', '', $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)) { $exclude = preg_replace('/[^0-9,]+/', '', $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 $attachment_id => $attachment) { $output .= wp_get_attachment_link($attachment_id, $size, true) . "\n"; } return $output; } // Get columns # $columns = intval($columns); // Float $float = is_rtl() ? 'right' : 'left'; $output .= '<div id="gallery-' . $instance . '" class="wpex-gallery wpex-row lightbox-group clr">'; // Begin Loop $count = 0; foreach ($attachments as $attachment_id => $attachment) { // Increase counter for clearing floats $count++; // Attachment Vars $alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); $caption = $attachment->post_excerpt; $full_img = wp_get_attachment_url($attachment_id); // Crop images using built-in function if enabled if (get_theme_mod('wpex_image_resizer', true)) { // Set cropping sizes if (!$img_width) { $img_width = get_theme_mod('gallery_image_width', '300'); } if (!$img_height) { $img_height = get_theme_mod('gallery_image_height', '300'); } // Set hard crop if ('9999' == $img_height) { $img_crop = false; } else { $img_crop = true; } // Set correct cropping sizes if ($columns > 1) { $img_url = wpex_image_resize($full_img, $img_width, $img_height, $img_crop); } else { $img_url = wp_get_attachment_url($attachment_id); } } else { if ('1' == $columns) { $size = 'large'; } elseif ($columns >= '4') { $size = 'thumbnail'; } $img_url = wp_get_attachment_image_src($attachment_id, $size, false); $img_url = $img_url[0]; } // Start Gallery Item $output .= '<figure class="gallery-item ' . wpex_grid_class($columns) . ' col col-' . $count . '">'; // Display image $output .= '<a href="' . $full_img . '" title="' . wp_strip_all_tags($caption) . '" class="lightbox-group-item"> <img src="' . $img_url . '" alt="' . $alt . '" /> </a>'; // Display Caption if (trim($attachment->post_excerpt)) { $output .= '<figcaption class="gallery-caption">' . wptexturize($attachment->post_excerpt) . '</figcaption>'; } // Close gallery item div $output .= "</figure>"; // Set vars to remove margin on last item of each row and clear floats if ($count == $columns) { $count = '0'; } } // Close gallery div $output .= "</div>\n"; return $output; }
function vcex_news_shortcode($atts) { extract(shortcode_atts(array('unique_id' => '', 'post_types' => '', 'term_slug' => 'all', 'include_categories' => '', 'exclude_categories' => '', 'count' => '12', 'grid_columns' => '1', 'order' => 'DESC', 'orderby' => 'date', 'header' => '', 'heading' => 'h3', 'date' => '', 'excerpt_length' => '15', 'read_more' => 'false', 'read_more_text' => __('read more', 'wpex'), 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'css_animation' => '', 'img_width' => '9999', 'img_height' => '9999', 'featured_image' => 'false', 'featured_video' => 'true', 'pagination' => 'false', 'get_posts' => '', 'title' => '', 'title_size' => '', 'url_target' => '_self'), $atts)); // Turn output buffer on ob_start(); // Get global $post global $post; // Custom taxonomy only for standard posts if ('custom_post_types' != $get_posts) { // Post type $post_types = array('post'); // Include categories $include_categories = !empty($include_categories) ? $include_categories : $term_slug; $include_categories = 'all' == $include_categories ? '' : $include_categories; if ($include_categories) { $include_categories = explode(',', $include_categories); } // Exclude categories if ($exclude_categories) { $exclude_categories = explode(',', $exclude_categories); if (!empty($exclude_categories) && is_array($exclude_categories)) { $exclude_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN'); } else { $exclude_categories = ''; } } // Start Tax Query if (!empty($include_categories) && is_array($include_categories)) { $include_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN'); } else { $include_categories = ''; } } else { // Don't exclude categories for custom post type queries $include_categories = $exclude_categories = NULL; // Post Types $post_types = $post_types ? $post_types : 'post'; $post_types = explode(',', $post_types); } // Pagination var if ('true' == $pagination) { global $paged; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $no_found_rows = false; } else { $paged = NULL; $no_found_rows = true; } // The Query $vcex_query = new WP_Query(array('post_type' => $post_types, 'posts_per_page' => $count, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'no_found_rows' => $no_found_rows, 'paged' => $paged, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories, array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-quote'), 'operator' => 'NOT IN')))); $output = ''; //Output posts if ($vcex_query->posts) { $unique_id = $unique_id ? ' id="' . $unique_id . '"' : NULL; // CSS animations $classes = 'vcex-recent-news clr'; if ('1' != $grid_columns) { $classes .= ' wpex-row'; } if ('' != $css_animation) { $classes .= ' wpb_animate_when_almost_visible wpb_' . $css_animation . ''; } ?> <div class="<?php echo $classes; ?> " <?php echo $unique_id; ?> > <?php // Header if ('' != $header) { ?> <h2 class="vcex-recent-news-header theme-heading"> <span><?php echo $header; ?> </span> </h2> <?php } ?> <?php // Loop through posts $count = '0'; foreach ($vcex_query->posts as $post) { setup_postdata($post); $count++; // Post VARS $post_id = $post->ID; $url = get_permalink($post_id); $post_title = get_the_title($post_id); $post_excerpt = $post->post_excerpt; $post_content = $post->post_content; // Get post format $format = get_post_format($post_id); // Get post video if ('true' == $featured_video) { $post_video = get_post_meta($post_id, 'wpex_post_oembed', true); } // Get permalink $link = get_permalink(); // Link format tweaks if ('link' == $format) { $link = wpex_permalink(); $url_target = '_blank'; } // Image $featured_img_url = wp_get_attachment_url(get_post_thumbnail_id($post_id)); $img_width = $img_width ? intval($img_width) : '9999'; $img_height = $img_height ? intval($img_height) : '9999'; $img_crop = $img_height == '9999' ? false : true; $cropped_img = wpex_image_resize($featured_img_url, $img_width, $img_height, $img_crop, 'array'); ?> <?php // Extra rapper for recent news within columns if ($grid_columns > '1') { ?> <div class="col span_1_of_<?php echo $grid_columns; ?> vcex-recent-news-entry-wrap col-<?php echo $count; ?> "> <?php } // Entry classes $entry_classes = 'vcex-recent-news-entry clr'; if ('false' == $date) { $entry_classes .= ' no-left-padding'; } ?> <article class="<?php echo $entry_classes; ?> "> <?php // Date if ('false' != $date) { ?> <div class="vcex-recent-news-date"> <span class="day"> <?php echo get_the_time('d', $post_id); ?> </span> <span class="month"> <?php echo get_the_time('M', $post_id); ?> </span> </div> <?php } ?> <div class="vcex-news-entry-details clr"> <?php // Thumbnail if ('true' == $featured_image) { if ('video' == $format && 'true' == $featured_video && $post_video) { ?> <div class="vcex-news-entry-video vcex-video-wrap clr"> <?php echo wp_oembed_get($post_video); ?> </div> <?php } elseif (has_post_thumbnail($post_id)) { ?> <div class="vcex-news-entry-thumbnail clr"> <a href="<?php echo $link; ?> " title="<?php echo $post_title; ?> " target="<?php echo $url_target; ?> "> <img src="<?php echo $cropped_img['url']; ?> " alt="<?php the_title(); ?> " class="vcex-recent-news-entry-img" height="<?php echo $cropped_img['height']; ?> " width="<?php echo $cropped_img['width']; ?> " /> </a> </div> <?php } ?> <?php } ?> <?php // Display title unless disabled if ('false' != $title) { // Custom title font-size $inline_style = ''; if ($title_size) { $inline_style .= 'font-size:' . intval($title_size) . 'px;'; } if ($inline_style) { $inline_style = 'style="' . $inline_style . '"'; } ?> <header class="vcex-recent-news-entry-title"> <<?php echo $heading; ?> class="vcex-recent-news-entry-title-heading" <?php echo $inline_style; ?> > <a href="<?php echo $link; ?> " title="<?php $post_title; ?> " target="<?php echo $url_target; ?> "> <?php if ('link' == $format) { ?> <span><?php echo _x('Link', 'Link Format Title', 'wpex'); ?> : </span> <?php the_title(); ?> <?php } else { ?> <?php the_title(); ?> <?php } ?> </a> </<?php echo $heading; ?> > </header><!-- .vcex-recent-news-entry-title --> <?php } ?> <div class="vcex-recent-news-entry-excerpt vcex-clearfix"> <?php // Excerpts $read_more = $read_more == 'true' ? true : false; $excerpt_array = array('length' => intval($excerpt_length), 'readmore' => false); vcex_excerpt($excerpt_array); ?> <?php // Read more if ('true' == $read_more) { if ('link' == $format) { $read_more_text = __('Visit Website', 'wpex'); } ?> <a href="<?php echo $link; ?> " title="<?php echo $read_more_text; ?> " rel="bookmark" class="vcex-readmore theme-button" target="<?php echo $url_target; ?> "> <?php echo $read_more_text; ?> <span class="vcex-readmore-rarr">→</span> </a> <?php } ?> </div><!-- .vcex-recent-news-entry-excerpt --> </div><!-- .vcex-recent-news-entry-details --> </article><!-- .vcex-recent-news-entry --> <?php if ($grid_columns > '1') { ?> </div> <?php } // Reset counter if ($count == $grid_columns) { $count = ''; } // End foreach loop } ?> </div><!-- .vcex-recent-news --> <div class="vcex-recent-news-pagination clr"> <?php // Paginate Posts if ('true' == $pagination) { $total = $vcex_query->max_num_pages; $big = 999999999; // need an unlikely integer if ($total > 1) { if (!($current_page = get_query_var('paged'))) { $current_page = 1; } if (get_option('permalink_structure')) { $format = 'page/%#%/'; } else { $format = '&paged=%#%'; } echo paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => $format, 'current' => max(1, get_query_var('paged')), 'total' => $total, 'mid_size' => 2, 'type' => 'list', 'prev_text' => '<i class="fa fa-angle-left"></i>', 'next_text' => '<i class="fa fa-angle-right"></i>')); } } ?> </div> <?php } // End has posts check // Set things back to normal wp_reset_postdata(); // Return data return ob_get_clean(); }