Example #1
0
 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('title' => esc_html__('Title', 'js_composer'), 'word' => 'false', 'line_color' => '#333333', 'border_width' => '1', 'line_width' => '', 'line_style' => '', 'size' => 'md', 'color' => 'grey', 'custom_color' => '', 'icon' => '', 'image' => '', 'spacer_position' => 'middle', 'spacer' => '', 'align' => 'center', 'font_size' => '', 'line_height' => '', 'letter_spacing' => '', 'font_container' => '', 'use_theme_fonts' => 'yes', 'google_fonts' => '', 'font_option' => '', 'css_animation' => '', 'animation_delay' => '', 'el_class' => '', 'css' => ''), $atts);
     // 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 (!empty($styles)) {
         $styles = array();
     }
     $font_option = explode(',', $font_option);
     if (in_array('uppercase', $font_option)) {
         $styles[] = 'text-transform: uppercase;';
     }
     if (in_array('underline', $font_option)) {
         $styles[] = 'text-decoration: underline;';
     }
     if (in_array('italic', $font_option)) {
         $styles[] = 'font-style: italic;';
     }
     if ($letter_spacing) {
         $styles[] = 'letter-spacing: ' . $letter_spacing . 'px';
     }
     if (count($styles)) {
         $style = 'style="' . esc_attr(implode(';', $styles)) . '"';
     } else {
         $style = '';
     }
     $output = '';
     $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'cruxstore-heading ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => cruxstore_getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'align' => 'text-' . $align);
     $custom_css = '';
     $rand = 'cruxstore_heading_' . rand();
     if ($font_size) {
         $custom_css .= cruxstore_responsive_render('#' . $rand . ' .cruxstore-heading-title', 'font-size', $font_size);
     }
     if ($line_height) {
         $custom_css .= cruxstore_responsive_render('#' . $rand . ' .cruxstore-heading-title', 'line-height', $line_height);
     }
     if ($word == 'true') {
         $title_arr = preg_split("/\\s+/", $title);
         $title_arr[0] = "<span>" . $title_arr[0] . "</span>";
         $title = join(" ", $title_arr);
     }
     $title = sprintf('<%1$s class="cruxstore-heading-title" %2$s>%3$s</%1$s>', $font_container_data['values']['tag'], $style, $title);
     $content = sprintf('<div class="cruxstore-heading-content">%s</div>', $content);
     $divider = '';
     if ($spacer) {
         $elementClass['spacer'] = 'cruxstore-heading-' . $spacer_position;
         $divider_content = '';
         $divider_class = array('cruxstore-heading-spacer', 'cruxstore-heading-' . $spacer);
         $styles_divider = array();
         if (!$line_style) {
             $line_style = 'solid';
         }
         if (!$border_width) {
             $border_width = 1;
         }
         if ($spacer == 'line') {
             $styles_divider[] = 'border-color: ' . $line_color;
             $styles_divider[] = 'border-top-width: ' . intval($border_width) . 'px';
             $styles_divider[] = 'border-top-style: ' . $line_style;
             if ($line_width) {
                 $styles_diver[] = 'width: ' . intval($line_width) . 'px';
             }
         } elseif ($spacer == 'icon') {
             if ($icon) {
                 $icon_style = '';
                 $icon_class = array('iconbox-ct', 'size-' . $size);
                 if ($color != '' && $color != 'custom') {
                     $icon_class[] = 'color-' . $color;
                     $custom_color = cruxstore_color2Hex($color);
                 }
                 if ($custom_color) {
                     $icon_style .= 'color: ' . $custom_color . ';';
                 }
                 if ($icon_style) {
                     $icon_style = sprintf('style="%s"', $icon_style);
                 }
                 $divider_content = sprintf('<span class="%s %s" %s></span>', $icon, implode(' ', $icon_class), $icon_style);
             }
         } elseif ($spacer == 'image') {
             $img_id = preg_replace('/[^\\d]/', '', $image);
             $img_url = wp_get_attachment_image_src($img_id, 'full');
             if (array($img_url)) {
                 $icon = sprintf('<img src="%s" class="img-responsive" alt="" />', $img_url['0']);
             }
             $divider_content = sprintf('<span class="%s">%s</span>', 'icon-image', $icon);
         }
         $styles_divider = 'style="' . esc_attr(implode(';', $styles_divider)) . '"';
         $divider = '<div class="' . implode(' ', $divider_class) . '" ' . $styles_divider . '>' . $divider_content . '</div>';
     }
     if ($custom_css) {
         $custom_css = '<div class="cruxstore_custom_css" data-css="' . esc_attr($custom_css) . '"></div>';
     }
     if ($spacer_position == 'bottom') {
         $output .= $title . $content . $divider;
     } elseif ($spacer_position == 'top') {
         $output .= $divider . $title . $content;
     } else {
         $output .= $title . $divider . $content;
     }
     $output .= $custom_css;
     if ($animation_delay) {
         $animation_delay = sprintf(' data-wow-delay="%sms"', $animation_delay);
     }
     $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
     return '<div id="' . $rand . '"  class="' . esc_attr($elementClass) . '"' . $animation_delay . '>' . $output . '</div>';
 }
 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;
 }
