PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.4.4
Easy Elements for Elementor – Addons & Website Templates v1.4.4
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / includes / Utils / Enqueue.php

Enqueue.php in Easy Elements for Elementor – Addons & Website Templates 1.4.4, at includes/Utils/Enqueue.php

381 lines 15.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Utils;
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 class Enqueue {
6
7 private static $instance = null;
8 const VERSION = EASYELEMENTS_VER;
9 public static function get_instance() {
10 if ( ! self::$instance ) self::$instance = new self();
11 return self::$instance;
12 }
13
14 private function __construct() {
15 // Assets
16 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_frontend_assets' ], 99 );
17 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_styles' ] );
18 add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] );
19
20 add_filter( 'script_loader_tag', [ $this, 'easyel_add_defer_attribute_free' ], 10, 2 );
21
22 add_action( 'wp_enqueue_scripts', [ $this, 'easyel_register_free_all_widget_assets'] );
23 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'easyel_register_free_all_widget_assets'] );
24
25 }
26
27
28 public function enqueue_frontend_assets() {
29 $dir = EASYELEMENTS_DIR_URL;
30 if ( is_admin() ) return;
31 if ( ! class_exists( 'Elementor\Plugin' ) ) return;
32 wp_enqueue_style( 'swiper', ELEMENTOR_ASSETS_URL . 'lib/swiper/css/swiper-bundle.min.css', [], '8.0.7' );
33 wp_enqueue_style( 'easy-hfe-elementor', EASYELEMENTS_ASSETS_URL . 'header-footer/css/easy-hfe-elementor.css', [], self::VERSION );
34 wp_enqueue_style( 'e-e-easy-custom-icons', $dir . 'assets/simplelineicons/css/simple-line-icons.css', [], self::VERSION );
35
36 wp_enqueue_style( 'eel-elements-plugins', $dir . 'assets/css/plugins.min.css', [], self::VERSION );
37 wp_enqueue_script( 'swiper', ELEMENTOR_ASSETS_URL . 'lib/swiper/swiper-bundle.min.js', [ 'jquery' ], '8.0.7', true );
38 wp_enqueue_script( 'jarallax', $dir . 'assets/js/jarallax.js', [ 'jquery' ], '2.2.1', true );
39 wp_enqueue_script( 'eel-custom-js', $dir . 'assets/js/custom.js', [ 'jquery' ], self::VERSION, true );
40 wp_enqueue_script( 'easy-wrapper-link', $dir . 'assets/js/easy-wrapper-link.js', [ 'jquery' ], self::VERSION, true );
41
42 /**
43 * Dynamic scrollbar CSS variables
44 */
45 $options = get_option( 'easyel_scroll_smoother_settings', [] );
46
47 $width = ! empty( $options['smooth_scroll_width'] ) ? intval( $options['smooth_scroll_width'] ) . 'px' : '3px';
48 $track = ! empty( $options['smooth_scroll_normal_color'] ) ? $options['smooth_scroll_normal_color'] : '#dddddd';
49 $thumb = ! empty( $options['smooth_scroll_highlight_color'] ) ? $options['smooth_scroll_highlight_color'] : 'var(--e-global-color-primary)';
50
51 $dynamic_css = "
52 :root {
53 --easyel-scrollbar-width: {$width};
54 --easyel-scrollbar-track: {$track};
55 --easyel-scrollbar-thumb: {$thumb};
56 }
57 ";
58
59 wp_add_inline_style( 'eel-elements-plugins', $dynamic_css );
60
61
62 }
63
64
65 public function enqueue_admin_styles() {
66 global $pagenow;
67 $screen = get_current_screen();
68 $dir = EASYELEMENTS_DIR_URL;
69 wp_enqueue_style( 'e-e-elements-admin', $dir . 'assets/css/admin/admin.min.css', [], self::VERSION );
70 wp_enqueue_style( 'e-e-easy-custom-icons', $dir . 'assets/simplelineicons/css/simple-line-icons.css', [], self::VERSION );
71 wp_enqueue_style( 'e-e-easy-icons-font', $dir . 'includes/Admin/icons/css/easy-icons.css', [], self::VERSION );
72 wp_enqueue_style('e-e-admin-fonts-inter','https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap',false, self::VERSION );
73
74 if ( ( 'ee-elementor-hf' == $screen->id && ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) ) || ( 'edit.php' == $pagenow && 'edit-ee-elementor-hf' == $screen->id ) ) {
75 wp_enqueue_script( 'easy-ehf-admin-script', $dir . 'assets/header-footer/js/ee-ehf-admin.js', [ 'jquery', 'updates' ], self::VERSION, true );
76
77 }
78 }
79
80 public function enqueue_editor_scripts() {
81 wp_enqueue_style( 'eel-elements-editor', EASYELEMENTS_DIR_URL . 'assets/css/editor.min.css', [], self::VERSION );
82 wp_enqueue_style( 'e-e-easy-custom-icons', EASYELEMENTS_DIR_URL . 'includes/Admin/icons/css/easy-icons.css', [], self::VERSION );
83 }
84
85
86
87 /**
88 * ------------------------------------------------------------
89 * Add defer attribute
90 * ------------------------------------------------------------
91 */
92 function easyel_add_defer_attribute_free( $tag, $handle ) {
93
94 $defer_handles = [
95 'swiper',
96 'jarallax',
97 'eel-custom-js',
98 'easy-wrapper-link',
99 'eel-countdown-script',
100 'eel-counter-script',
101 'eel-faq-accordion-script',
102 'eel-gallery-script',
103 'eel-login-register-script',
104 'eel-navigation-menu-script',
105 'eel-offcanvas-script',
106 'eel-scroll-to-top-script',
107 'eel-search-script',
108 'eel-tab-script',
109 'eel-table-script',
110 'eel-team-grid-script',
111 'eel-testimonials-script',
112 'eel-image-before-after-script',
113 ];
114
115 if ( in_array( $handle, $defer_handles, true ) ) {
116 return str_replace( ' src', ' defer src', $tag );
117 }
118
119 return $tag;
120 }
121
122 public function easyel_register_free_all_widget_assets() {
123
124 $widgets_assets = $this->easyel_enqueue_widget_assets();
125
126 $single_archive_widget = array(
127 'eel-featured-image',
128 'eel-post-content',
129 'eel-excerpt',
130 "eel-post-author-info",
131 'eel-post-comments',
132 'eel-post-meta',
133 'eel-post-pagination',
134 'eel-post-tags',
135 'eel-post-title',
136 "eel-breadcrumb",
137 "eel-navigation-menu",
138 "eel-site-logo",
139 );
140
141 foreach ( $widgets_assets as $widget => $assets ) {
142
143 /**
144 * CSS register
145 */
146 if ( ! empty( $assets['css'] ) ) {
147 foreach ( $assets['css'] as $css ) {
148
149 $handle = $widget;
150 $path = EASYELEMENTS_DIR_PATH . $css;
151 $url = EASYELEMENTS_DIR_URL . $css;
152
153 if ( ! file_exists( $path ) ) {
154 continue;
155 }
156
157 $version = filemtime( $path );
158
159 if ( is_singular( 'post' ) && in_array( $handle, $single_archive_widget, true ) ) {
160
161 wp_enqueue_style(
162 $handle,
163 $url,
164 [],
165 $version
166 );
167
168 } else {
169
170 wp_register_style(
171 $handle,
172 $url,
173 [],
174 $version
175 );
176 }
177 }
178 }
179
180 /**
181 * JS register
182 */
183 if ( ! empty( $assets['js'] ) ) {
184 foreach ( $assets['js'] as $js ) {
185
186 $handle = $widget;
187 $path = EASYELEMENTS_DIR_PATH . $js;
188
189 if ( file_exists( $path ) ) {
190 wp_register_script(
191 $handle,
192 EASYELEMENTS_DIR_URL . $js,
193 [ 'jquery' ],
194 filemtime( $path ),
195 true
196 );
197
198 if ( $handle === 'eel-login-register' ) {
199 wp_localize_script( $handle, 'eelLoginRegister', [
200 'ajaxurl' => admin_url( 'admin-ajax.php' ),
201 'nonce' => wp_create_nonce( 'easy_elements_nonce' ),
202 ] );
203 }
204 }
205 }
206 }
207 }
208
209 }
210
211 function easyel_enqueue_widget_assets() {
212 if ( ! class_exists( '\Elementor\Plugin' ) ) return;
213
214 $widgets_assets = [
215 'eel-archive-post' => [
216 'css' => ['widgets/archive-post/css/archive-post.min.css'],
217 ],
218 'eel-blog-grid' => [
219 'css' => ['widgets/blog-grid/css/blog-grid.min.css'],
220 ],
221 'eel-breadcrumb' => [
222 'css' => ['widgets/breadcrumb/css/breadcrumb.min.css'],
223 ],
224 'eel-button' => [
225 'css' => ['widgets/button/css/button.min.css'],
226 ],
227 'eel-copyright' => [
228 'css' => ['widgets/copyright/css/copyright.min.css'],
229 ],
230 'eel-cf7' => [
231 'css' => ['widgets/cf7/css/cf7.min.css'],
232 ],
233 'eel-clients-logo-grid' => [
234 'css' => ['widgets/clients-logo-grid/css/clients-logo.min.css'],
235 ],
236 'eel-contact-box' => [
237 'css' => ['widgets/contact-box/css/contact-box.min.css'],
238 ],
239 'eel-countdown' => [
240 'css' => ['widgets/countdown/css/countdown.min.css'],
241 'js' => ['widgets/countdown/js/countdown.js'],
242 ],
243 'eel-counter' => [
244 'css' => ['widgets/counter/css/counter.min.css'],
245 'js' => ['widgets/counter/js/counter.js'],
246 ],
247 'eel-domain-search' => [
248 'css' => ['widgets/domain-search/css/domain-search.min.css'],
249 ],
250 'eel-excerpt' => [
251 'css' => ['widgets/excerpt/css/excerpt.min.css'],
252 ],
253 'eel-faq-accordion' => [
254 'css' => ['widgets/faq/css/faq.min.css'],
255 'js' => ['widgets/faq/js/faq.js'],
256 ],
257 'eel-feature-list' => [
258 'css' => ['widgets/feature-list/css/feature-list.min.css'],
259 ],
260 'eel-featured-image' => [
261 'css' => ['widgets/featured-image/css/featured-image.min.css'],
262 ],
263 'eel-gallery' => [
264 'css' => ['widgets/gallery/css/gallery.min.css'],
265 'js' => ['widgets/gallery/js/simple-gallery.js'],
266 ],
267 'eel-heading' => [
268 'css' => ['widgets/heading/css/heading.min.css'],
269 ],
270 'eel-icon-box' => [
271 'css' => ['widgets/icon-box/css/icon-box.min.css'],
272 ],
273 'eel-login-register' => [
274 'css' => ['widgets/login-register/css/login-register.min.css'],
275 'js' => ['widgets/login-register/js/login-register.js'],
276 ],
277 'eel-navigation-menu' => [
278 'css' => ['widgets/navigation-menu/css/navigation-menu.min.css'],
279 'js' => [
280 'widgets/navigation-menu/js/navigation-menu.min.js',
281 ],
282 ],
283 'eel-offcanvas' => [
284 'css' => ['widgets/offcanvas/css/offcanvas.min.css'],
285 'js' => ['widgets/offcanvas/js/offcanvas.js'],
286 ],
287 'eel-page-title' => [
288 'css' => ['widgets/page-title/css/page-title.min.css'],
289 ],
290 'eel-post-author-info' => [
291 'css' => ['widgets/post-author/css/post-author.min.css'],
292 ],
293 'eel-post-comments' => [
294 'css' => ['widgets/post-comments/css/post-comments.min.css'],
295 ],
296 'eel-post-content' => [
297 'css' => ['widgets/post-content/css/post-content.min.css'],
298 ],
299 'eel-post-meta' => [
300 'css' => ['widgets/post-meta/css/post-meta.min.css'],
301 ],
302 'eel-post-pagination' => [
303 'css' => ['widgets/post-pagination/css/post-pagination.min.css'],
304 ],
305 'eel-post-tags' => [
306 'css' => ['widgets/post-tag/css/post-tag.min.css'],
307 ],
308 'eel-post-title' => [
309 'css' => ['widgets/post-title/css/post-title.min.css'],
310 ],
311 'eel-pricing' => [
312 'css' => ['widgets/pricing-table/css/pricing.min.css'],
313 ],
314 'eel-process' => [
315 'css' => ['widgets/process-grid/css/process.min.css'],
316 ],
317 'eel-process-list' => [
318 'css' => ['widgets/process-list/css/process-list.min.css'],
319 ],
320 'easyel-progress-bar' => [
321 'css' => ['widgets/progress/css/progress.min.css'],
322 ],
323 'eel-scroll-to-top' => [
324 'css' => ['widgets/scroll-to-top/css/scroll.min.css'],
325 'js' => ['widgets/scroll-to-top/js/scroll.js'],
326 ],
327 'eel-search' => [
328 'css' => ['widgets/search/css/search.min.css'],
329 'js' => ['widgets/search/js/search.js'],
330 ],
331 'eel-service-list' => [
332 'css' => ['widgets/service-list/css/service-list.min.css'],
333 ],
334 'eel-site-logo' => [
335 'css' => ['widgets/site-logo/css/logo.min.css'],
336 ],
337 'eel-social-icon' => [
338 'css' => ['widgets/social-icon/css/social.min.css'],
339 ],
340 'eel-social-share' => [
341 'css' => ['widgets/social-share/css/social-share.min.css'],
342 ],
343 'eel-tab' => [
344 'css' => ['widgets/tab/css/tab.min.css'],
345 'js' => ['widgets/tab/js/tab.js'],
346 ],
347 'eel-table' => [
348 'css' => ['widgets/table/css/table.min.css'],
349 'js' => ['widgets/table/js/table.js'],
350 ],
351 'eel-team-grid' => [
352 'css' => ['widgets/team-grid/css/team-grid.min.css'],
353 'js' => ['widgets/team-grid/js/team.js'],
354 ],
355 'eel-testimonials' => [
356 'css' => ['widgets/testimonials-grid/css/testimonials.min.css'],
357 'js' => ['widgets/testimonials-grid/js/testimonial.js'],
358 ],
359 'eel-video-popup' => [
360 'css' => ['widgets/video/css/video.min.css'],
361 ],
362 'eel-single-nav' => [
363 'css' => ['widgets/single-nav/css/single-nav.min.css'],
364 ],
365 'eel-vertical-navigation' => [
366 'css' => ['widgets/vertical-menu/css/vertical-menu.min.css'],
367 ],
368 'eel-image-before-after' => [
369 'css' => ['widgets/image-comparison/css/image-before-after.min.css'],
370 'js' => ['widgets/image-comparison/js/event.move.js'],
371 ],
372 'eel-product-grid-lite' => [
373 'css' => ['widgets/product-grid-lite/css/product-grid-lite.min.css'],
374 ],
375 'eel-mini-cart' => [
376 'css' => ['widgets/mini-cart/css/mini-cart.min.css'],
377 ],
378 ];
379 return $widgets_assets;
380 }
381 }