module_id ?? ''; if ( \Elementor\Plugin::$instance->preview->is_preview_mode() && Merchant_Modules::is_module_active( $module_id ) ) { return true; } // Todo: check if required for other modules as well if ( ! \Elementor\Plugin::$instance->preview->is_preview_mode() && Merchant_Modules::is_module_active( $module_id ) && ( $module_id === 'wishlist' ) ) { global $post; if ( empty( $post ) ) { return $enqueue; } $elementor_data = get_post_meta( $post->ID, '_elementor_data', true ); if ( $elementor_data && ( strpos( $elementor_data, 'woocommerce-products' ) !== false || strpos( $elementor_data, 'wc-products' ) !== false ) ) { return true; } } return $enqueue; } /** * Determines whether to enqueue scripts for modules. * * @param $enqueue * @param $module * * @return mixed|true */ public function should_enqueue_scripts( $enqueue, $module ) { $module_id = $module->module_id ?? ''; if ( \Elementor\Plugin::$instance->preview->is_preview_mode() && Merchant_Modules::is_module_active( $module_id ) ) { return true; } // Todo: check if required for other modules as well if ( ! \Elementor\Plugin::$instance->preview->is_preview_mode() && Merchant_Modules::is_module_active( $module_id ) && ( $module_id === 'wishlist' ) ) { global $post; if ( empty( $post ) ) { return $enqueue; } $elementor_data = get_post_meta( $post->ID, '_elementor_data', true ); if ( $elementor_data && ( strpos( $elementor_data, 'woocommerce-products' ) !== false || strpos( $elementor_data, 'wc-products' ) !== false ) ) { return true; } } return $enqueue; } /** * Frontend custom CSS. * * @param string $css The custom CSS. * @return string $css The custom CSS. */ public function frontend_custom_css( $css ) { $css .= Merchant_Side_Cart::get_module_custom_css(); // Quick View if ( Merchant_Modules::is_module_active( Merchant_Quick_View::MODULE_ID ) ) { $css .= ' .merchant-quick-view-button { padding: .618em 1em !important; } '; } // Payment Logos if ( Merchant_Modules::is_module_active( Merchant_Payment_Logos::MODULE_ID ) ) { $css .= ' .single-product li .merchant-payment-logos { display: none !important; } '; } // Trust Badges if ( Merchant_Modules::is_module_active( Merchant_Trust_Badges::MODULE_ID ) ) { $css .= ' .single-product li .merchant-trust-badges { display: none !important; } '; } if ( merchant_is_pro_active() ) { // Variation Swatches if ( Merchant_Modules::is_module_active( Merchant_Stock_Scarcity::MODULE_ID ) ) { $css .= ' .single-product form.cart { flex-wrap: wrap !important; } '; } // Wishlist if ( Merchant_Modules::is_module_active( Merchant_Wishlist::MODULE_ID ) ) { $css .= ' .single-product .merchant-wishlist-button { position: static; } .single-product li .merchant-wishlist-button { position: absolute; } .merchant-wishlist-button ~ .merchant-product-swatches .merchant-wishlist-button { display: none !important; } '; } // Product Brand Image if ( Merchant_Modules::is_module_active( Merchant_Product_Brand_Image::MODULE_ID ) ) { $css .= ' .single-product li .merchant-product-brand-image { display: none !important; } '; } // Product Navigation Links if ( Merchant_Modules::is_module_active( Merchant_Product_Navigation_Links::MODULE_ID ) ) { $css .= ' .single-product li .merchant-product-navigation { display: none !important; } '; } } return $css; } } add_action( 'init', function() { new Merchant_Elementor_Builder(); } ); }