PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.3.0
ShopBuilder – WooCommerce Builder For Elementor v3.3.0
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 +88 -30 2.1.143.3.0 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,9 +14,11 @@
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;
20 +use RadiusTheme\SB\Controllers\Admin\PluginRow;
17 21 use RadiusTheme\SB\Controllers\AssetsController;
18 22 use RadiusTheme\SB\Controllers\BuilderController;
19 23 use RadiusTheme\SB\Controllers\SupportController;
20 24 use RadiusTheme\SB\Controllers\Hooks\FilterHooks;
@@ -20,8 +24,9 @@
20 24 use RadiusTheme\SB\Controllers\Hooks\FilterHooks;
21 25 use RadiusTheme\SB\Controllers\Hooks\ActionHooks;
22 26 use RadiusTheme\SB\Controllers\Frontend\Ajax\AddToCart;
23 27 use RadiusTheme\SB\Controllers\Frontend\Ajax\AjaxLogin;
28 +use RadiusTheme\SB\Controllers\Frontend\Ajax\UpdateCheckoutSection;
24 29
25 30 // Do not allow directly accessing this file.
26 31 if ( ! defined( 'ABSPATH' ) ) {
27 32 exit( 'This script cannot be accessed directly.' );
@@ -67,9 +72,9 @@
67 72 * URL for fetch API
68 73 *
69 74 * @var string
70 75 */
71 - public $BASE_API = 'https://shopbuilderwp.com/wp-json/rtsb/v1/layouts/';
76 + public $BASE_API = 'https://shopbuilderwp.com/demo/wp-json/rtsb/v1/layouts/';
72 77
73 78 use SingletonTrait;
74 79
75 80 /**
@@ -77,11 +82,11 @@
77 82 */
78 83 private function __construct() {
79 84 $this->define_constants();
80 85 $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' ] );
86 + $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 87 add_action( 'plugins_loaded', [ $this, 'init' ], 15 );
88 + add_action( 'upgrader_process_complete', [ $this, 'maybe_run_after_update' ], 10, 2 );
84 89
85 90 // Register Plugin Active Hook.
86 91 register_activation_hook( RTSB_FILE, [ Installation::class, 'activate' ] );
87 92
@@ -87,10 +92,11 @@
87 92
88 93 // Register Plugin Deactivate Hook.
89 94 register_deactivation_hook( RTSB_FILE, [ Installation::class, 'deactivation' ] );
90 95
91 - SupportController::instance();
92 -
96 + if ( Dependencies::instance()->check() ) {
97 + SupportController::instance();
98 + }
93 99 // HPOS Declare compatibility.
94 100 add_action(
95 101 'before_woocommerce_init',
96 102 function () {
@@ -130,8 +136,21 @@
130 136 return trailingslashit( RTSB_URL . '/assets' ) . $file;
131 137 }
132 138
133 139 /**
140 + * Assets path.
141 + *
142 + * @param string $file File.
143 + *
144 + * @return string
145 + */
146 + public function get_assets_path( $file ) {
147 + $file = ltrim( $file, '/' );
148 +
149 + return trailingslashit( RTSB_PATH . 'assets' ) . $file;
150 + }
151 +
152 + /**
134 153 * Get the template path.
135 154 *
136 155 * @return string
137 156 */
@@ -148,57 +167,96 @@
148 167 return untrailingslashit( plugin_dir_path( RTSB_FILE ) );
149 168 }
150 169
151 170 /**
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 171 * Init
160 172 *
161 173 * @return void
162 174 */
163 175 public function init() {
176 + // Plugin row links (Settings/Demo/Documentation/Get Pro) must register
177 + // regardless of dependency state so users can always reach Settings or
178 + // docs even when WooCommerce/Elementor is inactive.
179 + if ( is_admin() ) {
180 + PluginRow::instance();
181 + }
182 +
164 183 if ( ! Dependencies::instance()->check() ) {
165 184 return;
166 185 }
167 186
168 - do_action( 'rtsb/before/loaded' );
187 + try {
188 + do_action( 'rtsb/before/loaded' );
189 + CacheController::instance();
190 + // Include File.
191 + AssetsController::instance();
192 + ModuleManager::instance();
169 193
170 - // Include File.
171 - AssetsController::instance();
172 - ModuleManager::instance();
194 + // Ajax.
195 + AddToCart::instance();
196 + AjaxLogin::instance();
197 + UpdateCheckoutSection::instance();
173 198
174 - // Ajax.
175 - AddToCart::instance();
176 - AjaxLogin::instance();
199 + BuilderController::instance();
200 + FilterHooks::init_hooks();
201 + ActionHooks::init_hooks();
177 202
178 - BuilderController::instance();
179 - FilterHooks::init_hooks();
180 - ActionHooks::init_hooks();
203 + Installation::init();
204 + Migration::init();
205 + AIinit::instance();
181 206
182 - Installation::init();
183 - Migration::init();
207 + if ( is_admin() ) {
208 + AdminInit::instance();
209 + }
184 210
185 - if ( is_admin() ) {
186 - AdminInit::instance();
211 + Shortcodes::instance();
212 +
213 + do_action( 'rtsb/after/loaded' );
214 + } catch ( \Throwable $e ) {
215 + error_log( 'ShopBuilder init error: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
187 216 }
217 + }
188 218
189 - Shortcodes::instance();
219 + /**
220 + * Maybe Run After Update
221 + *
222 + * @param object $upgrader_object Upgrader Object.
223 + * @param array $options Options.
224 + *
225 + * @return void
226 + */
227 + public function maybe_run_after_update( $upgrader_object, $options ) {
228 + if ( 'plugin' !== $options['type'] || ! in_array( $options['action'], [ 'install', 'update' ], true ) ) {
229 + return;
230 + }
190 231
191 - do_action( 'rtsb/after/loaded' );
232 + // For normal update flow.
233 + if ( ! empty( $options['plugins'] ) ) {
234 + foreach ( $options['plugins'] as $plugin ) {
235 + if ( strpos( $plugin, 'shopbuilder' ) !== false ) {
236 + Cache::clear_all_cache();
237 + break;
238 + }
239 + }
240 + return;
241 + }
242 +
243 + // For upload-based installation.
244 + if (
245 + ! empty( $upgrader_object->result['destination_name'] ) &&
246 + strpos( $upgrader_object->result['destination_name'], 'shopbuilder' ) !== false
247 + ) {
248 + Cache::clear_all_cache();
249 + }
192 250 }
193 251
194 252 /**
195 - * Checks if Pro version installed
253 + * Checks if Pro version installed.
196 254 *
197 255 * @return boolean
198 256 */
199 257 public function has_pro() {
200 - return function_exists( 'rtsbpro' );
258 + return function_exists( 'rtsbpro' ); // Fns::is_pro_authorized() will add in the future for checking pro Version Compatibility.
201 259 }
202 260
203 261 /**
204 262 * PRO Version URL.