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

378 lines 15.0 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-cf7' => [
228 'css' => ['widgets/cf7/css/cf7.min.css'],
229 ],
230 'eel-clients-logo-grid' => [
231 'css' => ['widgets/clients-logo-grid/css/clients-logo.min.css'],
232 ],
233 'eel-contact-box' => [
234 'css' => ['widgets/contact-box/css/contact-box.min.css'],
235 ],
236 'eel-countdown' => [
237 'css' => ['widgets/countdown/css/countdown.min.css'],
238 'js' => ['widgets/countdown/js/countdown.js'],
239 ],
240 'eel-counter' => [
241 'css' => ['widgets/counter/css/counter.min.css'],
242 'js' => ['widgets/counter/js/counter.js'],
243 ],
244 'eel-domain-search' => [
245 'css' => ['widgets/domain-search/css/domain-search.min.css'],
246 ],
247 'eel-excerpt' => [
248 'css' => ['widgets/excerpt/css/excerpt.min.css'],
249 ],
250 'eel-faq-accordion' => [
251 'css' => ['widgets/faq/css/faq.min.css'],
252 'js' => ['widgets/faq/js/faq.js'],
253 ],
254 'eel-feature-list' => [
255 'css' => ['widgets/feature-list/css/feature-list.min.css'],
256 ],
257 'eel-featured-image' => [
258 'css' => ['widgets/featured-image/css/featured-image.min.css'],
259 ],
260 'eel-gallery' => [
261 'css' => ['widgets/gallery/css/gallery.min.css'],
262 'js' => ['widgets/gallery/js/simple-gallery.js'],
263 ],
264 'eel-heading' => [
265 'css' => ['widgets/heading/css/heading.min.css'],
266 ],
267 'eel-icon-box' => [
268 'css' => ['widgets/icon-box/css/icon-box.min.css'],
269 ],
270 'eel-login-register' => [
271 'css' => ['widgets/login-register/css/login-register.min.css'],
272 'js' => ['widgets/login-register/js/login-register.js'],
273 ],
274 'eel-navigation-menu' => [
275 'css' => ['widgets/navigation-menu/css/navigation-menu.min.css'],
276 'js' => [
277 'widgets/navigation-menu/js/navigation-menu.min.js',
278 ],
279 ],
280 'eel-offcanvas' => [
281 'css' => ['widgets/offcanvas/css/offcanvas.min.css'],
282 'js' => ['widgets/offcanvas/js/offcanvas.js'],
283 ],
284 'eel-page-title' => [
285 'css' => ['widgets/page-title/css/page-title.min.css'],
286 ],
287 'eel-post-author-info' => [
288 'css' => ['widgets/post-author/css/post-author.min.css'],
289 ],
290 'eel-post-comments' => [
291 'css' => ['widgets/post-comments/css/post-comments.min.css'],
292 ],
293 'eel-post-content' => [
294 'css' => ['widgets/post-content/css/post-content.min.css'],
295 ],
296 'eel-post-meta' => [
297 'css' => ['widgets/post-meta/css/post-meta.min.css'],
298 ],
299 'eel-post-pagination' => [
300 'css' => ['widgets/post-pagination/css/post-pagination.min.css'],
301 ],
302 'eel-post-tags' => [
303 'css' => ['widgets/post-tag/css/post-tag.min.css'],
304 ],
305 'eel-post-title' => [
306 'css' => ['widgets/post-title/css/post-title.min.css'],
307 ],
308 'eel-pricing' => [
309 'css' => ['widgets/pricing-table/css/pricing.min.css'],
310 ],
311 'eel-process' => [
312 'css' => ['widgets/process-grid/css/process.min.css'],
313 ],
314 'eel-process-list' => [
315 'css' => ['widgets/process-list/css/process-list.min.css'],
316 ],
317 'easyel-progress-bar' => [
318 'css' => ['widgets/progress/css/progress.min.css'],
319 ],
320 'eel-scroll-to-top' => [
321 'css' => ['widgets/scroll-to-top/css/scroll.min.css'],
322 'js' => ['widgets/scroll-to-top/js/scroll.js'],
323 ],
324 'eel-search' => [
325 'css' => ['widgets/search/css/search.min.css'],
326 'js' => ['widgets/search/js/search.js'],
327 ],
328 'eel-service-list' => [
329 'css' => ['widgets/service-list/css/service-list.min.css'],
330 ],
331 'eel-site-logo' => [
332 'css' => ['widgets/site-logo/css/logo.min.css'],
333 ],
334 'eel-social-icon' => [
335 'css' => ['widgets/social-icon/css/social.min.css'],
336 ],
337 'eel-social-share' => [
338 'css' => ['widgets/social-share/css/social-share.min.css'],
339 ],
340 'eel-tab' => [
341 'css' => ['widgets/tab/css/tab.min.css'],
342 'js' => ['widgets/tab/js/tab.js'],
343 ],
344 'eel-table' => [
345 'css' => ['widgets/table/css/table.min.css'],
346 'js' => ['widgets/table/js/table.js'],
347 ],
348 'eel-team-grid' => [
349 'css' => ['widgets/team-grid/css/team-grid.min.css'],
350 'js' => ['widgets/team-grid/js/team.js'],
351 ],
352 'eel-testimonials' => [
353 'css' => ['widgets/testimonials-grid/css/testimonials.min.css'],
354 'js' => ['widgets/testimonials-grid/js/testimonial.js'],
355 ],
356 'eel-video-popup' => [
357 'css' => ['widgets/video/css/video.min.css'],
358 ],
359 'eel-single-nav' => [
360 'css' => ['widgets/single-nav/css/single-nav.min.css'],
361 ],
362 'eel-vertical-navigation' => [
363 'css' => ['widgets/vertical-menu/css/vertical-menu.min.css'],
364 ],
365 'eel-image-before-after' => [
366 'css' => ['widgets/image-comparison/css/image-before-after.min.css'],
367 'js' => ['widgets/image-comparison/js/event.move.js'],
368 ],
369 'eel-product-grid-lite' => [
370 'css' => ['widgets/product-grid-lite/css/product-grid-lite.min.css'],
371 ],
372 'eel-mini-cart' => [
373 'css' => ['widgets/mini-cart/css/mini-cart.min.css'],
374 ],
375 ];
376 return $widgets_assets;
377 }
378 }