PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.6.5
ShopBuilder – WooCommerce Builder For Elementor v2.6.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 -36 2.1.22.6.5 View file →
@@ -14,9 +14,8 @@
14 14 use RadiusTheme\SB\Controllers\Hooks\BuilderHooks;
15 15 use RadiusTheme\SB\Elementor\Controls\ImageSelectorControl;
16 16 use RadiusTheme\SB\Elementor\Controls\Select2AjaxControl;
17 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.
@@ -108,21 +104,29 @@
108 104 *
109 105 * @return void
110 106 */
111 107 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 - ];
108 + $categories = [];
109 + $builder_id = get_queried_object_id();
110 + $id = Fns::wpml_object_id( $builder_id, BuilderFns::$post_type_tb, 'default' );
111 + $type = BuilderFns::builder_type( $id );
123 112
124 - $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
113 + if ( $type ) {
114 + $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
115 + $builder_type = str_replace( [ 'My Account - ', 'Endpoint: ' ], '', $builder_type );
116 + $categories['rtsb-shopbuilder'] = [
117 + 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
118 + 'icon' => 'fa fa-plug',
119 + ];
120 + }
121 + if ( 'quick-view' !== $type ) {
122 + $categories['rtsb-shopbuilder-general'] = [
123 + 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
124 + 'icon' => 'fa fa-plug',
125 + ];
126 + }
127 + $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
128 +
125 129 $other_categories = $elements_manager->get_categories();
126 130 $categories = array_merge(
127 131 array_slice( $other_categories, 0, 1 ),
128 132 $categories,
@@ -128,10 +132,10 @@
128 132 $categories,
129 133 array_slice( $other_categories, 1 )
130 134 );
131 135
132 - $set_categories = function ( $categories ) {
133 - $this->categories = $categories;
136 + $set_categories = function ( $categories ) use ( $elements_manager ) {
137 + $elements_manager->categories = $categories;
134 138 };
135 139
136 140 $set_categories->call( $elements_manager, $categories );
137 141 }
@@ -223,9 +227,9 @@
223 227 *
224 228 * @return array
225 229 */
226 230 public function rtsb_icons( $tabs = [] ) {
227 - $custom_icons = $this->get_icons();
231 + $custom_icons = Fns::get_custom_icon_names();
228 232
229 233 $tabs['shopbuilder-icons'] = [
230 234 'name' => 'rtsb-fonts',
231 235 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
@@ -290,8 +294,18 @@
290 294
291 295 if ( BuilderFns::is_product() ) {
292 296 $product_id = Fns::get_prepared_product_id();
293 297 $parent_class = wc_get_product_class( $parent_class, $product_id );
298 + if ( function_exists( 'rtwpvs' ) ) {
299 + $_product = Fns::get_product();
300 + if ( $_product->is_type( 'variable' ) ) {
301 + $parent_class[] = 'rtwpvs-product';
302 + $beside_label = function_exists( 'rtwpvsp' ) && rtwpvs()->get_option( 'attribute_on_click_behavior' );
303 + if ( $beside_label ) {
304 + $parent_class[] = 'rtwpvs-selected-term-beside-label';
305 + }
306 + }
307 + }
294 308 }
295 309
296 310 if ( BuilderFns::is_shop() ) {
297 311 $parent_class[] = 'shop';
@@ -355,22 +369,26 @@
355 369 *
356 370 * @return void
357 371 */
358 372 public function select2_ajax_posts_filter_autocomplete() {
359 -
373 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
374 + wp_send_json_error( [] );
375 + }
360 376 $query_per_page = 15;
361 377 $post_type = 'post';
362 378 $source_name = 'post_type';
363 - $paged = $_POST['page'] ?? 1;
364 -
379 + $paged = absint( $_POST['page'] ?? 1 );
365 380 if ( ! empty( $_POST['post_type'] ) ) {
381 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
366 382 $post_type = sanitize_text_field( $_POST['post_type'] );
367 383 }
368 384
369 385 if ( ! empty( $_POST['source_name'] ) ) {
386 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
370 387 $source_name = sanitize_text_field( $_POST['source_name'] );
371 388 }
372 389
390 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
373 391 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
374 392 $results = $post_list = [];
375 393 switch ( $source_name ) {
376 394 case 'taxonomy':
@@ -430,17 +448,22 @@
430 448 * @return void
431 449 */
432 450 public function select2_ajax_get_posts_value_titles() {
433 451
452 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
453 + wp_send_json_error( [] );
454 + }
455 +
434 456 if ( empty( $_POST['id'] ) ) {
435 457 wp_send_json_error( [] );
436 458 }
437 459
460 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
438 461 if ( empty( array_filter( $_POST['id'] ) ) ) {
439 462 wp_send_json_error( [] );
440 463 }
441 464 $ids = array_map( 'intval', $_POST['id'] );
442 - $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : '';
465 + $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
443 466
444 467 switch ( $source_name ) {
445 468 case 'taxonomy':
446 469 $args = [
@@ -449,9 +472,11 @@
449 472 'order' => 'ASC',
450 473 'include' => implode( ',', $ids ),
451 474 ];
452 475
476 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
453 477 if ( $_POST['post_type'] !== 'all' ) {
478 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
454 479 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
455 480 }
456 481
457 482 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -469,9 +494,9 @@
469 494 break;
470 495 default:
471 496 $post_info = get_posts(
472 497 [
473 - 'post_type' => sanitize_text_field( $_POST['post_type'] ),
498 + 'post_type' => sanitize_text_field( $_POST['post_type'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
474 499 'include' => implode( ',', $ids ),
475 500 ]
476 501 );
477 502 $response = wp_list_pluck( $post_info, 'post_title', 'ID' );
@@ -529,10 +554,19 @@
529 554 if ( ! empty( $search ) ) {
530 555 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
531 556 }
532 557
558 + // Add a query for shop_coupon post-type to check 'show on frontend' meta.
559 + if ( 'shop_coupon' === $post_type ) {
560 + $where .= " AND {$wpdb->posts}.ID IN (
561 + SELECT post_id FROM {$wpdb->postmeta}
562 + WHERE meta_key = 'rtsb_show_on_frontend'
563 + AND meta_value = 'on'
564 + )";
565 + }
566 +
533 567 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
534 - $results = $wpdb->get_results( $query );
568 + $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
535 569
536 570 if ( ! empty( $results ) ) {
537 571 foreach ( $results as $row ) {
538 572 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -563,10 +597,10 @@
563 597
564 598 $pro_widgets = [
565 599 [
566 600 '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' ),
601 + 'title' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
602 + 'description' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
569 603 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
570 604 'categories' => '[ "rtsb-shopbuilder" ]',
571 605 ],
572 606 ];