PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.2
ShopBuilder – WooCommerce Builder For Elementor v3.2.2
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/ShopBuilder.php +59 -13 2.1.143.2.2 View file →
@@ -6,8 +6,10 @@
6 6 */
7 7
8 8 namespace RadiusTheme\SB;
9 9
10 +use RadiusTheme\SB\AI\AIinit;
11 +use RadiusTheme\SB\Helpers\Cache;
10 12 use RadiusTheme\SB\Helpers\Migration;
11 13 use RadiusTheme\SB\Helpers\Installation;
12 14 use RadiusTheme\SB\Modules\ModuleManager;
13 15 use RadiusTheme\SB\Traits\SingletonTrait;
@@ -12,8 +14,9 @@
12 14 use RadiusTheme\SB\Modules\ModuleManager;
13 15 use RadiusTheme\SB\Traits\SingletonTrait;
14 16 use RadiusTheme\SB\Controllers\Shortcodes;
15 17 use RadiusTheme\SB\Controllers\Dependencies;
18 +use RadiusTheme\SB\Controllers\CacheController;
16 19 use RadiusTheme\SB\Controllers\Admin\AdminInit;
17 20 use RadiusTheme\SB\Controllers\AssetsController;
18 21 use RadiusTheme\SB\Controllers\BuilderController;
19 22 use RadiusTheme\SB\Controllers\SupportController;
@@ -20,8 +23,9 @@
20 23 use RadiusTheme\SB\Controllers\Hooks\FilterHooks;
21 24 use RadiusTheme\SB\Controllers\Hooks\ActionHooks;
22 25 use RadiusTheme\SB\Controllers\Frontend\Ajax\AddToCart;
23 26 use RadiusTheme\SB\Controllers\Frontend\Ajax\AjaxLogin;
27 +use RadiusTheme\SB\Controllers\Frontend\Ajax\UpdateCheckoutSection;
24 28
25 29 // Do not allow directly accessing this file.
26 30 if ( ! defined( 'ABSPATH' ) ) {
27 31 exit( 'This script cannot be accessed directly.' );
@@ -67,9 +71,9 @@
67 71 * URL for fetch API
68 72 *
69 73 * @var string
70 74 */
71 - public $BASE_API = 'https://shopbuilderwp.com/wp-json/rtsb/v1/layouts/';
75 + public $BASE_API = 'https://shopbuilderwp.com/demo/wp-json/rtsb/v1/layouts/';
72 76
73 77 use SingletonTrait;
74 78
75 79 /**
@@ -77,11 +81,11 @@
77 81 */
78 82 private function __construct() {
79 83 $this->define_constants();
80 84 $this->post_type = 'product';
81 - $this->current_theme = wp_get_theme()->get( 'Template' ) ? wp_get_theme()->get( 'Template' ) : wp_get_theme()->get( 'TextDomain' );
82 - add_action( 'init', [ $this, 'language' ] );
85 + $this->current_theme = wp_get_theme()->get( 'Template' ) ? wp_get_theme()->get( 'Template' ) : ( wp_get_theme()->get( 'TextDomain' ) ? wp_get_theme()->get( 'TextDomain' ) : strtolower( str_replace( ' ', '', wp_get_theme()->get( 'Name' ) ) ) );
83 86 add_action( 'plugins_loaded', [ $this, 'init' ], 15 );
87 + add_action( 'upgrader_process_complete', [ $this, 'maybe_run_after_update' ], 10, 2 );
84 88
85 89 // Register Plugin Active Hook.
86 90 register_activation_hook( RTSB_FILE, [ Installation::class, 'activate' ] );
87 91
@@ -87,10 +91,11 @@
87 91
88 92 // Register Plugin Deactivate Hook.
89 93 register_deactivation_hook( RTSB_FILE, [ Installation::class, 'deactivation' ] );
90 94
91 - SupportController::instance();
92 -
95 + if ( Dependencies::instance()->check() ) {
96 + SupportController::instance();
97 + }
93 98 // HPOS Declare compatibility.
94 99 add_action(
95 100 'before_woocommerce_init',
96 101 function () {
@@ -130,8 +135,21 @@
130 135 return trailingslashit( RTSB_URL . '/assets' ) . $file;
131 136 }
132 137
133 138 /**
139 + * Assets path.
140 + *
141 + * @param string $file File.
142 + *
143 + * @return string
144 + */
145 + public function get_assets_path( $file ) {
146 + $file = ltrim( $file, '/' );
147 +
148 + return trailingslashit( RTSB_PATH . 'assets' ) . $file;
149 + }
150 +
151 + /**
134 152 * Get the template path.
135 153 *
136 154 * @return string
137 155 */
@@ -148,15 +166,8 @@
148 166 return untrailingslashit( plugin_dir_path( RTSB_FILE ) );
149 167 }
150 168
151 169 /**
152 - * Load Text Domain
153 - */
154 - public function language() {
155 - load_plugin_textdomain( 'shopbuilder', false, dirname( plugin_basename( RTSB_FILE ) ) . '/languages/' );
156 - }
157 -
158 - /**
159 170 * Init
160 171 *
161 172 * @return void
162 173 */
@@ -165,9 +176,9 @@
165 176 return;
166 177 }
167 178
168 179 do_action( 'rtsb/before/loaded' );
169 -
180 + CacheController::instance();
170 181 // Include File.
171 182 AssetsController::instance();
172 183 ModuleManager::instance();
173 184
@@ -173,8 +184,9 @@
173 184
174 185 // Ajax.
175 186 AddToCart::instance();
176 187 AjaxLogin::instance();
188 + UpdateCheckoutSection::instance();
177 189
178 190 BuilderController::instance();
179 191 FilterHooks::init_hooks();
180 192 ActionHooks::init_hooks();
@@ -180,8 +192,9 @@
180 192 ActionHooks::init_hooks();
181 193
182 194 Installation::init();
183 195 Migration::init();
196 + AIinit::instance();
184 197
185 198 if ( is_admin() ) {
186 199 AdminInit::instance();
187 200 }
@@ -188,8 +201,41 @@
188 201
189 202 Shortcodes::instance();
190 203
191 204 do_action( 'rtsb/after/loaded' );
205 + }
206 +
207 + /**
208 + * Maybe Run After Update
209 + *
210 + * @param object $upgrader_object Upgrader Object.
211 + * @param array $options Options.
212 + *
213 + * @return void
214 + */
215 + public function maybe_run_after_update( $upgrader_object, $options ) {
216 + if ( 'plugin' !== $options['type'] || ! in_array( $options['action'], [ 'install', 'update' ], true ) ) {
217 + return;
218 + }
219 +
220 + // For normal update flow.
221 + if ( ! empty( $options['plugins'] ) ) {
222 + foreach ( $options['plugins'] as $plugin ) {
223 + if ( strpos( $plugin, 'shopbuilder' ) !== false ) {
224 + Cache::clear_all_cache();
225 + break;
226 + }
227 + }
228 + return;
229 + }
230 +
231 + // For upload-based installation.
232 + if (
233 + ! empty( $upgrader_object->result['destination_name'] ) &&
234 + strpos( $upgrader_object->result['destination_name'], 'shopbuilder' ) !== false
235 + ) {
236 + Cache::clear_all_cache();
237 + }
192 238 }
193 239
194 240 /**
195 241 * Checks if Pro version installed