PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.6.1
ShopBuilder – WooCommerce Builder For Elementor v2.6.1
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 +79 -36 2.1.02.6.1 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';
@@ -306,9 +321,14 @@
306 321
307 322 ?>
308 323 <!-- Before Content start -->
309 324 <div class="<?php echo esc_attr( implode( ' ', $parent_class ) ); ?>">
310 - <?php if ( BuilderFns::is_checkout() ) { ?>
325 + <?php
326 + if ( BuilderFns::is_checkout() ) {
327 + if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
328 + return;
329 + }
330 + ?>
311 331 <form name="checkout" method="post" class="rtsb-woocommerce-checkout checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
312 332 <?php
313 333 }
314 334 }
@@ -330,8 +350,11 @@
330 350 do_action( 'elementor/page_templates/header-footer/after_content' );
331 351 }
332 352
333 353 if ( BuilderFns::is_checkout() ) {
354 + if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
355 + return;
356 + }
334 357 ?>
335 358 </form>
336 359 <?php
337 360 }
@@ -346,22 +369,26 @@
346 369 *
347 370 * @return void
348 371 */
349 372 public function select2_ajax_posts_filter_autocomplete() {
350 -
373 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
374 + wp_send_json_error( [] );
375 + }
351 376 $query_per_page = 15;
352 377 $post_type = 'post';
353 378 $source_name = 'post_type';
354 - $paged = $_POST['page'] ?? 1;
355 -
379 + $paged = absint( $_POST['page'] ?? 1 );
356 380 if ( ! empty( $_POST['post_type'] ) ) {
381 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
357 382 $post_type = sanitize_text_field( $_POST['post_type'] );
358 383 }
359 384
360 385 if ( ! empty( $_POST['source_name'] ) ) {
386 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
361 387 $source_name = sanitize_text_field( $_POST['source_name'] );
362 388 }
363 389
390 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
364 391 $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : '';
365 392 $results = $post_list = [];
366 393 switch ( $source_name ) {
367 394 case 'taxonomy':
@@ -421,17 +448,22 @@
421 448 * @return void
422 449 */
423 450 public function select2_ajax_get_posts_value_titles() {
424 451
452 + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
453 + wp_send_json_error( [] );
454 + }
455 +
425 456 if ( empty( $_POST['id'] ) ) {
426 457 wp_send_json_error( [] );
427 458 }
428 459
460 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
429 461 if ( empty( array_filter( $_POST['id'] ) ) ) {
430 462 wp_send_json_error( [] );
431 463 }
432 464 $ids = array_map( 'intval', $_POST['id'] );
433 - $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
434 466
435 467 switch ( $source_name ) {
436 468 case 'taxonomy':
437 469 $args = [
@@ -440,9 +472,11 @@
440 472 'order' => 'ASC',
441 473 'include' => implode( ',', $ids ),
442 474 ];
443 475
476 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
444 477 if ( $_POST['post_type'] !== 'all' ) {
478 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
445 479 $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] );
446 480 }
447 481
448 482 $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' );
@@ -460,9 +494,9 @@
460 494 break;
461 495 default:
462 496 $post_info = get_posts(
463 497 [
464 - '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
465 499 'include' => implode( ',', $ids ),
466 500 ]
467 501 );
468 502 $response = wp_list_pluck( $post_info, 'post_title', 'ID' );
@@ -520,10 +554,19 @@
520 554 if ( ! empty( $search ) ) {
521 555 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
522 556 }
523 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 +
524 567 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
525 - $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
526 569
527 570 if ( ! empty( $results ) ) {
528 571 foreach ( $results as $row ) {
529 572 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -554,10 +597,10 @@
554 597
555 598 $pro_widgets = [
556 599 [
557 600 'name' => 'rtsb-ajax-product-filters',
558 - 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ),
559 - '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' ),
560 603 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element',
561 604 'categories' => '[ "rtsb-shopbuilder" ]',
562 605 ],
563 606 ];