| @@ -19,8 +19,9 @@ | ||
| 19 | 19 | /** |
| 20 | 20 | * SingletonTrait. |
| 21 | 21 | */ |
| 22 | 22 | use SingletonTrait; |
| 23 | + | |
| 23 | 24 | /** |
| 24 | 25 | * Construct function |
| 25 | 26 | */ |
| 26 | 27 | private function __construct() { |
| @@ -25,10 +26,19 @@ | ||
| 25 | 26 | */ |
| 26 | 27 | private function __construct() { |
| 27 | 28 | add_action( 'init', [ $this, 'plugins_support' ], 9 ); |
| 28 | 29 | add_action( 'init', [ $this, 'themes_support' ], 9 ); |
| 29 | - add_filter( 'woocommerce_locate_template', [ $this, 'shipping_method_support' ], 10, 3 ); | |
| 30 | + add_filter( 'woocommerce_locate_template', [ $this, 'locate_template' ], 10, 3 ); | |
| 31 | + if ( defined( 'RTSB_DEVELOPER_MODE' ) && RTSB_DEVELOPER_MODE ) { | |
| 32 | + $this->developer_support(); | |
| 33 | + } | |
| 34 | + } | |
| 30 | 35 | |
| 36 | + /** | |
| 37 | + * @return void | |
| 38 | + */ | |
| 39 | + public function developer_support() { | |
| 40 | + add_filter( 'rtsb/builder/preview/access', '__return_false', 5 ); | |
| 31 | 41 | } |
| 32 | 42 | |
| 33 | 43 | /** |
| 34 | 44 | * Theme Support |
| @@ -38,11 +48,14 @@ | ||
| 38 | 48 | public function plugins_support() { |
| 39 | 49 | // Check for plugin using plugin name. |
| 40 | 50 | $active_plugin = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); |
| 41 | 51 | $supports = [ |
| 52 | + 'woo-address-book/woocommerce-address-book.php' => PluginsSupport\WooAddressBook::class, | |
| 42 | 53 | 'woo-product-variation-gallery/woo-product-variation-gallery.php' => PluginsSupport\RtwpvgSupport::class, |
| 43 | 54 | 'woo-product-variation-swatches-pro/woo-product-variation-swatches-pro.php' => PluginsSupport\RtwpvsSupport::class, |
| 55 | + 'products-visibility-by-user-roles/addify_product_visibility.php' => PluginsSupport\AddifyVisibilityByRoles::class, | |
| 44 | 56 | ]; |
| 57 | + $supports = apply_filters( 'rtsb/plugins/support', $supports ); | |
| 45 | 58 | foreach ( $supports as $active_path => $class ) { |
| 46 | 59 | $is_active = in_array( $active_path, $active_plugin, true ); |
| 47 | 60 | if ( $is_active && class_exists( $class ) && method_exists( $class, 'instance' ) ) { |
| 48 | 61 | $class::instance(); |
| @@ -80,21 +93,22 @@ | ||
| 80 | 93 | * Theme Support |
| 81 | 94 | * |
| 82 | 95 | * @return void |
| 83 | 96 | */ |
| 84 | - public function shipping_method_support( $template, $template_name, $template_path ) { | |
| 85 | - if ( 'checkout/review-order.php' !== $template_name || ! BuilderFns::is_checkout() ) { | |
| 86 | - return $template; | |
| 97 | + public function locate_template( $template, $template_name, $template_path ) { | |
| 98 | + if ( 'checkout/review-order.php' === $template_name && BuilderFns::is_checkout() ) { | |
| 99 | + $id = BuilderFns::is_builder_preview() ? get_the_ID() : BuilderFns::builder_page_id_by_type( 'checkout' ); | |
| 100 | + $elmap = ElementorDataMap::instance(); | |
| 101 | + if ( ! $id ) { | |
| 102 | + return $template; | |
| 103 | + } | |
| 104 | + $get_widget = $elmap->get_widget_data( 'rtsb-shipping-method', [], $id ); | |
| 105 | + if ( ! empty( $get_widget ) ) { | |
| 106 | + $template = Fns::locate_template( 'elementor/checkout/customized-order-review' ); | |
| 107 | + } | |
| 108 | + } elseif ( 'single-product/tabs/description.php' === $template_name && BuilderFns::is_product() ) { | |
| 109 | + $template = Fns::locate_template( 'elementor/single-product/tab-description' ); | |
| 87 | 110 | } |
| 88 | 111 | |
| 89 | - $id = BuilderFns::is_builder_preview() ? get_the_ID() : BuilderFns::builder_page_id_by_type( 'checkout' ); | |
| 90 | - $elmap = ElementorDataMap::instance(); | |
| 91 | - $get_widget = $elmap->get_widget_data( 'rtsb-shipping-method', [], $id ); | |
| 92 | - if ( ! empty( $get_widget ) ) { | |
| 93 | - $template = Fns::locate_template( 'elementor/checkout/customized-order-review' ); | |
| 94 | - } | |
| 95 | - | |
| 96 | 112 | return $template; |
| 97 | 113 | } |
| 98 | - | |
| 99 | - | |
| 100 | 114 | } |