Example #3
0
 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('title' => '', 'image' => '', 'link' => '', 'link_text' => '', 'link_color' => 'default', 'img_size' => 'full', 'align' => 'center', 'skin' => '', 'overlay' => '', 'position' => 'middle', 'style' => 1, 'font_container' => '', 'use_theme_fonts' => 'yes', 'google_fonts' => '', 'font_size' => '', 'line_height' => '', 'letter_spacing' => '', 'font_option' => '', 'css_animation' => '', 'animation_delay' => '', 'el_class' => '', 'css' => ''), $atts);
     // 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 (!empty($styles)) {
         $styles = array();
     }
     $font_option = explode(',', $font_option);
     if (in_array('uppercase', $font_option)) {
         $styles[] = 'text-transform: uppercase;';
     }
     if (in_array('underline', $font_option)) {
         $styles[] = 'text-decoration: underline;';
     }
     if (in_array('italic', $font_option)) {
         $styles[] = 'font-style: italic;';
     }
     if ($letter_spacing) {
         $styles[] = 'letter-spacing: ' . $letter_spacing . 'px';
     }
     if (count($styles)) {
         $style_banner = 'style="' . esc_attr(implode(';', $styles)) . '"';
     } else {
         $style_banner = '';
     }
     $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'banner ', $this->settings['base'], $atts), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'css_animation' => cruxstore_getCSSAnimation($css_animation), 'extra' => $this->getExtraClass($el_class), 'align' => 'banner-' . $align, 'position' => 'position-' . $position, 'style' => 'style-' . $style);
     if ($overlay) {
         $elementClass['overlay'] = 'banner-' . $overlay;
     }
     if ($skin) {
         $elementClass['skin'] = 'skin-' . $skin;
     }
     $rand = 'banner_id_' . rand();
     $custom_css = $banner_link = '';
     $img_id = preg_replace('/[^\\d]/', '', $image);
     $img = wpb_getImageBySize(array('attach_id' => $img_id, 'thumb_size' => $img_size, 'class' => 'img-responsive'));
     if ($img == null) {
         $img['thumbnail'] = '<img class="vc_img-placeholder img-responsive" src="' . vc_asset_url('vc/no_image.png') . '" />';
     }
     if ($title) {
         $title = sprintf('<%1$s class="banner-title" %2$s><span>%3$s</span></%1$s>', $font_container_data['values']['tag'], $style_banner, $title);
         if ($font_size) {
             $custom_css .= cruxstore_responsive_render('#' . $rand . ' .banner-title', 'font-size', $font_size);
         }
         if ($line_height) {
             $custom_css .= cruxstore_responsive_render('#' . $rand . ' .banner-title', 'line-height', $line_height);
         }
     }
     if ($content) {
         $content = sprintf('<div class="banner-inner">%s</div>', $content);
     }
     $icon = $style == 1 ? 'fa fa-caret-right' : 'fa fa-long-arrow-right';
     $more = $link_text ? sprintf('<div class="banner-more banner-more-%s"><span>%s <i class="%s" aria-hidden="true"></i></span></div>', $link_color, $link_text, $icon) : '';
     $output = $img['thumbnail'];
     $output .= sprintf('<div class="banner-content">%s</div>', $title . $content . $more);
     if ($link) {
         $link = vc_build_link($link);
         $a_href = $link['url'];
         $a_title = $link['title'];
         $a_target = $link['target'];
         $icon_box_link = array('href="' . esc_attr($a_href) . '"', 'title="' . esc_attr($a_title) . '"', 'target="' . esc_attr($a_target) . '"');
         $banner_link = '<a class="banner-link" ' . implode(' ', $icon_box_link) . '></a>';
     }
     $output .= $banner_link;
     if ($animation_delay) {
         $animation_delay = sprintf(' data-wow-delay="%sms"', $animation_delay);
     }
     if ($custom_css) {
         $custom_css = '<div class="cruxstore_custom_css" data-css="' . esc_attr($custom_css) . '"></div>';
     }
     $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
     $elementClass = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $elementClass, $this->settings['base'], $atts);
     return '<div id="' . $rand . '" class="' . esc_attr($elementClass) . '"' . $animation_delay . '>' . $output . $custom_css . '</div>';
 }