PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.3
ShopBuilder – WooCommerce Builder For Elementor v3.2.3
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 +101 -52 2.1.53.2.3 View file →
@@ -8,14 +8,14 @@
8 8 namespace RadiusTheme\SB\Controllers;
9 9
10 10 use RadiusTheme\SB\Helpers\Fns;
11 11 use RadiusTheme\SB\Helpers\BuilderFns;
12 +use RadiusTheme\SB\Models\ElementList;
12 13 use RadiusTheme\SB\Traits\SingletonTrait;
13 14 use RadiusTheme\SB\Controllers\Builder\BuilderCpt;
14 15 use RadiusTheme\SB\Controllers\Hooks\BuilderHooks;
15 16 use RadiusTheme\SB\Elementor\Controls\ImageSelectorControl;
16 17 use RadiusTheme\SB\Elementor\Controls\Select2AjaxControl;
17 -use RadiusTheme\SB\Models\ElementList;
18 18
19 19 // Do not allow directly accessing this file.
20 20 if ( ! defined( 'ABSPATH' ) ) {
21 21 exit( 'This script cannot be accessed directly.' );
@@ -60,22 +60,19 @@
60 60 BuilderHooks::instance();
61 61 }
62 62
63 63 BuilderCpt::instance();
64 -
65 - $this->elementor_init();
66 - $this->both_builder_frontend();
67 -
68 - // add_action( 'elementor/init', [ $this, 'elementor_init' ] );
69 - add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] );
70 - // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
71 -
64 + if ( defined( 'ELEMENTOR_VERSION' ) ) {
65 + $this->elementor_init();
66 + $this->both_builder_frontend();
67 + add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] );
68 + }
72 69 // RT Select2 Ajax.
73 - add_action( 'wp_ajax_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
74 - add_action( 'wp_ajax_nopriv_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
70 + add_action( 'wp_ajax_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
71 + add_action( 'wp_ajax_nopriv_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
75 72 // Select2 ajax save data.
76 - add_action( 'wp_ajax_rt_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
77 - add_action( 'wp_ajax_nopriv_rt_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
73 + add_action( 'wp_ajax_rtsb_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
74 + add_action( 'wp_ajax_nopriv_rtsb_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
78 75 }
79 76
80 77 /**
81 78 * Apply for frontend.
@@ -92,13 +89,20 @@
92 89 *
93 90 * @return void
94 91 */
95 92 public function elementor_init() {
96 - add_action( 'elementor/elements/categories_registered', [ $this, 'add_elementor_widget_categories' ] );
97 - add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] );
98 - add_action( 'elementor/controls/register', [ $this, 'init_controls' ] );
99 - add_filter( 'elementor/editor/localize_settings', [ $this, 'promotePremiumWidgets' ] );
100 - add_action( 'elementor/icons_manager/additional_tabs', [ $this, 'rtsb_icons' ] );
93 + add_action(
94 + 'init',
95 + function () {
96 + if ( Fns::should_load_elementor_scripts() ) {
97 + add_action( 'elementor/elements/categories_registered', [ $this, 'add_elementor_widget_categories' ] );
98 + add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] );
99 + add_action( 'elementor/controls/register', [ $this, 'init_controls' ] );
100 + add_filter( 'elementor/editor/localize_settings', [ $this, 'promotePremiumWidgets' ] );
101 + add_action( 'elementor/icons_manager/additional_tabs', [ $this, 'rtsb_icons' ] );
102 + }
103 + }
104 + );
101 105 }
102 106
103 107 /**
104 108 * Register Category
@@ -107,21 +111,29 @@
107 111 *
108 112 * @return void
109 113 */
110 114 public function add_elementor_widget_categories( $elements_manager ) {
111 - $type = BuilderFns::builder_type( get_the_ID() );
112 - $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
113 - $builder_type = str_replace( 'My Account - ', '', $builder_type );
114 - $categories['rtsb-shopbuilder'] = [
115 - 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
116 - 'icon' => 'fa fa-plug',
117 - ];
118 - $categories['rtsb-shopbuilder-general'] = [
119 - 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
120 - 'icon' => 'fa fa-plug',
121 - ];
115 + $categories = [];
116 + $builder_id = get_queried_object_id();
117 + $id = Fns::wpml_object_id( $builder_id, BuilderFns::$post_type_tb, 'default' );
118 + $type = BuilderFns::builder_type( $id );
122 119
123 - $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
120 + if ( $type && 'popup-builder' !== $type ) {
121 + $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
122 + $builder_type = str_replace( [ 'My Account - ', 'Endpoint: ' ], '', $builder_type );
123 + $categories['rtsb-shopbuilder'] = [
124 + 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
125 + 'icon' => 'fa fa-plug',
126 + ];
127 + }
128 + if ( 'quick-view' !== $type ) {
129 + $categories['rtsb-shopbuilder-general'] = [
130 + 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
131 + 'icon' => 'fa fa-plug',
132 + ];
133 + }
134 + $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
135 +
124 136 $other_categories = $elements_manager->get_categories();
125 137 $categories = array_merge(
126 138 array_slice( $other_categories, 0, 1 ),
127 139 $categories,
@@ -127,10 +139,10 @@
127 139 $categories,
128 140 array_slice( $other_categories, 1 )
129 141 );
130 142
131 - $set_categories = function ( $categories ) {
132 - $this->categories = $categories;
143 + $set_categories = function ( $categories ) use ( $elements_manager ) {
144 + $elements_manager->categories = $categories;
133 145 };
134 146
135 147 $set_categories->call( $elements_manager, $categories );
136 148 }
@@ -151,10 +163,14 @@
151 163
152 164 /**
153 165 * Init Widgets
154 166 *
155 - * Include widgets files and register them
167 + * Include widget files and register them
156 168 *
169 + * @param object $widgets_manager Widgets Manager.
170 + *
171 + * @return void
172 + *
157 173 * @since 1.0.0
158 174 */
159 175 public function init_widgets( $widgets_manager ) {
160 176
@@ -222,9 +238,9 @@
222 238 *
223 239 * @return array
224 240 */
225 241 public function rtsb_icons( $tabs = [] ) {
226 - $custom_icons = $this->get_icons();
242 + $custom_icons = Fns::get_custom_icon_names();
227 243
228 244 $tabs['shopbuilder-icons'] = [
229 245 'name' => 'rtsb-fonts',
230 246 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
@@ -281,9 +297,9 @@
281 297 *
282 298 * @since 2.0.0
283 299 */
284 300 if ( did_action( 'elementor/loaded' ) && 'elementor' === $this->page_edit_with ) {
285 - do_action( 'elementor/page_templates/header-footer/before_content' );
301 + do_action( 'elementor/page_templates/header-footer/before_content' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
286 302 }
287 303
288 304 $parent_class = apply_filters( 'rtsb/builder/content/parent_class', [] );
289 305
@@ -289,8 +305,18 @@
289 305
290 306 if ( BuilderFns::is_product() ) {
291 307 $product_id = Fns::get_prepared_product_id();
292 308 $parent_class = wc_get_product_class( $parent_class, $product_id );
309 + if ( function_exists( 'rtwpvs' ) ) {
310 + $_product = Fns::get_product();
311 + if ( $_product->is_type( 'variable' ) ) {
312 + $parent_class[] = 'rtwpvs-product';
313 + $beside_label = function_exists( 'rtwpvsp' ) && rtwpvs()->get_option( 'attribute_on_click_behavior' );
314 + if ( $beside_label ) {
315 + $parent_class[] = 'rtwpvs-selected-term-beside-label';
316 + }
317 + }
318 + }
293 319 }
294 320
295 321 if ( BuilderFns::is_shop() ) {
296 322 $parent_class[] = 'shop';
@@ -312,9 +338,12 @@
312 338 if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
313 339 return;
314 340 }
315 341 ?>
316 - <form name="checkout" method="post" class="rtsb-woocommerce-checkout checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
342 + <!--
343 + woocommerce-checkout added for fix issue with payment method ( Revolut Pay )
344 + -->
345 + <form name="checkout" method="post" class="rtsb-woocommerce-checkout woocommerce-checkout checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
317 346 <?php
318 347 }
319 348 }
320 349
@@ -331,9 +360,9 @@
331 360 *
332 361 * @since 2.0.0
333 362 */
334 363 if ( did_action( 'elementor/loaded' ) && 'elementor' === $this->page_edit_with ) {
335 - do_action( 'elementor/page_templates/header-footer/after_content' );
364 + do_action( 'elementor/page_templates/header-footer/after_content' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
336 365 }
337 366
338 367 if ( BuilderFns::is_checkout() ) {
339 368 if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
@@ -354,24 +383,28 @@
354 383 *
355 384 * @return void
356 385 */
357 386 public function select2_ajax_posts_filter_autocomplete() {
358 -
387 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
388 + wp_send_json_error( [] );
389 + }
359 390 $query_per_page = 15;
360 391 $post_type = 'post';
361 392 $source_name = 'post_type';
362 - $paged = $_POST['page'] ?? 1;
363 -
393 + $paged = absint( $_POST['page'] ?? 1 );
364 394 if ( ! empty( $_POST['post_type'] ) ) {
395 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
365 396 $post_type = sanitize_text_field( $_POST['post_type'] );
366 397 }
367 398
368 399 if ( ! empty( $_POST['source_name'] ) ) {
400 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
369 401 $source_name = sanitize_text_field( $_POST['source_name'] );
370 402 }
371 403
404 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
372 405 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
373 - $results = $post_list = [];
406 + $results = $post_list = []; // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
374 407 switch ( $source_name ) {
375 408 case 'taxonomy':
376 409 $args = [
377 410 'hide_empty' => false,
@@ -380,9 +413,9 @@
380 413 'search' => $search,
381 414 'number' => '5',
382 415 ];
383 416
384 - if ( $post_type !== 'all' ) {
417 + if ( 'all' !== $post_type ) {
385 418 $args['taxonomy'] = $post_type;
386 419 }
387 420
388 421 $post_list = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -429,17 +462,22 @@
429 462 * @return void
430 463 */
431 464 public function select2_ajax_get_posts_value_titles() {
432 465
466 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
467 + wp_send_json_error( [] );
468 + }
469 +
433 470 if ( empty( $_POST['id'] ) ) {
434 471 wp_send_json_error( [] );
435 472 }
436 473
474 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
437 475 if ( empty( array_filter( $_POST['id'] ) ) ) {
438 476 wp_send_json_error( [] );
439 477 }
440 478 $ids = array_map( 'intval', $_POST['id'] );
441 - $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : '';
479 + $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
442 480
443 481 switch ( $source_name ) {
444 482 case 'taxonomy':
445 483 $args = [
@@ -448,9 +486,11 @@
448 486 'order' => 'ASC',
449 487 'include' => implode( ',', $ids ),
450 488 ];
451 489
452 - if ( $_POST['post_type'] !== 'all' ) {
490 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
491 + if ( 'all' !== $_POST['post_type'] ) {
492 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
453 493 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
454 494 }
455 495
456 496 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -468,9 +508,9 @@
468 508 break;
469 509 default:
470 510 $post_info = get_posts(
471 511 [
472 - 'post_type' => sanitize_text_field( $_POST['post_type'] ),
512 + 'post_type' => sanitize_text_field( $_POST['post_type'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
473 513 'include' => implode( ',', $ids ),
474 514 ]
475 515 );
476 516 $response = wp_list_pluck( $post_info, 'post_title', 'ID' );
@@ -486,12 +526,12 @@
486 526
487 527 /**
488 528 * Ajax callback for rt-select2
489 529 *
490 - * @param $post_type
491 - * @param $limit
492 - * @param $search
493 - * @param $paged
530 + * @param string $post_type Post type.
531 + * @param int $limit Limit.
532 + * @param string $search Search.
533 + * @param int $paged Paged.
494 534 *
495 535 * @return array
496 536 */
497 537 public function get_query_data( $post_type = 'any', $limit = 10, $search = '', $paged = 1 ) {
@@ -528,10 +568,19 @@
528 568 if ( ! empty( $search ) ) {
529 569 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
530 570 }
531 571
572 + // Add a query for shop_coupon post-type to check 'show on frontend' meta.
573 + if ( 'shop_coupon' === $post_type ) {
574 + $where .= " AND {$wpdb->posts}.ID IN (
575 + SELECT post_id FROM {$wpdb->postmeta}
576 + WHERE meta_key = 'rtsb_show_on_frontend'
577 + AND meta_value = 'on'
578 + )";
579 + }
580 +
532 581 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
533 - $results = $wpdb->get_results( $query );
582 + $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
534 583
535 584 if ( ! empty( $results ) ) {
536 585 foreach ( $results as $row ) {
537 586 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -562,10 +611,10 @@
562 611
563 612 $pro_widgets = [
564 613 [
565 614 'name' => 'rtsb-ajax-product-filters',
566 - 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
567 - 'description' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
615 + 'title' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
616 + 'description' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
568 617 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
569 618 'categories' => '[ "rtsb-shopbuilder" ]',
570 619 ],
571 620 ];