PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.15
ShopBuilder – WooCommerce Builder For Elementor v2.1.15
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 2.3.0 All 62 releases
shopbuilder / app / Controllers / SupportController.php

SupportController.php in ShopBuilder – WooCommerce Builder For Elementor 2.1.15, at app/Controllers/SupportController.php

114 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 ];
56 $supports = apply_filters( 'rtsb/plugins/support', $supports );
57 foreach ( $supports as $active_path => $class ) {
58 $is_active = in_array( $active_path, $active_plugin, true );
59 if ( $is_active && class_exists( $class ) && method_exists( $class, 'instance' ) ) {
60 $class::instance();
61 }
62 }
63 }
64 /**
65 * Theme Support
66 *
67 * @return void
68 */
69 public function themes_support() {
70 $themeClass = ucwords( str_replace( [ '_', '-', ' ' ], '', rtsb()->current_theme ) );
71
72 $supportClass = apply_filters(
73 'RadiusTheme/SB/ThemesSupport/Class',
74 [
75 'ThemesSupport' => 'RadiusTheme\SB\Controllers\ThemesSupport\\' . $themeClass . '\\ThemeSupport',
76 'TheTheme' => '\ThemeSupport',
77 ]
78 );
79
80 foreach ( $supportClass as $key => $theClass ) {
81 $themeSupport = get_theme_file_path( '/shopbuilder/ThemeSupport.php' );
82 if ( 'TheTheme' === $key && file_exists( $themeSupport ) ) {
83 require_once $themeSupport;
84 }
85 if ( class_exists( $theClass ) && method_exists( $theClass, 'instance' ) ) {
86 $theClass::instance();
87 }
88 }
89 }
90
91 /**
92 * Theme Support
93 *
94 * @return void
95 */
96 public function locate_template( $template, $template_name, $template_path ) {
97 if ( 'checkout/review-order.php' === $template_name && BuilderFns::is_checkout() ) {
98 $id = BuilderFns::is_builder_preview() ? get_the_ID() : BuilderFns::builder_page_id_by_type( 'checkout' );
99 $elmap = ElementorDataMap::instance();
100 if ( ! $id ) {
101 return $template;
102 }
103 $get_widget = $elmap->get_widget_data( 'rtsb-shipping-method', [], $id );
104 if ( ! empty( $get_widget ) ) {
105 $template = Fns::locate_template( 'elementor/checkout/customized-order-review' );
106 }
107 } elseif ( 'single-product/tabs/description.php' === $template_name && BuilderFns::is_product() ) {
108 $template = Fns::locate_template( 'elementor/single-product/tab-description' );
109 }
110
111 return $template;
112 }
113 }
114