PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.1.1
ShopBuilder – WooCommerce Builder For Elementor v3.1.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 +42 -89 3.4.23.1.1 View file →
@@ -8,8 +8,9 @@
8 8 namespace RadiusTheme\SB\Controllers;
9 9
10 10 use RadiusTheme\SB\Helpers\Fns;
11 11 use RadiusTheme\SB\Helpers\BuilderFns;
12 +use RadiusTheme\SB\Models\GeneralList;
12 13 use RadiusTheme\SB\Models\ElementList;
13 14 use RadiusTheme\SB\Traits\SingletonTrait;
14 15 use RadiusTheme\SB\Controllers\Builder\BuilderCpt;
15 16 use RadiusTheme\SB\Controllers\Hooks\BuilderHooks;
@@ -54,8 +55,9 @@
54 55 */
55 56 private function __construct() {
56 57 $this->builder_page_id = BuilderFns::builder_page_id_by_page();
57 58 $this->page_edit_with = Fns::page_edit_with( $this->builder_page_id );
59 +
58 60 if ( ! is_admin() ) {
59 61 BuilderHooks::instance();
60 62 }
61 63
@@ -115,9 +117,9 @@
115 117 $builder_id = get_queried_object_id();
116 118 $id = Fns::wpml_object_id( $builder_id, BuilderFns::$post_type_tb, 'default' );
117 119 $type = BuilderFns::builder_type( $id );
118 120
119 - if ( $type && 'popup-builder' !== $type ) {
121 + if ( $type ) {
120 122 $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : '';
121 123 $builder_type = str_replace( [ 'My Account - ', 'Endpoint: ' ], '', $builder_type );
122 124 $categories['rtsb-shopbuilder'] = [
123 125 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ),
@@ -187,24 +189,45 @@
187 189 continue;
188 190 }
189 191
190 192 if ( ! empty( $element['category'] ) ) {
191 - try {
192 - $widget = false;
193 - $import = apply_filters( 'rtsb_import_status', false );
194 -
195 - if ( $this->should_register_widget( $element['category'], $import ) ) {
193 + $widget = false;
194 + $import = apply_filters( 'rtsb_import_status', false );
195 + switch ( $element['category'] ) {
196 + case 'product':
197 + if ( BuilderFns::is_product() || $import ) {
198 + $widget = new $element['base_class']();
199 + }
200 + break;
201 + case 'shop':
202 + if ( BuilderFns::is_archive() || BuilderFns::is_shop() || $import ) {
203 + $widget = new $element['base_class']();
204 + }
205 + break;
206 + case 'archive':
207 + if ( BuilderFns::is_archive() || $import ) {
208 + $widget = new $element['base_class']();
209 + }
210 + break;
211 + case 'cart':
212 + if ( BuilderFns::is_cart() || $import ) {
213 + $widget = new $element['base_class']();
214 + }
215 + break;
216 + case 'checkout':
217 + if ( BuilderFns::is_checkout() || $import ) {
218 + $widget = new $element['base_class']();
219 + }
220 + break;
221 + case 'general':
196 222 $widget = new $element['base_class']();
197 - }
223 + break;
224 + default:
225 + }
226 + $widget = apply_filters( 'rtsb/element/list/init/widgets', $widget, $element );
198 227
199 - $widget = apply_filters( 'rtsb/element/list/init/widgets', $widget, $element );
200 -
201 - if ( $widget && is_object( $widget ) ) {
202 - $widgets_manager->register( $widget );
203 - }
204 - } catch ( \Throwable $e ) {
205 - error_log( 'ShopBuilder widget error (' . $element['base_class'] . '): ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
206 - continue;
228 + if ( $widget && is_object( $widget ) ) {
229 + $widgets_manager->register( $widget );
207 230 }
208 231 }
209 232 }
210 233 }
@@ -209,48 +232,8 @@
209 232 }
210 233 }
211 234
212 235 /**
213 - * Determine whether a widget for the given category should be registered
214 - * in the current request context.
215 - *
216 - * @param string $category Element category.
217 - * @param bool $import Whether an import is in progress.
218 - *
219 - * @return bool
220 - */
221 - protected function should_register_widget( $category, $import ) {
222 - // On the frontend the Elementor Widgets Manager can initialise at an
223 - // unpredictable time — e.g. Elementor Pro's Theme Builder boots it on
224 - // template_redirect — when WooCommerce query conditionals such as
225 - // is_shop()/is_archive() are not yet reliable. Widget registration is
226 - // cached for the whole request, so gating it by those conditionals can
227 - // permanently skip ShopBuilder widgets, leaving the builder template to
228 - // render empty container shells. Register unconditionally on the
229 - // frontend; keep the per-category gate only for the editor widget panel.
230 - if ( ! is_admin() ) {
231 - return true;
232 - }
233 -
234 - switch ( $category ) {
235 - case 'product':
236 - return BuilderFns::is_product() || $import;
237 - case 'shop':
238 - return BuilderFns::is_archive() || BuilderFns::is_shop() || $import;
239 - case 'archive':
240 - return BuilderFns::is_archive() || $import;
241 - case 'cart':
242 - return BuilderFns::is_cart() || $import;
243 - case 'checkout':
244 - return BuilderFns::is_checkout() || $import;
245 - case 'general':
246 - return true;
247 - default:
248 - return false;
249 - }
250 - }
251 -
252 - /**
253 236 * Adding custom icons in Elementor
254 237 *
255 238 * @param array $tabs Tabs.
256 239 *
@@ -321,20 +304,12 @@
321 304
322 305 $parent_class = apply_filters( 'rtsb/builder/content/parent_class', [] );
323 306
324 307 if ( BuilderFns::is_product() ) {
325 - $product_id = Fns::get_prepared_product_id();
326 -
327 - // Ensure the WordPress global $product is a valid WC_Product before
328 - // wc_get_product_class() fires the `woocommerce_post_class` filter.
329 - // Some themes (e.g. Blocksy) read the global $product directly inside
330 - // that filter and call methods like get_type() on it, which throws a
331 - // fatal error when the global is still an unresolved string.
332 - $_product = Fns::get_product();
333 -
308 + $product_id = Fns::get_prepared_product_id();
334 309 $parent_class = wc_get_product_class( $parent_class, $product_id );
335 -
336 - if ( function_exists( 'rtwpvs' ) && $_product instanceof \WC_Product ) {
310 + if ( function_exists( 'rtwpvs' ) ) {
311 + $_product = Fns::get_product();
337 312 if ( $_product->is_type( 'variable' ) ) {
338 313 $parent_class[] = 'rtwpvs-product';
339 314 $beside_label = function_exists( 'rtwpvsp' ) && rtwpvs()->get_option( 'attribute_on_click_behavior' );
340 315 if ( $beside_label ) {
@@ -363,29 +338,8 @@
363 338 if ( BuilderFns::is_checkout() ) {
364 339 if ( ! apply_filters( 'rtsb/multi/step/checkout/widget', true ) ) {
365 340 return;
366 341 }
367 -
368 - $checkout = WC()->checkout();
369 -
370 - // Temporarily remove callbacks that Elementor checkout
371 - // handles via separate widgets to prevent duplicates.
372 - remove_action( 'woocommerce_before_checkout_form', [ Hooks\ActionHooks::class, 'woocommerce_checkout_login_form' ], 10 );
373 - remove_action( 'woocommerce_before_checkout_form', [ Hooks\ActionHooks::class, 'woocommerce_checkout_coupon_form' ], 10 );
374 - remove_action( 'woocommerce_before_checkout_form', [ Fns::class, 'woocommerce_output_all_notices' ], 10 );
375 -
376 - do_action( 'woocommerce_before_checkout_form', $checkout );
377 -
378 - // Restore callbacks for non-Elementor contexts.
379 - add_action( 'woocommerce_before_checkout_form', [ Hooks\ActionHooks::class, 'woocommerce_checkout_login_form' ], 10 );
380 - add_action( 'woocommerce_before_checkout_form', [ Hooks\ActionHooks::class, 'woocommerce_checkout_coupon_form' ], 10 );
381 - add_action( 'woocommerce_before_checkout_form', [ Fns::class, 'woocommerce_output_all_notices' ], 10 );
382 -
383 - // If checkout registration is disabled and not logged in, the user cannot checkout.
384 - if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
385 - echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'shopbuilder' ) ) );
386 - return;
387 - }
388 342 ?>
389 343 <!--
390 344 woocommerce-checkout added for fix issue with payment method ( Revolut Pay )
391 345 -->
@@ -417,9 +371,8 @@
417 371 }
418 372 ?>
419 373 </form>
420 374 <?php
421 - do_action( 'woocommerce_after_checkout_form', WC()->checkout() );
422 375 }
423 376 ?>
424 377 </div>
425 378 <!-- After Content end -->
@@ -457,9 +410,9 @@
457 410 $args = [
458 411 'hide_empty' => false,
459 412 'orderby' => 'name',
460 413 'order' => 'ASC',
461 - 'name__like' => $search,
414 + 'search' => $search,
462 415 'number' => '5',
463 416 ];
464 417
465 418 if ( 'all' !== $post_type ) {