PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.2
ShopBuilder – WooCommerce Builder For Elementor v3.2.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 +101 -53 2.1.23.2.2 View file →
@@ -8,15 +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 -use RadiusTheme\SBPRO\Helpers\FnsPro;
19 18
20 19 // Do not allow directly accessing this file.
21 20 if ( ! defined( 'ABSPATH' ) ) {
22 21 exit( 'This script cannot be accessed directly.' );
@@ -61,22 +60,19 @@
61 60 BuilderHooks::instance();
62 61 }
63 62
64 63 BuilderCpt::instance();
65 -
66 - $this->elementor_init();
67 - $this->both_builder_frontend();
68 -
69 - // add_action( 'elementor/init', [ $this, 'elementor_init' ] );
70 - add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] );
71 - // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
72 -
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 + }
73 69 // RT Select2 Ajax.
74 - add_action( 'wp_ajax_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
75 - 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' ] );
76 72 // Select2 ajax save data.
77 - add_action( 'wp_ajax_rt_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
78 - 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' ] );
79 75 }
80 76
81 77 /**
82 78 * Apply for frontend.
@@ -93,13 +89,20 @@
93 89 *
94 90 * @return void
95 91 */
96 92 public function elementor_init() {
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' ] );
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 + );
102 105 }
103 106
104 107 /**
105 108 * Register Category
@@ -108,21 +111,29 @@
108 111 *
109 112 * @return void
110 113 */
111 114 public function add_elementor_widget_categories( $elements_manager ) {
112 - $type = BuilderFns::builder_type( get_the_ID() );
113 - $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
114 - $builder_type = str_replace( 'My Account - ', '', $builder_type );
115 - $categories['rtsb-shopbuilder'] = [
116 - 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
117 - 'icon' => 'fa fa-plug',
118 - ];
119 - $categories['rtsb-shopbuilder-general'] = [
120 - 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
121 - 'icon' => 'fa fa-plug',
122 - ];
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 );
123 119
124 - $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 +
125 136 $other_categories = $elements_manager->get_categories();
126 137 $categories = array_merge(
127 138 array_slice( $other_categories, 0, 1 ),
128 139 $categories,
@@ -128,10 +139,10 @@
128 139 $categories,
129 140 array_slice( $other_categories, 1 )
130 141 );
131 142
132 - $set_categories = function ( $categories ) {
133 - $this->categories = $categories;
143 + $set_categories = function ( $categories ) use ( $elements_manager ) {
144 + $elements_manager->categories = $categories;
134 145 };
135 146
136 147 $set_categories->call( $elements_manager, $categories );
137 148 }
@@ -152,10 +163,14 @@
152 163
153 164 /**
154 165 * Init Widgets
155 166 *
156 - * Include widgets files and register them
167 + * Include widget files and register them
157 168 *
169 + * @param object $widgets_manager Widgets Manager.
170 + *
171 + * @return void
172 + *
158 173 * @since 1.0.0
159 174 */
160 175 public function init_widgets( $widgets_manager ) {
161 176
@@ -223,9 +238,9 @@
223 238 *
224 239 * @return array
225 240 */
226 241 public function rtsb_icons( $tabs = [] ) {
227 - $custom_icons = $this->get_icons();
242 + $custom_icons = Fns::get_custom_icon_names();
228 243
229 244 $tabs['shopbuilder-icons'] = [
230 245 'name' => 'rtsb-fonts',
231 246 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
@@ -282,9 +297,9 @@
282 297 *
283 298 * @since 2.0.0
284 299 */
285 300 if ( did_action( 'elementor/loaded' ) && 'elementor' === $this->page_edit_with ) {
286 - 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
287 302 }
288 303
289 304 $parent_class = apply_filters( 'rtsb/builder/content/parent_class', [] );
290 305
@@ -290,8 +305,18 @@
290 305
291 306 if ( BuilderFns::is_product() ) {
292 307 $product_id = Fns::get_prepared_product_id();
293 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 + }
294 319 }
295 320
296 321 if ( BuilderFns::is_shop() ) {
297 322 $parent_class[] = 'shop';
@@ -313,9 +338,12 @@
313 338 if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
314 339 return;
315 340 }
316 341 ?>
317 - <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">
318 346 <?php
319 347 }
320 348 }
321 349
@@ -332,9 +360,9 @@
332 360 *
333 361 * @since 2.0.0
334 362 */
335 363 if ( did_action( 'elementor/loaded' ) && 'elementor' === $this->page_edit_with ) {
336 - 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
337 365 }
338 366
339 367 if ( BuilderFns::is_checkout() ) {
340 368 if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
@@ -355,24 +383,28 @@
355 383 *
356 384 * @return void
357 385 */
358 386 public function select2_ajax_posts_filter_autocomplete() {
359 -
387 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
388 + wp_send_json_error( [] );
389 + }
360 390 $query_per_page = 15;
361 391 $post_type = 'post';
362 392 $source_name = 'post_type';
363 - $paged = $_POST['page'] ?? 1;
364 -
393 + $paged = absint( $_POST['page'] ?? 1 );
365 394 if ( ! empty( $_POST['post_type'] ) ) {
395 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
366 396 $post_type = sanitize_text_field( $_POST['post_type'] );
367 397 }
368 398
369 399 if ( ! empty( $_POST['source_name'] ) ) {
400 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
370 401 $source_name = sanitize_text_field( $_POST['source_name'] );
371 402 }
372 403
404 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
373 405 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
374 - $results = $post_list = [];
406 + $results = $post_list = []; // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
375 407 switch ( $source_name ) {
376 408 case 'taxonomy':
377 409 $args = [
378 410 'hide_empty' => false,
@@ -381,9 +413,9 @@
381 413 'search' => $search,
382 414 'number' => '5',
383 415 ];
384 416
385 - if ( $post_type !== 'all' ) {
417 + if ( 'all' !== $post_type ) {
386 418 $args['taxonomy'] = $post_type;
387 419 }
388 420
389 421 $post_list = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -430,17 +462,22 @@
430 462 * @return void
431 463 */
432 464 public function select2_ajax_get_posts_value_titles() {
433 465
466 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
467 + wp_send_json_error( [] );
468 + }
469 +
434 470 if ( empty( $_POST['id'] ) ) {
435 471 wp_send_json_error( [] );
436 472 }
437 473
474 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
438 475 if ( empty( array_filter( $_POST['id'] ) ) ) {
439 476 wp_send_json_error( [] );
440 477 }
441 478 $ids = array_map( 'intval', $_POST['id'] );
442 - $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
443 480
444 481 switch ( $source_name ) {
445 482 case 'taxonomy':
446 483 $args = [
@@ -449,9 +486,11 @@
449 486 'order' => 'ASC',
450 487 'include' => implode( ',', $ids ),
451 488 ];
452 489
453 - 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
454 493 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
455 494 }
456 495
457 496 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -469,9 +508,9 @@
469 508 break;
470 509 default:
471 510 $post_info = get_posts(
472 511 [
473 - '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
474 513 'include' => implode( ',', $ids ),
475 514 ]
476 515 );
477 516 $response = wp_list_pluck( $post_info, 'post_title', 'ID' );
@@ -487,12 +526,12 @@
487 526
488 527 /**
489 528 * Ajax callback for rt-select2
490 529 *
491 - * @param $post_type
492 - * @param $limit
493 - * @param $search
494 - * @param $paged
530 + * @param string $post_type Post type.
531 + * @param int $limit Limit.
532 + * @param string $search Search.
533 + * @param int $paged Paged.
495 534 *
496 535 * @return array
497 536 */
498 537 public function get_query_data( $post_type = 'any', $limit = 10, $search = '', $paged = 1 ) {
@@ -529,10 +568,19 @@
529 568 if ( ! empty( $search ) ) {
530 569 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
531 570 }
532 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 +
533 581 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
534 - $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
535 583
536 584 if ( ! empty( $results ) ) {
537 585 foreach ( $results as $row ) {
538 586 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -563,10 +611,10 @@
563 611
564 612 $pro_widgets = [
565 613 [
566 614 'name' => 'rtsb-ajax-product-filters',
567 - 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
568 - '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' ),
569 617 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
570 618 'categories' => '[ "rtsb-shopbuilder" ]',
571 619 ],
572 620 ];