PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.4.7
Easy Elements for Elementor – Addons & Website Templates v1.4.7
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.7, at includes/Utils/Enqueue.php

384 lines 15.4 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 public function enqueue_admin_styles() {
65 global $pagenow;
66 $screen = get_current_screen();
67 $dir = EASYELEMENTS_DIR_URL;
68 wp_enqueue_style( 'e-e-elements-admin', $dir . 'assets/css/admin/admin.min.css', [], self::VERSION );
69 wp_enqueue_style( 'e-e-easy-custom-icons', $dir . 'assets/simplelineicons/css/simple-line-icons.css', [], self::VERSION );
70 wp_enqueue_style( 'e-e-easy-icons-font', $dir . 'includes/Admin/icons/css/easy-icons.css', [], self::VERSION );
71 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 );
72
73 if ( ( 'ee-elementor-hf' == $screen->id && ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) ) || ( 'edit.php' == $pagenow && 'edit-ee-elementor-hf' == $screen->id ) ) {
74 wp_enqueue_script( 'easy-ehf-admin-script', $dir . 'assets/header-footer/js/ee-ehf-admin.js', [ 'jquery', 'updates' ], self::VERSION, true );
75
76 }
77 }
78
79 public function enqueue_editor_scripts() {
80 wp_enqueue_style( 'eel-elements-editor', EASYELEMENTS_DIR_URL . 'assets/css/editor.min.css', [], self::VERSION );
81 wp_enqueue_style( 'e-e-easy-custom-icons', EASYELEMENTS_DIR_URL . 'includes/Admin/icons/css/easy-icons.css', [], self::VERSION );
82 }
83
84
85
86 /**
87 * ------------------------------------------------------------
88 * Add defer attribute
89 * ------------------------------------------------------------
90 */
91 function easyel_add_defer_attribute_free( $tag, $handle ) {
92
93 $defer_handles = [
94 'swiper',
95 'jarallax',
96 'eel-custom-js',
97 'easy-wrapper-link',
98 'eel-countdown-script',
99 'eel-counter-script',
100 'eel-faq-accordion-script',
101 'eel-gallery-script',
102 'eel-login-register-script',
103 'eel-navigation-menu-script',
104 'eel-offcanvas-script',
105 'eel-scroll-to-top-script',
106 'eel-search-script',
107 'eel-tab-script',
108 'eel-table-script',
109 'eel-team-grid-script',
110 'eel-testimonials-script',
111 'eel-image-before-after-script',
112 ];
113
114 if ( in_array( $handle, $defer_handles, true ) ) {
115 return str_replace( ' src', ' defer src', $tag );
116 }
117
118 return $tag;
119 }
120
121 public function easyel_register_free_all_widget_assets() {
122
123 $widgets_assets = $this->easyel_enqueue_widget_assets();
124
125 $single_archive_widget = array(
126 'eel-featured-image',
127 'eel-post-content',
128 'eel-excerpt',
129 "eel-post-author-info",
130 'eel-post-comments',
131 'eel-post-meta',
132 'eel-post-pagination',
133 'eel-post-tags',
134 'eel-post-title',
135 "eel-breadcrumb",
136 "eel-navigation-menu",
137 "eel-site-logo",
138 );
139
140 if( is_array( $widgets_assets ) || is_object( $widgets_assets ) ) {
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
212 }
213
214 function easyel_enqueue_widget_assets() {
215 if ( ! class_exists( '\Elementor\Plugin' ) ) return;
216
217 $widgets_assets = [
218 'eel-archive-post' => [
219 'css' => ['widgets/archive-post/css/archive-post.min.css'],
220 ],
221 'eel-blog-grid' => [
222 'css' => ['widgets/blog-grid/css/blog-grid.min.css'],
223 ],
224 'eel-breadcrumb' => [
225 'css' => ['widgets/breadcrumb/css/breadcrumb.min.css'],
226 ],
227 'eel-button' => [
228 'css' => ['widgets/button/css/button.min.css'],
229 ],
230 'eel-copyright' => [
231 'css' => ['widgets/copyright/css/copyright.min.css'],
232 ],
233 'eel-cf7' => [
234 'css' => ['widgets/cf7/css/cf7.min.css'],
235 ],
236 'eel-clients-logo-grid' => [
237 'css' => ['widgets/clients-logo-grid/css/clients-logo.min.css'],
238 ],
239 'eel-contact-box' => [
240 'css' => ['widgets/contact-box/css/contact-box.min.css'],
241 ],
242 'eel-countdown' => [
243 'css' => ['widgets/countdown/css/countdown.min.css'],
244 'js' => ['widgets/countdown/js/countdown.js'],
245 ],
246 'eel-counter' => [
247 'css' => ['widgets/counter/css/counter.min.css'],
248 'js' => ['widgets/counter/js/counter.js'],
249 ],
250 'eel-domain-search' => [
251 'css' => ['widgets/domain-search/css/domain-search.min.css'],
252 ],
253 'eel-excerpt' => [
254 'css' => ['widgets/excerpt/css/excerpt.min.css'],
255 ],
256 'eel-faq-accordion' => [
257 'css' => ['widgets/faq/css/faq.min.css'],
258 'js' => ['widgets/faq/js/faq.js'],
259 ],
260 'eel-feature-list' => [
261 'css' => ['widgets/feature-list/css/feature-list.min.css'],
262 ],
263 'eel-featured-image' => [
264 'css' => ['widgets/featured-image/css/featured-image.min.css'],
265 ],
266 'eel-gallery' => [
267 'css' => ['widgets/gallery/css/gallery.min.css'],
268 'js' => ['widgets/gallery/js/simple-gallery.js'],
269 ],
270 'eel-heading' => [
271 'css' => ['widgets/heading/css/heading.min.css'],
272 ],
273 'eel-icon-box' => [
274 'css' => ['widgets/icon-box/css/icon-box.min.css'],
275 ],
276 'eel-login-register' => [
277 'css' => ['widgets/login-register/css/login-register.min.css'],
278 'js' => ['widgets/login-register/js/login-register.js'],
279 ],
280 'eel-navigation-menu' => [
281 'css' => ['widgets/navigation-menu/css/navigation-menu.min.css'],
282 'js' => [
283 'widgets/navigation-menu/js/navigation-menu.min.js',
284 ],
285 ],
286 'eel-offcanvas' => [
287 'css' => ['widgets/offcanvas/css/offcanvas.min.css'],
288 'js' => ['widgets/offcanvas/js/offcanvas.js'],
289 ],
290 'eel-page-title' => [
291 'css' => ['widgets/page-title/css/page-title.min.css'],
292 ],
293 'eel-post-author-info' => [
294 'css' => ['widgets/post-author/css/post-author.min.css'],
295 ],
296 'eel-post-comments' => [
297 'css' => ['widgets/post-comments/css/post-comments.min.css'],
298 ],
299 'eel-post-content' => [
300 'css' => ['widgets/post-content/css/post-content.min.css'],
301 ],
302 'eel-post-meta' => [
303 'css' => ['widgets/post-meta/css/post-meta.min.css'],
304 ],
305 'eel-post-pagination' => [
306 'css' => ['widgets/post-pagination/css/post-pagination.min.css'],
307 ],
308 'eel-post-tags' => [
309 'css' => ['widgets/post-tag/css/post-tag.min.css'],
310 ],
311 'eel-post-title' => [
312 'css' => ['widgets/post-title/css/post-title.min.css'],
313 ],
314 'eel-pricing' => [
315 'css' => ['widgets/pricing-table/css/pricing.min.css'],
316 ],
317 'eel-process' => [
318 'css' => ['widgets/process-grid/css/process.min.css'],
319 ],
320 'eel-process-list' => [
321 'css' => ['widgets/process-list/css/process-list.min.css'],
322 ],
323 'easyel-progress-bar' => [
324 'css' => ['widgets/progress/css/progress.min.css'],
325 ],
326 'eel-scroll-to-top' => [
327 'css' => ['widgets/scroll-to-top/css/scroll.min.css'],
328 'js' => ['widgets/scroll-to-top/js/scroll.js'],
329 ],
330 'eel-search' => [
331 'css' => ['widgets/search/css/search.min.css'],
332 'js' => ['widgets/search/js/search.js'],
333 ],
334 'eel-service-list' => [
335 'css' => ['widgets/service-list/css/service-list.min.css'],
336 ],
337 'eel-site-logo' => [
338 'css' => ['widgets/site-logo/css/logo.min.css'],
339 ],
340 'eel-social-icon' => [
341 'css' => ['widgets/social-icon/css/social.min.css'],
342 ],
343 'eel-social-share' => [
344 'css' => ['widgets/social-share/css/social-share.min.css'],
345 ],
346 'eel-tab' => [
347 'css' => ['widgets/tab/css/tab.min.css'],
348 'js' => ['widgets/tab/js/tab.js'],
349 ],
350 'eel-table' => [
351 'css' => ['widgets/table/css/table.min.css'],
352 'js' => ['widgets/table/js/table.js'],
353 ],
354 'eel-team-grid' => [
355 'css' => ['widgets/team-grid/css/team-grid.min.css'],
356 'js' => ['widgets/team-grid/js/team.js'],
357 ],
358 'eel-testimonials' => [
359 'css' => ['widgets/testimonials-grid/css/testimonials.min.css'],
360 'js' => ['widgets/testimonials-grid/js/testimonial.js'],
361 ],
362 'eel-video-popup' => [
363 'css' => ['widgets/video/css/video.min.css'],
364 ],
365 'eel-single-nav' => [
366 'css' => ['widgets/single-nav/css/single-nav.min.css'],
367 ],
368 'eel-vertical-navigation' => [
369 'css' => ['widgets/vertical-menu/css/vertical-menu.min.css'],
370 ],
371 'eel-image-before-after' => [
372 'css' => ['widgets/image-comparison/css/image-before-after.min.css'],
373 'js' => ['widgets/image-comparison/js/event.move.js'],
374 ],
375 'eel-product-grid-lite' => [
376 'css' => ['widgets/product-grid-lite/css/product-grid-lite.min.css'],
377 ],
378 'eel-mini-cart' => [
379 'css' => ['widgets/mini-cart/css/mini-cart.min.css'],
380 ],
381 ];
382 return $widgets_assets;
383 }
384 }