PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.4.2
ShopBuilder – WooCommerce Builder For Elementor v2.4.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 +56 -28 2.1.22.4.2 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.' );
@@ -70,13 +69,13 @@
70 69 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] );
71 70 // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
72 71
73 72 // 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' ] );
73 + add_action( 'wp_ajax_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
74 + add_action( 'wp_ajax_nopriv_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
76 75 // 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' ] );
76 + add_action( 'wp_ajax_rtsb_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
77 + add_action( 'wp_ajax_nopriv_rtsb_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] );
79 78 }
80 79
81 80 /**
82 81 * Apply for frontend.
@@ -108,21 +107,29 @@
108 107 *
109 108 * @return void
110 109 */
111 110 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 - ];
111 + $categories = [];
112 + $builder_id = get_queried_object_id();
113 + $id = Fns::wpml_object_id( $builder_id, BuilderFns::$post_type_tb, 'default' );
114 + $type = BuilderFns::builder_type( $id );
123 115
124 - $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
116 + if ( $type ) {
117 + $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
118 + $builder_type = str_replace( [ 'My Account - ', 'Endpoint: ' ], '', $builder_type );
119 + $categories['rtsb-shopbuilder'] = [
120 + 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
121 + 'icon' => 'fa fa-plug',
122 + ];
123 + }
124 + if ( 'quick-view' !== $type ) {
125 + $categories['rtsb-shopbuilder-general'] = [
126 + 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
127 + 'icon' => 'fa fa-plug',
128 + ];
129 + }
130 + $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
131 +
125 132 $other_categories = $elements_manager->get_categories();
126 133 $categories = array_merge(
127 134 array_slice( $other_categories, 0, 1 ),
128 135 $categories,
@@ -128,10 +135,10 @@
128 135 $categories,
129 136 array_slice( $other_categories, 1 )
130 137 );
131 138
132 - $set_categories = function ( $categories ) {
133 - $this->categories = $categories;
139 + $set_categories = function ( $categories ) use ( $elements_manager ) {
140 + $elements_manager->categories = $categories;
134 141 };
135 142
136 143 $set_categories->call( $elements_manager, $categories );
137 144 }
@@ -223,9 +230,9 @@
223 230 *
224 231 * @return array
225 232 */
226 233 public function rtsb_icons( $tabs = [] ) {
227 - $custom_icons = $this->get_icons();
234 + $custom_icons = Fns::get_custom_icon_names();
228 235
229 236 $tabs['shopbuilder-icons'] = [
230 237 'name' => 'rtsb-fonts',
231 238 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
@@ -290,8 +297,18 @@
290 297
291 298 if ( BuilderFns::is_product() ) {
292 299 $product_id = Fns::get_prepared_product_id();
293 300 $parent_class = wc_get_product_class( $parent_class, $product_id );
301 + if ( function_exists( 'rtwpvs' ) ) {
302 + $_product = Fns::get_product();
303 + if ( $_product->is_type( 'variable' ) ) {
304 + $parent_class[] = 'rtwpvs-product';
305 + $beside_label = function_exists( 'rtwpvsp' ) && rtwpvs()->get_option( 'attribute_on_click_behavior' );
306 + if ( $beside_label ) {
307 + $parent_class[] = 'rtwpvs-selected-term-beside-label';
308 + }
309 + }
310 + }
294 311 }
295 312
296 313 if ( BuilderFns::is_shop() ) {
297 314 $parent_class[] = 'shop';
@@ -355,22 +372,26 @@
355 372 *
356 373 * @return void
357 374 */
358 375 public function select2_ajax_posts_filter_autocomplete() {
359 -
376 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
377 + wp_send_json_error( [] );
378 + }
360 379 $query_per_page = 15;
361 380 $post_type = 'post';
362 381 $source_name = 'post_type';
363 - $paged = $_POST['page'] ?? 1;
364 -
382 + $paged = absint( $_POST['page'] ?? 1 );
365 383 if ( ! empty( $_POST['post_type'] ) ) {
384 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
366 385 $post_type = sanitize_text_field( $_POST['post_type'] );
367 386 }
368 387
369 388 if ( ! empty( $_POST['source_name'] ) ) {
389 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
370 390 $source_name = sanitize_text_field( $_POST['source_name'] );
371 391 }
372 392
393 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
373 394 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
374 395 $results = $post_list = [];
375 396 switch ( $source_name ) {
376 397 case 'taxonomy':
@@ -430,17 +451,22 @@
430 451 * @return void
431 452 */
432 453 public function select2_ajax_get_posts_value_titles() {
433 454
455 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
456 + wp_send_json_error( [] );
457 + }
458 +
434 459 if ( empty( $_POST['id'] ) ) {
435 460 wp_send_json_error( [] );
436 461 }
437 462
463 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
438 464 if ( empty( array_filter( $_POST['id'] ) ) ) {
439 465 wp_send_json_error( [] );
440 466 }
441 467 $ids = array_map( 'intval', $_POST['id'] );
442 - $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : '';
468 + $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
443 469
444 470 switch ( $source_name ) {
445 471 case 'taxonomy':
446 472 $args = [
@@ -449,9 +475,11 @@
449 475 'order' => 'ASC',
450 476 'include' => implode( ',', $ids ),
451 477 ];
452 478
479 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
453 480 if ( $_POST['post_type'] !== 'all' ) {
481 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
454 482 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
455 483 }
456 484
457 485 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -469,9 +497,9 @@
469 497 break;
470 498 default:
471 499 $post_info = get_posts(
472 500 [
473 - 'post_type' => sanitize_text_field( $_POST['post_type'] ),
501 + 'post_type' => sanitize_text_field( $_POST['post_type'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
474 502 'include' => implode( ',', $ids ),
475 503 ]
476 504 );
477 505 $response = wp_list_pluck( $post_info, 'post_title', 'ID' );
@@ -530,9 +558,9 @@
530 558 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
531 559 }
532 560
533 561 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
534 - $results = $wpdb->get_results( $query );
562 + $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
535 563
536 564 if ( ! empty( $results ) ) {
537 565 foreach ( $results as $row ) {
538 566 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -563,10 +591,10 @@
563 591
564 592 $pro_widgets = [
565 593 [
566 594 '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' ),
595 + 'title' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
596 + 'description' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ),
569 597 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
570 598 'categories' => '[ "rtsb-shopbuilder" ]',
571 599 ],
572 600 ];