PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 2.0.0
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v2.0.0
3.1.4 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 All 93 releases
ultimate-store-kit / loader.php

loader.php in Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder 2.0.0, at loader.php

342 lines 11.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimateStoreKit;
4
5 use Elementor\Plugin;
6 use Elementor\Core\Kits\Documents\Kit;
7 use UltimateStoreKit\Manager;
8
9 if (!defined('ABSPATH')) exit; // Exit if accessed directly
10
11 /**
12 * Main class for element pack
13 */
14 class Ultimate_Store_Kit_Loader {
15 /**
16 * @var Ultimate_Store_Kit_Loader
17 */
18 private static $_instance;
19
20 /**
21 * @var Manager
22 */
23 private $_modules_manager;
24
25 private $classes_aliases = [
26 'UltimateStoreKit\Modules\PanelPostsControl\Module' => 'UltimateStoreKit\Modules\QueryControl\Module',
27 'UltimateStoreKit\Modules\PanelPostsControl\Controls\Group_Control_Posts' => 'UltimateStoreKit\Modules\QueryControl\Controls\Group_Control_Posts',
28 'UltimateStoreKit\Modules\PanelPostsControl\Controls\Query' => 'UltimateStoreKit\Modules\QueryControl\Controls\Query',
29 ];
30
31 public $elements_data = [
32 'sections' => [],
33 'columns' => [],
34 'widgets' => [],
35 ];
36
37 /**
38 * @return string
39 * @deprecated
40 *
41 */
42 public function get_version() {
43 return BDTUSK_VER;
44 }
45
46 /**
47 * return active theme
48 */
49 public function get_theme() {
50 return wp_get_theme();
51 }
52
53 /**
54 * Throw error on object clone
55 *
56 * The whole idea of the singleton design pattern is that there is a single
57 * object therefore, we don't want the object to be cloned.
58 *
59 * @return void
60 * @since 1.0.0
61 */
62 public function __clone() {
63 // Cloning instances of the class is forbidden
64 _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin&#8217; huh?', 'ultimate-store-kit'), '1.6.0');
65 }
66
67 /**
68 * Disable unserializing of the class
69 *
70 * @return void
71 * @since 1.0.0
72 */
73 public function __wakeup() {
74 // Unserializing instances of the class is forbidden
75 _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin&#8217; huh?', 'ultimate-store-kit'), '1.6.0');
76 }
77
78 /**
79 * @return Plugin
80 */
81
82 public static function elementor() {
83 return Plugin::$instance;
84 }
85
86 /**
87 * @return Ultimate_Store_Kit_Loader
88 */
89 public static function instance() {
90 if (is_null(self::$_instance)) {
91 self::$_instance = new self();
92 }
93
94 do_action('bdthemes_ultimate_store_kit/init');
95 return self::$_instance;
96 }
97
98
99 /**
100 * we loaded module manager + admin php from here
101 * @return [type] [description]
102 */
103 private function _includes() {
104
105 require_once BDTUSK_ADMIN_PATH . 'module-settings.php';
106 // ========================
107 // Helper for global usec
108 //==========================
109 require(BDTUSK_PATH . 'base/support/helpers.php');
110 //===========================
111 // WISHLIST
112 //===========================
113 require(BDTUSK_INC_PATH . 'wishlist-compare.php');
114 //===========================
115 // WISHLIST
116 //===========================
117
118
119 // all widgets control from here
120 // require BDTUSK_INC_PATH . 'global-controls.php';
121 require BDTUSK_INC_PATH . 'modules-manager.php';
122 // Dynamic Select control
123 // require BDTUSK_INC_PATH . 'controls/group-query/group-control-query.php';
124 require BDTUSK_INC_PATH . 'controls/select-input/dynamic-select-input-module.php';
125 require BDTUSK_INC_PATH . 'controls/select-input/dynamic-select.php';
126
127
128 require_once 'includes/modal/modal-settings.php';
129
130
131 //GLOBAL CONTROLS
132 require_once BDTUSK_PATH . 'traits/global-widget-controls.php';
133 require_once BDTUSK_PATH . 'traits/global-widget-template.php';
134
135
136 if (class_exists('woocommerce')) {
137 require_once BDTUSK_PATH . 'includes/builder/loading-builder.php';
138 }
139
140 if (is_admin()) {
141 if (!defined('BDTUSK_CH')) {
142
143 // Admin settings controller
144 require(BDTUSK_ADM_PATH . 'class-settings-api.php');
145
146 require(BDTUSK_ADM_PATH . 'admin.php');
147 // element pack admin settings here
148 require(BDTUSK_ADM_PATH . 'admin-settings.php');
149
150 // Load admin class for admin related content process
151 new Admin();
152 }
153 }
154 }
155
156 /**
157 * Autoloader function for all classes files
158 * @param [type] string
159 * @return [type] [description]
160 */
161 public function autoload($class) {
162 if (0 !== strpos($class, __NAMESPACE__)) {
163 return;
164 }
165
166 $has_class_alias = isset($this->classes_aliases[$class]);
167
168 // Backward Compatibility: Save old class name for set an alias after the new class is loaded
169 if ($has_class_alias) {
170 $class_alias_name = $this->classes_aliases[$class];
171 $class_to_load = $class_alias_name;
172 } else {
173 $class_to_load = $class;
174 }
175
176 if (!class_exists($class_to_load)) {
177 $filename = strtolower(
178 preg_replace(
179 ['/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/'],
180 ['', '$1-$2', '-', DIRECTORY_SEPARATOR],
181 $class_to_load
182 )
183 );
184 $filename = BDTUSK_PATH . $filename . '.php';
185
186 if (is_readable($filename)) {
187 include($filename);
188 }
189 }
190
191 if ($has_class_alias) {
192 class_alias($class_alias_name, $class);
193 }
194 }
195
196 /**
197 * Register all script that need for any specific widget on call basis.
198 * @return [type] [description]
199 */
200 public function register_site_scripts() {
201 wp_register_script('datatables', BDTUSK_ASSETS_URL . 'vendor/js/datatables.min.js', [], '1.0.0', true);
202 wp_register_script('micromodal', BDTUSK_ASSETS_URL . 'vendor/js/micromodal.min.js', [], '1.0.0', true);
203 wp_register_script('usk-accordion', BDTUSK_ASSETS_URL . 'vendor/js/usk-accordion.min.js', [], '1.0.0', true);
204 }
205
206 public function register_site_styles() {
207 $direction_suffix = is_rtl() ? '.rtl' : '';
208 wp_register_style('usk-all-styles', BDTUSK_URL . 'assets/css/usk-all-styles' . $direction_suffix . '.css', [], BDTUSK_VER);
209 wp_register_style('usk-font', BDTUSK_URL . 'assets/css/usk-font' . $direction_suffix . '.css', [], BDTUSK_VER);
210 }
211
212 /**
213 * Loading site related style from here.
214 * @return [type] [description]
215 */
216 public function enqueue_site_styles() {
217
218 $direction_suffix = is_rtl() ? '.rtl' : '';
219
220 wp_enqueue_style('usk-site', BDTUSK_ASSETS_URL . 'css/usk-site' . $direction_suffix . '.css', [], BDTUSK_VER);
221 wp_enqueue_style('slick-modal', BDTUSK_ASSETS_URL . 'vendor/css/slickmodal.css', [], BDTUSK_VER);
222 wp_enqueue_style('toolslide-css', BDTUSK_ASSETS_URL . 'vendor/css/toolslide.css', [], BDTUSK_VER);
223 }
224
225
226 /**
227 * Loading site related script that needs all time such as uikit.
228 * @return [type] [description]
229 */
230 public function enqueue_site_scripts() {
231
232 wp_enqueue_script('usk-core', BDTUSK_ASSETS_URL . 'js/usk-core.min.js', ['jquery', 'elementor-frontend'], BDTUSK_VER, true); // tooltip file should be separate
233 wp_enqueue_script('usk-site', BDTUSK_ASSETS_URL . 'js/usk-site.min.js', ['jquery', 'elementor-frontend'], BDTUSK_VER, true); // tooltip file should be separate
234 wp_enqueue_script('slick-modal', BDTUSK_ASSETS_URL . 'vendor/js/jquery.slickmodal.min.js', ['jquery', 'elementor-frontend'], BDTUSK_VER, true); // tooltip file should be separate
235 wp_enqueue_script('toolslide-js', BDTUSK_ASSETS_URL . 'vendor/js/toolslide.min.js', ['elementor-frontend'], BDTUSK_VER, true); // tooltip file should be separate
236
237 wp_localize_script('usk-site', 'ultimate_store_kit_ajax_config', array(
238 'ajaxurl' => admin_url('admin-ajax.php'),
239 ));
240 }
241
242 public function enqueue_editor_scripts() {
243
244 wp_enqueue_script('usk-editor', BDTUSK_ASSETS_URL . 'js/usk-editor.min.js', ['backbone-marionette', 'elementor-common-modules', 'elementor-editor-modules',], BDTUSK_VER, true);
245
246 $_is_usk_pro_activated = false;
247 if (function_exists('usk_license_validation') && true === usk_license_validation()) {
248 $_is_usk_pro_activated = true;
249 }
250
251 $localize_data = [
252 'pro_installed' => _is_usk_pro_activated(),
253 'pro_license_activated' => $_is_usk_pro_activated,
254 'promotional_widgets' => [],
255 ];
256
257 if (!$_is_usk_pro_activated) {
258 $pro_widget_map = new \UltimateStoreKit\Includes\Pro_Widget_Map();
259 $localize_data['promotional_widgets'] = $pro_widget_map->get_pro_widget_map();
260 }
261
262 wp_localize_script('usk-editor', 'UltimateStoreKitConfigEditor', $localize_data);
263 }
264
265 public function enqueue_admin_scripts() {
266 wp_enqueue_script('usk-admin', BDTUSK_ASSETS_URL . 'js/usk-admin.min.js', ['jquery'], BDTUSK_VER, true);
267 }
268
269 public function enqueue_editor_styles() {
270 $direction_suffix = is_rtl() ? '.rtl' : '';
271
272 wp_enqueue_style('usk-editor', BDTUSK_ASSETS_URL . 'css/usk-editor' . $direction_suffix . '.css', '', BDTUSK_VER);
273 wp_enqueue_style('usk-font', BDTUSK_ASSETS_URL . 'css/usk-font' . $direction_suffix . '.css', [], BDTUSK_VER);
274 }
275
276
277
278 public function ultimate_store_kit_init() {
279 $this->_modules_manager = new Manager();
280 $this->ultimate_store_kit_modal_settings_init();
281 do_action('bdthemes_ultimate_store_kit/init');
282 }
283
284 /**
285 * initialize the category
286 * @return [type] [description]
287 */
288 public function ultimate_store_kit_category_register() {
289
290 $elementor = Plugin::$instance;
291
292 // Add element category in panel
293 $elementor->elements_manager->add_category('ultimate-store-kit-single', ['title' => 'Ultimate Store Kit (Single)', 'icon' => 'font']);
294 $elementor->elements_manager->add_category(BDTUSK_SLUG, ['title' => BDTUSK_TITLE, 'icon' => 'font']);
295 }
296
297 private function setup_hooks() {
298 add_action('elementor/elements/categories_registered', [$this, 'ultimate_store_kit_category_register']);
299 add_action('elementor/init', [$this, 'ultimate_store_kit_init']);
300 add_action('elementor/editor/after_enqueue_styles', [$this, 'enqueue_editor_styles']);
301 add_action('elementor/frontend/before_register_styles', [$this, 'register_site_styles']);
302 add_action('elementor/frontend/before_register_scripts', [$this, 'register_site_scripts']);
303 // add_action('elementor/preview/enqueue_styles', [$this, 'enqueue_preview_styles']);
304 add_action('elementor/editor/after_enqueue_scripts', [$this, 'enqueue_editor_scripts']);
305 add_action('elementor/frontend/after_register_styles', [$this, 'enqueue_site_styles']);
306 add_action('elementor/frontend/before_enqueue_scripts', [$this, 'enqueue_site_scripts']);
307 add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
308 }
309
310 public function ultimate_store_kit_modal_settings_init() {
311 require 'includes/modal/modal-controls.php';
312 add_action('elementor/kit/register_tabs', function (Kit $kit) {
313 $kit->register_tab('ultimate-store-kit-modal', Includes\Settings\Settings_Modal::class);
314 }, 1, 40);
315 }
316
317
318
319 /**
320 * Ultimate_Store_Kit_Loader constructor.
321 */
322 private function __construct() {
323 // Register class automatically
324 spl_autoload_register([$this, 'autoload']);
325 // Include some backend files
326 $this->_includes();
327
328 // Finally hooked up all things here
329 $this->setup_hooks();
330 }
331 }
332
333 if (!defined('BDTUSK_TESTS')) {
334 // In tests we run the instance manually.
335 Ultimate_Store_Kit_Loader::instance();
336 }
337
338 // handy fundtion for push data
339 function ultimate_store_kit_config() {
340 return Ultimate_Store_Kit_Loader::instance();
341 }
342