function ux_products($atts, $content = null, $tag) { global $woocommerce; $sliderrandomid = rand(); extract(shortcode_atts(array('title' => '', 'products' => '8', 'columns' => '4', 'orderby' => '', 'type' => 'slider', 'cat' => '', 'show' => '', 'tags' => '', 'ids' => '', 'infinitive' => 'true', 'auto_slide' => 'false', 'bullets' => 'false', 'arrows' => 'true'), $atts)); if ($tag == 'ux_bestseller_products') { if (!$orderby) { $atts['orderby'] = 'sales'; } } else { if ($tag == 'ux_featured_products') { $atts['show'] = 'featured'; } else { if ($tag == 'ux_sale_products') { $atts['show'] = 'onsale'; } else { if ($tag == 'ux_custom_products') { } else { if ($tag == 'product_lookbook') { $type = 'lookbook'; } else { if ($tag == 'products_pinterest_style') { $type = 'masonry'; if ($products == '8') { $atts['products'] = '999'; $columns = '3'; } } } } } } } if ($type == 'lookbook') { $infinitive = 'true'; } ob_start(); ?> <?php if ($title) { ?> <div class="row"> <div class="large-12 columns"> <h3 class="section-title"><span><?php echo $title; ?> </span></h3> </div> </div><!-- end .title --> <?php } ?> <?php if ($type !== 'lookbook') { ?> <div class="row"><?php } ?> <?php if ($type == 'normal') { ?> <div class="large-12 columns"> <ul class="large-block-grid-<?php echo $columns; ?> small-block-grid-2"> <?php } else { if ($type == 'lookbook') { ?> <div class="lookbook-slider"> <ul class="ux-slider js-flickity slider-nav-small slider-nav-circle large-block-grid-<?php echo $columns; ?> small-block-grid-2" data-flickity-options='{ "cellAlign": "left", "wrapAround": <?php echo $infinitive; ?> , "percentPosition": true, "imagesLoaded": true, "selectedAttraction" : 0.05, "friction": 0.6, "pageDots": <?php echo $bullets; ?> , "contain": true }'> <?php } else { if ($type == 'masonry') { ?> <div class="large-12 columns"> <ul class="pinterest-style large-block-grid-<?php echo $columns; ?> small-block-grid-2"> <?php } else { if ($type == 'slider') { ?> <div class="large-12 columns"> <ul class="ux-row-slider js-flickity slider-nav-small slider-nav-reveal slider-nav-push large-block-grid-<?php echo $columns; ?> small-block-grid-2" data-flickity-options='{ "cellAlign": "left", "wrapAround": <?php echo $infinitive; ?> , "percentPosition": true, "imagesLoaded": true, "pageDots": <?php echo $bullets; ?> , "selectedAttraction" : 0.05, "friction": 0.6, "contain": true }'> <?php } } } } $r = ux_list_products($atts); if ($r->have_posts()) { ?> <?php while ($r->have_posts()) { $r->the_post(); ?> <?php if ($type == 'lookbook') { woocommerce_get_template_part('content', 'product-lookbook'); } else { if ($type == 'masonry') { woocommerce_get_template_part('content', 'product-pinterest-style'); } else { woocommerce_get_template_part('content', 'product'); } } ?> <?php } // end of the loop. ?> <?php } wp_reset_query(); ?> </ul> <!-- .products --> </div> <?php if ($type !== 'lookbook') { ?> </div><!-- .row --><?php } ?> <?php if ($type == 'masonry') { ?> <script> /* PACKERY GRID */ jQuery(document).ready(function ($) { var $container = $(".pinterest-style"); // initialize $container.packery({ itemSelector: "li", gutter: 0 }); imagesLoaded( document.querySelector('.pinterest-style'), function( instance, container ) { $container.packery('layout'); }); }); </script> <?php } ?> <?php $content = ob_get_contents(); ob_end_clean(); return $content; }
function ux_products($atts, $content = null, $tag) { global $woocommerce; $sliderrandomid = rand(); extract(shortcode_atts(array('title' => '', 'products' => '8', 'columns' => '4', 'orderby' => '', 'type' => 'slider', 'cat' => '', 'show' => '', 'tags' => '', 'ids' => '', 'infinitive' => 'false', 'auto_slide' => 'false', 'arrows' => 'true'), $atts)); if ($tag == 'ux_bestseller_products') { if (!$orderby) { $atts['orderby'] = 'sales'; } } else { if ($tag == 'ux_featured_products') { $atts['show'] = 'featured'; } else { if ($tag == 'ux_sale_products') { $atts['show'] = 'onsale'; } else { if ($tag == 'ux_custom_products') { } else { if ($tag == 'product_lookbook') { $type = 'lookbook'; } else { if ($tag == 'products_pinterest_style') { $type = 'masonry'; if ($products == '8') { $atts['products'] = '999'; $columns = '3'; } } } } } } } if ($type == 'lookbook') { $infinitive = 'true'; } ob_start(); ?> <?php /** * Check if WooCommerce is active **/ if (function_exists('wc_print_notices')) { ?> <?php if ($title) { ?> <div class="row"> <div class="large-12 columns"> <h3 class="section-title"><span><?php echo $title; ?> </span></h3> </div> </div><!-- end .title --> <?php } ?> <?php if ($type !== 'lookbook') { ?> <div class="row"><?php } ?> <?php if ($type == 'normal') { ?> <div class="large-12 columns"> <ul class="large-block-grid-<?php echo $columns; ?> small-block-grid-2"><?php } ?> <?php if ($type == 'lookbook') { ?> <div id="slider_<?php echo $sliderrandomid; ?> " class="iosSlider lookbook-slider" style="overflow:hidden;height:350px;min-height:350px;"> <ul class="slider large-block-grid-<?php echo $columns; ?> small-block-grid-2"> <?php } ?> <?php if ($type == 'masonry') { ?> <div class="large-12 columns"> <ul class="pinterest-style large-block-grid-<?php echo $columns; ?> small-block-grid-2"> <?php } ?> <?php if ($type == 'slider') { ?> <div id="slider_<?php echo $sliderrandomid; ?> " class="iosSlider column-slider" style="overflow:hidden;height:250px;min-height:250px;"> <ul class="slider large-block-grid-<?php echo $columns; ?> small-block-grid-2"> <?php } ?> <?php $r = ux_list_products($atts); if ($r->have_posts()) { ?> <?php while ($r->have_posts()) { $r->the_post(); ?> <?php if ($type == 'lookbook') { woocommerce_get_template_part('content', 'product-lookbook'); } else { if ($type == 'masonry') { woocommerce_get_template_part('content', 'product-pinterest-style'); } else { woocommerce_get_template_part('content', 'product'); } } ?> <?php } // end of the loop. ?> <?php } wp_reset_query(); ?> </ul> <!-- .products --> <?php if ($type == 'slider' || $type == 'lookbook' || $arrows == 'true') { ?> <div class="sliderControlls <?php if ($type == 'lookbook') { ?> dark<?php } ?> "> <div class="sliderNav <?php if ($type !== 'lookbook') { ?> small<?php } ?> hide-for-small"> <a href="javascript:void(0)" class="nextSlide disabled prev_<?php echo $sliderrandomid; ?> "><span class="icon-angle-left"></span></a> <a href="javascript:void(0)" class="prevSlide next_<?php echo $sliderrandomid; ?> "><span class="icon-angle-right"></span></a> </div> </div><!-- .sliderControlls --> <?php // Run slider script slider_script($sliderrandomid, $columns, $infinitive); } ?> </div> <?php if ($type !== 'lookbook') { ?> </div><!-- .row --><?php } ?> <?php if ($type == 'masonry') { ?> <script> /* PACKERY GRID */ jQuery(document).ready(function ($) { var $container = $(".pinterest-style"); // initialize $container.packery({ itemSelector: "li", gutter: 0 }); imagesLoaded( document.querySelector('.pinterest-style'), function( instance, container ) { $container.packery('layout'); }); }); </script> <?php } ?> <?php } // if woocommerce is active ?> <?php $content = ob_get_contents(); ob_end_clean(); return $content; }