PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.1.0
ShopBuilder – WooCommerce Builder For Elementor v3.1.0
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 +43 -25 2.2.23.1.0 View file →
@@ -8,14 +8,15 @@
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\GeneralList;
13 +use RadiusTheme\SB\Models\ElementList;
12 14 use RadiusTheme\SB\Traits\SingletonTrait;
13 15 use RadiusTheme\SB\Controllers\Builder\BuilderCpt;
14 16 use RadiusTheme\SB\Controllers\Hooks\BuilderHooks;
15 17 use RadiusTheme\SB\Elementor\Controls\ImageSelectorControl;
16 18 use RadiusTheme\SB\Elementor\Controls\Select2AjaxControl;
17 -use RadiusTheme\SB\Models\ElementList;
18 19
19 20 // Do not allow directly accessing this file.
20 21 if ( ! defined( 'ABSPATH' ) ) {
21 22 exit( 'This script cannot be accessed directly.' );
@@ -60,16 +61,13 @@
60 61 BuilderHooks::instance();
61 62 }
62 63
63 64 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 -
65 + if ( defined( 'ELEMENTOR_VERSION' ) ) {
66 + $this->elementor_init();
67 + $this->both_builder_frontend();
68 + add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] );
69 + }
72 70 // RT Select2 Ajax.
73 71 add_action( 'wp_ajax_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
74 72 add_action( 'wp_ajax_nopriv_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
75 73 // Select2 ajax save data.
@@ -92,13 +90,20 @@
92 90 *
93 91 * @return void
94 92 */
95 93 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' ] );
94 + add_action(
95 + 'init',
96 + function () {
97 + if ( Fns::should_load_elementor_scripts() ) {
98 + add_action( 'elementor/elements/categories_registered', [ $this, 'add_elementor_widget_categories' ] );
99 + add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] );
100 + add_action( 'elementor/controls/register', [ $this, 'init_controls' ] );
101 + add_filter( 'elementor/editor/localize_settings', [ $this, 'promotePremiumWidgets' ] );
102 + add_action( 'elementor/icons_manager/additional_tabs', [ $this, 'rtsb_icons' ] );
103 + }
104 + }
105 + );
101 106 }
102 107
103 108 /**
104 109 * Register Category
@@ -159,10 +164,14 @@
159 164
160 165 /**
161 166 * Init Widgets
162 167 *
163 - * Include widgets files and register them
168 + * Include widget files and register them
164 169 *
170 + * @param object $widgets_manager Widgets Manager.
171 + *
172 + * @return void
173 + *
165 174 * @since 1.0.0
166 175 */
167 176 public function init_widgets( $widgets_manager ) {
168 177
@@ -289,9 +298,9 @@
289 298 *
290 299 * @since 2.0.0
291 300 */
292 301 if ( did_action( 'elementor/loaded' ) && 'elementor' === $this->page_edit_with ) {
293 - do_action( 'elementor/page_templates/header-footer/before_content' );
302 + do_action( 'elementor/page_templates/header-footer/before_content' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
294 303 }
295 304
296 305 $parent_class = apply_filters( 'rtsb/builder/content/parent_class', [] );
297 306
@@ -349,9 +358,9 @@
349 358 *
350 359 * @since 2.0.0
351 360 */
352 361 if ( did_action( 'elementor/loaded' ) && 'elementor' === $this->page_edit_with ) {
353 - do_action( 'elementor/page_templates/header-footer/after_content' );
362 + do_action( 'elementor/page_templates/header-footer/after_content' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
354 363 }
355 364
356 365 if ( BuilderFns::is_checkout() ) {
357 366 if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
@@ -391,9 +400,9 @@
391 400 }
392 401
393 402 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
394 403 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
395 - $results = $post_list = [];
404 + $results = $post_list = []; // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
396 405 switch ( $source_name ) {
397 406 case 'taxonomy':
398 407 $args = [
399 408 'hide_empty' => false,
@@ -402,9 +411,9 @@
402 411 'search' => $search,
403 412 'number' => '5',
404 413 ];
405 414
406 - if ( $post_type !== 'all' ) {
415 + if ( 'all' !== $post_type ) {
407 416 $args['taxonomy'] = $post_type;
408 417 }
409 418
410 419 $post_list = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -476,10 +485,10 @@
476 485 'include' => implode( ',', $ids ),
477 486 ];
478 487
479 488 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
480 - if ( $_POST['post_type'] !== 'all' ) {
481 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
489 + if ( 'all' !== $_POST['post_type'] ) {
490 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
482 491 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
483 492 }
484 493
485 494 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -515,12 +524,12 @@
515 524
516 525 /**
517 526 * Ajax callback for rt-select2
518 527 *
519 - * @param $post_type
520 - * @param $limit
521 - * @param $search
522 - * @param $paged
528 + * @param string $post_type Post type.
529 + * @param int $limit Limit.
530 + * @param string $search Search.
531 + * @param int $paged Paged.
523 532 *
524 533 * @return array
525 534 */
526 535 public function get_query_data( $post_type = 'any', $limit = 10, $search = '', $paged = 1 ) {
@@ -555,8 +564,17 @@
555 564 }
556 565
557 566 if ( ! empty( $search ) ) {
558 567 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
568 + }
569 +
570 + // Add a query for shop_coupon post-type to check 'show on frontend' meta.
571 + if ( 'shop_coupon' === $post_type ) {
572 + $where .= " AND {$wpdb->posts}.ID IN (
573 + SELECT post_id FROM {$wpdb->postmeta}
574 + WHERE meta_key = 'rtsb_show_on_frontend'
575 + AND meta_value = 'on'
576 + )";
559 577 }
560 578
561 579 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
562 580 $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching