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/Controllers/BuilderController.php +49 -112 2.2.12.0.2 View file →
@@ -6,8 +6,9 @@
6 6 */
7 7
8 8 namespace RadiusTheme\SB\Controllers;
9 9
10 +use Elementor\Plugin;
10 11 use RadiusTheme\SB\Helpers\Fns;
11 12 use RadiusTheme\SB\Helpers\BuilderFns;
12 13 use RadiusTheme\SB\Traits\SingletonTrait;
13 14 use RadiusTheme\SB\Controllers\Builder\BuilderCpt;
@@ -25,13 +26,8 @@
25 26 * Builder Controller
26 27 */
27 28 class BuilderController {
28 29 /**
29 - * @var array
30 - */
31 - private static $cache = [];
32 -
33 - /**
34 30 * Builder page id.
35 31 *
36 32 * @var integer
37 33 */
@@ -61,21 +57,18 @@
61 57 }
62 58
63 59 BuilderCpt::instance();
64 60
65 - $this->elementor_init();
66 - $this->both_builder_frontend();
67 -
68 - // add_action( 'elementor/init', [ $this, 'elementor_init' ] );
61 + add_action( 'elementor/init', [ $this, 'elementor_init' ] );
69 62 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] );
70 - // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
63 + add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
71 64
72 65 // RT Select2 Ajax.
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' ] );
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' ] );
75 68 // Select2 ajax save data.
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' ] );
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' ] );
78 71 }
79 72
80 73 /**
81 74 * Apply for frontend.
@@ -107,29 +100,21 @@
107 100 *
108 101 * @return void
109 102 */
110 103 public function add_elementor_widget_categories( $elements_manager ) {
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 );
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 + ];
115 115
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 -
116 + $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
132 117 $other_categories = $elements_manager->get_categories();
133 118 $categories = array_merge(
134 119 array_slice( $other_categories, 0, 1 ),
135 120 $categories,
@@ -135,10 +120,10 @@
135 120 $categories,
136 121 array_slice( $other_categories, 1 )
137 122 );
138 123
139 - $set_categories = function ( $categories ) use ( $elements_manager ) {
140 - $elements_manager->categories = $categories;
124 + $set_categories = function ( $categories ) {
125 + $this->categories = $categories;
141 126 };
142 127
143 128 $set_categories->call( $elements_manager, $categories );
144 129 }
@@ -164,11 +149,16 @@
164 149 *
165 150 * @since 1.0.0
166 151 */
167 152 public function init_widgets( $widgets_manager ) {
153 + $product = Fns::get_product();
168 154
169 - $get_list = ElementList::instance()->get_list( true, 'active' );
170 - foreach ( $get_list as $element ) {
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 ) {
171 161 if ( isset( $element['active'] ) && 'on' !== $element['active'] ) {
172 162 continue;
173 163 }
174 164
@@ -230,10 +220,23 @@
230 220 *
231 221 * @return array
232 222 */
233 223 public function rtsb_icons( $tabs = [] ) {
234 - $custom_icons = Fns::get_custom_icon_names();
224 + $fonts = rtsb()->get_assets_uri( 'fonts/rtsb-icons.json' );
235 225
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 +
236 239 $tabs['shopbuilder-icons'] = [
237 240 'name' => 'rtsb-fonts',
238 241 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
239 242 'labelIcon' => 'fab fa-elementor',
@@ -297,18 +300,8 @@
297 300
298 301 if ( BuilderFns::is_product() ) {
299 302 $product_id = Fns::get_prepared_product_id();
300 303 $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 - }
311 304 }
312 305
313 306 if ( BuilderFns::is_shop() ) {
314 307 $parent_class[] = 'shop';
@@ -324,14 +317,9 @@
324 317
325 318 ?>
326 319 <!-- Before Content start -->
327 320 <div class="<?php echo esc_attr( implode( ' ', $parent_class ) ); ?>">
328 - <?php
329 - if ( BuilderFns::is_checkout() ) {
330 - if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
331 - return;
332 - }
333 - ?>
321 + <?php if ( BuilderFns::is_checkout() ) { ?>
334 322 <form name="checkout" method="post" class="rtsb-woocommerce-checkout checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
335 323 <?php
336 324 }
337 325 }
@@ -353,11 +341,8 @@
353 341 do_action( 'elementor/page_templates/header-footer/after_content' );
354 342 }
355 343
356 344 if ( BuilderFns::is_checkout() ) {
357 - if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
358 - return;
359 - }
360 345 ?>
361 346 </form>
362 347 <?php
363 348 }
@@ -372,15 +357,14 @@
372 357 *
373 358 * @return void
374 359 */
375 360 public function select2_ajax_posts_filter_autocomplete() {
376 - if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
377 - wp_send_json_error( [] );
378 - }
361 +
379 362 $query_per_page = 15;
380 363 $post_type = 'post';
381 364 $source_name = 'post_type';
382 - $paged = absint( $_POST['page'] ?? 1 );
365 + $paged = $_POST['page'] ?? 1;
366 +
383 367 if ( ! empty( $_POST['post_type'] ) ) {
384 368 $post_type = sanitize_text_field( $_POST['post_type'] );
385 369 }
386 370
@@ -448,12 +432,8 @@
448 432 * @return void
449 433 */
450 434 public function select2_ajax_get_posts_value_titles() {
451 435
452 - if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
453 - wp_send_json_error( [] );
454 - }
455 -
456 436 if ( empty( $_POST['id'] ) ) {
457 437 wp_send_json_error( [] );
458 438 }
459 439
@@ -552,9 +532,9 @@
552 532 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
553 533 }
554 534
555 535 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
556 - $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
536 + $results = $wpdb->get_results( $query );
557 537
558 538 if ( ! empty( $results ) ) {
559 539 foreach ( $results as $row ) {
560 540 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -585,10 +565,10 @@
585 565
586 566 $pro_widgets = [
587 567 [
588 568 'name' => 'rtsb-ajax-product-filters',
589 - 'title' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
590 - 'description' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
569 + 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
570 + 'description' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
591 571 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
592 572 'categories' => '[ "rtsb-shopbuilder" ]',
593 573 ],
594 574 ];
@@ -599,49 +579,6 @@
599 579 }
600 580 }
601 581
602 582 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 - ];
646 583 }
647 584 }