PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.2.3
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.2.3
4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 All 146 releases
ultimate-post-kit / includes / modules-manager.php

modules-manager.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.2.3, at includes/modules-manager.php

135 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimatePostKit;
4
5 use UltimatePostKit\Admin\ModuleService;
6
7 if (!defined('ABSPATH')) {
8 exit;
9 } // Exit if accessed directly
10
11 if (!function_exists('is_plugin_active')) {
12 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
13 }
14
15 final class Manager
16 {
17 private $_modules = [];
18
19 private function is_module_active($module_id)
20 {
21
22 $module_data = $this->get_module_data($module_id);
23 $options = get_option('ultimate_post_kit_active_modules', []);
24
25 if (!isset($options[$module_id])) {
26 return $module_data['default_activation'];
27 } else {
28 if ($options[$module_id] == "on") {
29 return true;
30 } else {
31 return false;
32 }
33 }
34 }
35
36 private function has_module_style($module_id)
37 {
38
39 $module_data = $this->get_module_data($module_id);
40
41 if (isset($module_data['has_style'])) {
42 return $module_data['has_style'];
43 } else {
44 return false;
45 }
46 }
47 private function has_module_script($module_id)
48 {
49
50 $module_data = $this->get_module_data($module_id);
51
52 if (isset($module_data['has_script'])) {
53 return $module_data['has_script'];
54 } else {
55 return false;
56 }
57 }
58
59 private function get_module_data($module_id)
60 {
61 return isset($this->_modules[$module_id]) ? $this->_modules[$module_id] : false;
62 }
63
64 public function register_module_and_assets()
65 {
66
67 ModuleService::get_widget_settings(function ($settings) {
68 $core_widgets = $settings['settings_fields']['ultimate_post_kit_active_modules'];
69 $extensions = $settings['settings_fields']['ultimate_post_kit_elementor_extend'];
70 // $third_party_widgets = $settings['settings_fields']['ultimate_post_kit_third_party_widget'];
71
72 /**
73 * Our Widget
74 */
75 foreach ($core_widgets as $widget) {
76 if (ultimate_post_kit_is_widget_enabled($widget['name'])) {
77 $this->load_module_instance($widget);
78 }
79 }
80
81 /**
82 * Extension
83 */
84 foreach ($extensions as $extension) {
85 if (ultimate_post_kit_is_extend_enabled($extension['name'])) {
86 $this->load_module_instance($extension);
87 }
88 }
89
90 // Static module if need
91 $this->load_module_instance(['name' => 'elementor']);
92
93 });
94 }
95
96 public function load_module_instance($module)
97 {
98
99 if(isset($_GET['page']) && 'ultimate_post_kit_options' == $_GET['page']){
100 return;
101 }
102
103 $direction = is_rtl() ? '.rtl' : '';
104 $suffix = '.min';
105
106 $module_id = $module['name'];
107 $class_name = str_replace('-', ' ', $module_id);
108 $class_name = str_replace(' ', '', ucwords($class_name));
109 $class_name = __NAMESPACE__ . '\\Modules\\' . $class_name . '\\Module';
110
111
112 if (!ultimate_post_kit_is_preview()) {
113 // register widgets css
114 if (ModuleService::has_module_style( $module_id, BDTUPK_MODULES_PATH )) {
115 wp_register_style('upk-' . $module_id, BDTUPK_URL . 'assets/css/upk-' . $module_id . $direction . '.css', [], BDTUPK_VER);
116 }
117 // register widget JS
118 if (ModuleService::has_module_script( $module_id, BDTUPK_MODULES_PATH )) {
119 wp_register_script('upk-' . $module_id, BDTUPK_URL . 'assets/js/widgets/upk-' . $module_id . $suffix . '.js', ['jquery'], BDTUPK_VER, true);
120 }
121 }
122
123
124 if (class_exists($class_name)) {
125 $class_name::instance();
126 }
127 }
128
129 public function __construct()
130 {
131
132 $this->register_module_and_assets();
133 }
134 }
135