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