function vcex_staff_carousel_shortcode($atts) { // Define shortcode params extract(shortcode_atts(array('unique_id' => '', 'term_slug' => 'all', 'style' => 'default', 'count' => '8', 'item_width' => '230', 'min_slides' => '1', 'max_slides' => '4', 'items_scroll' => 'page', 'animation' => 'CSS', 'auto_play' => 'false', 'timeout_duration' => '5000', 'arrows' => 'true', 'order' => 'DESC', 'orderby' => 'date', 'thumbnail_link' => 'post', 'img_crop' => 'false', 'img_width' => '9999', 'img_height' => '9999', 'title' => 'true', 'excerpt' => 'true', 'excerpt_length' => '30', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'social' => '', 'img_hover_style' => ''), $atts)); $output = ''; // Required Scripts wp_enqueue_script('vcex-caroufredsel'); // Give caroufredsel a unique name $rand_num = rand(1, 100); $unique_carousel_id = 'caroufredsel-' . $rand_num; // Output filter JS into the footer like a WP Jedi Master $output .= ' <script type="text/javascript"> jQuery(function($){ $(document).ready(function(){ $("#' . $unique_carousel_id . '").carouFredSel({ responsive : true, height: "variable", width : "100%", auto : { play: ' . $auto_play . ', timeoutDuration : ' . $timeout_duration . ', }, swipe : { onTouch: true, onMouse: true },'; if ($items_scroll !== 'page') { $output .= 'scroll : { items : ' . $items_scroll . ', },'; } if ($arrows == 'true') { $output .= 'prev : "#prev-' . $rand_num . '",'; $output .= 'next : "#next-' . $rand_num . '",'; } $output .= 'items : { width : ' . intval($item_width) . ', height: "variable", visible : { min : ' . intval($min_slides) . ', max : ' . intval($max_slides) . ' } } }); }); $(window).load(function(){ $(".vcex-caroufredsel-loading").removeClass("vcex-caroufredsel-loading"); $(".vcex-caroufredsel").animate({ opacity: 1 }); }); }); </script>'; // Start Tax Query if ($term_slug !== 'all') { $tax_query = array(array('taxonomy' => 'staff_category', 'field' => 'slug', 'terms' => $term_slug)); } else { $tax_query = NULL; } // The Query $vcex_carousel_query = new WP_Query(array('post_type' => 'staff', 'posts_per_page' => $count, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'no_found_rows' => true, 'tax_query' => $tax_query, 'meta_query' => array(array('key' => '_thumbnail_id')))); //Output posts if ($vcex_carousel_query->posts) { $unique_id = $unique_id ? ' id="' . $unique_id . '"' : NULL; // Main wrapper div $output .= '<div class="vcex-caroufredsel-wrap clr vcex-caroufredsel-staff vcex-caroufredsel-' . $style . ' vcex-caroufredsel-loading"' . $unique_id . '>'; $output .= '<div class="vcex-caroufredsel"><ul id="' . $unique_carousel_id . '">'; // Loop through posts foreach ($vcex_carousel_query->posts as $post) { // Post VARS $postid = $post->ID; $featured_img_url = wp_get_attachment_url(get_post_thumbnail_id($postid)); $featured_img = wp_get_attachment_url(get_post_thumbnail_id($postid)); $url = get_permalink($postid); $post_title = get_the_title($postid); $the_content = $post->post_content; // Load scripts if ($thumbnail_link == 'lightbox') { wp_enqueue_script('vcex-magnific-popup'); wp_enqueue_script('vcex-lightbox'); } // Crop featured images if necessary if ($img_crop == 'true') { $thumbnail_hard_crop = $img_height == '9999' ? false : true; $img_width = intval($img_width); $img_height = intval($img_height); $featured_img = aq_resize($featured_img_url, $img_width, $img_height, $thumbnail_hard_crop); } // Carousel item start $output .= '<li class="vcex-caroufredsel-slide">'; // Image hover styles $img_hover_style_class = $img_hover_style ? 'vcex-img-hover-parent vcex-img-hover-' . $img_hover_style : ''; // Media Wrap if (has_post_thumbnail($postid)) { $output .= '<div class="vcex-caroufredsel-entry-media ' . $img_hover_style_class . '">'; if ($thumbnail_link == 'none') { $output .= '<img src="' . $featured_img . '" alt="' . $post_title . '" />'; } elseif ($thumbnail_link == 'lightbox') { $output .= '<a href="' . $featured_img_url . '" title="' . $post_title . '" class="vcex-caroufredsel-entry-img vcex-lightbox">'; $output .= '<img src="' . $featured_img . '" alt="' . $post_title . '" />'; if (function_exists('wpex_get_staff_overlay')) { $output .= wpex_get_staff_overlay(); } $output .= '</a><!-- .vcex-caroufredsel-entry-img -->'; } else { $output .= '<a href="' . $url . '" title="' . $post_title . '" class="vcex-caroufredsel-entry-img">'; $output .= '<img src="' . $featured_img . '" alt="' . $post_title . '" />'; if (function_exists('wpex_get_staff_overlay')) { $output .= wpex_get_staff_overlay(); } $output .= '</a><!-- .vcex-caroufredsel-entry-img -->'; } $output .= '</div>'; } if ($title == 'true' || $excerpt == 'true') { $output .= '<div class="vcex-caroufredsel-entry-details">'; if ($title == 'true' && $post_title) { $centered_title = $excerpt ? '' : 'textcenter'; $output .= '<div class="vcex-caroufredsel-entry-title ' . $centered_title . '"><a href="' . $url . '" title="' . $post_title . '">' . $post_title . '</a></div>'; } if ($excerpt == 'true' && !empty($the_content)) { if (has_excerpt($postid)) { $the_excerpt = $post->post_excerpt; $output .= '<div class="vcex-caroufredsel-entry-excerpt">' . $the_excerpt . '</div>'; } else { $output .= '<div class="vcex-caroufredsel-entry-excerpt">' . wp_trim_words($the_content_stripped, $excerpt_length) . '</div>'; } // Display social links if (function_exists('wpex_get_staff_social') && $social !== 'false') { $output .= wpex_get_staff_social($postid); } } $output .= '</div>'; } // Close main wrap $output .= '</li>'; // End foreach loop } // End UL $output .= '</ul>'; // Next/Prev arrows if ($arrows == 'true') { $output .= '<div id="prev-' . $rand_num . '" class="vcex-caroufredsel-prev theme-button"><span class="fa fa-chevron-left"></span></div><div id="next-' . $rand_num . '" class="vcex-caroufredsel-next theme-button"><span class="fa fa-chevron-right"></span></div>'; } // Close main wrap $output .= '</div></div><div class="vcex-clear-floats"></div>'; } // End has posts check // Set things back to normal $vcex_carousel_query = NULL; wp_reset_postdata(); // Return data return $output; }
function vcex_staff_grid_shortcode($atts) { // Define shortcode params extract(shortcode_atts(array('unique_id' => '', 'term_slug' => 'all', 'posts_per_page' => '12', 'grid_style' => 'fit_columns', 'columns' => '', 'order' => 'DESC', 'orderby' => 'date', 'filter' => 'true', 'thumbnail_link' => 'post', 'img_crop' => 'true', 'img_width' => '9999', 'img_height' => '9999', 'thumb_link' => 'post', 'img_filter' => '', 'title' => 'true', 'excerpt' => 'true', 'excerpt_length' => '15', 'read_more' => 'false', 'read_more_text' => __('read more', 'vcex'), 'pagination' => 'false', 'filter_content' => 'false', 'social_links' => 'true', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'img_hover_style' => '', 'img_overlay_disable' => ''), $atts)); // Get global $post var global $post; // Start Tax Query $tax_query = ''; if ($term_slug !== '' && $term_slug !== 'all') { $tax_query = array(array('taxonomy' => 'staff_category', 'field' => 'slug', 'terms' => $term_slug)); } // Pagination var if ($pagination == 'true') { global $paged; $paged = get_query_var('paged') ? get_query_var('paged') : 1; } else { $paged = NULL; } // The Query $vcex_query = new WP_Query(array('post_type' => 'staff', 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'tax_query' => $tax_query, 'filter_content' => $filter_content, 'paged' => $paged)); //Output posts if ($vcex_query->posts) { $rand_num = rand(1, 100); $unique_port_id = 'staff-' . $rand_num; $unique_id = $unique_id ? ' id="' . $unique_id . '"' : 'id="' . $unique_port_id . '"'; $img_crop = $img_crop == 'true' ? true : false; $read_more = $read_more == 'true' ? true : false; // Set correct grid class $col_class = 'span_8'; if ($columns == '1') { $col_class = 'span_1_of_1'; } if ($columns == '2') { $col_class = 'span_1_of_2'; } if ($columns == '3') { $col_class = 'span_1_of_3'; } if ($columns == '4') { $col_class = 'span_1_of_4'; } if ($columns == '5') { $col_class = 'span_1_of_5'; } if ($columns == '6') { $col_class = 'span_1_of_6'; } if ($columns == '7') { $col_class = 'span_1_of_7'; } if ($columns == '8') { $col_class = 'span_1_of_8'; } if ($columns == '9') { $col_class = 'span_1_of_9'; } if ($columns == '10') { $col_class = 'span_1_of_10'; } if ($columns == '11') { $col_class = 'span_1_of_11'; } if ($columns == '12') { $col_class = 'span_1_of_12'; } // Looad lightbox scripts if ($thumb_link == 'lightbox') { wp_enqueue_script('vcex-magnific-popup'); wp_enqueue_script('vcex-lightbox'); } // Load Masonry scripts if ($filter == 'true' || $grid_style == 'masonry') { wp_enqueue_script('vcex-isotope'); // Load Isotope Script } ob_start(); ?> <?php // Display filter links if ($filter == 'true') { ?> <?php $filter_parent = $term_slug !== '' && $term_slug !== 'all' ? $term_slug : NULL; ?> <?php $terms = get_terms('staff_category', array('child_of' => $filter_parent)); ?> <?php if ($terms) { ?> <ul class="vcex-staff-filter filter-<?php echo $unique_port_id; ?> vcex-filter-links clr"> <li class="active"><a href="#" data-filter="*"><span><?php _e('All', 'vcex'); ?> </span></a></li> <?php foreach ($terms as $term) { ?> <li><a href="#" data-filter=".<?php echo $term->slug; ?> "><?php echo $term->name; ?> </a></li> <?php } ?> </ul><!-- .vcex-staff-filter --> <?php } ?> <?php } ?> <?php if ($filter == 'true' || $grid_style == 'masonry') { ?> <script type="text/javascript"> jQuery(function($){ $(window).load(function() { function wpexStaffIsotope() { var $container = $('#<?php echo $unique_port_id; ?> '); $container.isotope({ itemSelector: '.staff-entry', animationEngine: 'css', layoutMode: 'masonry' }); } wpexStaffIsotope(); var $filterLinks = $('.filter-<?php echo $unique_port_id; ?> a'); $filterLinks.each( function() { var $filterableDiv = $(this).data('filter'); if ( $filterableDiv == '*' ) { // ignore this one } else { if ( $($filterableDiv).width() ) { // keep these } else { // remove these $(this).parent().hide(); } } }); $filterLinks.css({ opacity: 1 } ); $filterLinks.click(function(){ var selector = $(this).attr('data-filter'); $('#<?php echo $unique_port_id; ?> ').isotope({ filter: selector }); $(this).parents('ul').find('li').removeClass('active'); $(this).parent('li').addClass('active'); return false; }); var isIE8 = $.browser.msie && +$.browser.version === 8; if (isIE8) { document.body.onresize = function () { wpexStaffIsotope(); }; } else { $(window).resize(function () { wpexStaffIsotope(); }); } window.addEventListener("orientationchange", function() { wpexStaffIsotope(); }); }); }); </script> <?php } ?> <div class="vcex-staff-grid vcex-clearfix <?php if ($filter == 'true' || $grid_style == 'masonry') { echo 'vcex-masonry-grid'; } ?> " <?php echo $unique_id; ?> > <?php $count = ''; foreach ($vcex_query->posts as $post) { setup_postdata($post); $count++; $post_id = get_the_ID(); ?> <?php $post_terms = get_the_terms($post, 'staff_category'); ?> <article id="#post-<?php the_ID(); ?> " class="staff-entry col <?php foreach ($post_terms as $post_term) { echo $post_term->slug . ' '; } ?> <?php echo $col_class; ?> <?php echo 'col-' . $count . ''; ?> "> <?php if (has_post_thumbnail()) { ?> <?php // Image Filter class $img_filter_class = $img_filter ? 'vcex-' . $img_filter : ''; ?> <?php // Image hover styles $img_hover_style_class = $img_hover_style ? 'vcex-img-hover-parent vcex-img-hover-' . $img_hover_style : ''; ?> <div class="staff-entry-media <?php echo $img_filter_class; ?> <?php echo $img_hover_style_class; ?> "> <?php if ($thumb_link == 'post' || $thumb_link == 'lightbox') { ?> <?php if ($thumb_link == 'post') { ?> <a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> "> <?php } ?> <?php if ($thumb_link == 'lightbox') { ?> <a href="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " class="vcex-lightbox"> <?php } ?> <?php } ?> <img src="<?php echo aq_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop); ?> " alt="<?php the_title(); ?> " class="staff-entry-img" /> <?php if ($thumb_link == 'post' || $thumb_link == 'lightbox') { ?> <?php if ($img_filter !== 'grayscale') { if ($img_overlay_disable !== 'yes') { // Display Staff Position if (get_post_meta(get_the_ID(), 'wpex_staff_position', true) !== '' && function_exists('wpex_get_staff_overlay')) { echo wpex_get_staff_overlay(); } } } ?> </a> <?php } ?> <?php // Display Staff Position if ($img_filter !== 'grayscale' && $thumb_link == 'nowhere' && function_exists('wpex_get_staff_overlay')) { echo wpex_get_staff_overlay(); } ?> </div><!-- .staff-dia --> <?php } ?> <?php if ($title == 'true' || $excerpt == 'true') { ?> <div class="staff-entry-details clr"> <?php if ($title == 'true') { ?> <h2 class="staff-entry-title"><a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> "><?php the_title(); ?> </a></h2> <?php } ?> <?php if ($excerpt == 'true') { ?> <div class="clr"></div> <div class="staff-entry-excerpt clr"> <?php if ($excerpt_length == "9999") { ?> <?php the_content(); ?> <?php } else { ?> <?php vcex_excerpt($excerpt_length, $read_more, $read_more_text); ?> <?php } ?> </div> <?php } ?> <?php // Display social links if (function_exists('wpex_get_staff_social') && $social_links == 'true') { echo wpex_get_staff_social($post_id); } ?> </div><!-- .staff-entry-details --> <?php } ?> </article><!-- .staff-entry --> <?php // Reset counter if ($count == $columns) { $count = ''; } ?> <?php } ?> </div><!-- .vcex-staff-grid --> <?php // Paginate Posts if ($pagination == 'true') { $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>')); } } } // End has posts check // Set things back to normal wp_reset_postdata(); return ob_get_clean(); }