protected function content($atts, $content = null) { $atts = shortcode_atts(array('per_page' => 10, 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'source' => '', 'categories' => '', 'products' => '', 'operator' => 'IN', 'layout' => 'normal', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'carousel_skin' => '', 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => false, 'navigation' => true, 'navigation_always_on' => false, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts); extract($atts); $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'products-carousel ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'woocommerce' => 'woocommerce columns-' . $desktop, 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'layout' => 'layout-' . $layout); $meta_query = WC()->query->get_meta_query(); if ($source == 'best-sellers') { $meta_key = 'total_sales'; $orderby = 'meta_value_num'; } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'meta_query' => $meta_query, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key); if ($source == 'onsale') { $product_ids_on_sale = wc_get_product_ids_on_sale(); $args['post__in'] = array_merge(array(0), $product_ids_on_sale); } elseif ($source == 'featured') { $args['meta_query'][] = array('key' => '_featured', 'value' => 'yes'); } elseif ($source == 'top-rated') { add_filter('posts_clauses', array(__CLASS__, 'order_by_rating_post_clauses')); } elseif ($source == 'categories') { if (!empty($categories)) { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array_map('sanitize_title', explode(',', $categories)), 'field' => 'slug', 'operator' => $operator)); } } elseif ($source == 'products') { if (!empty($atts['products'])) { $args['post__in'] = array_map('trim', explode(',', $atts['products'])); } } $output = $carousel_html = ''; ob_start(); $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts)); if ($products->have_posts()) { global $woocommerce_loop; $woocommerce_loop['columns'] = $desktop; $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'wc-carousel-wrapper'); if ($layout == 'transparent') { $woocommerce_loop['type'] = 'transparent'; } else { $woocommerce_loop['type'] = 'normal'; } woocommerce_product_loop_start(); while ($products->have_posts()) { $products->the_post(); wc_get_template_part('content', 'product'); } // end of the loop. woocommerce_product_loop_end(); } $carousel_html .= ob_get_clean(); wp_reset_postdata(); if ($carousel_html) { $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); $output = '<div class="' . esc_attr($elementClass) . '">' . str_replace('%carousel_html%', $carousel_html, $carousel_ouput) . '</div>'; } return $output; }
protected function content($atts, $content = null) { $atts = shortcode_atts(array('loop_stype' => 'grid', 'source' => 'all', 'categories' => '', 'posts' => '', 'authors' => '', 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'max_items' => 10, "excerpt_length" => 20, 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => true, 'navigation' => true, 'navigation_always_on' => false, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css' => '', 'css_animation' => '', 'el_class' => ''), $atts); extract($atts); $output = ''; $excerpt_length = intval($excerpt_length); $exl_function = create_function('$n', 'return ' . $excerpt_length . ';'); add_filter('excerpt_length', $exl_function, 999); $args = array('order' => $order, 'orderby' => $orderby, 'posts_per_page' => $max_items, 'ignore_sticky_posts' => true); if ($orderby == 'meta_value' || $orderby == 'meta_value_num') { $args['meta_key'] = $meta_key; } if ($source == 'categories') { if ($categories) { $categories_arr = array_filter(explode(',', $categories)); if (count($categories_arr)) { $args['category__in'] = $categories_arr; } } } elseif ($source == 'posts') { if ($posts) { $posts_arr = array_filter(explode(',', $posts)); if (count($posts_arr)) { $args['post__in'] = $posts_arr; } } } elseif ($source == 'authors') { if ($authors) { $authors_arr = array_filter(explode(',', $authors)); if (count($authors_arr)) { $args['author__in'] = $authors_arr; } } } ob_start(); query_posts($args); if (have_posts()) { while (have_posts()) { the_post(); get_template_part('templates/blog/carousel/content', $loop_stype); } echo "</div><!-- .blog-posts -->"; } wp_reset_query(); remove_filter('excerpt_length', $exl_function, 999); $post_carousel_html = ob_get_clean(); $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'blog-posts-carousel-wrapper ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' ')); $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); $output = ''; $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts)); $output .= str_replace('%carousel_html%', $post_carousel_html, $carousel_ouput); return '<div class="' . esc_attr($elementClass) . '"><div class="blog-posts blog-posts-carousel">' . $output . '</div></div>'; }
protected function content($atts, $content = null) { $atts = shortcode_atts(array('per_page' => '', 'orderby' => 'name', 'order' => 'ASC', 'ids' => '', 'categories_style' => 'normal', 'hide_empty' => 'true', 'parent' => '', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'carousel_skin' => '', 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => false, 'navigation' => true, 'navigation_always_on' => true, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts); if ($atts['categories_style'] == 'modern') { $atts['gutters'] = true; } $atts['columns'] = $atts['desktop']; $atts['number'] = $atts['per_page']; $atts['hide_empty'] = apply_filters('sanitize_boolean', $atts['hide_empty']); extract($atts); $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'products-categories-carousel ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'woocommerce' => 'woocommerce columns-' . $desktop, 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'style' => 'style-' . $categories_style); $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'cruxstore-owl-carousel'); $output = $carousel_html = ''; if (isset($atts['ids'])) { $ids = explode(',', $atts['ids']); $ids = array_map('trim', $ids); } else { $ids = array(); } $hide_empty = $atts['hide_empty'] == true || $atts['hide_empty'] == 1 ? 1 : 0; // get terms and workaround WP bug with parents/pad counts $args = array('orderby' => $atts['orderby'], 'order' => $atts['order'], 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $atts['parent']); $product_categories = get_terms('product_cat', $args); if ('' !== $atts['parent']) { $product_categories = wp_list_filter($product_categories, array('parent' => $atts['parent'])); } if ($hide_empty) { foreach ($product_categories as $key => $category) { if ($category->count == 0) { unset($product_categories[$key]); } } } if ($atts['number']) { $product_categories = array_slice($product_categories, 0, $atts['number']); } ob_start(); if ($product_categories) { global $woocommerce_carousel; $woocommerce_carousel = $categories_style; foreach ($product_categories as $category) { wc_get_template('content-product_cat_carousel.php', array('category' => $category)); } } wp_reset_postdata(); $carousel_html .= ob_get_clean(); if ($carousel_html) { $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); $output = '<div class="' . esc_attr($elementClass) . '">' . str_replace('%carousel_html%', $carousel_html, $carousel_ouput) . '</div>'; } return $output; }
public function widget($args, $instance) { if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; if (!$number) { $number = 5; } $args_article = array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'order' => $instance['order'], 'orderby' => $instance['orderby']); if (is_array($instance['category'])) { $args_article['category__in'] = $instance['category']; } $r = new WP_Query(apply_filters('widget_posts_args', $args_article)); if ($r->have_posts()) { echo $args['before_widget']; if ($title) { echo $args['before_title'] . $title . $args['after_title']; } ob_start(); $carousel_html = ''; ?> <?php while ($r->have_posts()) { $r->the_post(); ?> <div <?php post_class(); ?> > <?php cruxstore_post_thumbnail_image('cruxstore_square', 'img-responsive', false); ?> <div class="post-carousel-content"> <?php cruxstore_post_meta_categories(); ?> <h4><?php get_the_title() ? the_title() : the_ID(); ?> </h4> </div> <a href="<?php the_permalink(); ?> " class="post-carousel-link"></a> </div> <?php } ?> <?php wp_reset_postdata(); $carousel_html .= ob_get_clean(); if ($carousel_html) { $atts = array('desktop' => 1, 'tablet' => 1, 'mobile' => 1, 'navigation_always_on' => false, 'navigation_position' => 'center', 'carousel_skin' => 'white', 'gutters' => false); $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'cruxstore-owl-carousel'); echo str_replace('%carousel_html%', $carousel_html, $carousel_ouput); } echo $args['after_widget']; } }
protected function content($atts, $content = null) { $atts = shortcode_atts(array('title' => esc_html__('Title', 'js_composer'), 'source' => 'widgets', 'categories' => '', 'per_page' => 8, 'orderby' => 'date', 'order' => 'DESC', 'style' => 1, 'active_section' => 1, 'font_size' => '', 'line_height' => '', 'letter_spacing' => '', 'font_container' => '', 'use_theme_fonts' => 'yes', 'google_fonts' => '', 'css_animation' => '', 'el_class' => '', 'css' => '', 'operator' => 'IN'), $atts); $columns = 3; $product_type = 'classic'; // This is needed to extract $font_container_data and $google_fonts_data extract($this->getAttributes($atts)); unset($font_container_data['values']['text_align']); $atts = vc_map_get_attributes($this->getShortcode(), $atts); extract($atts); extract($this->getStyles($el_class, $css, $google_fonts_data, $font_container_data, $atts)); $settings = get_option('wpb_js_google_fonts_subsets'); if (is_array($settings) && !empty($settings)) { $subsets = '&subset=' . implode(',', $settings); } else { $subsets = ''; } if (isset($google_fonts_data['values']['font_family'])) { wp_enqueue_style('vc_google_fonts_' . vc_build_safe_css_class($google_fonts_data['values']['font_family']), '//fonts.googleapis.com/css?family=' . $google_fonts_data['values']['font_family'] . $subsets); } if ($letter_spacing) { if (empty($styles)) { $styles = array(); } $styles[] = 'letter-spacing: ' . $letter_spacing . 'px'; } if (!empty($styles)) { $style = 'style="' . esc_attr(implode(';', $styles)) . '"'; } else { $style = ''; } $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'wc-products-vertical', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'product_stype' => 'cruxstore-products cruxstore-products-classic', 'woocommerce' => 'woocommerce columns-' . $columns); if (!$active_section) { $active_section = 1; } $uniqeID = uniqid(); $meta_query = WC()->query->get_meta_query(); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $atts['per_page'], 'meta_query' => $meta_query); if ($source == 'categories') { $tabs = explode(',', $categories); $args['order'] = $order; $args['orderby'] = $orderby; } else { $tabs = array('onsale', 'new', 'bestselling'); } $tab_heading = '<ul class="nav-style" data-count="' . count($tabs) . '">'; $i = 1; foreach ($tabs as $tab) { if ($source == 'categories') { $term = get_term_by('slug', sanitize_title($tab), 'product_cat'); $text = $term->name; } else { if ($tab == 'new') { $text = esc_html__('Arrivals Products', 'cruxstore'); } elseif ($tab == 'bestselling') { $text = esc_html__('Best Sellers', 'cruxstore'); } elseif ($tab == 'onsale') { $text = esc_html__('On sale', 'cruxstore'); } } $class = $active_section == $i ? ' class="active"' : ''; $tab_heading .= sprintf('<li %s><a href="%s" data-toggle="tab"><span data-hover="%s">%s</span></a></li>', $class, '#tab-' . $tab . '-' . $uniqeID, esc_attr($text), $text); $i++; } $tab_heading .= "</ul>"; global $woocommerce_loop; $i = 1; $output_content = ''; $carousel_atts = array('desktop' => $columns, 'navigation' => false, 'gutters' => false); $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $carousel_atts), '', 'wc-carousel-wrapper'); foreach ($tabs as $tab) { $new_args = $args; if ($source == 'categories') { $new_args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => sanitize_title($tab), 'field' => 'slug', 'operator' => $atts['operator'])); } else { if ($tab == 'bestselling') { $new_args['meta_key'] = 'total_sales'; $new_args['orderby'] = 'meta_value_num'; } elseif ($tab == 'featured') { $new_args['meta_query'][] = array('key' => '_featured', 'value' => 'yes'); } elseif ($tab == 'onsale') { $new_args['post__in'] = array_merge(array(0), wc_get_product_ids_on_sale()); } } $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $new_args, $atts)); $woocommerce_loop['columns'] = $columns; $woocommerce_loop['type'] = $product_type; ob_start(); if ($products->have_posts()) { woocommerce_product_loop_start(); while ($products->have_posts()) { $products->the_post(); wc_get_template_part('content', 'product'); } // end of the loop. woocommerce_product_loop_end(); } wp_reset_postdata(); $carousel_html = ob_get_clean(); $carousel_html = str_replace('%carousel_html%', $carousel_html, $carousel_ouput); $class = $active_section == $i ? 'fade in active' : 'fade'; $output_content .= sprintf('<div id="%s" class="tab-pane %s">%s</div><!-- .tab-pane -->', 'tab-' . $tab . '-' . $uniqeID, $class, $carousel_html); $i++; } $custom_css = ''; $rand = 'wc-products-vertical-' . rand(); if ($font_size) { $custom_css .= cruxstore_responsive_render('#' . $rand . ' .wc-products-vertical-title', 'font-size', $font_size); } if ($line_height) { $custom_css .= cruxstore_responsive_render('#' . $rand . ' .wc-products-vertical-title', 'line-height', $line_height); } $title = sprintf('<%1$s class="wc-products-vertical-title" %2$s>%3$s</%1$s>', $font_container_data['values']['tag'], $style, $title); $heading = sprintf('<div class="wc-products-vertical-heading">%s</div>', $tab_heading); $navigation = '<div class="wc-products-vertical-navigation"><span class="wc-products-vertical-left"><i class="fa fa-angle-left" aria-hidden="true"></i></span><span class="wc-products-vertical-right"><i class="fa fa-angle-right" aria-hidden="true"></i></span></div>'; $content = $content ? sprintf('<div class="wc-products-vertical-content">%s</div>', $content) : ''; $output = sprintf('<div class="row"><div class="col-md-3">%s</div><div class="col-md-9"><div class="tab-content">%s</div></div></div>', $title . $content . $heading . $navigation, $output_content); if ($custom_css) { $custom_css = '<div class="cruxstore_custom_css" data-css="' . esc_attr($custom_css) . '"></div>'; } $output .= $custom_css; $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); $output = '<div id="' . $rand . '" class="' . esc_attr($elementClass) . '">' . $output . '</div>'; return $output; }
protected function content($atts, $content = null) { $atts = shortcode_atts(array('per_page' => '', 'orderby' => 'name', 'order' => 'ASC', 'ids' => '', 'hide_empty' => 'true', 'parent' => '', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'carousel_skin' => '', 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => true, 'navigation' => true, 'navigation_always_on' => true, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'animation_delay' => '', 'el_class' => '', 'css' => ''), $atts); $atts['columns'] = $atts['desktop']; $atts['number'] = $atts['per_page']; $atts['hide_empty'] = apply_filters('sanitize_boolean', $atts['hide_empty']); extract($atts); $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'products-brands-carousel ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'woocommerce' => 'woocommerce columns-' . $desktop, 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' ')); $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'cruxstore-owl-carousel'); $output = $carousel_html = ''; if (isset($atts['ids'])) { $ids = explode(',', $atts['ids']); $ids = array_map('trim', $ids); } else { $ids = array(); } $hide_empty = $atts['hide_empty'] == true || $atts['hide_empty'] == 1 ? 1 : 0; // get terms and workaround WP bug with parents/pad counts $args = array('orderby' => $atts['orderby'], 'order' => $atts['order'], 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $atts['parent']); $product_brands = get_terms('yith_product_brand', $args); if ('' !== $atts['parent']) { $product_brands = wp_list_filter($product_brands, array('parent' => $atts['parent'])); } if ($hide_empty) { foreach ($product_brands as $key => $brand) { if ($brand->count == 0) { unset($product_brands[$key]); } } } if ($atts['number']) { $product_brands = array_slice($product_brands, 0, $atts['number']); } ob_start(); if ($product_brands) { global $woocommerce_carousel; $woocommerce_carousel = 'normal'; $css_animation = cruxstore_getCSSAnimation($css_animation); foreach ($product_brands as $key => $term) { if ($animation_delay) { $animation_delay_item = sprintf(' data-wow-delay="%sms"', $key * $animation_delay); } else { $animation_delay_item = ''; } echo '<div class="brand-banner' . $css_animation . '"' . $animation_delay_item . '><div class="brand-banner-content">'; $thumbnail_id = absint(yith_wcbr_get_term_meta($term->term_id, 'thumbnail_id', true)); $image_size = apply_filters('cruxstore_brand_logo', 'cruxstore_grid'); if ($thumbnail_id) { $image = wp_get_attachment_image_src($thumbnail_id, $image_size); printf('<div class="brand-image"><img src="%s" width="%d" height="%d" alt="%s"/></div>', $image[0], $image[1], $image[2], $term->name); } else { do_action('yith_wcbr_no_brand_logo', $term->term_id, $term, 'yith_wcbr_logo_size', false, false); echo '<div class="brand-image">' . wc_placeholder_img() . '</div>'; } printf('<h4 class="brand-count"><span>%s</span> %s</a></h4>', $term->count, esc_html__('Products', 'cruxstore')); printf('<a href="%s">%s</a>', get_term_link($term), $term->name); echo '</div></div>'; } } wp_reset_postdata(); $carousel_html .= ob_get_clean(); if ($carousel_html) { $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); $output = '<div class="' . esc_attr($elementClass) . '"><div class="products-brands-inner">' . str_replace('%carousel_html%', $carousel_html, $carousel_ouput) . '</div></div>'; } return $output; }
protected function content($atts, $content = null) { $atts = shortcode_atts(array('img_size' => 'thumbnail', 'source' => 'all', 'categories' => '', 'posts' => '', 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'target_link' => '_self', 'image_overlay' => '', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => true, 'navigation' => true, 'navigation_always_on' => false, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'animation_delay' => '', 'el_class' => '', 'css' => ''), $atts); extract($atts); if ($image_overlay == 'white-boxed') { $atts['gutters'] = false; } $args = array('post_type' => 'crux_client', 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => -1, 'ignore_sticky_posts' => true); if ($orderby == 'meta_value' || $orderby == 'meta_value_num') { $args['meta_key'] = $meta_key; } if ($source == 'categories') { if ($categories) { $categories_arr = array_filter(explode(',', $categories)); if (count($categories_arr)) { $args['tax_query'] = array(array('taxonomy' => 'client-category', 'field' => 'slug', 'terms' => $categories)); } } } elseif ($source == 'posts') { if ($posts) { $posts_arr = array_filter(explode(',', $posts)); if (count($posts_arr)) { $args['post__in'] = $posts_arr; } } } $client_carousel_html = $post_thumbnail = ''; $query = new WP_Query($args); if ($query->have_posts()) { $css_animation = cruxstore_getCSSAnimation($css_animation); $i = 1; while ($query->have_posts()) { $query->the_post(); $link = cruxstore_meta('_cruxstore_link_client'); if ($animation_delay) { $animation_delay_item = sprintf(' data-wow-delay="%sms"', $i * $animation_delay); } else { $animation_delay_item = ''; } if ($link) { $post_thumbnail = '<a target="' . $target_link . '" href="' . $link . '">' . get_the_post_thumbnail(get_the_ID(), $img_size) . '</a>'; } else { $post_thumbnail = get_the_post_thumbnail(get_the_ID(), $img_size, ''); } $client_carousel_html .= sprintf('<div class="%s" %s>%s</div>', 'clients-carousel-item' . $css_animation, $animation_delay_item, $post_thumbnail); $i++; } wp_reset_postdata(); } $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'clients-carousel ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' ')); if ($image_overlay) { $elementClass['overlay'] = 'overlay-' . $image_overlay; } $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); $output = ''; $output .= '<div class="' . esc_attr($elementClass) . '">'; $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts)); $output .= str_replace('%carousel_html%', $client_carousel_html, $carousel_ouput); $output .= '</div>'; return $output; }
function cruxstore_related_article($post_id = null, $type = 'categories') { global $post; if (!$post_id) { $post_id = $post->ID; } $posts_per_page = cruxstore_option('blog_related_sidebar', 5); $excerpt_length = 15; $args = array('posts_per_page' => $posts_per_page, 'post__not_in' => array($post_id)); if ($type == 'tags') { $tags = wp_get_post_tags($post_id); if (!$tags) { return false; } $tag_ids = array(); foreach ($tags as $tag) { $tag_ids[] = $tag->term_id; } $args['tag__in'] = $tag_ids; } elseif ($type == 'author') { $args['author'] = get_the_author(); } else { $categories = get_the_category($post_id); if (!$categories) { return false; } $category_ids = array(); foreach ($categories as $category) { $category_ids[] = $category->term_id; } $args['category__in'] = $category_ids; } $args = apply_filters('cruxstore_related_article_args', $args); $exl_function = create_function('$n', 'return ' . $excerpt_length . ';'); add_filter('excerpt_length', $exl_function, 999); $query = new WP_Query($args); if ($query->have_posts()) { ?> <div id="related-article"> <h3 class="post-single-heading"><?php esc_html_e('Related Article', 'cruxstore'); ?> </h3> <div class="blog-posts blog-posts-carousel no-readmore"> <?php ob_start(); $carousel_html = ''; while ($query->have_posts()) { $query->the_post(); echo '<div class="blog-post-wrap col-lg-6 col-md-6 col-sm-6">'; get_template_part('templates/blog/grid/content-relate', get_post_format()); echo '</div>'; } $carousel_html .= ob_get_clean(); if ($carousel_html) { $atts = array('desktop' => 2, 'navigation_position' => 'heading', 'navigation_always_on' => true); $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'cruxstore-owl-carousel'); echo str_replace('%carousel_html%', $carousel_html, $carousel_ouput); } ?> </div> </div><!-- #related-article --> <?php } remove_filter('excerpt_length', $exl_function, 999); wp_reset_postdata(); }
protected function content($atts, $content = null) { $atts = shortcode_atts(array('layout' => '1', 'testimonial_skin' => '', 'font_container' => '', 'use_theme_fonts' => 'yes', 'google_fonts' => '', 'font_container_company' => '', 'use_theme_fonts_company' => 'yes', 'google_fonts_company' => '', 'source' => 'all', 'categories' => '', 'posts' => '', 'max_items' => 10, 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'desktop' => 1, 'desktopsmall' => 1, 'tablet' => 1, 'mobile' => 1, 'gutters' => true, 'navigation' => true, 'navigation_always_on' => false, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts); $atts['carousel_skin'] = $atts['testimonial_skin']; extract($atts); $args = array('order' => $order, 'orderby' => $orderby, 'posts_per_page' => $max_items, 'ignore_sticky_posts' => true, 'post_type' => 'crux_testimonial'); if ($orderby == 'meta_value' || $orderby == 'meta_value_num') { $args['meta_key'] = $meta_key; } if ($source == 'categories') { if ($categories) { $categories_arr = array_filter(explode(',', $categories)); if (count($categories_arr)) { $args['tax_query'] = array(array('taxonomy' => 'testimonial-category', 'field' => 'id', 'terms' => $categories_arr)); } } } elseif ($source == 'posts') { if ($posts) { $posts_arr = array_filter(explode(',', $posts)); if (count($posts_arr)) { $args['post__in'] = $posts_arr; } } } $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'testimonial-carousel', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'layout' => 'testimonial-layout-' . $layout); $query = new WP_Query($args); $output = ''; if ($query->have_posts()) { $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts)); $carousel_html = ''; while ($query->have_posts()) { $query->the_post(); $testimonial_content = '<div class="testimonial-content">' . do_shortcode(get_the_content()) . '</div>'; $link = cruxstore_meta('_crux_testimonial_link'); $title = get_the_title(); if ($link) { $title = '<a target="_blank" href="' . $link . '">' . $title . '</a>'; } $testimonial_rate = ''; if ($rate = cruxstore_meta('_cruxstore_testimonial_rate')) { $testimonial_rate = '<div class="testimonial-rate rate-' . $rate . '"><span class="star-active"></span></div>'; } $image_size = 'cruxstore_small'; if ($layout == 4) { $image_size = 'cruxstore_grid'; } $testimonial_image = has_post_thumbnail() ? '<div class="testimonial-image">' . get_the_post_thumbnail(null, $image_size) . '</div>' : ''; $company = cruxstore_meta('_cruxstore_testimonial_company'); $testimonial_company = $company ? sprintf('<div class="testimonial-info">%s</div>', $company) : ''; if ($layout == 1 && $testimonial_company) { $title .= ', '; } $testimonial_title = sprintf('<h4 class="testimonial-author">%s</h4>', $title); $testimonial_author = '<div class="testimonial-author-content">' . $testimonial_title . $testimonial_company . '</div>'; if ($layout == '4') { $carousel_html .= sprintf('<div class="testimonial-item">%s %s %s<div class="testimonial-author-infos"> %s</div></div>', $testimonial_image, $testimonial_author, $testimonial_rate, $testimonial_content); } else { $carousel_html .= sprintf('<div class="testimonial-item">%s %s <div class="testimonial-author-infos"> %s</div></div>', $testimonial_image, $testimonial_content, $testimonial_author); } } wp_reset_postdata(); $output .= str_replace('%carousel_html%', $carousel_html, $carousel_ouput); } $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); return '<div class="' . esc_attr($elementClass) . '">' . $output . '</div>'; }