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