PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.2
ShopBuilder – WooCommerce Builder For Elementor v2.0.2
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Elementor/Render/Render.php +28 -88 2.1.12.0.2 View file →
@@ -9,9 +9,8 @@
9 9
10 10 namespace RadiusTheme\SB\Elementor\Render;
11 11
12 12 use WP_Query;
13 -use WC_Product;
14 13 use RadiusTheme\SB\Helpers\Fns;
15 14 use RadiusTheme\SB\Models\QueryArgs;
16 15 use RadiusTheme\SB\Helpers\BuilderFns;
17 16 use RadiusTheme\SB\Traits\SingletonTrait;
@@ -67,13 +66,12 @@
67 66 * @param array $settings Settings.
68 67 * @param string $class Class.
69 68 * @param string $template Template name.
70 69 * @param bool $fullwidth Fullwidth check.
71 - * @param bool $ajax_attr Ajax attributes.
72 70 *
73 71 * @return string
74 72 */
75 - public function container( $content, $settings, $class = '', $template = '', $fullwidth = false, $ajax_attr = true ) {
73 + public function container( $content, $settings, $class = '', $template = '', $fullwidth = false ) {
76 74 $layout_id = 'rtsb-container-' . absint( wp_rand() );
77 75 $container_attr = null;
78 76 $cart_txt_class = '';
79 77 $container_class = 'rtsb-elementor-container products rtsb-pos-r ' . esc_attr( $class );
@@ -78,11 +76,10 @@
78 76 $cart_txt_class = '';
79 77 $container_class = 'rtsb-elementor-container products rtsb-pos-r ' . esc_attr( $class );
80 78 $metas = RenderHelpers::meta_dataset( $settings, $template );
81 79
82 - $layout = $metas['layout'];
83 - $animation = $metas['hover_animation'];
84 - $animation .= ' gallery-hover-' . ( ! empty( $settings['gallery_hover_animation'] ) ? $settings['gallery_hover_animation'] : 'fade' );
80 + $layout = $metas['layout'];
81 + $animation = $metas['hover_animation'];
85 82
86 83 $is_cat = preg_match( '/category/', $layout );
87 84 $is_carousel = preg_match( '/slider/', $layout );
88 85
@@ -98,23 +95,18 @@
98 95 'position' => $metas['badge_position'],
99 96 'alignment' => $metas['badge_alignment'],
100 97 ];
101 98
102 - if ( ! rtsb()->has_pro() && ! in_array( $layout, array_keys( Fns::free_layouts() ), true ) ) {
99 + if ( ! in_array( $layout, array_keys( Fns::free_layouts() ), true ) ) {
103 100 $layout = RenderHelpers::set_default_layout( $layout );
104 101 }
105 102
106 - $has_tab_filters = rtsb()->has_pro() && ! empty( $settings['tax_filter'] );
107 -
108 103 if ( $is_carousel ) {
109 - $pagination_attr = $has_tab_filters ? RenderHelpers::pagination_data( $settings, $template ) : '';
104 + $pagination_attr = ! empty( $metas['show_filter'] ) ? RenderHelpers::pagination_data( $settings, $template ) : '';
110 105 } elseif ( $is_cat ) {
111 106 $pagination_attr = '';
112 107 } else {
113 - $ajax_pagination = ! empty( $settings['show_pagination'] ) && 'pagination' !== $settings['pagination_type'];
114 - $page = Fns::product_filters_has_ajax( 'shop' ) || Fns::product_filters_has_ajax( 'archive' );
115 - $condition = rtsb()->has_pro() && $ajax_attr && ( $ajax_pagination || $has_tab_filters || $page );
116 - $pagination_attr = $condition ? RenderHelpers::pagination_data( $settings, $template ) : '';
108 + $pagination_attr = RenderHelpers::pagination_data( $settings, $template );
117 109 }
118 110
119 111 if ( ! in_array( 'clear-btn', $metas['visibility'], true ) ) {
120 112 $container_class .= ' no-clear-btn';
@@ -125,11 +117,10 @@
125 117 $tooltip_attr = ' data-tooltip-position="' . esc_attr( $metas['tooltip_position'] ) . '"';
126 118
127 119 $view_mode = $settings['view_mode'] ?? 'grid';
128 120
129 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended
130 121 if ( isset( $_GET['displayview'] ) ) {
131 - $view_mode = sanitize_text_field( wp_unslash( $_GET['displayview'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
122 + $view_mode = sanitize_text_field( wp_unslash( $_GET['displayview'] ) );
132 123 }
133 124
134 125 if ( 'list' == $view_mode && ! empty( $metas['tooltip_position_list'] ) ) {
135 126 $tooltip_attr = ' data-tooltip-position="' . esc_attr( $metas['tooltip_position_list'] ) . '"';
@@ -145,39 +136,8 @@
145 136 if ( in_array( 'single-cat', $metas['visibility'], true ) ) {
146 137 $container_class .= ' show-single-cat';
147 138 }
148 139
149 - if ( ! empty( $settings['show_compare_text'] ) ) {
150 - $container_class .= ' has-compare-text';
151 - }
152 -
153 - if ( ! empty( $settings['show_quick_view_text'] ) ) {
154 - $container_class .= ' has-quick-view-text';
155 - }
156 -
157 - if ( ! empty( $settings['show_wishlist_text'] ) ) {
158 - $container_class .= ' has-wishlist-text';
159 - }
160 -
161 - if ( empty( $settings['show_compare_icon'] ) ) {
162 - $container_class .= ' no-compare-icon';
163 - }
164 -
165 - if ( empty( $settings['show_quick_view_icon'] ) ) {
166 - $container_class .= ' no-quick-view-icon';
167 - }
168 -
169 - if ( empty( $settings['show_wishlist_icon'] ) ) {
170 - $container_class .= ' no-wishlist-icon';
171 - }
172 -
173 - if ( empty( $settings['show_quick_checkout_icon'] ) ) {
174 - $container_class .= ' no-quick_checkout-icon';
175 - }
176 - if ( $is_cat && empty( $settings['show_overlay'] ) ) {
177 - $container_class .= ' no-category-bg-overlay';
178 - }
179 -
180 140 $container_class = apply_filters( 'rtsb/product/container/class', $container_class, $settings );
181 141 $this->html = '<div class="' . esc_attr( $container_class ) . '" id="' . esc_attr( $layout_id ) . '" ' . $container_attr . '>';
182 142
183 143 if ( ! empty( $settings['query_products'] ) && count( $settings['query_products'] ) && 'yes' === $settings['show_section_title'] ) {
@@ -331,16 +291,13 @@
331 291 *
332 292 * @return string|null
333 293 */
334 294 public function category_loop( $query, $settings, $template, $is_single = false ) {
335 - $html = null;
336 - $category_loop = false;
337 - if ( 'category-layout3' === $settings['raw_settings']['layout'] || 'category-single-layout2' === $settings['raw_settings']['layout'] ) {
338 - $category_loop = true;
339 - }
295 + $html = null;
296 +
340 297 if ( $is_single ) {
341 298 // Loop arg.
342 - $arg = $this->cat_arg_dataset( $settings, $query, true, false, $category_loop );
299 + $arg = $this->cat_arg_dataset( $settings, $query, true );
343 300
344 301 // Get template.
345 302 $html .= Fns::load_template( $template . $settings['layout'], $arg, true );
346 303 } else {
@@ -345,9 +302,9 @@
345 302 $html .= Fns::load_template( $template . $settings['layout'], $arg, true );
346 303 } else {
347 304 foreach ( $query as $term ) {
348 305 // Loop arg.
349 - $arg = $this->cat_arg_dataset( $settings, $term, false, false, $category_loop );
306 + $arg = $this->cat_arg_dataset( $settings, $term );
350 307
351 308 // Get template.
352 309 $html .= Fns::load_template( $template . $settings['layout'], $arg, true );
353 310 }
@@ -405,9 +362,9 @@
405 362 do_action( 'rtsb/elementor/render/after_row', $metas, $settings, $product_query );
406 363 $this->html .= ob_get_clean();
407 364
408 365 } else {
409 - $content = '<div class="woocommerce-no-products-found"><div class="woocommerce-info">' . esc_html__( 'No products were found matching your selection.', 'shopbuilder' ) . '</div></div>';
366 + $content = '<div class="woocommerce-no-products-found"><div class="woocommerce-info">' . esc_html__( 'No products were found matching your selection.', 'shopbuilder-pro' ) . '</div></div>';
410 367
411 368 $this->row( $content, $metas );
412 369 }
413 370
@@ -463,9 +420,9 @@
463 420 if ( ! empty( $ordering['order'] ) ) {
464 421 $wp_query_args['order'] = $ordering['order'];
465 422 }
466 423
467 - $wp_query = new WP_Query( $wp_query_args ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
424 + $wp_query = new \WP_Query( $wp_query_args ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
468 425 wc_set_loop_prop( 'total', $wp_query->found_posts );
469 426 wc_set_loop_prop( 'total_pages', $wp_query->max_num_pages );
470 427 }
471 428
@@ -487,9 +444,9 @@
487 444 if ( Fns::product_filters_has_ajax( 'shop' ) || Fns::product_filters_has_ajax( 'archive' ) ) {
488 445 if ( $wp_query->max_num_pages > 1 ) {
489 446 $this->html .= "
490 447 <div class='rtsb-load-more rtsb-pos-r'>
491 - <button data-paged='2' data-max-page='{$wp_query->max_num_pages}'><span>" . esc_html__( 'Load More', 'shopbuilder' ) . "</span></button>
448 + <button data-paged='2' data-max-page='{$wp_query->max_num_pages}'><span>" . esc_html__( 'Load More', 'shopbuilder-pro' ) . "</span></button>
492 449 <div class='rtsb-loadmore-loading rtsb-ball-clip-rotate'><div></div></div>
493 450 </div>
494 451 ";
495 452 }
@@ -504,9 +461,9 @@
504 461 }
505 462
506 463 $this->html .= '</div>';
507 464 } else {
508 - $content = '<div class="woocommerce-no-products-found"><div class="woocommerce-info">' . esc_html__( 'No products were found matching your selection.', 'shopbuilder' ) . '</div></div>';
465 + $content = '<div class="woocommerce-no-products-found"><div class="woocommerce-info">' . esc_html__( 'No products were found matching your selection.', 'shopbuilder-pro' ) . '</div></div>';
509 466
510 467 $this->row( $content, $metas );
511 468 }
512 469
@@ -554,9 +511,9 @@
554 511 $this->row( $html, $metas );
555 512 }
556 513
557 514 // Container.
558 - $this->container( $this->html, $settings, 'rtsb-products-container', '', false, false );
515 + $this->container( $this->html, $settings, 'rtsb-products-container' );
559 516
560 517 wp_reset_postdata();
561 518
562 519 return $this->html;
@@ -595,9 +552,9 @@
595 552
596 553 $taxonomy_query = get_terms( $args );
597 554 }
598 555
599 - if ( ! is_wp_error( $taxonomy_query ) && ! empty( $taxonomy_query ) ) {
556 + if ( ! empty( $taxonomy_query ) ) {
600 557 // Row.
601 558 $this->row( $this->category_loop( $taxonomy_query, $metas, $template, $is_single ), $metas );
602 559 } else {
603 560 $this->html .= '<p>' . esc_html__( 'No categories found', 'shopbuilder' ) . '</p>';
@@ -660,17 +617,14 @@
660 617 if ( ( empty( $meta ) && ! $post_id ) || ! in_array( get_post_type( $post_id ), [ 'product_variation', 'product' ] ) ) {
661 618 return [];
662 619 }
663 620
664 - global $post, $product;
621 + global $post;
665 622
666 - if ( ! $product instanceof WC_Product && $post_id ) {
667 - $product = wc_get_product( $post_id );
668 - }
623 + $arg = [];
624 + $_product = wc_get_product( $post_id );
625 + $p_type = $_product->get_type();
669 626
670 - $arg = [];
671 - $p_type = $product->get_type();
672 -
673 627 $arg['class'] = null;
674 628 $arg['grid'] = null;
675 629 $arg['anchor_class'] = null;
676 630 $arg['hover_img_html'] = null;
@@ -678,10 +632,9 @@
678 632 $arg['add_to_cart'] = '';
679 633 $arg['p_id'] = $post_id;
680 634 $arg['p_link'] = get_permalink();
681 635 $arg['p_sale'] = '';
682 - $arg['rating_args'] = [];
683 - $arg['has_attributes'] = $product->is_type( 'variable' ) && $product->get_attributes();
636 + $arg['has_attributes'] = $_product->is_type( 'variable' ) && $_product->get_attributes();
684 637 $arg['raw_settings'] = ! empty( $meta['raw_settings'] ) ? $meta['raw_settings'] : [];
685 638 $cart_icon_html = '';
686 639
687 640 $layout = $meta['layout'];
@@ -754,10 +707,10 @@
754 707 }
755 708
756 709 $cart_icon = '<span class="icon">' . $cart_icon_html . '</span>';
757 710
758 - if ( $product->is_purchasable() || 'grouped' === $p_type || 'external' === $p_type ) {
759 - if ( $product->is_in_stock() ) {
711 + if ( $_product->is_purchasable() || 'grouped' === $p_type || 'external' === $p_type ) {
712 + if ( $_product->is_in_stock() ) {
760 713 $arg['add_to_cart'] = $this->render_add_to_cart_button(
761 714 get_permalink(),
762 715 $post_id,
763 716 $p_type,
@@ -793,10 +746,10 @@
793 746 $meta['custom_img_size'],
794 747 $lazy_load
795 748 ) : null;
796 749
797 - if ( ! ( function_exists( 'rtwpvsp' ) && $product->is_type( 'variable' ) && $product->get_attributes() ) ) {
798 - $gallery_ids = $product->get_gallery_image_ids();
750 + if ( ! ( function_exists( 'rtwpvsp' ) && $_product->is_type( 'variable' ) && $_product->get_attributes() ) ) {
751 + $gallery_ids = $_product->get_gallery_image_ids();
799 752
800 753 if ( $meta['hover_img'] && ! empty( $gallery_ids ) ) {
801 754 $arg['class'] .= ! $meta['gallery_img'] ? ' rtsb-double-img' : '';
802 755
@@ -844,9 +797,9 @@
844 797 * @param bool $lazy_load Lazy Load.
845 798 *
846 799 * @return array
847 800 */
848 - public function cat_arg_dataset( $meta, $query = null, $fullwidth = false, $lazy_load = false, $category_loop = false ) {
801 + public function cat_arg_dataset( $meta, $query = null, $fullwidth = false, $lazy_load = false ) {
849 802 if ( empty( $meta ) ) {
850 803 return [];
851 804 }
852 805
@@ -851,9 +804,8 @@
851 804 }
852 805
853 806 $arg = [];
854 807
855 - $products = null;
856 808 $arg['class'] = null;
857 809 $arg['grid'] = null;
858 810 $arg['anchor_class'] = null;
859 811 $arg['p_sale'] = null;
@@ -939,21 +891,9 @@
939 891 }
940 892
941 893 $arg['excerpt_class'] = 'category-info' . ( 'block' === $meta['count_position'] ? ' block-count' : ' inline-count' ) . ( 'above' === $meta['cat_excerpt_position'] ? ' excerpt-above' : '' ) . ( empty( $arg['excerpt'] ) ? ' no-excerpt' : '' );
942 894
943 - if ( $category_loop ) {
944 - $query_args = [
945 - 'product_category_id' => $query->term_id,
946 - 'limit' => -1,
947 - 'order' => 'DESC',
948 - 'orderby' => 'date',
949 - ];
950 -
951 - $products_query = new \WC_Product_Query( $query_args );
952 - $products = $products_query->get_products();
953 - }
954 -
955 - return apply_filters( 'rtsb/elementor/render/cat_arg_dataset', $arg, $meta, $query, $fullwidth, $lazy_load, $products );
895 + return $arg;
956 896 }
957 897
958 898 /**
959 899 * Renders add to cart button.