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 +70 -40 2.1.83.2.2 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
@@ -108,12 +112,15 @@
108 112 * @return void
109 113 */
110 114 public function add_elementor_widget_categories( $elements_manager ) {
111 115 $categories = [];
112 - $type = BuilderFns::builder_type( get_the_ID() );
113 - if ( $type ) {
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 );
119 +
120 + if ( $type && 'popup-builder' !== $type ) {
114 121 $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
115 - $builder_type = str_replace( 'My Account - ', '', $builder_type );
122 + $builder_type = str_replace( [ 'My Account - ', 'Endpoint: ' ], '', $builder_type );
116 123 $categories['rtsb-shopbuilder'] = [
117 124 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
118 125 'icon' => 'fa fa-plug',
119 126 ];
@@ -123,9 +130,10 @@
123 130 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
124 131 'icon' => 'fa fa-plug',
125 132 ];
126 133 }
127 - $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
134 + $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
135 +
128 136 $other_categories = $elements_manager->get_categories();
129 137 $categories = array_merge(
130 138 array_slice( $other_categories, 0, 1 ),
131 139 $categories,
@@ -131,10 +139,10 @@
131 139 $categories,
132 140 array_slice( $other_categories, 1 )
133 141 );
134 142
135 - $set_categories = function ( $categories ) {
136 - $this->categories = $categories;
143 + $set_categories = function ( $categories ) use ( $elements_manager ) {
144 + $elements_manager->categories = $categories;
137 145 };
138 146
139 147 $set_categories->call( $elements_manager, $categories );
140 148 }
@@ -155,10 +163,14 @@
155 163
156 164 /**
157 165 * Init Widgets
158 166 *
159 - * Include widgets files and register them
167 + * Include widget files and register them
160 168 *
169 + * @param object $widgets_manager Widgets Manager.
170 + *
171 + * @return void
172 + *
161 173 * @since 1.0.0
162 174 */
163 175 public function init_widgets( $widgets_manager ) {
164 176
@@ -226,9 +238,9 @@
226 238 *
227 239 * @return array
228 240 */
229 241 public function rtsb_icons( $tabs = [] ) {
230 - $custom_icons = $this->get_icons();
242 + $custom_icons = Fns::get_custom_icon_names();
231 243
232 244 $tabs['shopbuilder-icons'] = [
233 245 'name' => 'rtsb-fonts',
234 246 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
@@ -285,9 +297,9 @@
285 297 *
286 298 * @since 2.0.0
287 299 */
288 300 if ( did_action( 'elementor/loaded' ) && 'elementor' === $this->page_edit_with ) {
289 - 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
290 302 }
291 303
292 304 $parent_class = apply_filters( 'rtsb/builder/content/parent_class', [] );
293 305
@@ -326,9 +338,12 @@
326 338 if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
327 339 return;
328 340 }
329 341 ?>
330 - <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">
331 346 <?php
332 347 }
333 348 }
334 349
@@ -345,9 +360,9 @@
345 360 *
346 361 * @since 2.0.0
347 362 */
348 363 if ( did_action( 'elementor/loaded' ) && 'elementor' === $this->page_edit_with ) {
349 - 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
350 365 }
351 366
352 367 if ( BuilderFns::is_checkout() ) {
353 368 if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
@@ -376,17 +391,20 @@
376 391 $post_type = 'post';
377 392 $source_name = 'post_type';
378 393 $paged = absint( $_POST['page'] ?? 1 );
379 394 if ( ! empty( $_POST['post_type'] ) ) {
395 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
380 396 $post_type = sanitize_text_field( $_POST['post_type'] );
381 397 }
382 398
383 399 if ( ! empty( $_POST['source_name'] ) ) {
400 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
384 401 $source_name = sanitize_text_field( $_POST['source_name'] );
385 402 }
386 403
404 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
387 405 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
388 - $results = $post_list = [];
406 + $results = $post_list = []; // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
389 407 switch ( $source_name ) {
390 408 case 'taxonomy':
391 409 $args = [
392 410 'hide_empty' => false,
@@ -395,9 +413,9 @@
395 413 'search' => $search,
396 414 'number' => '5',
397 415 ];
398 416
399 - if ( $post_type !== 'all' ) {
417 + if ( 'all' !== $post_type ) {
400 418 $args['taxonomy'] = $post_type;
401 419 }
402 420
403 421 $post_list = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -452,13 +470,14 @@
452 470 if ( empty( $_POST['id'] ) ) {
453 471 wp_send_json_error( [] );
454 472 }
455 473
474 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
456 475 if ( empty( array_filter( $_POST['id'] ) ) ) {
457 476 wp_send_json_error( [] );
458 477 }
459 478 $ids = array_map( 'intval', $_POST['id'] );
460 - $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
461 480
462 481 switch ( $source_name ) {
463 482 case 'taxonomy':
464 483 $args = [
@@ -467,9 +486,11 @@
467 486 'order' => 'ASC',
468 487 'include' => implode( ',', $ids ),
469 488 ];
470 489
471 - 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
472 493 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
473 494 }
474 495
475 496 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -487,9 +508,9 @@
487 508 break;
488 509 default:
489 510 $post_info = get_posts(
490 511 [
491 - '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
492 513 'include' => implode( ',', $ids ),
493 514 ]
494 515 );
495 516 $response = wp_list_pluck( $post_info, 'post_title', 'ID' );
@@ -505,12 +526,12 @@
505 526
506 527 /**
507 528 * Ajax callback for rt-select2
508 529 *
509 - * @param $post_type
510 - * @param $limit
511 - * @param $search
512 - * @param $paged
530 + * @param string $post_type Post type.
531 + * @param int $limit Limit.
532 + * @param string $search Search.
533 + * @param int $paged Paged.
513 534 *
514 535 * @return array
515 536 */
516 537 public function get_query_data( $post_type = 'any', $limit = 10, $search = '', $paged = 1 ) {
@@ -547,8 +568,17 @@
547 568 if ( ! empty( $search ) ) {
548 569 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
549 570 }
550 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 +
551 581 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
552 582 $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
553 583
554 584 if ( ! empty( $results ) ) {
@@ -581,10 +611,10 @@
581 611
582 612 $pro_widgets = [
583 613 [
584 614 'name' => 'rtsb-ajax-product-filters',
585 - 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
586 - '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' ),
587 617 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
588 618 'categories' => '[ "rtsb-shopbuilder" ]',
589 619 ],
590 620 ];