PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 1.3.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v1.3.1
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.3.1, at handler.php

250 lines 7.3 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 }
66
67 /**
68 * Enqueue scripts
69 *
70 * Enqueue js and css to frontend.
71 *
72 * @since 1.0.0
73 * @access public
74 */
75 public function enqueue_frontend(){
76 wp_enqueue_style( 'elementskit-framework-css-frontend', \ElementsKit::lib_url() . 'framework/assets/css/frontend-style.css', \ElementsKit::VERSION );
77 wp_enqueue_script( 'elementskit-framework-js-frontend', \ElementsKit::lib_url() . 'framework/assets/js/frontend-script.js', \ElementsKit::VERSION, true );
78 }
79 public function enqueue_frontend_inline(){
80 $script_builder = new Core\Build_Inline_scripts();
81 $script_builder->script_for_frontend();
82 }
83
84 /**
85 * Enqueue scripts
86 *
87 * Enqueue js and css to admin.
88 *
89 * @since 1.0.0
90 * @access public
91 */
92 public function enqueue_admin(){
93 wp_register_style( 'elementskit-global-css-admin', \ElementsKit::lib_url() . 'framework/assets/css/admin-global.css', \ElementsKit::VERSION );
94 wp_enqueue_style( 'elementskit-global-css-admin' );
95
96 $screen = get_current_screen();
97 if(!in_array($screen->id, ['nav-menus', 'toplevel_page_elementskit', 'edit-elementskit_template'])){
98 return;
99 }
100
101 wp_register_style( 'fontawesome', \ElementsKit::widget_url() . 'init/assets/css/font-awesome.min.css', \ElementsKit::VERSION );
102 wp_register_style( 'elementskit-font-css-admin', \ElementsKit::widget_url() . 'init/assets/css/admin-ekiticon.css', \ElementsKit::VERSION );
103 wp_register_style( 'elementskit-lib-css-admin', \ElementsKit::lib_url() . 'framework/assets/css/framework.css', \ElementsKit::VERSION );
104 wp_register_style( 'elementskit-init-css-admin', \ElementsKit::lib_url() . 'framework/assets/css/admin-style.css', \ElementsKit::VERSION );
105 wp_register_style( 'elementskit-init-css-ems-admin', \ElementsKit::lib_url() . 'framework/assets/css/admin-style-ems-dev.css', \ElementsKit::VERSION );
106
107
108 wp_enqueue_style( 'fontawesome' );
109 wp_enqueue_style( 'elementskit-font-css-admin' );
110 wp_enqueue_style( 'elementskit-lib-css-admin' );
111 wp_enqueue_style( 'elementskit-init-css-ems-admin' );
112 wp_enqueue_style( 'elementskit-init-css-admin' );
113
114 wp_enqueue_script( 'elementskit-admin-core-ui', \ElementsKit::lib_url() . 'framework/assets/js/core-ui.min.js', \ElementsKit::VERSION, true );
115 wp_enqueue_script( 'elementskit-init-js-admin', \ElementsKit::lib_url() . 'framework/assets/js/admin-script.js', \ElementsKit::VERSION, true );
116 }
117 public function enqueue_admin_inline(){
118 $script_builder = new Core\Build_Inline_scripts();
119 $script_builder->script_for_admin();
120 }
121
122
123 /**
124 * Control registrar.
125 *
126 * Register the custom controls for Elementor
127 * using `elementskit/widgets/widgets_registered` action.
128 *
129 * @since 1.0.0
130 * @access public
131 */
132 public function register_control($widgets_manager){
133 do_action('elementskit/widgets/widgets_registered', $widgets_manager);
134 }
135
136
137 /**
138 * Api registrar.
139 *
140 * Retrieve all the registered API's endpoints
141 * using `elementskit/apis/apis_registered/post` action (for POST method).
142 * using `elementskit/apis/apis_registered/get` action (for GET method).
143 *
144 * @since 1.0.0
145 * @access public
146 */
147 public function register_apis(){
148 new Core\Build_Apis();
149 }
150
151
152 /**
153 * Widget registrar.
154 *
155 * Retrieve all the registered widgets
156 * using `elementor/widgets/widgets_registered` action.
157 *
158 * @since 1.0.0
159 * @access public
160 */
161 public function register_widgets($widgets_manager){
162 do_action('elementskit/widgets/widgets_registered', $widgets_manager);
163 }
164
165
166 /**
167 * Construct the plugin object.
168 *
169 * @since 1.0.0
170 * @access public
171 */
172 private function registrar_version_manager(){
173 // run the migration class if current version is greater than old installed version.
174 if(Helper::current_version() > Helper::old_version()){
175 // load the update and related migration classes
176 // new ElementsKit_Version_Manager();
177 }
178 }
179
180
181 /**
182 * Autoloader.
183 *
184 * ElementsKit autoloader loads all the classes needed to run the plugin.
185 *
186 * @since 1.0.0
187 * @access private
188 */
189 private function registrar_autoloader() {
190 require_once \ElementsKit::plugin_dir() . '/autoloader.php';
191 Autoloader::run();
192 }
193
194
195 /**
196 * Disable class cloning and throw an error on object clone.
197 *
198 * The whole idea of the singleton design pattern is that there is a single
199 * object. Therefore, we don't want the object to be cloned.
200 *
201 * @access public
202 * @since 1.0.0
203 */
204 public function __clone() {
205
206 // Cloning instances of the class is forbidden.
207 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'elementskit' ), '1.0.0' );
208 }
209
210
211 /**
212 * Disable unserializing of the class.
213 *
214 * @access public
215 * @since 1.0.0
216 */
217 public function __wakeup() {
218
219 // Unserializing instances of the class is forbidden.
220 _doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing instances of this class is forbidden.', 'elementskit' ), '1.0.0' );
221 }
222
223
224 /**
225 * Instance.
226 *
227 * Ensures only one instance of the plugin class is loaded or can be loaded.
228 *
229 * @since 1.0.0
230 * @access public
231 * @static
232 *
233 * @return Handler An instance of the class.
234 */
235 public static function instance() {
236 if ( is_null( self::$instance ) ) {
237
238 // Fire when ElementsKit instance.
239 self::$instance = new self();
240
241 // Fire when ElementsKit was fully loaded and instantiated.
242 do_action( 'elementskit/loaded' );
243 }
244
245 return self::$instance;
246 }
247 }
248
249 // Run the instance.
250 Handler::instance();