PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.4.0
ShopBuilder – WooCommerce Builder For Elementor v3.4.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 +85 -44 2.1.133.4.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 /**
@@ -75,13 +80,12 @@
75 80 /**
76 81 * Class Constructor
77 82 */
78 83 private function __construct() {
79 - $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 () {
@@ -101,34 +106,31 @@
101 106 );
102 107 }
103 108
104 109 /**
105 - * Constants
110 + * Assets url generate with given assets file
106 111 *
107 - * @return void
112 + * @param string $file File.
113 + *
114 + * @return string
108 115 */
109 - private function define_constants() {
110 - if ( ! defined( 'RTSB_ABSPATH' ) ) {
111 - define( 'RTSB_ABSPATH', dirname( RTSB_FILE ) . '/' );
112 - }
116 + public function get_assets_uri( $file ) {
117 + $file = ltrim( $file, '/' );
113 118
114 - if ( ! defined( 'RTSB_URL' ) ) {
115 - define( 'RTSB_URL', plugins_url( '', RTSB_FILE ) );
116 - }
119 + return trailingslashit( RTSB_URL . '/assets' ) . $file;
117 120 }
118 121
119 -
120 122 /**
121 - * Assets url generate with given assets file
123 + * Assets path.
122 124 *
123 125 * @param string $file File.
124 126 *
125 127 * @return string
126 128 */
127 - public function get_assets_uri( $file ) {
129 + public function get_assets_path( $file ) {
128 130 $file = ltrim( $file, '/' );
129 131
130 - return trailingslashit( RTSB_URL . '/assets' ) . $file;
132 + return trailingslashit( RTSB_PATH . 'assets' ) . $file;
131 133 }
132 134
133 135 /**
134 136 * Get the template path.
@@ -148,57 +150,96 @@
148 150 return untrailingslashit( plugin_dir_path( RTSB_FILE ) );
149 151 }
150 152
151 153 /**
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 154 * Init
160 155 *
161 156 * @return void
162 157 */
163 158 public function init() {
159 + // Plugin row links (Settings/Demo/Documentation/Get Pro) must register
160 + // regardless of dependency state so users can always reach Settings or
161 + // docs even when WooCommerce/Elementor is inactive.
162 + if ( is_admin() ) {
163 + PluginRow::instance();
164 + }
165 +
164 166 if ( ! Dependencies::instance()->check() ) {
165 167 return;
166 168 }
167 169
168 - do_action( 'rtsb/before/loaded' );
170 + try {
171 + do_action( 'rtsb/before/loaded' );
172 + CacheController::instance();
173 + // Include File.
174 + AssetsController::instance();
175 + ModuleManager::instance();
169 176
170 - // Include File.
171 - AssetsController::instance();
172 - ModuleManager::instance();
177 + // Ajax.
178 + AddToCart::instance();
179 + AjaxLogin::instance();
180 + UpdateCheckoutSection::instance();
173 181
174 - // Ajax.
175 - AddToCart::instance();
176 - AjaxLogin::instance();
182 + BuilderController::instance();
183 + FilterHooks::init_hooks();
184 + ActionHooks::init_hooks();
177 185
178 - BuilderController::instance();
179 - FilterHooks::init_hooks();
180 - ActionHooks::init_hooks();
186 + Installation::init();
187 + Migration::init();
188 + AIinit::instance();
181 189
182 - Installation::init();
183 - Migration::init();
190 + if ( is_admin() ) {
191 + AdminInit::instance();
192 + }
184 193
185 - if ( is_admin() ) {
186 - AdminInit::instance();
194 + Shortcodes::instance();
195 +
196 + do_action( 'rtsb/after/loaded' );
197 + } catch ( \Throwable $e ) {
198 + error_log( 'ShopBuilder init error: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
187 199 }
200 + }
188 201
189 - Shortcodes::instance();
202 + /**
203 + * Maybe Run After Update
204 + *
205 + * @param object $upgrader_object Upgrader Object.
206 + * @param array $options Options.
207 + *
208 + * @return void
209 + */
210 + public function maybe_run_after_update( $upgrader_object, $options ) {
211 + if ( 'plugin' !== $options['type'] || ! in_array( $options['action'], [ 'install', 'update' ], true ) ) {
212 + return;
213 + }
190 214
191 - do_action( 'rtsb/after/loaded' );
215 + // For normal update flow.
216 + if ( ! empty( $options['plugins'] ) ) {
217 + foreach ( $options['plugins'] as $plugin ) {
218 + if ( strpos( $plugin, 'shopbuilder' ) !== false ) {
219 + Cache::clear_all_cache();
220 + break;
221 + }
222 + }
223 + return;
224 + }
225 +
226 + // For upload-based installation.
227 + if (
228 + ! empty( $upgrader_object->result['destination_name'] ) &&
229 + strpos( $upgrader_object->result['destination_name'], 'shopbuilder' ) !== false
230 + ) {
231 + Cache::clear_all_cache();
232 + }
192 233 }
193 234
194 235 /**
195 - * Checks if Pro version installed
236 + * Checks if Pro version installed.
196 237 *
197 238 * @return boolean
198 239 */
199 240 public function has_pro() {
200 - return function_exists( 'rtsbpro' );
241 + return function_exists( 'rtsbpro' ); // Fns::is_pro_authorized() will add in the future for checking pro Version Compatibility.
201 242 }
202 243
203 244 /**
204 245 * PRO Version URL.