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

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