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

362 lines 14.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
35 wp_enqueue_style( 'eel-elements-plugins', $dir . 'assets/css/plugins.min.css', [], self::VERSION );
36 wp_enqueue_script( 'swiper', ELEMENTOR_ASSETS_URL . 'lib/swiper/swiper-bundle.min.js', [ 'jquery' ], '8.0.7', true );
37 wp_enqueue_script( 'jarallax', $dir . 'assets/js/jarallax.js', [ 'jquery' ], '2.2.1', true );
38 wp_enqueue_script( 'eel-custom-js', $dir . 'assets/js/custom.js', [ 'jquery' ], self::VERSION, true );
39 wp_enqueue_script( 'easy-wrapper-link', $dir . 'assets/js/easy-wrapper-link.js', [ 'jquery' ], self::VERSION, true );
40
41 /**
42 * Dynamic scrollbar CSS variables
43 */
44 $options = get_option( 'easyel_scroll_smoother_settings', [] );
45
46 $width = ! empty( $options['smooth_scroll_width'] ) ? intval( $options['smooth_scroll_width'] ) . 'px' : '3px';
47 $track = ! empty( $options['smooth_scroll_normal_color'] ) ? $options['smooth_scroll_normal_color'] : '#dddddd';
48 $thumb = ! empty( $options['smooth_scroll_highlight_color'] ) ? $options['smooth_scroll_highlight_color'] : 'var(--e-global-color-primary)';
49
50 $dynamic_css = "
51 :root {
52 --easyel-scrollbar-width: {$width};
53 --easyel-scrollbar-track: {$track};
54 --easyel-scrollbar-thumb: {$thumb};
55 }
56 ";
57
58 wp_add_inline_style( 'eel-elements-plugins', $dynamic_css );
59
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 . 'includes/Admin/icons/css/easy-icons.css', [], self::VERSION );
70 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 );
71
72 if ( ( 'ee-elementor-hf' == $screen->id && ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) ) || ( 'edit.php' == $pagenow && 'edit-ee-elementor-hf' == $screen->id ) ) {
73 wp_enqueue_script( 'easy-ehf-admin-script', $dir . 'assets/header-footer/js/ee-ehf-admin.js', [ 'jquery', 'updates' ], self::VERSION, true );
74
75 }
76 }
77
78 public function enqueue_editor_scripts() {
79 wp_enqueue_style( 'eel-elements-editor', EASYELEMENTS_DIR_URL . 'assets/css/editor.min.css', [], self::VERSION );
80 wp_enqueue_style( 'e-e-easy-custom-icons', EASYELEMENTS_DIR_URL . 'includes/Admin/icons/css/easy-icons.css', [], self::VERSION );
81 }
82
83
84
85 /**
86 * ------------------------------------------------------------
87 * Add defer attribute
88 * ------------------------------------------------------------
89 */
90 function easyel_add_defer_attribute_free( $tag, $handle ) {
91
92 $defer_handles = [
93 'swiper',
94 'jarallax',
95 'eel-custom-js',
96 'easy-wrapper-link',
97 'eel-countdown-script',
98 'eel-counter-script',
99 'eel-faq-accordion-script',
100 'eel-gallery-script',
101 'eel-login-register-script',
102 'eel-navigation-menu-script',
103 'eel-offcanvas-script',
104 'eel-scroll-to-top-script',
105 'eel-search-script',
106 'eel-tab-script',
107 'eel-table-script',
108 'eel-team-grid-script',
109 'eel-testimonials-script',
110 'eel-image-before-after-script',
111 ];
112
113 if ( in_array( $handle, $defer_handles, true ) ) {
114 return str_replace( ' src', ' defer src', $tag );
115 }
116
117 return $tag;
118 }
119
120 public function easyel_register_free_all_widget_assets() {
121
122 $widgets_assets = $this->easyel_enqueue_widget_assets();
123
124 $single_archive_widget = array(
125 'eel-featured-image',
126 'eel-post-content',
127 'eel-excerpt',
128 "eel-post-author-info",
129 'eel-post-comments',
130 'eel-post-meta',
131 'eel-post-pagination',
132 'eel-post-tags',
133 'eel-post-title',
134 "eel-breadcrumb",
135 "eel-navigation-menu",
136 "eel-site-logo",
137 );
138
139 foreach ( $widgets_assets as $widget => $assets ) {
140
141 /**
142 * CSS register
143 */
144 if ( ! empty( $assets['css'] ) ) {
145 foreach ( $assets['css'] as $css ) {
146
147 $handle = $widget;
148 $path = EASYELEMENTS_DIR_PATH . $css;
149 $url = EASYELEMENTS_DIR_URL . $css;
150
151 if ( ! file_exists( $path ) ) {
152 continue;
153 }
154
155 $version = filemtime( $path );
156
157 if ( is_singular( 'post' ) && in_array( $handle, $single_archive_widget, true ) ) {
158
159 wp_enqueue_style(
160 $handle,
161 $url,
162 [],
163 $version
164 );
165
166 } else {
167
168 wp_register_style(
169 $handle,
170 $url,
171 [],
172 $version
173 );
174 }
175 }
176 }
177
178 /**
179 * JS register
180 */
181 if ( ! empty( $assets['js'] ) ) {
182 foreach ( $assets['js'] as $js ) {
183
184 $handle = $widget;
185 $path = EASYELEMENTS_DIR_PATH . $js;
186
187 if ( file_exists( $path ) ) {
188 wp_register_script(
189 $handle,
190 EASYELEMENTS_DIR_URL . $js,
191 [ 'jquery' ],
192 filemtime( $path ),
193 true
194 );
195 }
196 }
197 }
198 }
199 }
200
201 function easyel_enqueue_widget_assets() {
202 if ( ! class_exists( '\Elementor\Plugin' ) ) return;
203
204 $widgets_assets = [
205 'eel-archive-post' => [
206 'css' => ['widgets/archive-post/css/archive-post.min.css'],
207 ],
208 'eel-blog-grid' => [
209 'css' => ['widgets/blog-grid/css/blog-grid.min.css'],
210 ],
211 'eel-breadcrumb' => [
212 'css' => ['widgets/breadcrumb/css/breadcrumb.min.css'],
213 ],
214 'eel-button' => [
215 'css' => ['widgets/button/css/button.min.css'],
216 ],
217 'eel-cf7' => [
218 'css' => ['widgets/cf7/css/cf7.min.css'],
219 ],
220 'eel-clients-logo-grid' => [
221 'css' => ['widgets/clients-logo-grid/css/clients-logo.min.css'],
222 ],
223 'eel-contact-box' => [
224 'css' => ['widgets/contact-box/css/contact-box.min.css'],
225 ],
226 'eel-countdown' => [
227 'css' => ['widgets/countdown/css/countdown.min.css'],
228 'js' => ['widgets/countdown/js/countdown.js'],
229 ],
230 'eel-counter' => [
231 'css' => ['widgets/counter/css/counter.min.css'],
232 'js' => ['widgets/counter/js/counter.js'],
233 ],
234 'eel-domain-search' => [
235 'css' => ['widgets/domain-search/css/domain-search.min.css'],
236 ],
237 'eel-excerpt' => [
238 'css' => ['widgets/excerpt/css/excerpt.min.css'],
239 ],
240 'eel-faq-accordion' => [
241 'css' => ['widgets/faq/css/faq.min.css'],
242 'js' => ['widgets/faq/js/faq.js'],
243 ],
244 'eel-feature-list' => [
245 'css' => ['widgets/feature-list/css/feature-list.min.css'],
246 ],
247 'eel-featured-image' => [
248 'css' => ['widgets/featured-image/css/featured-image.min.css'],
249 ],
250 'eel-gallery' => [
251 'css' => ['widgets/gallery/css/gallery.min.css'],
252 'js' => ['widgets/gallery/js/simple-gallery.js'],
253 ],
254 'eel-heading' => [
255 'css' => ['widgets/heading/css/heading.min.css'],
256 ],
257 'eel-icon-box' => [
258 'css' => ['widgets/icon-box/css/icon-box.min.css'],
259 ],
260 'eel-login-register' => [
261 'css' => ['widgets/login-register/css/login-register.min.css'],
262 'js' => ['widgets/login-register/js/login-register.js'],
263 ],
264 'eel-navigation-menu' => [
265 'css' => ['widgets/navigation-menu/css/navigation-menu.min.css'],
266 'js' => [
267 'widgets/navigation-menu/js/navigation-menu.min.js',
268 ],
269 ],
270 'eel-offcanvas' => [
271 'css' => ['widgets/offcanvas/css/offcanvas.min.css'],
272 'js' => ['widgets/offcanvas/js/offcanvas.js'],
273 ],
274 'eel-page-title' => [
275 'css' => ['widgets/page-title/css/page-title.min.css'],
276 ],
277 'eel-post-author-info' => [
278 'css' => ['widgets/post-author/css/post-author.min.css'],
279 ],
280 'eel-post-comments' => [
281 'css' => ['widgets/post-comments/css/post-comments.min.css'],
282 ],
283 'eel-post-content' => [
284 'css' => ['widgets/post-content/css/post-content.min.css'],
285 ],
286 'eel-post-meta' => [
287 'css' => ['widgets/post-meta/css/post-meta.min.css'],
288 ],
289 'eel-post-pagination' => [
290 'css' => ['widgets/post-pagination/css/post-pagination.min.css'],
291 ],
292 'eel-post-tags' => [
293 'css' => ['widgets/post-tag/css/post-tag.min.css'],
294 ],
295 'eel-post-title' => [
296 'css' => ['widgets/post-title/css/post-title.min.css'],
297 ],
298 'eel-pricing' => [
299 'css' => ['widgets/pricing-table/css/pricing.min.css'],
300 ],
301 'eel-process' => [
302 'css' => ['widgets/process-grid/css/process.min.css'],
303 ],
304 'eel-process-list' => [
305 'css' => ['widgets/process-list/css/process-list.min.css'],
306 ],
307 'easyel-progress-bar' => [
308 'css' => ['widgets/progress/css/progress.min.css'],
309 ],
310 'eel-scroll-to-top' => [
311 'css' => ['widgets/scroll-to-top/css/scroll.min.css'],
312 'js' => ['widgets/scroll-to-top/js/scroll.js'],
313 ],
314 'eel-search' => [
315 'css' => ['widgets/search/css/search.min.css'],
316 'js' => ['widgets/search/js/search.js'],
317 ],
318 'eel-service-list' => [
319 'css' => ['widgets/service-list/css/service-list.min.css'],
320 ],
321 'eel-site-logo' => [
322 'css' => ['widgets/site-logo/css/logo.min.css'],
323 ],
324 'eel-social-icon' => [
325 'css' => ['widgets/social-icon/css/social.min.css'],
326 ],
327 'eel-social-share' => [
328 'css' => ['widgets/social-share/css/social-share.min.css'],
329 ],
330 'eel-tab' => [
331 'css' => ['widgets/tab/css/tab.min.css'],
332 'js' => ['widgets/tab/js/tab.js'],
333 ],
334 'eel-table' => [
335 'css' => ['widgets/table/css/table.min.css'],
336 'js' => ['widgets/table/js/table.js'],
337 ],
338 'eel-team-grid' => [
339 'css' => ['widgets/team-grid/css/team-grid.min.css'],
340 'js' => ['widgets/team-grid/js/team.js'],
341 ],
342 'eel-testimonials' => [
343 'css' => ['widgets/testimonials-grid/css/testimonials.min.css'],
344 'js' => ['widgets/testimonials-grid/js/testimonial.js'],
345 ],
346 'eel-video-popup' => [
347 'css' => ['widgets/video/css/video.min.css'],
348 ],
349 'eel-single-nav' => [
350 'css' => ['widgets/single-nav/css/single-nav.min.css'],
351 ],
352 'eel-vertical-navigation' => [
353 'css' => ['widgets/vertical-menu/css/vertical-menu.min.css'],
354 ],
355 'eel-image-before-after' => [
356 'css' => ['widgets/image-comparison/css/image-before-after.min.css'],
357 'js' => ['widgets/image-comparison/js/event.move.js'],
358 ],
359 ];
360 return $widgets_assets;
361 }
362 }