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 / core.php

core.php in ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor 1.4.7, at core.php

385 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || exit;
4
5 if(!class_exists('ElementsKit')):
6 final class ElementsKit{
7 /**
8 * Plugin Version
9 *
10 * @since 1.0.0
11 * @var string The plugin version.
12 */
13 const VERSION = '1.4.7';
14
15 /**
16 * Package type
17 *
18 * @since 1.1.0
19 * @var string The plugin purchase type [pro/ free].
20 */
21 const PACKAGE_TYPE = 'free';
22
23 /**
24 * Product ID
25 *
26 * @since 1.2.6
27 * @var string The plugin ID in our server.
28 */
29 const PRODUCT_ID = '9';
30
31 /**
32 * Minimum Elementor Version
33 *
34 * @since 1.0.0
35 * @var string Minimum Elementor version required to run the plugin.
36 */
37
38 const MINIMUM_ELEMENTOR_VERSION = '2.4.0';
39
40 /**
41 * Minimum PHP Version
42 *
43 * @since 1.0.0
44 * @var string Minimum PHP version required to run the plugin.
45 */
46 const MINIMUM_PHP_VERSION = '5.6';
47
48 /**
49 * API url
50 *
51 * @since 1.0.0
52 * @var string plugins's root url.
53 */
54 static function api_url(){
55 return 'https://api.wpmet.com/public/';
56 }
57
58 /**
59 * Plugin url
60 *
61 * @since 1.0.0
62 * @var string plugins's root url.
63 */
64 static function plugin_url(){
65 return trailingslashit(plugin_dir_url( __FILE__ ));
66 }
67
68 /**
69 * Plugin dir
70 *
71 * @since 1.0.0
72 * @var string plugins's root directory.
73 */
74 static function plugin_dir(){
75 return trailingslashit(plugin_dir_path( __FILE__ ));
76 }
77
78 /**
79 * Plugin's widget directory.
80 *
81 * @since 1.0.0
82 * @var string widget's root directory.
83 */
84 static function widget_dir(){
85 return self::plugin_dir() . 'widgets/';
86 }
87
88 /**
89 * Plugin's widget url.
90 *
91 * @since 1.0.0
92 * @var string widget's root url.
93 */
94 static function widget_url(){
95 return self::plugin_url() . 'widgets/';
96 }
97
98
99 /**
100 * Plugin's widget image choose url.
101 *
102 * @since 1.0.0
103 * @var string widget image choose's root url.
104 */
105
106 /**
107 * Plugin's module directory.
108 *
109 * @since 1.0.0
110 * @var string module's root directory.
111 */
112 static function module_dir(){
113 return self::plugin_dir() . 'modules/';
114 }
115
116 /**
117 * Plugin's module url.
118 *
119 * @since 1.0.0
120 * @var string module's root url.
121 */
122 static function module_url(){
123 return self::plugin_url() . 'modules/';
124 }
125
126
127 /**
128 * Plugin's lib directory.
129 *
130 * @since 1.0.0
131 * @var string lib's root directory.
132 */
133 static function lib_dir(){
134 return self::plugin_dir() . 'libs/';
135 }
136
137 /**
138 * Plugin's lib url.
139 *
140 * @since 1.0.0
141 * @var string lib's root url.
142 */
143 static function lib_url(){
144 return self::plugin_url() . 'libs/';
145 }
146
147 /**
148 * Constructor
149 *
150 * @since 1.0.0
151 * @access public
152 */
153 public function __construct() {
154 // Load translation
155 add_action( 'init', array( $this, 'i18n' ) );
156 // Init Plugin
157 $this->init();
158 }
159
160 /**
161 * Load Textdomain
162 *
163 * Load plugin localization files.
164 * Fired by `init` action hook.
165 *
166 * @since 1.0.0
167 * @access public
168 */
169 public function i18n() {
170 load_plugin_textdomain( 'elementskit', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
171 }
172
173 /**
174 * Initialize the plugin
175 *
176 * Checks for basic plugin requirements, if one check fail don't continue,
177 * if all check have passed include the plugin class.
178 *
179 * Fired by `plugins_loaded` action hook.
180 *
181 * @since 1.0.0
182 * @access public
183 */
184 public function init() {
185 // Load the main static helper class.
186 require_once self::plugin_dir() . 'helpers/notice.php';
187 require_once self::plugin_dir() . 'helpers/utils.php';
188
189 // Check if Elementor installed and activated.
190 if ( ! did_action( 'elementor/loaded' ) ) {
191 add_action( 'admin_notices', array( $this, 'missing_elementor' ) );
192 return;
193 }
194 // Check for required Elementor version.
195 if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
196 add_action( 'admin_notices', array( $this, 'failed_elementor_version' ) );
197 return;
198 }
199 // Check for required PHP version.
200 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
201 add_action( 'admin_notices', array( $this, 'failed_php_version' ) );
202 return;
203 }
204 // Once we get here, We have passed all validation checks so we can safely include our plugin.
205
206 // Register ElementsKit widget category
207 add_action('elementor/init', [$this, 'elementor_widget_category']);
208
209 add_action( 'elementor/init', function(){
210 // Load the Handler class, it's the core class of ElementsKit.
211 require_once self::plugin_dir() . 'handler.php';
212 });
213
214 }
215
216 /**
217 * Admin notice
218 *
219 * Warning when the site doesn't have required Elementor.
220 *
221 * @since 1.0.0
222 * @access public
223 */
224 public function missing_elementor() {
225 if ( isset( $_GET['activate'] ) ) {
226 unset( $_GET['activate'] );
227 }
228
229 if ( file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) ) {
230 $btn['label'] = esc_html__('Activate Elementor', 'elementskit');
231 $btn['url'] = wp_nonce_url( 'plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php' );
232 } else {
233 $btn['label'] = esc_html__('Install Elementor', 'elementskit');
234 $btn['url'] = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
235 }
236
237 \ElementsKit\Notice::push(
238 [
239 'id' => 'unsupported-elementor-version',
240 'type' => 'error',
241 'dismissible' => true,
242 'btn' => $btn,
243 'message' => sprintf( esc_html__( 'ElementsKit requires Elementor version %1$s+, which is currently NOT RUNNING.', 'elementskit' ), self::MINIMUM_ELEMENTOR_VERSION ),
244 ]
245 );
246 }
247
248
249 /**
250 * Admin notice
251 *
252 * Warning when the site doesn't have a minimum required PHP version.
253 *
254 * @since 1.0.0
255 * @access public
256 */
257 public function admin_notice_minimum_php_version() {
258 \ElementsKit\Notice::push(
259 [
260 'id' => 'unsupported-php-version',
261 'type' => 'error',
262 'dismissible' => true,
263 'message' => sprintf( esc_html__( 'ElementsKit requires PHP version %1$s+, which is currently NOT RUNNING on this server.', 'elementskit' ), self::MINIMUM_PHP_VERSION ),
264 ]
265 );
266 }
267
268 /**
269 * Add category.
270 *
271 * Register custom widget category in Elementor's editor
272 *
273 * @since 1.0.0
274 * @access public
275 */
276 public function elementor_widget_category($widgets_manager){
277 \Elementor\Plugin::$instance->elements_manager->add_category(
278 'elementskit',
279 [
280 'title' =>esc_html__( 'ElementsKit', 'elementskit' ),
281 'icon' => 'fa fa-plug',
282 ],
283 1
284 );
285 \Elementor\Plugin::$instance->elements_manager->add_category(
286 'elementskit_headerfooter',
287 [
288 'title' =>esc_html__( 'ElementsKit Header Footer', 'elementskit' ),
289 'icon' => 'fa fa-plug',
290 ],
291 1
292 );
293 }
294
295
296 static function default_widgets($package = null){
297 $package = ($package != null) ? $package : self::PACKAGE_TYPE;
298
299 $default_list = [
300 'image-accordion',
301 'accordion',
302 'button',
303 'heading',
304 'blog-posts',
305 'icon-box',
306 'image-box',
307 'countdown-timer',
308 'client-logo',
309 'faq',
310 'funfact',
311 'image-comparison',
312 'testimonial',
313 'pricing',
314 'team',
315 'social',
316 'progressbar',
317 'category-list',
318 'page-list',
319 'post-grid',
320 'post-list',
321 'post-tab',
322 'nav-menu',
323 'mail-chimp',
324 'header-info',
325 'piechart',
326 'header-search',
327 'header-offcanvas',
328 'tab',
329 'contact-form7',
330 'video',
331 'business-hours',
332 'drop-caps',
333 'social-share',
334 'dual-button',
335 'caldera-forms',
336 'we-forms',
337 'wp-forms',
338 'ninja-forms',
339 ];
340
341 $optional_list = [
342 'advanced-accordion',
343 'advanced-tab',
344 'hotspot',
345 'motion-text',
346 'twitter-feed',
347 'facebook-feed',
348 'instagram-feed',
349 'gallery',
350 'chart',
351 'woo-category-list',
352 'woo-mini-cart',
353 'woo-product-carousel',
354 'woo-product-list',
355 'table',
356 'timeline',
357 'creative-button',
358 ];
359
360 if(class_exists('\ElementsKit_Widget_Config')){
361 return (array_merge($default_list, \ElementsKit_Widget_Config::instance()->get_widgets()));
362 }else{
363 return ($package == 'pro') ? array_merge($default_list, $optional_list) : $default_list;
364 }
365 }
366
367 static function default_modules($package = null){
368 $package = ($package != null) ? $package : self::PACKAGE_TYPE;
369 $default_list = [
370 'header-footer',
371 'megamenu',
372 ];
373
374 $optional_list =[
375 'parallax',
376 'sticky-content',
377 ];
378
379 return ($package == 'pro') ? array_merge($default_list, $optional_list) : $default_list;
380 }
381 }
382
383 new ElementsKit();
384
385 endif;