PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
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 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / init / enqueue-scripts.php
elementskit-lite / widgets / init Last commit date
assets 3 weeks ago enqueue-scripts.php 3 weeks ago
enqueue-scripts.php
235 lines
1 <?php
2 namespace ElementsKit_Lite\Widgets\Init;
3 use ElementsKit_Lite\Libs\Framework\Attr;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class Enqueue_Scripts {
8
9 public function __construct() {
10 add_action( 'wp_enqueue_scripts', [$this, 'register_scripts'], 9 );
11 add_action( 'elementor/frontend/after_enqueue_scripts', [$this, 'enqueue_scripts'] );
12
13 add_action( 'elementor/frontend/after_register_styles', [$this, 'register_frontend_css'] );
14 add_action( 'wp_enqueue_scripts', [$this, 'enqueue_frontend_scripts'], 99 );
15 add_action( 'wp_enqueue_scripts', [$this, 'enqueue_frontend_css'], 99 );
16
17 add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_3rd_party_style' ] );
18 add_action( 'elementor/editor/after_enqueue_styles', [$this, 'elementor_editor_css'] );
19 }
20
21 public function is_plugin_active($plugin) {
22 return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || $this->is_plugin_active_for_network( $plugin );
23 }
24
25 public function is_plugin_active_for_network($plugin) {
26 if ( ! is_multisite() ) {
27 return false;
28 }
29
30 $plugins = get_site_option( 'active_sitewide_plugins' );
31 if ( isset( $plugins[ $plugin ] ) ) {
32 return true;
33 }
34
35 return false;
36 }
37
38 public function register_scripts() {
39 if( is_admin() ) {
40 return;
41 }
42
43 //third party scripts for widgets
44 // these both library is for image comparison widget
45 wp_register_script('event.move', \ElementsKit_Lite::plugin_url() . 'assets/libs/event-move-js/jquery.event.move.js', ['jquery'], \ElementsKit_Lite::version(), true);
46 wp_register_script('twentytwenty', \ElementsKit_Lite::plugin_url() . 'assets/libs/twentytwenty/jquery.twentytwenty.js', ['jquery'], \ElementsKit_Lite::version(), true);
47
48 //ekit masonry layout
49 wp_register_script('ekit-masonry', \ElementsKit_Lite::widget_url() . 'init/assets/js/ekit-masonry.js', [], \ElementsKit_Lite::version(), true);
50
51 // ui script alternative of bootstrap. Used in [Tab, Advanced Tab, Accordion, Advanced Accordion, Advanced Toggle] widget
52 wp_register_script('ui-slim', \ElementsKit_Lite::widget_url() . 'init/assets/js/ekit-ui.js', ['jquery'], \ElementsKit_Lite::version(), true);
53
54 // register script for countdown timer
55 wp_register_script( 'final-countdown', \ElementsKit_Lite::plugin_url() . 'assets/libs/final-countdown/jquery.countdown.min.js', array(), \ElementsKit_Lite::version(), true );
56
57 // register script for piechart
58 wp_register_script( 'easy-pie-chart', \ElementsKit_Lite::plugin_url() . 'assets/libs/easy-pie-chart/jquery.easypiechart.min.js', array(), \ElementsKit_Lite::version(), true );
59
60 // register script for magnific-popup. Used in [video, team, header-search, team-slider, video-gallery, woo-product-carousel, woo-product-list] widget
61 wp_register_script( 'magnific-popup', \ElementsKit_Lite::plugin_url() . 'assets/libs/magnific-popup/jquery.magnific-popup.min.js', array(), \ElementsKit_Lite::version(), true );
62
63 // register script for mailchimp
64 wp_register_script( 'ekit-mailchimp', \ElementsKit_Lite::widget_url() . 'init/assets/js/mail-chimp.js', array(), \ElementsKit_Lite::version(), true );
65
66 // register script for pricing table
67 wp_register_script( 'ekit-info-tip', \ElementsKit_Lite::widget_url() . 'init/assets/js/info-tip.js', array(), \ElementsKit_Lite::version(), true );
68
69 // social share
70 wp_register_script( 'goodshare', \ElementsKit_Lite::plugin_url() . 'assets/libs/goodshare/goodshare.min.js', array( 'jquery' ), \ElementsKit_Lite::version(), true );
71
72 // funfact widget
73 wp_register_script( 'odometer', \ElementsKit_Lite::plugin_url() . 'assets/libs/odometer/odometer.min.js', array('jquery'), \ElementsKit_Lite::version(), true );
74
75 // Animate Circle Script. Used in [Back to Top] widget
76 wp_register_script( 'animate-circle', \ElementsKit_Lite::widget_url() . 'init/assets/js/animate-circle.js', [], \ElementsKit_Lite::version(), true );
77
78 // register scripts for lottie widget
79 wp_register_script( 'lottie', \ElementsKit_Lite::plugin_url() . 'assets/libs/lottie/lottie.min.js', [], \ElementsKit_Lite::version(), true );
80 wp_register_script( 'lottie-init', \ElementsKit_Lite::widget_url() . 'init/assets/js/lottie.init.js', ['lottie', 'elementor-frontend'], \ElementsKit_Lite::version(), true );
81
82 // Nav menu & vertical menu widget script
83 wp_register_script( 'ekit-menu', \ElementsKit_Lite::widget_url() . 'init/assets/js/nav-menu.js', ['jquery'], \ElementsKit_Lite::version(), true );
84
85 // Register split Elementor widget scripts.
86 wp_register_script( 'ekit-core', \ElementsKit_Lite::widget_url() . 'init/assets/js/widgets/core.js', ['jquery', 'elementor-frontend'], \ElementsKit_Lite::version(), true );
87 wp_register_script( 'ekit-admin-toolbar', \ElementsKit_Lite::widget_url() . 'init/assets/js/widgets/admin-toolbar.js', ['jquery'], \ElementsKit_Lite::version(), true );
88 wp_register_script( 'ekit-animate-numbers', \ElementsKit_Lite::widget_url() . 'init/assets/js/widgets/animate-numbers.js', ['jquery'], \ElementsKit_Lite::version(), true );
89
90 $widget_list = \ElementsKit_Lite\Config\Widget_List::instance()->get_list( 'all' );
91
92 wp_register_style( 'ekit-widget-common', \ElementsKit_Lite::widget_url() . 'init/assets/css/common.css', [], \ElementsKit_Lite::version() );
93
94 foreach ( $widget_list as $widget_slug => $widget ) {
95 if ( ! empty( $widget['hasJS'] ) ) {
96 $script_handle = 'ekit-' . $widget_slug;
97 $script_file = $widget_slug . '.js';
98
99 wp_register_script( $script_handle, \ElementsKit_Lite::widget_url() . 'init/assets/js/widgets/' . $script_file, [ 'ekit-core' ], \ElementsKit_Lite::version(), true );
100 }
101
102 $css_file = $widget_slug . '.css';
103 if ( file_exists( \ElementsKit_Lite::widget_dir() . 'init/assets/css/' . $css_file ) ) {
104 wp_register_style( 'ekit-' . $widget_slug, \ElementsKit_Lite::widget_url() . 'init/assets/css/' . $css_file, [ 'ekit-widget-common' ], \ElementsKit_Lite::version() );
105 }
106 }
107 }
108
109 public function enqueue_scripts() {
110 /**
111 * Localize frontend configuration for ElementsKit.
112 */
113 $config = apply_filters(
114 'elementskit/common/localize_settings',
115 [
116 'ajaxurl' => admin_url( 'admin-ajax.php' ),
117 'nonce' => wp_create_nonce( 'ekit_pro' ),
118 ]
119 );
120
121 wp_localize_script( 'ekit-core', 'ekit_config', $config );
122
123 // compatibility
124 if($this->is_plugin_active('elementskit/elementskit.php') && version_compare(\Elementskit::version(), '3.2.0', '<=')) {
125 // added swiper js - elementor remove it when "Improved Asset Loading" is active
126 if(defined('ELEMENTOR_ASSETS_URL')) {
127 wp_enqueue_script(
128 'swiper',
129 ELEMENTOR_ASSETS_URL . 'lib/swiper/swiper.min.js',
130 [],
131 \ElementsKit_Lite::version(),
132 true
133 );
134 }
135 }
136
137 // added fluent form styles on the editor
138 if (in_array('fluentform/fluentform.php', apply_filters('active_plugins', get_option('active_plugins')))) {
139 wp_enqueue_style( 'fluent-form-styles' );
140 wp_enqueue_style( 'fluentform-public-default' );
141 }
142
143 // Enqueue admin toolbar script for logged-in users
144 if(is_user_logged_in()) {
145 wp_enqueue_script( 'ekit-admin-toolbar' );
146 }
147 }
148
149 public function register_frontend_css() {
150 //third party styles for widgets
151 // odometer styles
152 wp_register_style( 'odometer', \ElementsKit_Lite::plugin_url() . 'assets/libs/odometer/odometer-theme-default.css', [], \ElementsKit_Lite::version() );
153 // twentytwenty styles - this library is used for image comparison widget
154 wp_register_style( 'twentytwenty', \ElementsKit_Lite::plugin_url() . 'assets/libs/twentytwenty/twentytwenty.css', [], \ElementsKit_Lite::version() );
155
156 //maginific-popup styles
157 wp_register_style( 'magnific-popup', \ElementsKit_Lite::plugin_url() . 'assets/libs/magnific-popup/magnific-popup.css', [], time() );
158 }
159
160 /**
161 * Enqueues scripts required by interactive Header/Footer Builder widgets.
162 *
163 * Header content can render before normal widget-level asset detection runs.
164 * These scripts are intentionally enqueued as a narrow exception so header
165 * controls initialize reliably; all other widget scripts remain dynamically
166 * loaded only when required.
167 *
168 * @return void
169 */
170 public function enqueue_frontend_scripts() {
171 $header_script_handles = [
172 'ekit-core',
173 'ekit-nav-menu',
174 'magnific-popup',
175 'ekit-menu',
176 'countdown-timer',
177 'ekit-header-search',
178 'ekit-header-offcanvas',
179 ];
180
181 foreach ( $header_script_handles as $script_handle ) {
182 if ( wp_script_is( $script_handle, 'registered' ) ) {
183 wp_enqueue_script( $script_handle );
184 }
185 }
186 }
187
188 /**
189 * Enqueues frontend styles that must be available before header markup renders.
190 *
191 * Header/Footer Builder content can render before normal widget-level asset
192 * detection enqueues the nav menu, header search, offcanvas, and info styles.
193 * These styles are intentionally enqueued in the document head to prevent unstyled
194 * header content, layout shifts, and flashes of unstyled content. This is a
195 * narrow exception to the dynamic CSS loading strategy; all other widget styles
196 * continue to load only when their widgets require them.
197 *
198 * @return void
199 */
200 public function enqueue_frontend_css() {
201 $header_style_handles = [
202 'ekit-nav-menu',
203 'ekit-header-search',
204 'ekit-header-offcanvas',
205 'ekit-header-info',
206 'countdown-timer',
207 ];
208
209 foreach ( $header_style_handles as $style_handle ) {
210 if ( wp_style_is( $style_handle, 'registered' ) ) {
211 wp_enqueue_style( $style_handle );
212 }
213 }
214
215 // RTL styles
216 if ( is_rtl() ) {
217 wp_enqueue_style( 'elementskit-rtl', \ElementsKit_Lite::widget_url() . 'init/assets/css/rtl.css', [], \ElementsKit_Lite::version() );
218 }
219 }
220
221 public function enqueue_3rd_party_style() {
222 if (function_exists( 'weforms' )) {
223 wp_enqueue_style( 'weforms', plugins_url('/weforms/assets/wpuf/css/frontend-forms.css', 'weforms' ), [], \ElementsKit_Lite::version() );
224 }
225
226 if(defined('WPFORMS_PLUGIN_SLUG')){
227 wp_enqueue_style( 'wpforms', plugins_url( '/'. WPFORMS_PLUGIN_SLUG . '/assets/css/wpforms-full.css', WPFORMS_PLUGIN_SLUG ), [], \ElementsKit_Lite::version() );
228 }
229 }
230
231 public function elementor_editor_css() {
232 wp_enqueue_style( 'elementskit-panel', \ElementsKit_Lite::widget_url() . 'init/assets/css/editor.css', [], \ElementsKit_Lite::version() );
233 }
234 }
235