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 +86 -47 2.2.23.4.0 View file →
@@ -6,9 +6,10 @@
6 6 */
7 7
8 8 namespace RadiusTheme\SB;
9 9
10 -use RadiusTheme\SB\Controllers\CacheController;
10 +use RadiusTheme\SB\AI\AIinit;
11 +use RadiusTheme\SB\Helpers\Cache;
11 12 use RadiusTheme\SB\Helpers\Migration;
12 13 use RadiusTheme\SB\Helpers\Installation;
13 14 use RadiusTheme\SB\Modules\ModuleManager;
14 15 use RadiusTheme\SB\Traits\SingletonTrait;
@@ -13,9 +14,11 @@
13 14 use RadiusTheme\SB\Modules\ModuleManager;
14 15 use RadiusTheme\SB\Traits\SingletonTrait;
15 16 use RadiusTheme\SB\Controllers\Shortcodes;
16 17 use RadiusTheme\SB\Controllers\Dependencies;
18 +use RadiusTheme\SB\Controllers\CacheController;
17 19 use RadiusTheme\SB\Controllers\Admin\AdminInit;
20 +use RadiusTheme\SB\Controllers\Admin\PluginRow;
18 21 use RadiusTheme\SB\Controllers\AssetsController;
19 22 use RadiusTheme\SB\Controllers\BuilderController;
20 23 use RadiusTheme\SB\Controllers\SupportController;
21 24 use RadiusTheme\SB\Controllers\Hooks\FilterHooks;
@@ -21,8 +24,9 @@
21 24 use RadiusTheme\SB\Controllers\Hooks\FilterHooks;
22 25 use RadiusTheme\SB\Controllers\Hooks\ActionHooks;
23 26 use RadiusTheme\SB\Controllers\Frontend\Ajax\AddToCart;
24 27 use RadiusTheme\SB\Controllers\Frontend\Ajax\AjaxLogin;
28 +use RadiusTheme\SB\Controllers\Frontend\Ajax\UpdateCheckoutSection;
25 29
26 30 // Do not allow directly accessing this file.
27 31 if ( ! defined( 'ABSPATH' ) ) {
28 32 exit( 'This script cannot be accessed directly.' );
@@ -68,9 +72,9 @@
68 72 * URL for fetch API
69 73 *
70 74 * @var string
71 75 */
72 - public $BASE_API = 'https://shopbuilderwp.com/wp-json/rtsb/v1/layouts/';
76 + public $BASE_API = 'https://shopbuilderwp.com/demo/wp-json/rtsb/v1/layouts/';
73 77
74 78 use SingletonTrait;
75 79
76 80 /**
@@ -76,13 +80,12 @@
76 80 /**
77 81 * Class Constructor
78 82 */
79 83 private function __construct() {
80 - $this->define_constants();
81 84 $this->post_type = 'product';
82 - $this->current_theme = wp_get_theme()->get( 'Template' ) ? wp_get_theme()->get( 'Template' ) : wp_get_theme()->get( 'TextDomain' );
83 - 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' ) ) ) );
84 86 add_action( 'plugins_loaded', [ $this, 'init' ], 15 );
87 + add_action( 'upgrader_process_complete', [ $this, 'maybe_run_after_update' ], 10, 2 );
85 88
86 89 // Register Plugin Active Hook.
87 90 register_activation_hook( RTSB_FILE, [ Installation::class, 'activate' ] );
88 91
@@ -88,10 +91,11 @@
88 91
89 92 // Register Plugin Deactivate Hook.
90 93 register_deactivation_hook( RTSB_FILE, [ Installation::class, 'deactivation' ] );
91 94
92 - SupportController::instance();
93 -
95 + if ( Dependencies::instance()->check() ) {
96 + SupportController::instance();
97 + }
94 98 // HPOS Declare compatibility.
95 99 add_action(
96 100 'before_woocommerce_init',
97 101 function () {
@@ -102,34 +106,31 @@
102 106 );
103 107 }
104 108
105 109 /**
106 - * Constants
110 + * Assets url generate with given assets file
107 111 *
108 - * @return void
112 + * @param string $file File.
113 + *
114 + * @return string
109 115 */
110 - private function define_constants() {
111 - if ( ! defined( 'RTSB_ABSPATH' ) ) {
112 - define( 'RTSB_ABSPATH', dirname( RTSB_FILE ) . '/' );
113 - }
116 + public function get_assets_uri( $file ) {
117 + $file = ltrim( $file, '/' );
114 118
115 - if ( ! defined( 'RTSB_URL' ) ) {
116 - define( 'RTSB_URL', plugins_url( '', RTSB_FILE ) );
117 - }
119 + return trailingslashit( RTSB_URL . '/assets' ) . $file;
118 120 }
119 121
120 -
121 122 /**
122 - * Assets url generate with given assets file
123 + * Assets path.
123 124 *
124 125 * @param string $file File.
125 126 *
126 127 * @return string
127 128 */
128 - public function get_assets_uri( $file ) {
129 + public function get_assets_path( $file ) {
129 130 $file = ltrim( $file, '/' );
130 131
131 - return trailingslashit( RTSB_URL . '/assets' ) . $file;
132 + return trailingslashit( RTSB_PATH . 'assets' ) . $file;
132 133 }
133 134
134 135 /**
135 136 * Get the template path.
@@ -149,57 +150,96 @@
149 150 return untrailingslashit( plugin_dir_path( RTSB_FILE ) );
150 151 }
151 152
152 153 /**
153 - * Load Text Domain
154 - */
155 - public function language() {
156 - load_plugin_textdomain( 'shopbuilder', false, dirname( plugin_basename( RTSB_FILE ) ) . '/languages/' );
157 - }
158 -
159 - /**
160 154 * Init
161 155 *
162 156 * @return void
163 157 */
164 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 +
165 166 if ( ! Dependencies::instance()->check() ) {
166 167 return;
167 168 }
168 169
169 - do_action( 'rtsb/before/loaded' );
170 - CacheController::instance();
171 - // Include File.
172 - AssetsController::instance();
173 - ModuleManager::instance();
170 + try {
171 + do_action( 'rtsb/before/loaded' );
172 + CacheController::instance();
173 + // Include File.
174 + AssetsController::instance();
175 + ModuleManager::instance();
174 176
175 - // Ajax.
176 - AddToCart::instance();
177 - AjaxLogin::instance();
177 + // Ajax.
178 + AddToCart::instance();
179 + AjaxLogin::instance();
180 + UpdateCheckoutSection::instance();
178 181
179 - BuilderController::instance();
180 - FilterHooks::init_hooks();
181 - ActionHooks::init_hooks();
182 + BuilderController::instance();
183 + FilterHooks::init_hooks();
184 + ActionHooks::init_hooks();
182 185
183 - Installation::init();
184 - Migration::init();
186 + Installation::init();
187 + Migration::init();
188 + AIinit::instance();
185 189
186 - if ( is_admin() ) {
187 - AdminInit::instance();
190 + if ( is_admin() ) {
191 + AdminInit::instance();
192 + }
193 +
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
188 199 }
200 + }
189 201
190 - 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 + }
191 214
192 - 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 + }
193 233 }
194 234
195 235 /**
196 - * Checks if Pro version installed
236 + * Checks if Pro version installed.
197 237 *
198 238 * @return boolean
199 239 */
200 240 public function has_pro() {
201 - return function_exists( 'rtsbpro' );
241 + return function_exists( 'rtsbpro' ); // Fns::is_pro_authorized() will add in the future for checking pro Version Compatibility.
202 242 }
203 243
204 244 /**
205 245 * PRO Version URL.
@@ -209,5 +249,4 @@
209 249 public function pro_version_link() {
210 250 return 'https://shopbuilderwp.com/';
211 251 }
212 252 }
213 -