PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.4.2
ShopBuilder – WooCommerce Builder For Elementor v2.4.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 +120 -51 2.0.22.4.2 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,
@@ -120,10 +135,10 @@
120 135 $categories,
121 136 array_slice( $other_categories, 1 )
122 137 );
123 138
124 - $set_categories = function ( $categories ) {
125 - $this->categories = $categories;
139 + $set_categories = function ( $categories ) use ( $elements_manager ) {
140 + $elements_manager->categories = $categories;
126 141 };
127 142
128 143 $set_categories->call( $elements_manager, $categories );
129 144 }
@@ -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,22 +372,26 @@
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'] ) ) {
384 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
368 385 $post_type = sanitize_text_field( $_POST['post_type'] );
369 386 }
370 387
371 388 if ( ! empty( $_POST['source_name'] ) ) {
389 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
372 390 $source_name = sanitize_text_field( $_POST['source_name'] );
373 391 }
374 392
393 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
375 394 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
376 395 $results = $post_list = [];
377 396 switch ( $source_name ) {
378 397 case 'taxonomy':
@@ -432,17 +451,22 @@
432 451 * @return void
433 452 */
434 453 public function select2_ajax_get_posts_value_titles() {
435 454
455 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
456 + wp_send_json_error( [] );
457 + }
458 +
436 459 if ( empty( $_POST['id'] ) ) {
437 460 wp_send_json_error( [] );
438 461 }
439 462
463 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
440 464 if ( empty( array_filter( $_POST['id'] ) ) ) {
441 465 wp_send_json_error( [] );
442 466 }
443 467 $ids = array_map( 'intval', $_POST['id'] );
444 - $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : '';
468 + $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
445 469
446 470 switch ( $source_name ) {
447 471 case 'taxonomy':
448 472 $args = [
@@ -451,9 +475,11 @@
451 475 'order' => 'ASC',
452 476 'include' => implode( ',', $ids ),
453 477 ];
454 478
479 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
455 480 if ( $_POST['post_type'] !== 'all' ) {
481 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
456 482 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
457 483 }
458 484
459 485 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -471,9 +497,9 @@
471 497 break;
472 498 default:
473 499 $post_info = get_posts(
474 500 [
475 - 'post_type' => sanitize_text_field( $_POST['post_type'] ),
501 + 'post_type' => sanitize_text_field( $_POST['post_type'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
476 502 'include' => implode( ',', $ids ),
477 503 ]
478 504 );
479 505 $response = wp_list_pluck( $post_info, 'post_title', 'ID' );
@@ -532,9 +558,9 @@
532 558 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
533 559 }
534 560
535 561 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
536 - $results = $wpdb->get_results( $query );
562 + $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
537 563
538 564 if ( ! empty( $results ) ) {
539 565 foreach ( $results as $row ) {
540 566 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -565,10 +591,10 @@
565 591
566 592 $pro_widgets = [
567 593 [
568 594 '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' ),
595 + 'title' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
596 + 'description' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
571 597 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
572 598 'categories' => '[ "rtsb-shopbuilder" ]',
573 599 ],
574 600 ];
@@ -579,6 +605,49 @@
579 605 }
580 606 }
581 607
582 608 return $config;
609 + }
610 +
611 + /**
612 + * Get Icons.
613 + *
614 + * @return array
615 + */
616 + public function get_icons() {
617 + return [
618 + 'heart-empty',
619 + 'heart',
620 + 'eye',
621 + 'exchange',
622 + 'plus',
623 + 'minus',
624 + 'avatar',
625 + 'pay',
626 + 'share',
627 + 'clock',
628 + 'check-alt',
629 + 'check',
630 + 'delete',
631 + 'marker',
632 + 'list',
633 + 'list-2',
634 + 'power',
635 + 'cart',
636 + 'cart-2',
637 + 'cart-3',
638 + 'downloads',
639 + 'zoom',
640 + 'user-edit',
641 + 'grid',
642 + 'filter',
643 + 'billing',
644 + 'login',
645 + 'payment',
646 + 'search',
647 + 'edit',
648 + 'coupon',
649 + 'arrows-cw',
650 + 'trash-empty',
651 + ];
583 652 }
584 653 }