-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathplugin.php
More file actions
executable file
·709 lines (609 loc) · 16.6 KB
/
Copy pathplugin.php
File metadata and controls
executable file
·709 lines (609 loc) · 16.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
<?php
namespace PowerpackElementsLite;
use Elementor\Utils;
use PowerpackElementsLite\Classes\PP_Config;
use PowerpackElementsLite\Classes\PP_Helper;
if ( ! defined( 'ABSPATH' ) ) {
exit; } // Exit if accessed directly
/**
* Main class plugin
*/
class PowerpackLitePlugin {
/**
* @var Plugin
*/
private static $_instance;
/**
* @var Manager
*/
private $_extensions_manager;
/**
* @var Manager
*/
public $modules_manager;
/**
* @var array
*/
private $_localize_settings = [];
/**
* @return string
*/
public function get_version() {
return POWERPACK_ELEMENTS_LITE_VER;
}
/**
* Throw error on object clone
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @since 1.0.0
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'powerpack-lite-for-elementor' ), '1.0.0' );
}
/**
* Disable unserializing of the class
*
* @since 1.0.0
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'powerpack-lite-for-elementor' ), '1.0.0' );
}
/**
* @return Plugin
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
private function _includes() {
require POWERPACK_ELEMENTS_LITE_PATH . 'includes/extensions-manager.php';
require POWERPACK_ELEMENTS_LITE_PATH . 'includes/modules-manager.php';
}
public function autoload( $class ) {
if ( 0 !== strpos( $class, __NAMESPACE__ ) ) {
return;
}
$filename = strtolower(
preg_replace(
[ '/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ],
[ '', '$1-$2', '-', DIRECTORY_SEPARATOR ],
$class
)
);
$filename = POWERPACK_ELEMENTS_LITE_PATH . $filename . '.php';
if ( is_readable( $filename ) ) {
include $filename;
}
}
public function get_localize_settings() {
return $this->_localize_settings;
}
public function add_localize_settings( $setting_key, $setting_value = null ) {
if ( is_array( $setting_key ) ) {
$this->_localize_settings = array_replace_recursive( $this->_localize_settings, $setting_key );
return;
}
if ( ! is_array( $setting_value ) || ! isset( $this->_localize_settings[ $setting_key ] ) || ! is_array( $this->_localize_settings[ $setting_key ] ) ) {
$this->_localize_settings[ $setting_key ] = $setting_value;
return;
}
$this->_localize_settings[ $setting_key ] = array_replace_recursive( $this->_localize_settings[ $setting_key ], $setting_value );
}
public function register_styles() {
$settings = \PowerpackElementsLite\Classes\PP_Admin_Settings::get_settings();
$debug_suffix = ( PP_Helper::is_script_debug() ) ? '' : '.min';
$direction_suffix = is_rtl() ? '-rtl' : '';
$suffix = $direction_suffix . $debug_suffix;
$path = ( PP_Helper::is_script_debug() ) ? 'assets/css/' : 'assets/css/min/';
wp_register_style(
'pp-extensions',
POWERPACK_ELEMENTS_LITE_URL . $path . 'extensions' . $suffix . '.css',
array(),
POWERPACK_ELEMENTS_LITE_VER
);
wp_register_style(
'pp-tooltip',
POWERPACK_ELEMENTS_LITE_URL . $path . 'tooltip' . $suffix . '.css',
array(),
POWERPACK_ELEMENTS_LITE_VER
);
wp_register_style(
'pp-elementor-grid',
POWERPACK_ELEMENTS_LITE_URL . $path . 'elementor-grid' . $suffix . '.css',
array(),
POWERPACK_ELEMENTS_LITE_VER
);
wp_register_style(
'pp-swiper',
POWERPACK_ELEMENTS_LITE_URL . $path . 'pp-swiper' . $suffix . '.css',
array(),
POWERPACK_ELEMENTS_LITE_VER
);
wp_register_style(
'pp-image-filters',
POWERPACK_ELEMENTS_LITE_URL . $path . 'image-filters' . $suffix . '.css',
array(),
POWERPACK_ELEMENTS_LITE_VER
);
wp_register_style(
'pp-interactive-circle-animations',
POWERPACK_ELEMENTS_LITE_URL . $path . 'widget-interactive-circle-animations' . $suffix . '.css',
array(),
POWERPACK_ELEMENTS_LITE_VER
);
}
public function register_style_scripts() {
$settings = \PowerpackElementsLite\Classes\PP_Admin_Settings::get_settings();
$suffix = ( PP_Helper::is_script_debug() ) ? '' : '.min';
$path = ( PP_Helper::is_script_debug() ) ? 'assets/js/' : 'assets/js/min/';
$this->register_styles();
wp_register_script(
'pp-advanced-accordion',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-accordion' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-buttons',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-buttons' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-carousel',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-carousel' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-content-reveal',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-content-reveal' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-counter',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-counter' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-gravity-forms',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-gravity-forms' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-hotspots',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-hotspots' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-image-accordion',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-image-accordion' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-image-comparison',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-image-comparison' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-instafeed',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-instafeed' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-interactive-circle',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-interactive-circle' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-marquee',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-marquee' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-chartjs',
POWERPACK_ELEMENTS_LITE_URL . 'assets/lib/chartjs/chart.umd.min.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-chart',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-charts' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-scroll-image',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-scroll-image' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-pricing-table',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-pricing-table' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-progress-bar',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-progress-bar' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-twitter',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-twitter' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'isotope',
POWERPACK_ELEMENTS_LITE_URL . 'assets/lib/isotope/isotope.pkgd' . $suffix . '.js',
array(
'jquery',
),
'0.5.3',
true
);
wp_register_script(
'jquery-event-move',
POWERPACK_ELEMENTS_LITE_URL . 'assets/lib/jquery-event-move/jquery.event.move' . $suffix . '.js',
array(
'jquery',
),
'2.0.0',
true
);
wp_register_script(
'pp-jquery-plugin',
POWERPACK_ELEMENTS_LITE_URL . 'assets/js/jquery.plugin.js',
[
'jquery',
],
'1.0.0',
true
);
wp_register_script(
'twitter-widgets',
POWERPACK_ELEMENTS_LITE_URL . $path . 'twitter-widgets' . $suffix . '.js',
[
'jquery',
],
'1.0.0',
true
);
wp_register_script(
'powerpack-pp-posts',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-posts' . $suffix . '.js',
[
'jquery',
],
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_localize_script(
'powerpack-pp-posts',
'ppPostsScript',
[
'ajax_url' => admin_url( 'admin-ajax.php' ),
'posts_nonce' => wp_create_nonce( 'pp-posts-widget-nonce' ),
]
);
wp_register_script(
'pp-tooltipster',
POWERPACK_ELEMENTS_LITE_URL . 'assets/lib/tooltipster/tooltipster' . $suffix . '.js',
[
'jquery',
],
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-animated-gradient-bg',
POWERPACK_ELEMENTS_LITE_URL . $path . 'pp-gradient-bg-animation' . $suffix . '.js',
array(
'jquery',
),
'1.0.0',
true
);
wp_register_script(
'pp-custom-cursor',
POWERPACK_ELEMENTS_LITE_URL . $path . 'pp-custom-cursor' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
wp_register_script(
'pp-wrapper-link',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend-wrapper-link' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
$localize_data = PP_Helper::apply_deprecated_filter(
'pp_elements_lite_js_localize',
'powerpack_elements_js_localize',
[
'ajax_url' => admin_url( 'admin-ajax.php' ),
],
[],
'2.9.10'
);
wp_localize_script( 'jquery', 'pp', $localize_data );
}
/**
* Enqueue frontend styles
*
* @since 1.3.3
*
* @access public
*/
public function enqueue_frontend_styles() {
$debug_suffix = ( PP_Helper::is_script_debug() ) ? '' : '.min';
$direction_suffix = is_rtl() ? '-rtl' : '';
$suffix = $direction_suffix . $debug_suffix;
$path = ( PP_Helper::is_script_debug() ) ? 'assets/css/' : 'assets/css/min/';
/* wp_enqueue_style(
'powerpack-frontend',
POWERPACK_ELEMENTS_LITE_URL . $path . 'frontend' . $suffix . '.css',
[],
POWERPACK_ELEMENTS_LITE_VER
); */
if ( class_exists( 'GFCommon' ) && \Elementor\Plugin::$instance->preview->is_preview_mode() && PP_Helper::is_widget_active( 'Gravity_Forms' ) ) {
$gf_forms = \RGFormsModel::get_forms( null, 'title' );
foreach ( $gf_forms as $form ) {
if ( '0' !== $form->id ) {
wp_enqueue_script( 'gform_gravityforms' );
gravity_form_enqueue_scripts( $form->id );
}
}
}
if ( function_exists( 'wpforms' ) ) {
wpforms()->frontend->assets_css();
}
}
/**
* Enqueue frontend scripts
*
* @since 1.3.3
*
* @access public
*/
public function enqueue_frontend_scripts() {
$settings = \PowerpackElementsLite\Classes\PP_Admin_Settings::get_settings();
$suffix = ( PP_Helper::is_script_debug() ) ? '' : '.min';
$path = ( PP_Helper::is_script_debug() ) ? 'assets/js/' : 'assets/js/min/';
if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
wp_enqueue_script(
'powerpack-upgrade',
POWERPACK_ELEMENTS_LITE_URL . $path . 'editor-panel-upgrade' . $suffix . '.js',
array(
'jquery',
),
POWERPACK_ELEMENTS_LITE_VER,
true
);
}
}
/**
* Enqueue editor styles
*
* @since 1.3.3
*
* @access public
*/
public function enqueue_editor_styles() {
wp_enqueue_style(
'powerpack-editor',
POWERPACK_ELEMENTS_LITE_URL . 'assets/css/editor.css',
[],
POWERPACK_ELEMENTS_LITE_VER
);
wp_enqueue_style(
'powerpack-icons',
POWERPACK_ELEMENTS_LITE_URL . 'assets/lib/ppicons/css/powerpack-icons.css',
[],
POWERPACK_ELEMENTS_LITE_VER
);
}
/**
* Enqueue editor scripts
*
* @since 1.3.3
*
* @access public
*/
public function enqueue_editor_scripts() {
wp_enqueue_script(
'powerpack-editor',
POWERPACK_ELEMENTS_LITE_URL . 'assets/js/editor.js',
[
'jquery',
],
POWERPACK_ELEMENTS_LITE_VER,
true
);
}
public function enqueue_panel_scripts() {}
public function enqueue_editor_preview_styles() {
$debug_suffix = ( PP_Helper::is_script_debug() ) ? '' : '.min';
$direction_suffix = is_rtl() ? '-rtl' : '';
$suffix = $direction_suffix . $debug_suffix;
$path = ( PP_Helper::is_script_debug() ) ? 'assets/css/' : 'assets/css/min/';
wp_enqueue_style(
'powerpack-editor',
POWERPACK_ELEMENTS_LITE_URL . $path . 'editor' . $debug_suffix . '.css',
array(),
POWERPACK_ELEMENTS_LITE_VER
);
}
/**
* Register Group Controls
*
* @since 1.2.9
*/
public function include_group_controls() {
// Include Control Groups
require POWERPACK_ELEMENTS_LITE_PATH . 'includes/controls/groups/transition.php';
// Add Control Groups
\Elementor\Plugin::instance()->controls_manager->add_group_control( 'pp-transition', new Group_Control_Transition() );
}
/**
* Register Controls
*
* @since 1.2.9
*
* @access private
*/
public function register_controls() {
// Include Controls
require POWERPACK_ELEMENTS_LITE_PATH . 'includes/controls/query.php';
// Register Controls
//\Elementor\Plugin::instance()->controls_manager->register_control( 'pp-query', new Control_Query() );
if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
\Elementor\Plugin::instance()->controls_manager->register( new Control_Query() );
} else {
\Elementor\Plugin::instance()->controls_manager->register_control( 'pp-query', new Control_Query() );
}
}
public function elementor_init() {
$this->modules_manager = new Modules_Manager();
$this->_extensions_manager = new Extensions_Manager();
}
/**
* Register Elementor widget category
*
* @since 2.6.7
* @access public
*
* @param ElementorElements_Manager $manager Elements manager.
*/
public function register_category( $manager ) {
// Add element category in panel
$manager->add_category(
'powerpack-elements', // This is the name of your addon's category and will be used to group your widgets/elements in the Edit sidebar pane!
array(
'title' => __( 'PowerPack Elements', 'powerpack-lite-for-elementor' ), // The title of your modules category - keep it simple and short!
'icon' => 'font',
),
1
);
}
public function get_promotion_widgets( $config ) {
if ( is_pp_elements_active() ) {
return $config;
}
$promotion_widgets = [];
if ( isset( $config['promotionWidgets'] ) ) {
$promotion_widgets = $config['promotionWidgets'];
}
$pro_widgets = PP_Config::get_pro_widgets();
$combine_array = array_merge( $promotion_widgets, $pro_widgets );
$config['promotionWidgets'] = $combine_array;
return $config;
}
protected function add_actions() {
add_action( 'elementor/init', [ $this, 'elementor_init' ] );
add_action( 'elementor/elements/categories_registered', array( $this, 'register_category' ) );
add_action( 'elementor/controls/register', array( $this, 'register_controls' ) );
add_action( 'elementor/controls/register', array( $this, 'include_group_controls' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'register_style_scripts' ) );
add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'register_style_scripts' ) );
add_action( 'elementor/frontend/before_enqueue_scripts', array( $this, 'register_style_scripts' ) );
add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] );
add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_styles' ] );
add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_editor_preview_styles' ] );
add_action( 'elementor/frontend/after_register_scripts', [ $this, 'enqueue_frontend_scripts' ] );
add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'enqueue_frontend_styles' ] );
add_filter( 'elementor/editor/localize_settings', [ $this, 'get_promotion_widgets' ] );
}
/**
* Plugin constructor.
*/
private function __construct() {
spl_autoload_register( [ $this, 'autoload' ] );
$this->_includes();
$this->add_actions();
Classes\UsageTracking::get_instance();
}
}
if ( ! defined( 'POWERPACK_ELEMENTS_TESTS' ) ) {
// In tests we run the instance manually.
PowerpackLitePlugin::instance();
}