PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 1.4.4
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v1.4.4
4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 All 183 releases
elementskit-lite / handler.php

handler.php in ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor 1.4.4, at handler.php

256 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ElementsKit;
3
4 defined( 'ABSPATH' ) || exit;
5
6
7 /**
8 * ElementsKit - the God class.
9 * Initiate all necessary classes, hooks, configs.
10 *
11 * @since 1.1.0
12 */
13 class Handler{
14
15
16 /**
17 * The plugin instance.
18 *
19 * @since 1.0.0
20 * @access public
21 * @static
22 *
23 * @var Handler
24 */
25 public static $instance = null;
26
27 /**
28 * Construct the plugin object.
29 *
30 * @since 1.0.0
31 * @access public
32 */
33 public function __construct() {
34
35 // Call the method for ElementsKit autoloader.
36 $this->registrar_autoloader();
37
38 // Enqueue frontend scripts.
39 add_action( 'wp_enqueue_scripts', [$this, 'enqueue_frontend'] );
40
41 // Enqueue admin scripts.
42 add_action( 'admin_enqueue_scripts', [$this, 'enqueue_admin'] );
43
44 // Enqueue inline scripts
45 Core\Build_Inline_Scripts::instance();
46
47 // Register plugin settings pages
48 Libs\Framework\Attr::instance();
49
50 // Register default widgets
51 Core\Build_Widgets::instance();
52
53 // Register default modules
54 Core\Build_Modules::instance();
55
56 // Register ElementsKit supported widgets to Elementor from 3rd party plugins.
57 add_action( 'elementor/widgets/widgets_registered', [$this, 'register_widgets'], 1050);
58
59 // Register ElementsKit's custom endpoints for WP RESTful APIs and 3rd party hooks.
60 add_action( 'init', [$this, 'register_apis'], 1055);
61
62 // Adding pro lebel
63 new Libs\Pro_Label\Init();
64
65 // Add banner class
66 add_action('admin_notices', function(){
67 include \ElementsKit::lib_dir() . 'banner/init.php';
68 \WpMet_Banner::run();
69 });
70
71 }
72
73 /**
74 * Enqueue scripts
75 *
76 * Enqueue js and css to frontend.
77 *
78 * @since 1.0.0
79 * @access public
80 */
81 public function enqueue_frontend(){
82 wp_enqueue_style( 'elementskit-framework-css-frontend', \ElementsKit::lib_url() . 'framework/assets/css/frontend-style.css', \ElementsKit::VERSION );
83 wp_enqueue_script( 'elementskit-framework-js-frontend', \ElementsKit::lib_url() . 'framework/assets/js/frontend-script.js', ['jquery'], \ElementsKit::VERSION, true );
84 }
85 public function enqueue_frontend_inline(){
86 $script_builder = new Core\Build_Inline_scripts();
87 $script_builder->script_for_frontend();
88 }
89
90 /**
91 * Enqueue scripts
92 *
93 * Enqueue js and css to admin.
94 *
95 * @since 1.0.0
96 * @access public
97 */
98 public function enqueue_admin(){
99 wp_register_style( 'elementskit-global-css-admin', \ElementsKit::lib_url() . 'framework/assets/css/admin-global.css', \ElementsKit::VERSION );
100 wp_enqueue_style( 'elementskit-global-css-admin' );
101
102 $screen = get_current_screen();
103 if(!in_array($screen->id, ['nav-menus', 'toplevel_page_elementskit', 'edit-elementskit_template'])){
104 return;
105 }
106
107 wp_register_style( 'fontawesome', \ElementsKit::widget_url() . 'init/assets/css/font-awesome.min.css', \ElementsKit::VERSION );
108 wp_register_style( 'elementskit-font-css-admin', \ElementsKit::widget_url() . 'init/assets/css/admin-ekiticon.css', \ElementsKit::VERSION );
109 wp_register_style( 'elementskit-lib-css-admin', \ElementsKit::lib_url() . 'framework/assets/css/framework.css', \ElementsKit::VERSION );
110 wp_register_style( 'elementskit-init-css-admin', \ElementsKit::lib_url() . 'framework/assets/css/admin-style.css', \ElementsKit::VERSION );
111 wp_register_style( 'elementskit-init-css-ems-admin', \ElementsKit::lib_url() . 'framework/assets/css/admin-style-ems-dev.css', \ElementsKit::VERSION );
112
113
114 wp_enqueue_style( 'fontawesome' );
115 wp_enqueue_style( 'elementskit-font-css-admin' );
116 wp_enqueue_style( 'elementskit-lib-css-admin' );
117 wp_enqueue_style( 'elementskit-init-css-ems-admin' );
118 wp_enqueue_style( 'elementskit-init-css-admin' );
119
120 wp_enqueue_script( 'elementskit-admin-core-ui', \ElementsKit::lib_url() . 'framework/assets/js/core-ui.min.js', \ElementsKit::VERSION, true );
121 wp_enqueue_script( 'elementskit-init-js-admin', \ElementsKit::lib_url() . 'framework/assets/js/admin-script.js', ['jquery'], \ElementsKit::VERSION, true );
122 }
123 public function enqueue_admin_inline(){
124 $script_builder = new Core\Build_Inline_scripts();
125 $script_builder->script_for_admin();
126 }
127
128
129 /**
130 * Control registrar.
131 *
132 * Register the custom controls for Elementor
133 * using `elementskit/widgets/widgets_registered` action.
134 *
135 * @since 1.0.0
136 * @access public
137 */
138 public function register_control($widgets_manager){
139 do_action('elementskit/widgets/widgets_registered', $widgets_manager);
140 }
141
142
143 /**
144 * Api registrar.
145 *
146 * Retrieve all the registered API's endpoints
147 * using `elementskit/apis/apis_registered/post` action (for POST method).
148 * using `elementskit/apis/apis_registered/get` action (for GET method).
149 *
150 * @since 1.0.0
151 * @access public
152 */
153 public function register_apis(){
154 new Core\Build_Apis();
155 }
156
157
158 /**
159 * Widget registrar.
160 *
161 * Retrieve all the registered widgets
162 * using `elementor/widgets/widgets_registered` action.
163 *
164 * @since 1.0.0
165 * @access public
166 */
167 public function register_widgets($widgets_manager){
168 do_action('elementskit/widgets/widgets_registered', $widgets_manager);
169 }
170
171
172 /**
173 * Construct the plugin object.
174 *
175 * @since 1.0.0
176 * @access public
177 */
178 private function registrar_version_manager(){
179 // run the migration class if current version is greater than old installed version.
180 if(Helper::current_version() > Helper::old_version()){
181 // load the update and related migration classes
182 // new ElementsKit_Version_Manager();
183 }
184 }
185
186
187 /**
188 * Autoloader.
189 *
190 * ElementsKit autoloader loads all the classes needed to run the plugin.
191 *
192 * @since 1.0.0
193 * @access private
194 */
195 private function registrar_autoloader() {
196 require_once \ElementsKit::plugin_dir() . '/autoloader.php';
197 Autoloader::run();
198 }
199
200
201 /**
202 * Disable class cloning and throw an error on object clone.
203 *
204 * The whole idea of the singleton design pattern is that there is a single
205 * object. Therefore, we don't want the object to be cloned.
206 *
207 * @access public
208 * @since 1.0.0
209 */
210 public function __clone() {
211
212 // Cloning instances of the class is forbidden.
213 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'elementskit' ), '1.0.0' );
214 }
215
216
217 /**
218 * Disable unserializing of the class.
219 *
220 * @access public
221 * @since 1.0.0
222 */
223 public function __wakeup() {
224
225 // Unserializing instances of the class is forbidden.
226 _doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing instances of this class is forbidden.', 'elementskit' ), '1.0.0' );
227 }
228
229
230 /**
231 * Instance.
232 *
233 * Ensures only one instance of the plugin class is loaded or can be loaded.
234 *
235 * @since 1.0.0
236 * @access public
237 * @static
238 *
239 * @return Handler An instance of the class.
240 */
241 public static function instance() {
242 if ( is_null( self::$instance ) ) {
243
244 // Fire when ElementsKit instance.
245 self::$instance = new self();
246
247 // Fire when ElementsKit was fully loaded and instantiated.
248 do_action( 'elementskit/loaded' );
249 }
250
251 return self::$instance;
252 }
253 }
254
255 // Run the instance.
256 Handler::instance();