| @@ -1,114 +1,97 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace RadiusTheme\SB\Controllers; | |
| 4 | - | |
| 5 | -use RadiusTheme\SB\Helpers\BuilderFns; | |
| 6 | -use RadiusTheme\SB\Helpers\ElementorDataMap; | |
| 7 | -use RadiusTheme\SB\Helpers\Fns; | |
| 8 | -use RadiusTheme\SB\Traits\SingletonTrait; | |
| 9 | -use RadiusTheme\SB\Controllers\PluginsSupport; | |
| 10 | -// Do not allow directly accessing this file. | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | - exit( 'This script cannot be accessed directly.' ); | |
| 13 | -} | |
| 14 | - | |
| 15 | -/** | |
| 16 | - * Plugin Support | |
| 17 | - */ | |
| 18 | -class SupportController { | |
| 19 | - /** | |
| 20 | - * SingletonTrait. | |
| 21 | - */ | |
| 22 | - use SingletonTrait; | |
| 23 | - | |
| 24 | - /** | |
| 25 | - * Construct function | |
| 26 | - */ | |
| 27 | - private function __construct() { | |
| 28 | - add_action( 'init', [ $this, 'plugins_support' ], 9 ); | |
| 29 | - add_action( 'init', [ $this, 'themes_support' ], 9 ); | |
| 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 | - } | |
| 35 | - | |
| 36 | - /** | |
| 37 | - * @return void | |
| 38 | - */ | |
| 39 | - public function developer_support() { | |
| 40 | - add_filter( 'rtsb/builder/args/publicly_queryable', '__return_true', 5 ); | |
| 41 | - } | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * Theme Support | |
| 45 | - * | |
| 46 | - * @return void | |
| 47 | - */ | |
| 48 | - public function plugins_support() { | |
| 49 | - // Check for plugin using plugin name. | |
| 50 | - $active_plugin = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); | |
| 51 | - $supports = [ | |
| 52 | - 'woo-address-book/woocommerce-address-book.php' => PluginsSupport\WooAddressBook::class, | |
| 53 | - 'woo-product-variation-gallery/woo-product-variation-gallery.php' => PluginsSupport\RtwpvgSupport::class, | |
| 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, | |
| 56 | - ]; | |
| 57 | - $supports = apply_filters( 'rtsb/plugins/support', $supports ); | |
| 58 | - foreach ( $supports as $active_path => $class ) { | |
| 59 | - $is_active = in_array( $active_path, $active_plugin, true ); | |
| 60 | - if ( $is_active && class_exists( $class ) && method_exists( $class, 'instance' ) ) { | |
| 61 | - $class::instance(); | |
| 62 | - } | |
| 63 | - } | |
| 64 | - } | |
| 65 | - /** | |
| 66 | - * Theme Support | |
| 67 | - * | |
| 68 | - * @return void | |
| 69 | - */ | |
| 70 | - public function themes_support() { | |
| 71 | - $themeClass = ucwords( str_replace( [ '_', '-', ' ' ], '', rtsb()->current_theme ) ); | |
| 72 | - | |
| 73 | - $supportClass = apply_filters( | |
| 74 | - 'RadiusTheme/SB/ThemesSupport/Class', | |
| 75 | - [ | |
| 76 | - 'ThemesSupport' => 'RadiusTheme\SB\Controllers\ThemesSupport\\' . $themeClass . '\\ThemeSupport', | |
| 77 | - 'TheTheme' => '\ThemeSupport', | |
| 78 | - ] | |
| 79 | - ); | |
| 80 | - | |
| 81 | - foreach ( $supportClass as $key => $theClass ) { | |
| 82 | - $themeSupport = get_theme_file_path( '/shopbuilder/ThemeSupport.php' ); | |
| 83 | - if ( 'TheTheme' === $key && file_exists( $themeSupport ) ) { | |
| 84 | - require_once $themeSupport; | |
| 85 | - } | |
| 86 | - if ( class_exists( $theClass ) && method_exists( $theClass, 'instance' ) ) { | |
| 87 | - $theClass::instance(); | |
| 88 | - } | |
| 89 | - } | |
| 90 | - } | |
| 91 | - | |
| 92 | - /** | |
| 93 | - * Theme Support | |
| 94 | - * | |
| 95 | - * @return void | |
| 96 | - */ | |
| 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' ); | |
| 110 | - } | |
| 111 | - | |
| 112 | - return $template; | |
| 113 | - } | |
| 114 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace RadiusTheme\SB\Controllers; | |
| 4 | + | |
| 5 | +use RadiusTheme\SB\Helpers\BuilderFns; | |
| 6 | +use RadiusTheme\SB\Helpers\ElementorDataMap; | |
| 7 | +use RadiusTheme\SB\Helpers\Fns; | |
| 8 | +use RadiusTheme\SB\Traits\SingletonTrait; | |
| 9 | +use RadiusTheme\SB\Controllers\PluginsSupport; | |
| 10 | +// Do not allow directly accessing this file. | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit( 'This script cannot be accessed directly.' ); | |
| 13 | +} | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * Plugin Support | |
| 17 | + */ | |
| 18 | +class SupportController { | |
| 19 | + /** | |
| 20 | + * SingletonTrait. | |
| 21 | + */ | |
| 22 | + use SingletonTrait; | |
| 23 | + /** | |
| 24 | + * Construct function | |
| 25 | + */ | |
| 26 | + private function __construct() { | |
| 27 | + add_action( 'init' , [ $this, 'plugins_support' ]); | |
| 28 | + add_action( 'init' , [ $this, 'themes_support' ]); | |
| 29 | + add_filter( 'woocommerce_locate_template', [ $this, 'shipping_method_support' ], 10, 3 ); | |
| 30 | + } | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * Theme Support | |
| 34 | + * | |
| 35 | + * @return void | |
| 36 | + */ | |
| 37 | + public function plugins_support() { | |
| 38 | + // Check for plugin using plugin name. | |
| 39 | + $active_plugin = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); | |
| 40 | + $supports = [ | |
| 41 | + 'woo-product-variation-gallery/woo-product-variation-gallery.php' => PluginsSupport\RtwpvgSupport::class, | |
| 42 | + 'woo-product-variation-swatches-pro/woo-product-variation-swatches-pro.php' => PluginsSupport\RtwpvsSupport::class, | |
| 43 | + ]; | |
| 44 | + foreach ( $supports as $active_path => $class ) { | |
| 45 | + $is_active = in_array( $active_path, $active_plugin, true ); | |
| 46 | + if ( $is_active && class_exists( $class ) && method_exists( $class, 'instance' ) ) { | |
| 47 | + $class::instance(); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + } | |
| 51 | + /** | |
| 52 | + * Theme Support | |
| 53 | + * | |
| 54 | + * @return void | |
| 55 | + */ | |
| 56 | + public function themes_support() { | |
| 57 | + $themeClass = ucwords( str_replace( [ '_', '-', ' ' ], '', rtsb()->current_theme ) ); | |
| 58 | + | |
| 59 | + $supportClass = apply_filters( 'RadiusTheme/SB/ThemesSupport/Class', [ | |
| 60 | + 'ThemesSupport' => 'RadiusTheme\SB\Controllers\ThemesSupport\\' . $themeClass . '\\ThemeSupport', | |
| 61 | + 'TheTheme' => '\ThemeSupport', | |
| 62 | + ] ); | |
| 63 | + | |
| 64 | + foreach ( $supportClass as $key => $theClass) { | |
| 65 | + $themeSupport = get_theme_file_path('/shopbuilder/ThemeSupport.php'); | |
| 66 | + if ('TheTheme' === $key && file_exists($themeSupport)) { | |
| 67 | + require_once $themeSupport; | |
| 68 | + } | |
| 69 | + if ( class_exists( $theClass ) && method_exists( $theClass, 'instance' ) ) { | |
| 70 | + $theClass::instance(); | |
| 71 | + } | |
| 72 | + | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * Theme Support | |
| 79 | + * | |
| 80 | + * @return void | |
| 81 | + */ | |
| 82 | + public function shipping_method_support( $template, $template_name, $template_path ) { | |
| 83 | + if( 'checkout/review-order.php' !== $template_name || ! BuilderFns::is_checkout() ) { | |
| 84 | + return $template; | |
| 85 | + } | |
| 86 | + | |
| 87 | + $id = BuilderFns::is_builder_preview() ? get_the_ID() : BuilderFns::builder_page_id_by_type( 'checkout' ); | |
| 88 | + $elmap = ElementorDataMap::instance(); | |
| 89 | + $get_widget = $elmap->get_widget_data('rtsb-shipping-method', [], $id); | |
| 90 | + if( ! empty( $get_widget ) ){ | |
| 91 | + $template = Fns::locate_template( 'elementor/checkout/customized-order-review' ); | |
| 92 | + } | |
| 93 | + | |
| 94 | + return $template; | |
| 95 | + } | |
| 96 | + | |
| 97 | +} | |