/**
  * Blog Carousel	
  * returns html ouput of posts for carousel
  * 
  * @param  array   $atts   
  * @return output 
  */
 function rt_blog_carousel($atts = array())
 {
     global $rt_post_values, $rt_blog_list_atts;
     //sanitize fields
     $atts["id"] = isset($atts["id"]) ? sanitize_html_class($atts["id"]) : 'blog-carousel-dynamicID-' . rand(100000, 1000000);
     //defaults
     $rt_blog_list_atts = shortcode_atts(array("id" => 'blog-carousel-dynamicID-' . rand(100000, 1000000), "list_layout" => "1/3", "nav" => "true", "dots" => "false", "featured_image_resize" => "true", "featured_image_max_width" => 0, "featured_image_max_height" => 0, "featured_image_crop" => "false", "list_orderby" => "date", "list_order" => "DESC", "max_item" => 10, "categories" => "", "ids" => "", "show_author" => "true", "show_categories" => "true", "show_comment_numbers" => "true", "show_date" => "true", "use_excerpts" => "true", "excerpt_length" => 100, "autoplay" => "false", "timeout" => 5000), $atts);
     extract($rt_blog_list_atts);
     //counter
     $counter = 1;
     //create a post status array
     $post_status = is_user_logged_in() ? array('private', 'publish') : "publish";
     //general query
     $args = array('post_status' => $post_status, 'post_type' => 'post', 'orderby' => $list_orderby, 'order' => $list_order, 'showposts' => $max_item);
     if (!empty($ids)) {
         $ids = !empty($ids) ? explode(",", trim($ids)) : array();
         $args = array_merge($args, array('post__in' => $ids));
     }
     if (!empty($categories)) {
         $categories = is_array($categories) ? $categories : explode(",", rt_wpml_lang_object_ids($categories, "category"));
         $args = array_merge($args, array('tax_query' => array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $categories, 'operator' => "IN"))));
     }
     $wp_query = new WP_Query($args);
     wp_reset_postdata();
     //column count
     $item_width = rt_column_count($list_layout);
     //column class
     $add_column_class = "item post";
     if ($wp_query->have_posts()) {
         $output = array();
         //the loop
         while ($wp_query->have_posts()) {
             $wp_query->the_post();
             //get post values
             $rt_post_values = rt_get_loop_post_values($wp_query->post, $rt_blog_list_atts, "carousel");
             ob_start();
             echo '<div class="' . $add_column_class . '">' . "\n";
             get_template_part('/post-contents/carousel', 'content');
             echo '</div>' . "\n";
             $output[] .= ob_get_contents();
             ob_end_clean();
             $counter++;
         }
         //reset post data for the new query
         wp_reset_postdata();
         //carousel atts
         $atts = array("id" => sanitize_html_class($id), "item_width" => $item_width, "class" => "blog-carousel", "nav" => $nav, "dots" => $dots, "autoplay" => $autoplay, "timeout" => $timeout);
         //create carousel
         return rt_create_carousel($output, $atts);
     }
 }
 /**
  * Product Carousel	
  * returns html ouput of woo products for carousel
  * 
  * @param  array   $atts   
  * @return output 
  */
 function rt_woo_products_carousel($atts = array())
 {
     //defaults
     $rt_product_list_atts = shortcode_atts(array("id" => 'carousel-dynamicID-' . rand(100000, 1000000), "list_layout" => "1/3", "nav" => "true", "dots" => "false", "list_orderby" => "date", "list_order" => "DESC", "max_item" => 10, "categories" => "", "ids" => "", "autoplay" => "false", "timeout" => 5000), $atts);
     extract($rt_product_list_atts);
     //sanitize fields
     $id = sanitize_html_class($id);
     //counter
     $counter = 1;
     //create a post status array
     $post_status = is_user_logged_in() ? array('private', 'publish') : "publish";
     //general query
     $args = array('post_status' => $post_status, 'post_type' => 'product', 'orderby' => $list_orderby, 'order' => $list_order, 'showposts' => $max_item, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')));
     if (!empty($ids)) {
         $ids = !empty($ids) ? explode(",", trim($ids)) : array();
         $args = array_merge($args, array('post__in' => $ids));
     }
     if (!empty($categories)) {
         $categories = is_array($categories) ? $categories : explode(",", rt_wpml_lang_object_ids($categories, "product_cat"));
         $args = array_merge($args, array('tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $categories, 'operator' => "IN"))));
     }
     $wp_query = new WP_Query($args);
     //column count
     $item_width = rt_column_count($list_layout);
     //column class
     $add_column_class = "product_item_holder item product";
     if ($wp_query->have_posts()) {
         $output = array();
         //the loop
         while ($wp_query->have_posts()) {
             $wp_query->the_post();
             ob_start();
             echo '<div class="' . $add_column_class . '">' . "\n";
             get_template_part('woocommerce/content-product', 'carousel');
             echo '</div>' . "\n";
             $output[] .= ob_get_contents();
             ob_end_clean();
             $counter++;
         }
         //reset post data for the new query
         wp_reset_postdata();
         //carousel atts
         $atts = array("id" => sanitize_html_class($id), "item_width" => $item_width, "class" => "wc-product-carousel woocommerce", "nav" => $nav, "dots" => $dots, "margin" => 14, "autoplay" => $autoplay, "timeout" => $timeout);
         //create carousel
         return rt_create_carousel($output, $atts);
     }
 }
 /**
  * Create a carousel from the provided images
  *
  * @since 1.0
  * 
  * @param  array $rt_gallery_images  
  * @param  string $id  
  * @return output html
  */
 function rt_create_image_carousel($atts = array())
 {
     //defaults
     extract(shortcode_atts(array("id" => 'carousel-' . rand(100000, 1000000), "crop" => false, "h" => 10000, "w" => 10000, "rt_gallery_images" => array(), "column_width" => "1/1", "carousel_atts" => array(), "echo" => true, "lightbox" => "true"), $atts));
     //slider id
     $slider_id = "slider-" . $id;
     //crop
     $crop = $crop === "false" ? false : $crop;
     //image dimensions for product image slider
     $w = empty($w) ? rt_get_min_resize_size($column_width) : $w;
     //height
     if (empty($h)) {
         $h = $crop ? $w / 1.5 : 10000;
     }
     //create slides and thumbnails outputs
     $output = array();
     foreach ($rt_gallery_images as $image) {
         // Resize Image
         $image_output = is_numeric($image) ? rt_get_image_data(array("image_id" => trim($image), "w" => $w, "h" => $h, "crop" => $crop)) : rt_get_image_data(array("image_url" => trim($image), "w" => $w, "h" => $h, "crop" => $crop));
         if ($lightbox != "false") {
             //create lightbox link
             $output[] = rt_create_lightbox_link(array('class' => 'imgeffect zoom lightbox_', 'href' => $image_output["image_url"], 'title' => __('Enlarge Image', 'rt_theme'), 'data_group' => $slider_id, 'data_title' => $image_output["image_title"], 'data_description' => $image_output["image_caption"], 'data_thumbnail' => $image_output["lightbox_thumbnail"], 'echo' => false, 'inner_content' => sprintf('<img src="%s" alt="%s" itemprop="image">', $image_output["thumbnail_url"], $image_output["image_alternative_text"])));
         } else {
             $output[] = sprintf('<img src="%s" alt="%s" itemprop="image">', $image_output["thumbnail_url"], $image_output["image_alternative_text"]);
         }
     }
     //create slider
     if ($echo) {
         echo rt_create_carousel($output, $carousel_atts);
     } else {
         return rt_create_carousel($output, $carousel_atts);
     }
 }
 /**
  * Product Carousel	
  * returns html ouput of products custom post type for carousel
  * 
  * @param  array   $atts   
  * @return output 
  */
 function rt_products_carousel($atts = array())
 {
     global $rt_product_post_values, $rt_product_list_atts;
     //sanitize fields
     $atts["id"] = isset($atts["id"]) ? sanitize_html_class($atts["id"]) : 'product-dynamicID-' . rand(100000, 1000000);
     //defaults
     $rt_product_list_atts = shortcode_atts(array("id" => 'product-dynamicID-' . rand(100000, 1000000), "list_layout" => "1/3", "nav" => "true", "dots" => "false", "featured_image_resize" => "true", "featured_image_max_width" => 0, "featured_image_max_height" => 0, "featured_image_crop" => "false", "list_orderby" => "date", "list_order" => "DESC", "max_item" => 10, "categories" => "", "ids" => "", "display_descriptions" => "true", "display_titles" => "true", "display_price" => "true", "autoplay" => "false", "timeout" => 5000), $atts);
     extract($rt_product_list_atts);
     //counter
     $counter = 1;
     //create a post status array
     $post_status = is_user_logged_in() ? array('private', 'publish') : "publish";
     //general query
     $args = array('post_status' => $post_status, 'post_type' => 'products', 'orderby' => $list_orderby, 'order' => $list_order, 'showposts' => $max_item);
     if (!empty($ids)) {
         $ids = !empty($ids) ? explode(",", trim($ids)) : array();
         $args = array_merge($args, array('post__in' => $ids));
     }
     if (!empty($categories)) {
         $categories = is_array($categories) ? $categories : explode(",", rt_wpml_lang_object_ids($categories, "product_categories", $wpml_lang));
         $args = array_merge($args, array('tax_query' => array(array('taxonomy' => 'product_categories', 'field' => 'id', 'terms' => $categories, 'operator' => "IN"))));
     }
     $wp_query = new WP_Query($args);
     //column count
     $item_width = rt_column_count($list_layout);
     //column class
     $add_column_class = "product_item_holder item product";
     if ($wp_query->have_posts()) {
         $output = array();
         //the loop
         while ($wp_query->have_posts()) {
             $wp_query->the_post();
             //get post values
             $rt_product_post_values = rt_get_product_loop_post_values($wp_query->post, $rt_product_list_atts);
             //selected term list of each post
             $term_list = get_the_terms($wp_query->post->ID, 'product_categories');
             //add terms as class name
             $addTermsClass = "";
             if ($term_list) {
                 if (is_array($term_list)) {
                     foreach ($term_list as $termSlug) {
                         $addTermsClass .= " " . $termSlug->slug;
                     }
                 }
             }
             ob_start();
             echo '<div class="' . $add_column_class . ' ' . $addTermsClass . '">' . "\n";
             get_template_part('product-contents/loop', 'content');
             echo '</div>' . "\n";
             $output[] .= ob_get_contents();
             ob_end_clean();
             $counter++;
         }
         //reset post data for the new query
         wp_reset_postdata();
         //carousel atts
         $atts = array("id" => sanitize_html_class($id), "item_width" => $item_width, "class" => "product-carousel", "nav" => $nav, "dots" => $dots, "autoplay" => $autoplay, "timeout" => $timeout);
         //create carousel
         return rt_create_carousel($output, $atts);
     }
 }