PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.13
ShopBuilder – WooCommerce Builder For Elementor v2.1.13
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/Controllers/BuilderController.php +110 -47 2.0.22.1.13 View file →
@@ -6,9 +6,8 @@
6 6 */
7 7
8 8 namespace RadiusTheme\SB\Controllers;
9 9
10 -use Elementor\Plugin;
11 10 use RadiusTheme\SB\Helpers\Fns;
12 11 use RadiusTheme\SB\Helpers\BuilderFns;
13 12 use RadiusTheme\SB\Traits\SingletonTrait;
14 13 use RadiusTheme\SB\Controllers\Builder\BuilderCpt;
@@ -26,8 +25,13 @@
26 25 * Builder Controller
27 26 */
28 27 class BuilderController {
29 28 /**
29 + * @var array
30 + */
31 + private static $cache = [];
32 +
33 + /**
30 34 * Builder page id.
31 35 *
32 36 * @var integer
33 37 */
@@ -57,18 +61,21 @@
57 61 }
58 62
59 63 BuilderCpt::instance();
60 64
61 - add_action( 'elementor/init', [ $this, 'elementor_init' ] );
65 + $this->elementor_init();
66 + $this->both_builder_frontend();
67 +
68 + // add_action( 'elementor/init', [ $this, 'elementor_init' ] );
62 69 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] );
63 - add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
70 + // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
64 71
65 72 // RT Select2 Ajax.
66 - add_action( 'wp_ajax_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
67 - add_action( 'wp_ajax_nopriv_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
73 + add_action( 'wp_ajax_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
74 + add_action( 'wp_ajax_nopriv_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
68 75 // Select2 ajax save data.
69 - add_action( 'wp_ajax_rt_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
70 - add_action( 'wp_ajax_nopriv_rt_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
76 + add_action( 'wp_ajax_rtsb_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
77 + add_action( 'wp_ajax_nopriv_rtsb_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
71 78 }
72 79
73 80 /**
74 81 * Apply for frontend.
@@ -100,21 +107,29 @@
100 107 *
101 108 * @return void
102 109 */
103 110 public function add_elementor_widget_categories( $elements_manager ) {
104 - $type = BuilderFns::builder_type( get_the_ID() );
105 - $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
106 - $builder_type = str_replace( 'My Account - ', '', $builder_type );
107 - $categories['rtsb-shopbuilder'] = [
108 - 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
109 - 'icon' => 'fa fa-plug',
110 - ];
111 - $categories['rtsb-shopbuilder-general'] = [
112 - 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
113 - 'icon' => 'fa fa-plug',
114 - ];
111 + $categories = [];
112 + $builder_id = get_queried_object_id();
113 + $id = Fns::wpml_object_id( $builder_id, BuilderFns::$post_type_tb, 'default' );
114 + $type = BuilderFns::builder_type( $id );
115 115
116 - $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
116 + if ( $type ) {
117 + $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
118 + $builder_type = str_replace( [ 'My Account - ', 'Endpoint: ' ], '', $builder_type );
119 + $categories['rtsb-shopbuilder'] = [
120 + 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
121 + 'icon' => 'fa fa-plug',
122 + ];
123 + }
124 + if ( 'quick-view' !== $type ) {
125 + $categories['rtsb-shopbuilder-general'] = [
126 + 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
127 + 'icon' => 'fa fa-plug',
128 + ];
129 + }
130 + $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
131 +
117 132 $other_categories = $elements_manager->get_categories();
118 133 $categories = array_merge(
119 134 array_slice( $other_categories, 0, 1 ),
120 135 $categories,
@@ -149,16 +164,11 @@
149 164 *
150 165 * @since 1.0.0
151 166 */
152 167 public function init_widgets( $widgets_manager ) {
153 - $product = Fns::get_product();
154 168
155 - // TODO: Need to remove below condition and make compitability in each widgets.
156 - if ( ! $product ) {
157 - return;
158 - }
159 -
160 - foreach ( ElementList::instance()->get_list( true, 'active' ) as $element ) {
169 + $get_list = ElementList::instance()->get_list( true, 'active' );
170 + foreach ( $get_list as $element ) {
161 171 if ( isset( $element['active'] ) && 'on' !== $element['active'] ) {
162 172 continue;
163 173 }
164 174
@@ -220,23 +230,10 @@
220 230 *
221 231 * @return array
222 232 */
223 233 public function rtsb_icons( $tabs = [] ) {
224 - $fonts = rtsb()->get_assets_uri( 'fonts/rtsb-icons.json' );
234 + $custom_icons = Fns::get_custom_icon_names();
225 235
226 - $response = wp_remote_get( $fonts );
227 -
228 - if ( is_wp_error( $response ) ) {
229 - return $tabs;
230 - }
231 -
232 - $icons_json = wp_remote_retrieve_body( $response );
233 - $custom_icons = json_decode( $icons_json, true );
234 -
235 - if ( null === $custom_icons ) {
236 - return $tabs;
237 - }
238 -
239 236 $tabs['shopbuilder-icons'] = [
240 237 'name' => 'rtsb-fonts',
241 238 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
242 239 'labelIcon' => 'fab fa-elementor',
@@ -300,8 +297,18 @@
300 297
301 298 if ( BuilderFns::is_product() ) {
302 299 $product_id = Fns::get_prepared_product_id();
303 300 $parent_class = wc_get_product_class( $parent_class, $product_id );
301 + if ( function_exists( 'rtwpvs' ) ) {
302 + $_product = Fns::get_product();
303 + if ( $_product->is_type( 'variable' ) ) {
304 + $parent_class[] = 'rtwpvs-product';
305 + $beside_label = function_exists( 'rtwpvsp' ) && rtwpvs()->get_option( 'attribute_on_click_behavior' );
306 + if ( $beside_label ) {
307 + $parent_class[] = 'rtwpvs-selected-term-beside-label';
308 + }
309 + }
310 + }
304 311 }
305 312
306 313 if ( BuilderFns::is_shop() ) {
307 314 $parent_class[] = 'shop';
@@ -317,9 +324,14 @@
317 324
318 325 ?>
319 326 <!-- Before Content start -->
320 327 <div class="<?php echo esc_attr( implode( ' ', $parent_class ) ); ?>">
321 - <?php if ( BuilderFns::is_checkout() ) { ?>
328 + <?php
329 + if ( BuilderFns::is_checkout() ) {
330 + if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
331 + return;
332 + }
333 + ?>
322 334 <form name="checkout" method="post" class="rtsb-woocommerce-checkout checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
323 335 <?php
324 336 }
325 337 }
@@ -341,8 +353,11 @@
341 353 do_action( 'elementor/page_templates/header-footer/after_content' );
342 354 }
343 355
344 356 if ( BuilderFns::is_checkout() ) {
357 + if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
358 + return;
359 + }
345 360 ?>
346 361 </form>
347 362 <?php
348 363 }
@@ -357,14 +372,15 @@
357 372 *
358 373 * @return void
359 374 */
360 375 public function select2_ajax_posts_filter_autocomplete() {
361 -
376 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
377 + wp_send_json_error( [] );
378 + }
362 379 $query_per_page = 15;
363 380 $post_type = 'post';
364 381 $source_name = 'post_type';
365 - $paged = $_POST['page'] ?? 1;
366 -
382 + $paged = absint( $_POST['page'] ?? 1 );
367 383 if ( ! empty( $_POST['post_type'] ) ) {
368 384 $post_type = sanitize_text_field( $_POST['post_type'] );
369 385 }
370 386
@@ -432,8 +448,12 @@
432 448 * @return void
433 449 */
434 450 public function select2_ajax_get_posts_value_titles() {
435 451
452 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
453 + wp_send_json_error( [] );
454 + }
455 +
436 456 if ( empty( $_POST['id'] ) ) {
437 457 wp_send_json_error( [] );
438 458 }
439 459
@@ -532,9 +552,9 @@
532 552 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
533 553 }
534 554
535 555 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
536 - $results = $wpdb->get_results( $query );
556 + $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
537 557
538 558 if ( ! empty( $results ) ) {
539 559 foreach ( $results as $row ) {
540 560 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -565,10 +585,10 @@
565 585
566 586 $pro_widgets = [
567 587 [
568 588 'name' => 'rtsb-ajax-product-filters',
569 - 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
570 - 'description' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
589 + 'title' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
590 + 'description' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
571 591 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
572 592 'categories' => '[ "rtsb-shopbuilder" ]',
573 593 ],
574 594 ];
@@ -579,6 +599,49 @@
579 599 }
580 600 }
581 601
582 602 return $config;
603 + }
604 +
605 + /**
606 + * Get Icons.
607 + *
608 + * @return array
609 + */
610 + public function get_icons() {
611 + return [
612 + 'heart-empty',
613 + 'heart',
614 + 'eye',
615 + 'exchange',
616 + 'plus',
617 + 'minus',
618 + 'avatar',
619 + 'pay',
620 + 'share',
621 + 'clock',
622 + 'check-alt',
623 + 'check',
624 + 'delete',
625 + 'marker',
626 + 'list',
627 + 'list-2',
628 + 'power',
629 + 'cart',
630 + 'cart-2',
631 + 'cart-3',
632 + 'downloads',
633 + 'zoom',
634 + 'user-edit',
635 + 'grid',
636 + 'filter',
637 + 'billing',
638 + 'login',
639 + 'payment',
640 + 'search',
641 + 'edit',
642 + 'coupon',
643 + 'arrows-cw',
644 + 'trash-empty',
645 + ];
583 646 }
584 647 }