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