PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.4
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.4
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 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 1 day ago enqueue-scripts.php 1 day ago nested-document-assets.php 1 day ago
enqueue-scripts.php
255 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 // Strings needed by markup that is built in JS and so cannot use
119 // the PHP translation functions. Consumers must read these
120 // defensively and fall back, since a widget script can run before
121 // this is localized depending on which plugin registers ekit-core.
122 'i18n' => [
123 'video_frame' => __( 'Video player', 'elementskit-lite' ),
124 'close' => __( 'Close', 'elementskit-lite' ),
125
126 // Swiper's A11y module is enabled by default and already names
127 // the slider controls, but only in hardcoded English. These are
128 // the same messages, translatable.
129 'slider_prev' => __( 'Previous slide', 'elementskit-lite' ),
130 'slider_next' => __( 'Next slide', 'elementskit-lite' ),
131 'slider_first' => __( 'This is the first slide', 'elementskit-lite' ),
132 'slider_last' => __( 'This is the last slide', 'elementskit-lite' ),
133 /* translators: {{index}} is replaced by Swiper with the slide number. Keep it as-is. */
134 'slider_bullet' => __( 'Go to slide {{index}}', 'elementskit-lite' ),
135 ],
136 ]
137 );
138
139 wp_localize_script( 'ekit-core', 'ekit_config', $config );
140
141 // compatibility
142 if($this->is_plugin_active('elementskit/elementskit.php') && version_compare(\Elementskit::version(), '3.2.0', '<=')) {
143 // added swiper js - elementor remove it when "Improved Asset Loading" is active
144 if(defined('ELEMENTOR_ASSETS_URL')) {
145 wp_enqueue_script(
146 'swiper',
147 ELEMENTOR_ASSETS_URL . 'lib/swiper/swiper.min.js',
148 [],
149 \ElementsKit_Lite::version(),
150 true
151 );
152 }
153 }
154
155 // added fluent form styles on the editor
156 if (in_array('fluentform/fluentform.php', apply_filters('active_plugins', get_option('active_plugins')))) {
157 wp_enqueue_style( 'fluent-form-styles' );
158 wp_enqueue_style( 'fluentform-public-default' );
159 }
160
161 // Enqueue admin toolbar script for logged-in users
162 if(is_user_logged_in()) {
163 wp_enqueue_script( 'ekit-admin-toolbar' );
164 }
165 }
166
167 public function register_frontend_css() {
168 //third party styles for widgets
169 // odometer styles
170 wp_register_style( 'odometer', \ElementsKit_Lite::plugin_url() . 'assets/libs/odometer/odometer-theme-default.css', [], \ElementsKit_Lite::version() );
171 // twentytwenty styles - this library is used for image comparison widget
172 wp_register_style( 'twentytwenty', \ElementsKit_Lite::plugin_url() . 'assets/libs/twentytwenty/twentytwenty.css', [], \ElementsKit_Lite::version() );
173
174 //maginific-popup styles
175 wp_register_style( 'magnific-popup', \ElementsKit_Lite::plugin_url() . 'assets/libs/magnific-popup/magnific-popup.css', [], time() );
176 }
177
178 /**
179 * Enqueues scripts required by interactive Header/Footer Builder widgets.
180 *
181 * Header content can render before normal widget-level asset detection runs.
182 * These scripts are intentionally enqueued as a narrow exception so header
183 * controls initialize reliably; all other widget scripts remain dynamically
184 * loaded only when required.
185 *
186 * @return void
187 */
188 public function enqueue_frontend_scripts() {
189 $header_script_handles = [
190 'ekit-core',
191 'ekit-nav-menu',
192 'magnific-popup',
193 'ekit-menu',
194 'countdown-timer',
195 'ekit-header-search',
196 'ekit-header-offcanvas',
197 ];
198
199 foreach ( $header_script_handles as $script_handle ) {
200 if ( wp_script_is( $script_handle, 'registered' ) ) {
201 wp_enqueue_script( $script_handle );
202 }
203 }
204 }
205
206 /**
207 * Enqueues frontend styles that must be available before header markup renders.
208 *
209 * Header/Footer Builder content can render before normal widget-level asset
210 * detection enqueues the nav menu, header search, offcanvas, and info styles.
211 * These styles are intentionally enqueued in the document head to prevent unstyled
212 * header content, layout shifts, and flashes of unstyled content. This is a
213 * narrow exception to the dynamic CSS loading strategy; all other widget styles
214 * continue to load only when their widgets require them.
215 *
216 * @return void
217 */
218 public function enqueue_frontend_css() {
219 $header_style_handles = [
220 'ekit-nav-menu',
221 'ekit-header-search',
222 'ekit-header-offcanvas',
223 'ekit-header-info',
224 'countdown-timer',
225 ];
226
227 foreach ( $header_style_handles as $style_handle ) {
228 if ( wp_style_is( $style_handle, 'registered' ) ) {
229 wp_enqueue_style( $style_handle );
230 }
231 }
232
233 ( new Nested_Document_Assets() )->enqueue();
234
235 // RTL styles
236 if ( is_rtl() ) {
237 wp_enqueue_style( 'elementskit-rtl', \ElementsKit_Lite::widget_url() . 'init/assets/css/rtl.css', [], \ElementsKit_Lite::version() );
238 }
239 }
240
241 public function enqueue_3rd_party_style() {
242 if (function_exists( 'weforms' )) {
243 wp_enqueue_style( 'weforms', plugins_url('/weforms/assets/wpuf/css/frontend-forms.css', 'weforms' ), [], \ElementsKit_Lite::version() );
244 }
245
246 if(defined('WPFORMS_PLUGIN_SLUG')){
247 wp_enqueue_style( 'wpforms', plugins_url( '/'. WPFORMS_PLUGIN_SLUG . '/assets/css/wpforms-full.css', WPFORMS_PLUGIN_SLUG ), [], \ElementsKit_Lite::version() );
248 }
249 }
250
251 public function elementor_editor_css() {
252 wp_enqueue_style( 'elementskit-panel', \ElementsKit_Lite::widget_url() . 'init/assets/css/editor.css', [], \ElementsKit_Lite::version() );
253 }
254 }
255