PluginProbe
Ultimate Store Kit / 3.1.2
Ultimate Store Kit v3.1.2
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 2.0.6 All 92 releases
ultimate-store-kit / includes / modules-manager.php

modules-manager.php in Ultimate Store Kit 3.1.2, at includes/modules-manager.php

87 lines 2.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 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 * Our Widget
23 */
24 foreach ($general_widgets as $widget) {
25 if (ultimate_store_kit_is_general_widget_enabled($widget['name'])) {
26 $this->load_module_instance($widget);
27 }
28 }
29
30 foreach ($wc_widgets as $widget) {
31 if (ultimate_store_kit_is_widget_enabled($widget['name'])) {
32 if (isset($widget['plugin_path']) && ModuleService::is_plugin_active($widget['plugin_path'])) {
33 $this->load_module_instance($widget);
34 }
35 }
36 }
37
38 /**
39 * EDD Widget
40 */
41 foreach ($edd_widgets as $widget) {
42 if (ultimate_store_kit_is_edd_enabled($widget['name'])) {
43 if (isset($widget['plugin_path']) && ModuleService::is_plugin_active($widget['plugin_path'])) {
44 $this->load_module_instance($widget);
45 }
46 }
47 }
48 // Static module if need
49 $this->load_module_instance(['name' => 'elementor']);
50 });
51 }
52
53 public function load_module_instance($module) {
54
55
56 $direction = is_rtl() ? '.rtl' : '';
57
58
59 $module_id = $module['name'];
60 $class_name = str_replace('-', ' ', $module_id);
61 $class_name = str_replace(' ', '', ucwords($class_name));
62 $class_name = __NAMESPACE__ . '\\Modules\\' . $class_name . '\\Module';
63
64
65 if (!ultimate_store_kit_is_preview()) {
66 // register widgets css
67 if (ModuleService::has_module_style($module_id)) {
68 wp_register_style('usk-' . $module_id, BDTUSK_URL . 'assets/css/widgets/' . $module_id . $direction . '.css', [], BDTUSK_VER);
69 }
70 // register widget JS
71 if (ModuleService::has_module_script($module_id)) {
72 wp_register_script('usk-' . $module_id, BDTUSK_URL . 'assets/js/widgets/' . $module_id . '.js', ['jquery'], BDTUSK_VER, true);
73 }
74 }
75
76
77 if (class_exists($class_name)) {
78 $class_name::instance();
79 }
80 }
81
82 public function __construct() {
83
84 $this->register_module_and_assets();
85 }
86 }
87