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