PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 1.5.2
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v1.5.2
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 / includes / modules-manager.php

modules-manager.php in Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder 1.5.2, at includes/modules-manager.php

95 lines 3.0 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 UltimateStoreKit\Admin\ModuleService;
6
7 if (!defined('ABSPATH')) {
8 exit;
9 } // Exit if accessed directly
10
11 final class Manager {
12
13
14 public function register_module_and_assets() {
15
16 ModuleService::get_widget_settings(function ($settings) {
17 $wc_widgets = $settings['settings_fields']['ultimate_store_kit_active_modules'];
18 $edd_widgets = $settings['settings_fields']['ultimate_store_kit_edd_modules'];
19 $general_widgets = $settings['settings_fields']['ultimate_store_kit_general_modules'];
20
21
22
23
24 /**
25 * Our Widget
26 */
27 foreach ($general_widgets as $widget) {
28 if (ultimate_store_kit_is_general_widget_enabled($widget['name'])) {
29 // print_r($widget);
30 // die;
31
32 $this->load_module_instance($widget);
33 }
34 }
35
36
37 foreach ($wc_widgets as $widget) {
38 if (ultimate_store_kit_is_widget_enabled($widget['name'])) {
39 if (isset($widget['plugin_path']) && ModuleService::is_plugin_active($widget['plugin_path'])) {
40 $this->load_module_instance($widget);
41 }
42 }
43 }
44
45
46 /**
47 * EDD Widget
48 */
49 foreach ($edd_widgets as $widget) {
50 if (ultimate_store_kit_is_edd_enabled($widget['name'])) {
51 if (isset($widget['plugin_path']) && ModuleService::is_plugin_active($widget['plugin_path'])) {
52 $this->load_module_instance($widget);
53 }
54 }
55 }
56 // Static module if need
57 $this->load_module_instance(['name' => 'elementor']);
58 });
59 }
60
61 public function load_module_instance($module) {
62
63
64 $direction = is_rtl() ? '.rtl' : '';
65 $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
66
67 $module_id = $module['name'];
68 $class_name = str_replace('-', ' ', $module_id);
69 $class_name = str_replace(' ', '', ucwords($class_name));
70 $class_name = __NAMESPACE__ . '\\Modules\\' . $class_name . '\\Module';
71
72
73 if (!ultimate_store_kit_is_preview()) {
74 // register widgets css
75 if (ModuleService::has_module_style($module_id)) {
76 wp_register_style('usk-' . $module_id, BDTUSK_URL . 'assets/css/usk-' . $module_id . $direction . '.css', [], BDTUSK_VER);
77 }
78 // register widget JS
79 if (ModuleService::has_module_script($module_id)) {
80 wp_register_script('usk-' . $module_id, BDTUSK_URL . 'assets/js/widgets/usk-' . $module_id . '.js', ['jquery', 'bdt-uikit', 'elementor-frontend'], BDTUSK_VER, true);
81 }
82 }
83
84
85 if (class_exists($class_name)) {
86 $class_name::instance();
87 }
88 }
89
90 public function __construct() {
91
92 $this->register_module_and_assets();
93 }
94 }
95