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 -35 2.1.32.6.5 View file →
@@ -60,22 +60,19 @@
60 60 BuilderHooks::instance();
61 61 }
62 62
63 63 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 -
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 + }
72 69 // 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' ] );
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' ] );
75 72 // 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' ] );
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' ] );
78 75 }
79 76
80 77 /**
81 78 * Apply for frontend.
@@ -107,21 +104,29 @@
107 104 *
108 105 * @return void
109 106 */
110 107 public function add_elementor_widget_categories( $elements_manager ) {
111 - $type = BuilderFns::builder_type( get_the_ID() );
112 - $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
113 - $builder_type = str_replace( 'My Account - ', '', $builder_type );
114 - $categories['rtsb-shopbuilder'] = [
115 - 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
116 - 'icon' => 'fa fa-plug',
117 - ];
118 - $categories['rtsb-shopbuilder-general'] = [
119 - 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
120 - 'icon' => 'fa fa-plug',
121 - ];
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 );
122 112
123 - $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 +
124 129 $other_categories = $elements_manager->get_categories();
125 130 $categories = array_merge(
126 131 array_slice( $other_categories, 0, 1 ),
127 132 $categories,
@@ -127,10 +132,10 @@
127 132 $categories,
128 133 array_slice( $other_categories, 1 )
129 134 );
130 135
131 - $set_categories = function ( $categories ) {
132 - $this->categories = $categories;
136 + $set_categories = function ( $categories ) use ( $elements_manager ) {
137 + $elements_manager->categories = $categories;
133 138 };
134 139
135 140 $set_categories->call( $elements_manager, $categories );
136 141 }
@@ -222,9 +227,9 @@
222 227 *
223 228 * @return array
224 229 */
225 230 public function rtsb_icons( $tabs = [] ) {
226 - $custom_icons = $this->get_icons();
231 + $custom_icons = Fns::get_custom_icon_names();
227 232
228 233 $tabs['shopbuilder-icons'] = [
229 234 'name' => 'rtsb-fonts',
230 235 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
@@ -289,8 +294,18 @@
289 294
290 295 if ( BuilderFns::is_product() ) {
291 296 $product_id = Fns::get_prepared_product_id();
292 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 + }
293 308 }
294 309
295 310 if ( BuilderFns::is_shop() ) {
296 311 $parent_class[] = 'shop';
@@ -354,22 +369,26 @@
354 369 *
355 370 * @return void
356 371 */
357 372 public function select2_ajax_posts_filter_autocomplete() {
358 -
373 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
374 + wp_send_json_error( [] );
375 + }
359 376 $query_per_page = 15;
360 377 $post_type = 'post';
361 378 $source_name = 'post_type';
362 - $paged = $_POST['page'] ?? 1;
363 -
379 + $paged = absint( $_POST['page'] ?? 1 );
364 380 if ( ! empty( $_POST['post_type'] ) ) {
381 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
365 382 $post_type = sanitize_text_field( $_POST['post_type'] );
366 383 }
367 384
368 385 if ( ! empty( $_POST['source_name'] ) ) {
386 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
369 387 $source_name = sanitize_text_field( $_POST['source_name'] );
370 388 }
371 389
390 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
372 391 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
373 392 $results = $post_list = [];
374 393 switch ( $source_name ) {
375 394 case 'taxonomy':
@@ -429,17 +448,22 @@
429 448 * @return void
430 449 */
431 450 public function select2_ajax_get_posts_value_titles() {
432 451
452 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
453 + wp_send_json_error( [] );
454 + }
455 +
433 456 if ( empty( $_POST['id'] ) ) {
434 457 wp_send_json_error( [] );
435 458 }
436 459
460 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
437 461 if ( empty( array_filter( $_POST['id'] ) ) ) {
438 462 wp_send_json_error( [] );
439 463 }
440 464 $ids = array_map( 'intval', $_POST['id'] );
441 - $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
442 466
443 467 switch ( $source_name ) {
444 468 case 'taxonomy':
445 469 $args = [
@@ -448,9 +472,11 @@
448 472 'order' => 'ASC',
449 473 'include' => implode( ',', $ids ),
450 474 ];
451 475
476 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
452 477 if ( $_POST['post_type'] !== 'all' ) {
478 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
453 479 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
454 480 }
455 481
456 482 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -468,9 +494,9 @@
468 494 break;
469 495 default:
470 496 $post_info = get_posts(
471 497 [
472 - '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
473 499 'include' => implode( ',', $ids ),
474 500 ]
475 501 );
476 502 $response = wp_list_pluck( $post_info, 'post_title', 'ID' );
@@ -528,10 +554,19 @@
528 554 if ( ! empty( $search ) ) {
529 555 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
530 556 }
531 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 +
532 567 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
533 - $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
534 569
535 570 if ( ! empty( $results ) ) {
536 571 foreach ( $results as $row ) {
537 572 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -562,10 +597,10 @@
562 597
563 598 $pro_widgets = [
564 599 [
565 600 'name' => 'rtsb-ajax-product-filters',
566 - 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
567 - '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' ),
568 603 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
569 604 'categories' => '[ "rtsb-shopbuilder" ]',
570 605 ],
571 606 ];