Repository navigation
Expand file tree
/
Copy pathloader.php
More file actions
415 lines (337 loc) · 13.1 KB
/
Copy pathloader.php
File metadata and controls
415 lines (337 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<?php
namespace UltimateStoreKit;
use Elementor\Plugin;
use Elementor\Core\Kits\Documents\Kit;
use UltimateStoreKit\Manager;
use UltimateStoreKit\Admin\Dashboard;
if (!defined('ABSPATH'))
exit; // Exit if accessed directly
/**
* Main class for element pack
*/
class Ultimate_Store_Kit_Loader {
/**
* @var Ultimate_Store_Kit_Loader
*/
private static $_instance;
/**
* @var Manager
*/
private $_modules_manager;
private $classes_aliases = [
'UltimateStoreKit\Modules\PanelPostsControl\Module' => 'UltimateStoreKit\Modules\QueryControl\Module',
'UltimateStoreKit\Modules\PanelPostsControl\Controls\Group_Control_Posts' => 'UltimateStoreKit\Modules\QueryControl\Controls\Group_Control_Posts',
'UltimateStoreKit\Modules\PanelPostsControl\Controls\Query' => 'UltimateStoreKit\Modules\QueryControl\Controls\Query',
];
public $elements_data = [
'sections' => [],
'columns' => [],
'widgets' => [],
];
/**
* @return string
* @deprecated
*
*/
public function get_version() {
return BDTUSK_VER;
}
/**
* return active theme
*/
public function get_theme() {
return wp_get_theme();
}
/**
* Throw error on object clone
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @return void
* @since 1.0.0
*/
public function __clone() {
// Cloning instances of the class is forbidden
_doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'ultimate-store-kit'), '1.6.0');
}
/**
* Disable unserializing of the class
*
* @return void
* @since 1.0.0
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden
_doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'ultimate-store-kit'), '1.6.0');
}
/**
* @return Plugin
*/
public static function elementor() {
return Plugin::$instance;
}
/**
* @return Ultimate_Store_Kit_Loader
*/
public static function instance() {
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
do_action('bdthemes_ultimate_store_kit/init');
return self::$_instance;
}
/**
* we loaded module manager + admin php from here
* @return [type] [description]
*/
private function _includes() {
// require_once BDTUSK_ADMIN_PATH . 'module-settings.php';
// ========================
// Helper for global usec
//==========================
require(BDTUSK_PATH . 'base/support/helpers.php');
//===========================
// WISHLIST
//===========================
require(BDTUSK_INC_PATH . 'wishlist-compare.php');
//===========================
// WISHLIST
//===========================
// all widgets control from here
// require BDTUSK_INC_PATH . 'global-controls.php';
require BDTUSK_INC_PATH . 'modules-manager.php';
// Dynamic Select control
// require BDTUSK_INC_PATH . 'controls/group-query/group-control-query.php';
require BDTUSK_INC_PATH . 'controls/select-input/dynamic-select-input-module.php';
require BDTUSK_INC_PATH . 'controls/select-input/dynamic-select.php';
require_once 'includes/modal/modal-settings.php';
//GLOBAL CONTROLS
require_once BDTUSK_PATH . 'traits/global-widget-controls.php';
require_once BDTUSK_PATH . 'traits/global-widget-template.php';
// GRID TEMPLATES
require_once BDTUSK_PATH . 'templates/shiny-grid.php';
require_once BDTUSK_PATH . 'templates/florence-grid.php';
require_once BDTUSK_PATH . 'templates/glossy-grid.php';
if (class_exists('woocommerce')) {
require_once BDTUSK_PATH . 'includes/builder/loading-builder.php';
}
}
/**
* Autoloader function for all classes files
* @param [type] string
* @return [type] [description]
*/
public function autoload($class) {
if (0 !== strpos($class, __NAMESPACE__)) {
return;
}
$has_class_alias = isset($this->classes_aliases[$class]);
// Backward Compatibility: Save old class name for set an alias after the new class is loaded
if ($has_class_alias) {
$class_alias_name = $this->classes_aliases[$class];
$class_to_load = $class_alias_name;
} else {
$class_to_load = $class;
}
if (!class_exists($class_to_load)) {
$filename = strtolower(
preg_replace(
['/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/'],
['', '$1-$2', '-', DIRECTORY_SEPARATOR],
$class_to_load
)
);
$filename = BDTUSK_PATH . $filename . '.php';
if (is_readable($filename)) {
include($filename);
}
}
if ($has_class_alias) {
class_alias($class_alias_name, $class);
}
}
/**
* Register all script that need for any specific widget on call basis.
* @return [type] [description]
*/
public function register_site_scripts() {
wp_register_script('ultimate-store-kit-datatables', BDTUSK_ASSETS_URL . 'vendor/js/datatables.js', [], '1.0.0', true);
wp_register_script('ultimate-store-kit-micromodal', BDTUSK_ASSETS_URL . 'vendor/js/micromodal.js', [], '1.0.0', true);
wp_register_script('usk-accordion', BDTUSK_ASSETS_URL . 'vendor/js/accordion.js', [], '1.0.0', true);
if (ultimate_store_kit_is_widget_enabled('image-hotspot')) {
wp_register_script('ultimate-store-kit-popper', BDTUSK_ASSETS_URL . 'vendor/js/popper.min.js', ['jquery'], BDTUSK_VER, true);
wp_register_script('ultimate-store-kit-tippyjs', BDTUSK_ASSETS_URL . 'vendor/js/tippy.all.min.js', ['jquery'], BDTUSK_VER, true);
}
}
public function register_site_styles() {
$direction_suffix = is_rtl() ? '.rtl' : '';
wp_register_style('usk-all-styles', BDTUSK_URL . 'assets/css/all-styles' . $direction_suffix . '.css', [], BDTUSK_VER);
wp_register_style('usk-font', BDTUSK_URL . 'assets/css/font' . $direction_suffix . '.css', [], BDTUSK_VER);
if (ultimate_store_kit_is_widget_enabled('image-hotspot')) {
wp_register_style('ultimate-store-kit-tippy', BDTUSK_URL . 'assets/css/tippy' . $direction_suffix . '.css', [], BDTUSK_VER);
}
}
/**
* Loading site related style from here.
* @return [type] [description]
*/
public function enqueue_site_styles() {
$direction_suffix = is_rtl() ? '.rtl' : '';
wp_register_style('usk-site', BDTUSK_ASSETS_URL . 'css/site' . $direction_suffix . '.css', [], BDTUSK_VER);
// The Product Table widget lists this as a style dependency and the file has
// always shipped, but it was never registered: the widget was silently
// relying on another plugin registering a "datatables" stylesheet.
wp_register_style('ultimate-store-kit-datatables', BDTUSK_ASSETS_URL . 'vendor/css/datatables.css', [], BDTUSK_VER);
wp_register_style('ultimate-store-kit-slick-modal', BDTUSK_ASSETS_URL . 'vendor/css/slickmodal.css', [], BDTUSK_VER);
wp_register_style('ultimate-store-kit-toolslide', BDTUSK_ASSETS_URL . 'vendor/css/toolslide.css', [], BDTUSK_VER);
wp_enqueue_style('usk-site');
wp_enqueue_style('ultimate-store-kit-slick-modal');
wp_enqueue_style('ultimate-store-kit-toolslide');
}
/**
* Loading site related script that needs all time such as uikit.
* @return [type] [description]
*/
public function enqueue_site_scripts() {
wp_register_script('usk-core', BDTUSK_ASSETS_URL . 'js/core.js', ['jquery'], BDTUSK_VER, true); // tooltip file should be separate
wp_register_script('usk-site', BDTUSK_ASSETS_URL . 'js/site.js', ['jquery'], BDTUSK_VER, true); // tooltip file should be separate
wp_register_script('ultimate-store-kit-slick-modal', BDTUSK_ASSETS_URL . 'vendor/js/jquery.slickmodal.js', ['jquery'], BDTUSK_VER, true); // tooltip file should be separate
wp_register_script('ultimate-store-kit-toolslide', BDTUSK_ASSETS_URL . 'vendor/js/toolslide.js', [], BDTUSK_VER, true); // tooltip file should be separate
wp_enqueue_script('usk-core');
// wp_enqueue_script('usk-site');
wp_enqueue_script('ultimate-store-kit-slick-modal');
wp_enqueue_script('ultimate-store-kit-toolslide');
wp_localize_script('usk-core', 'ultimate_store_kit_ajax_config', array(
'ajaxurl' => admin_url('admin-ajax.php'),
// Only consumed for logged-in requests — see WishlistCompare::verify_request().
'nonce' => wp_create_nonce('usk_wishlist_compare'),
));
}
public function enqueue_editor_scripts() {
wp_register_script('usk-editor', BDTUSK_ASSETS_URL . 'js/editor.js', ['backbone-marionette', 'elementor-common-modules', 'elementor-editor-modules',], BDTUSK_VER, true);
wp_enqueue_script('usk-editor');
$ultimate_store_kit_is_pro_activated = false;
if (function_exists('ultimate_store_kit_license_validation') && true === ultimate_store_kit_license_validation()) {
$ultimate_store_kit_is_pro_activated = true;
}
$localize_data = [
'pro_installed' => ultimate_store_kit_is_pro_activated(),
'pro_license_activated' => $ultimate_store_kit_is_pro_activated,
'promotional_widgets' => [],
];
if (!$ultimate_store_kit_is_pro_activated) {
$pro_widget_map = new \UltimateStoreKit\Includes\Pro_Widget_Map();
$localize_data['promotional_widgets'] = $pro_widget_map->get_pro_widget_map();
}
wp_localize_script('usk-editor', 'UltimateStoreKitConfigEditor', $localize_data);
}
public function enqueue_admin_scripts() {
wp_register_script('usk-admin', BDTUSK_ASSETS_URL . 'js/admin.js', ['jquery'], BDTUSK_VER, true);
wp_enqueue_script('usk-admin');
}
public function enqueue_editor_styles() {
$direction_suffix = is_rtl() ? '.rtl' : '';
wp_register_style('usk-editor', BDTUSK_ASSETS_URL . 'css/editor' . $direction_suffix . '.css', [], BDTUSK_VER);
wp_register_style('usk-font', BDTUSK_ASSETS_URL . 'css/font' . $direction_suffix . '.css', [], BDTUSK_VER);
wp_enqueue_style('usk-editor');
wp_enqueue_style('usk-font');
}
public function ultimate_store_kit_init() {
$this->_modules_manager = new Manager();
$this->ultimate_store_kit_modal_settings_init();
do_action('bdthemes_ultimate_store_kit/init');
}
/**
* initialize the category
* @return [type] [description]
*/
public function ultimate_store_kit_category_register() {
$elementor = Plugin::$instance;
$new_category = [
'ultimate-store-kit-single' => [
'title' => 'Ultimate Store Kit (Single)',
'icon' => 'font',
],
'ultimate-store-kit-my-account' => [
'title' => 'Ultimate Store Kit (Account)',
'icon' => 'font',
],
'ultimate-store-kit-checkout' => [
'title' => 'Ultimate Store Kit (Checkout)',
'icon' => 'font',
'active' => false,
],
'ultimate-store-kit-order-thankyou' => [
'title' => 'Ultimate Store Kit (ThankYou)',
'icon' => 'font',
'active' => false,
],
];
$existing_categories = $elementor->elements_manager->get_categories();
$merged_categories = $new_category + $existing_categories;
/**
* Override categories using reflection (since it's private)
*/
$reflection = new \ReflectionClass($elementor->elements_manager);
$property = $reflection->getProperty('categories');
// $property->setAccessible(true);
$property->setValue($elementor->elements_manager, $merged_categories);
$elementor->elements_manager->add_category(BDTUSK_SLUG, ['title' => BDTUSK_TITLE, 'icon' => 'font']);
}
/**
* Setup all hooks here
* @return [type] [description]
*/
private function setup_hooks() {
add_filter('body_class', [$this, 'add_body_classes']);
add_action('elementor/elements/categories_registered', [$this, 'ultimate_store_kit_category_register'], 1, 1);
add_action('elementor/init', [$this, 'ultimate_store_kit_init']);
add_action('elementor/editor/after_enqueue_styles', [$this, 'enqueue_editor_styles']);
add_action('wp_enqueue_scripts', [$this, 'register_site_styles'], 99999);
add_action('wp_enqueue_scripts', [$this, 'register_site_scripts'], 99999);
add_action('wp_enqueue_scripts', [$this, 'enqueue_site_styles'], 99999);
add_action('wp_enqueue_scripts', [$this, 'enqueue_site_scripts'], 99999);
add_action('elementor/editor/after_enqueue_scripts', [$this, 'enqueue_editor_scripts']);
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
}
public function add_body_classes($classes) {
$single_page_checkout_classes = ['ultimate-store-kit'];
return is_array($classes)
? array_merge($classes, $single_page_checkout_classes)
: $classes . ' ' . implode(' ', $single_page_checkout_classes);
}
public function ultimate_store_kit_modal_settings_init() {
require 'includes/modal/modal-controls.php';
add_action('elementor/kit/register_tabs', function (Kit $kit) {
$kit->register_tab('ultimate-store-kit-modal', Includes\Settings\Settings_Modal::class);
}, 1, 40);
}
public function init() {
if (!defined('BDTUSK_CH') && is_admin()) {
Dashboard::get_instance();
}
}
/**
* Ultimate_Store_Kit_Loader constructor.
*/
private function __construct() {
// Register class automatically
spl_autoload_register([$this, 'autoload']);
// Include some backend files
$this->_includes();
// Finally hooked up all things here
$this->setup_hooks();
// Register REST API routes unconditionally (outside is_admin)
\UltimateStoreKit\API\Settings::get_instance();
add_action('init', [$this, 'init']);
}
}
if (!defined('BDTUSK_TESTS')) {
// In tests we run the instance manually.
Ultimate_Store_Kit_Loader::instance();
}
// handy fundtion for push data
function ultimate_store_kit_config() {
return Ultimate_Store_Kit_Loader::instance();
}