PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.4.0
ShopBuilder – WooCommerce Builder For Elementor v3.4.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 +43 -33 3.3.03.4.0 View file →
@@ -190,39 +190,13 @@
190 190 if ( ! empty( $element['category'] ) ) {
191 191 try {
192 192 $widget = false;
193 193 $import = apply_filters( 'rtsb_import_status', false );
194 - switch ( $element['category'] ) {
195 - case 'product':
196 - if ( BuilderFns::is_product() || $import ) {
197 - $widget = new $element['base_class']();
198 - }
199 - break;
200 - case 'shop':
201 - if ( BuilderFns::is_archive() || BuilderFns::is_shop() || $import ) {
202 - $widget = new $element['base_class']();
203 - }
204 - break;
205 - case 'archive':
206 - if ( BuilderFns::is_archive() || $import ) {
207 - $widget = new $element['base_class']();
208 - }
209 - break;
210 - case 'cart':
211 - if ( BuilderFns::is_cart() || $import ) {
212 - $widget = new $element['base_class']();
213 - }
214 - break;
215 - case 'checkout':
216 - if ( BuilderFns::is_checkout() || $import ) {
217 - $widget = new $element['base_class']();
218 - }
219 - break;
220 - case 'general':
221 - $widget = new $element['base_class']();
222 - break;
223 - default:
194 +
195 + if ( $this->should_register_widget( $element['category'], $import ) ) {
196 + $widget = new $element['base_class']();
224 197 }
198 +
225 199 $widget = apply_filters( 'rtsb/element/list/init/widgets', $widget, $element );
226 200
227 201 if ( $widget && is_object( $widget ) ) {
228 202 $widgets_manager->register( $widget );
@@ -235,8 +209,36 @@
235 209 }
236 210 }
237 211
238 212 /**
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 + switch ( $category ) {
223 + case 'product':
224 + return BuilderFns::is_product() || $import;
225 + case 'shop':
226 + return BuilderFns::is_archive() || BuilderFns::is_shop() || $import;
227 + case 'archive':
228 + return BuilderFns::is_archive() || $import;
229 + case 'cart':
230 + return BuilderFns::is_cart() || $import;
231 + case 'checkout':
232 + return BuilderFns::is_checkout() || $import;
233 + case 'general':
234 + return true;
235 + default:
236 + return false;
237 + }
238 + }
239 +
240 + /**
239 241 * Adding custom icons in Elementor
240 242 *
241 243 * @param array $tabs Tabs.
242 244 *
@@ -307,12 +309,20 @@
307 309
308 310 $parent_class = apply_filters( 'rtsb/builder/content/parent_class', [] );
309 311
310 312 if ( BuilderFns::is_product() ) {
311 - $product_id = Fns::get_prepared_product_id();
313 + $product_id = Fns::get_prepared_product_id();
314 +
315 + // Ensure the WordPress global $product is a valid WC_Product before
316 + // wc_get_product_class() fires the `woocommerce_post_class` filter.
317 + // Some themes (e.g. Blocksy) read the global $product directly inside
318 + // that filter and call methods like get_type() on it, which throws a
319 + // fatal error when the global is still an unresolved string.
320 + $_product = Fns::get_product();
321 +
312 322 $parent_class = wc_get_product_class( $parent_class, $product_id );
313 - if ( function_exists( 'rtwpvs' ) ) {
314 - $_product = Fns::get_product();
323 +
324 + if ( function_exists( 'rtwpvs' ) && $_product instanceof \WC_Product ) {
315 325 if ( $_product->is_type( 'variable' ) ) {
316 326 $parent_class[] = 'rtwpvs-product';
317 327 $beside_label = function_exists( 'rtwpvsp' ) && rtwpvs()->get_option( 'attribute_on_click_behavior' );
318 328 if ( $beside_label ) {