PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.0
ShopBuilder – WooCommerce Builder For Elementor v2.0.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 +41 -100 2.1.82.0.0 View file →
@@ -6,8 +6,9 @@
6 6 */
7 7
8 8 namespace RadiusTheme\SB\Controllers;
9 9
10 +use Elementor\Plugin;
10 11 use RadiusTheme\SB\Helpers\Fns;
11 12 use RadiusTheme\SB\Helpers\BuilderFns;
12 13 use RadiusTheme\SB\Traits\SingletonTrait;
13 14 use RadiusTheme\SB\Controllers\Builder\BuilderCpt;
@@ -25,13 +26,8 @@
25 26 * Builder Controller
26 27 */
27 28 class BuilderController {
28 29 /**
29 - * @var array
30 - */
31 - private static $cache = [];
32 -
33 - /**
34 30 * Builder page id.
35 31 *
36 32 * @var integer
37 33 */
@@ -61,14 +57,11 @@
61 57 }
62 58
63 59 BuilderCpt::instance();
64 60
65 - $this->elementor_init();
66 - $this->both_builder_frontend();
67 -
68 - // add_action( 'elementor/init', [ $this, 'elementor_init' ] );
61 + add_action( 'elementor/init', [ $this, 'elementor_init' ] );
69 62 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] );
70 - // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
63 + add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 );
71 64
72 65 // RT Select2 Ajax.
73 66 add_action( 'wp_ajax_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
74 67 add_action( 'wp_ajax_nopriv_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] );
@@ -107,24 +100,20 @@
107 100 *
108 101 * @return void
109 102 */
110 103 public function add_elementor_widget_categories( $elements_manager ) {
111 - $categories = [];
112 - $type = BuilderFns::builder_type( get_the_ID() );
113 - if ( $type ) {
114 - $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
115 - $builder_type = str_replace( 'My Account - ', '', $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 - }
104 + $type = BuilderFns::builder_type( get_the_ID() );
105 + $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
106 + $builder_type = str_replace( 'My Account - ', '', $builder_type );
107 + $categories['rtsb-shopbuilder'] = [
108 + 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
109 + 'icon' => 'fa fa-plug',
110 + ];
111 + $categories['rtsb-shopbuilder-general'] = [
112 + 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ),
113 + 'icon' => 'fa fa-plug',
114 + ];
115 +
127 116 $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories );
128 117 $other_categories = $elements_manager->get_categories();
129 118 $categories = array_merge(
130 119 array_slice( $other_categories, 0, 1 ),
@@ -160,11 +149,16 @@
160 149 *
161 150 * @since 1.0.0
162 151 */
163 152 public function init_widgets( $widgets_manager ) {
153 + $product = Fns::get_product();
164 154
165 - $get_list = ElementList::instance()->get_list( true, 'active' );
166 - foreach ( $get_list as $element ) {
155 + // TODO: Need to remove below condition and make compitability in each widgets.
156 + if ( ! $product ) {
157 + return;
158 + }
159 +
160 + foreach ( ElementList::instance()->get_list( true, 'active' ) as $element ) {
167 161 if ( isset( $element['active'] ) && 'on' !== $element['active'] ) {
168 162 continue;
169 163 }
170 164
@@ -226,10 +220,23 @@
226 220 *
227 221 * @return array
228 222 */
229 223 public function rtsb_icons( $tabs = [] ) {
230 - $custom_icons = $this->get_icons();
224 + $fonts = rtsb()->get_assets_uri( 'fonts/rtsb-icons.json' );
231 225
226 + $response = wp_remote_get( $fonts );
227 +
228 + if ( is_wp_error( $response ) ) {
229 + return $tabs;
230 + }
231 +
232 + $icons_json = wp_remote_retrieve_body( $response );
233 + $custom_icons = json_decode( $icons_json, true );
234 +
235 + if ( null === $custom_icons ) {
236 + return $tabs;
237 + }
238 +
232 239 $tabs['shopbuilder-icons'] = [
233 240 'name' => 'rtsb-fonts',
234 241 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ),
235 242 'labelIcon' => 'fab fa-elementor',
@@ -293,18 +300,8 @@
293 300
294 301 if ( BuilderFns::is_product() ) {
295 302 $product_id = Fns::get_prepared_product_id();
296 303 $parent_class = wc_get_product_class( $parent_class, $product_id );
297 - if ( function_exists( 'rtwpvs' ) ) {
298 - $_product = Fns::get_product();
299 - if ( $_product->is_type( 'variable' ) ) {
300 - $parent_class[] = 'rtwpvs-product';
301 - $beside_label = function_exists( 'rtwpvsp' ) && rtwpvs()->get_option( 'attribute_on_click_behavior' );
302 - if ( $beside_label ) {
303 - $parent_class[] = 'rtwpvs-selected-term-beside-label';
304 - }
305 - }
306 - }
307 304 }
308 305
309 306 if ( BuilderFns::is_shop() ) {
310 307 $parent_class[] = 'shop';
@@ -320,14 +317,9 @@
320 317
321 318 ?>
322 319 <!-- Before Content start -->
323 320 <div class="<?php echo esc_attr( implode( ' ', $parent_class ) ); ?>">
324 - <?php
325 - if ( BuilderFns::is_checkout() ) {
326 - if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
327 - return;
328 - }
329 - ?>
321 + <?php if ( BuilderFns::is_checkout() ) { ?>
330 322 <form name="checkout" method="post" class="rtsb-woocommerce-checkout checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
331 323 <?php
332 324 }
333 325 }
@@ -349,11 +341,8 @@
349 341 do_action( 'elementor/page_templates/header-footer/after_content' );
350 342 }
351 343
352 344 if ( BuilderFns::is_checkout() ) {
353 - if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
354 - return;
355 - }
356 345 ?>
357 346 </form>
358 347 <?php
359 348 }
@@ -368,15 +357,14 @@
368 357 *
369 358 * @return void
370 359 */
371 360 public function select2_ajax_posts_filter_autocomplete() {
372 - if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
373 - wp_send_json_error( [] );
374 - }
361 +
375 362 $query_per_page = 15;
376 363 $post_type = 'post';
377 364 $source_name = 'post_type';
378 - $paged = absint( $_POST['page'] ?? 1 );
365 + $paged = $_POST['page'] ?? 1;
366 +
379 367 if ( ! empty( $_POST['post_type'] ) ) {
380 368 $post_type = sanitize_text_field( $_POST['post_type'] );
381 369 }
382 370
@@ -444,12 +432,8 @@
444 432 * @return void
445 433 */
446 434 public function select2_ajax_get_posts_value_titles() {
447 435
448 - if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
449 - wp_send_json_error( [] );
450 - }
451 -
452 436 if ( empty( $_POST['id'] ) ) {
453 437 wp_send_json_error( [] );
454 438 }
455 439
@@ -548,9 +532,9 @@
548 532 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' );
549 533 }
550 534
551 535 $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}";
552 - $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
536 + $results = $wpdb->get_results( $query );
553 537
554 538 if ( ! empty( $results ) ) {
555 539 foreach ( $results as $row ) {
556 540 $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']';
@@ -595,49 +579,6 @@
595 579 }
596 580 }
597 581
598 582 return $config;
599 - }
600 -
601 - /**
602 - * Get Icons.
603 - *
604 - * @return array
605 - */
606 - public function get_icons() {
607 - return [
608 - 'heart-empty',
609 - 'heart',
610 - 'eye',
611 - 'exchange',
612 - 'plus',
613 - 'minus',
614 - 'avatar',
615 - 'pay',
616 - 'share',
617 - 'clock',
618 - 'check-alt',
619 - 'check',
620 - 'delete',
621 - 'marker',
622 - 'list',
623 - 'list-2',
624 - 'power',
625 - 'cart',
626 - 'cart-2',
627 - 'cart-3',
628 - 'downloads',
629 - 'zoom',
630 - 'user-edit',
631 - 'grid',
632 - 'filter',
633 - 'billing',
634 - 'login',
635 - 'payment',
636 - 'search',
637 - 'edit',
638 - 'coupon',
639 - 'arrows-cw',
640 - 'trash-empty',
641 - ];
642 583 }
643 584 }