* Shortcode attributes * @var $atts * @var $el_class * @var $width * @var $css * @var $offset * @var $content - shortcode content * Shortcode class * @var $this WPBakeryShortCode_VC_Column */ $el_class = $width = $css = $offset = ''; $output = ''; $atts = vc_map_get_attributes($this->getShortcode(), $atts); extract($atts); $width = wpb_translateColumnWidthToSpan($width); $width = vc_column_offset_class_merge($offset, $width); $css_classes = array($this->getExtraClass($el_class), 'wpb_column', 'vc_column_container', $width); if (vc_shortcode_custom_css_has_property($css, array('border', 'background'))) { $css_classes[] = 'vc_col-has-fill'; } $wrapper_attributes = array(); /*start*/ $css_classes[] = !empty($st_animate) ? ' wow animated ' . $st_animate : ''; /*end*/ $css_class = preg_replace('/\\s+/', ' ', apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, implode(' ', array_filter($css_classes)), $this->settings['base'], $atts)); $wrapper_attributes[] = 'class="' . esc_attr(trim($css_class)) . '"'; $output .= '<div ' . implode(' ', $wrapper_attributes) . '>'; $output .= '<div class="vc_column-inner ' . esc_attr(trim(vc_shortcode_custom_css_class($css))) . '">'; $output .= '<div class="wpb_wrapper">'; $output .= wpb_js_remove_wpautop($content); $output .= '</div>';
public function products($atts, $contents) { self::$int++; $int = self::$int; if (!class_exists('WooCommerce')) { return false; } $atts = shortcode_atts(array('title' => '', 'product_layout' => '', 'product_banner' => '', 'product_banner_align' => 'center', 'product_group' => 'products_categories', 'product_cat_ids' => '', 'product_ids' => '', 'product_skus' => '', 'product_orderby' => 'date', 'product_order' => 'DESC', 'after_content' => '', 'before_content' => '', 'max_items' => '10', 'img_size' => 'shop_catalog_image_size', 'el_class' => '', 'css' => '', 'width' => '1/3', 'offset' => ''), $atts); // Add Class $width = $css = ''; $width = wpb_translateColumnWidthToSpan($atts['width']); $width = vc_column_offset_class_merge($atts['offset'], $width); $__width = array(); $__width = explode(' ', $width); $parent_class = array(); $item_class = array(); if (is_array($__width)) { foreach ($__width as $__class) { if (strpos($__class, 'hidden') > 0) { $parent_class[] = $__class; } else { $item_class[] = $__class; } } //$width = implode($item_class, ' '); } $parent_class[] = vc_shortcode_custom_css_class($atts['css']); $parent_class[] = $atts['product_styles']; $parent_class[] = 'woocommerce'; if (!empty($atts['el_class'])) { $parent_class[] = $atts['el_class']; } $layout = ''; if ($atts['product_layout'] == 'tab') { $parent_class[] = 'mTheme-products-tab'; } else { $layout = $atts['product_layout']; } $columns = m_wedding_translateColumnWidthVC($atts['width']); //$css_classes = array( //'wpb_column', //'vc_column_container', //$width //); // Query $args = array('post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => $atts['max_items']); if ($atts['product_group'] == 'recent_products') { $args = array_merge($args, array('ignore_sticky_posts' => 1, 'orderby' => $atts['product_orderby'], 'order' => $atts['product_order'], 'meta_query' => WC()->query->get_meta_query())); } elseif ($atts['product_group'] == 'featured_products') { $meta_query = WC()->query->get_meta_query(); $meta_query[] = array('key' => '_featured', 'value' => 'yes'); $args = array_merge($args, array('ignore_sticky_posts' => 1, 'orderby' => $atts['product_orderby'], 'order' => $atts['product_order'], 'meta_query' => $meta_query)); } elseif ($atts['product_group'] == 'sale_products') { $args = array_merge($args, array('no_found_rows' => 1, 'orderby' => $atts['product_orderby'], 'order' => $atts['product_order'], 'meta_query' => WC()->query->get_meta_query(), 'post__in' => array_merge(array(0), wc_get_product_ids_on_sale()))); } elseif ($atts['product_group'] == 'best_selling_products') { $args = array_merge($args, array('ignore_sticky_posts' => 1, 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'meta_query' => WC()->query->get_meta_query())); } elseif ($atts['product_group'] == 'top_rated_products') { $args = array_merge($args, array('ignore_sticky_posts' => 1, 'orderby' => $atts['product_orderby'], 'order' => $atts['product_order'], 'meta_query' => WC()->query->get_meta_query())); add_filter('posts_clauses', array('WC_Shortcodes', 'order_by_rating_post_clauses')); } elseif ($atts['product_group'] == 'products_categories') { if (isset($atts['product_cat_ids'])) { $term_ids = explode(',', $atts['product_cat_ids']); $term_ids = array_map('trim', $term_ids); } else { $term_ids = array(); } $args = array_merge($args, array('ignore_sticky_posts' => 1, 'orderby' => $atts['product_orderby'], 'order' => $atts['product_order'], 'meta_query' => WC()->query->get_meta_query(), 'tax_query' => array(array('taxonomy' => 'product_cat', 'terms' => $term_ids, 'field' => 'term_id')))); } else { $post__in = ''; if (!empty($atts['product_ids'])) { $post__in = array_map('trim', explode(',', $atts['product_ids'])); } $args = array_merge($args, array('ignore_sticky_posts' => 1, 'meta_query' => WC()->query->get_meta_query(), 'post__in' => $post__in)); if (!empty($atts['product_skus'])) { $args['meta_query'][] = array('key' => '_sku', 'value' => array_map('trim', explode(',', $atts['product_skus'])), 'compare' => 'IN'); } } $query = new WP_Query($args); ob_start(); echo '<div id="mtheme-products-' . $int . '" class="mtheme-products ' . join($parent_class, ' ') . '">'; if (!empty($atts['title']) || !empty($atts['before_content'])) { echo '<div class="mtheme-title">'; if (!empty($atts['title'])) { echo wpb_widget_title(array('title' => $atts['title'], 'extraclass' => 'wpb_singleimage_heading')); } if (!empty($atts['before_content'])) { echo '<div class="before-content">' . $atts['before_content'] . '</div>'; } echo '</div>'; } echo '<div class="mtheme-products-inner">'; $template = self::mTheme_get_template_part('content-products', $layout); if (file_exists("{$template}")) { if ($query->have_posts()) { require "{$template}"; } else { echo __('Not empty', 'mTheme'); } } echo '</div>'; if (!empty($contents)) { echo '<div class="after-content">' . $contents . '</div>'; } echo "</div>"; if ($atts['product_group'] == 'top_rated_products') { remove_filter('posts_clauses', array('WC_Shortcodes', 'order_by_rating_post_clauses')); } wp_reset_postdata(); return ob_get_clean(); }
function vc_theme_vc_column($atts, $content = null) { $output = $el_class = $width = ''; extract(shortcode_atts(array('font_color' => '', 'el_class' => '', 'width' => '1/1', 'css' => '', 'offset' => ''), $atts)); switch ($width) { case "1/12": $w = "span1"; break; case "1/6": $w = "span2"; break; case "1/4": $w = "span3"; break; case "1/3": $w = "span4"; break; case "5/12": $w = "span5"; break; case "1/2": $w = "span6"; break; case "7/12": $w = "span7"; break; case "2/3": $w = "span8"; break; case "3/4": $w = "span9"; break; case "5/6": $w = "span10"; break; case "11/12": $w = "span11"; break; case "1/1": $w = "span12"; break; default: $w = $width; } $w = vc_column_offset_class_merge($offset, $w); $el_class .= ' ' . $w . ' ' . vc_shortcode_custom_css_class($css, ' '); $style = buildStyle($font_color); $output .= "\n\t" . '<div class="wpb_column ' . $el_class . '" ' . $style . '>'; $output .= "\n\t\t" . '<div class="wpb_wrapper">'; $output .= "\n\t\t\t" . wpb_js_remove_wpautop($content); $output .= "\n\t\t" . '</div>'; $output .= "\n\t" . '</div>'; return $output; }
public static function agni_gallery($atts = null, $content = null) { $atts = shortcode_atts(array('img_url' => '', 'img_size' => '', 'lightbox' => '', 'width' => '1/1', 'offset' => '', 'class' => ''), $atts, 'gallery'); $width = wpb_translateColumnWidthToSpan($atts['width']); $width = vc_column_offset_class_merge($atts['offset'], $width); $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $width . ' custom-gallery-item ' . $atts['class'], 'agni_gallery', $atts); if ($atts['lightbox'] == 'custom-gallery') { $atts['lightbox'] = 'class="' . $atts['lightbox'] . '"'; } $slides = explode(",", $atts['img_url']); $src1 = null; foreach ((array) $slides as $key => $slide) { $src1 .= '<div class="' . $css_class . '"><a href="' . wp_get_attachment_url($slide) . '">' . wp_get_attachment_image($slide, $atts['img_size']) . '</a></div>'; } $output = '<div ' . $atts['lightbox'] . '><div class="row">' . $src1 . '</div></div>'; return $output; }
<?php // If this file is called directly, abort. if (!defined('WPINC')) { die; } $width = $css = ''; $width = wpb_translateColumnWidthToSpan($atts['width']); $width = vc_column_offset_class_merge($atts['offset'], $width); $__width = array(); $__width = explode(' ', $width); $parent_class = array(); $item_class = array(); if (is_array($__width)) { foreach ($__width as $__class) { if (strpos($__class, 'hidden') > 0) { $parent_class[] = $__class; } else { $item_class[] = $__class; } } $width = implode($item_class, ' '); } $parent_class[] = vc_shortcode_custom_css_class($atts['css']); $parent_class[] = 'mtheme-post-type-' . $atts['styles']; if (!empty($atts['el_class'])) { $parent_class[] = $atts['el_class']; } $css_classes = array($width); ?> <div class="mtheme-post-type <?php
extract($atts); //$col_name = wpb_translateColumnWidthToSpan($width); $col_name = ''; preg_match('/(\\d+)\\/(\\d+)/', $width, $matches); $w = $width; if (!empty($matches)) { $part_x = (int) $matches[1]; $part_y = (int) $matches[2]; if ($part_x > 0 && $part_y > 0) { $value = ceil($part_x / $part_y * 12); if ($value > 0 && $value <= 12) { $w = 'vc_col-md-' . $value; } } } $col_name = vc_column_offset_class_merge($offset, $w); $css_class[] = 'column wpb_column'; if (!empty($el_class)) { $css_class[] = $el_class; } if (!empty($alt_color)) { $css_class[] = 'alt-color'; } if (!empty($alt_bg_color)) { $css_class[] = 'alt-background-color'; } if (!empty($padding_size)) { $css_class[] = $padding_size; } if (!empty($text_align)) { $css_class[] = 'text-' . $text_align;