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

357 lines 13.7 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 ];
111
112 if ( in_array( $handle, $defer_handles, true ) ) {
113 return str_replace( ' src', ' defer src', $tag );
114 }
115
116 return $tag;
117 }
118
119 public function easyel_register_free_all_widget_assets() {
120
121 $widgets_assets = $this->easyel_enqueue_widget_assets();
122
123 $single_archive_widget = array(
124 'eel-featured-image',
125 'eel-post-content',
126 'eel-excerpt',
127 "eel-post-author-info",
128 'eel-post-comments',
129 'eel-post-meta',
130 'eel-post-pagination',
131 'eel-post-tags',
132 'eel-post-title',
133 "eel-breadcrumb",
134 "eel-navigation-menu",
135 "eel-site-logo",
136 );
137
138 foreach ( $widgets_assets as $widget => $assets ) {
139
140 /**
141 * CSS register
142 */
143 if ( ! empty( $assets['css'] ) ) {
144 foreach ( $assets['css'] as $css ) {
145
146 $handle = $widget;
147 $path = EASYELEMENTS_DIR_PATH . $css;
148 $url = EASYELEMENTS_DIR_URL . $css;
149
150 if ( ! file_exists( $path ) ) {
151 continue;
152 }
153
154 $version = filemtime( $path );
155
156 if ( is_singular( 'post' ) && in_array( $handle, $single_archive_widget, true ) ) {
157
158 wp_enqueue_style(
159 $handle,
160 $url,
161 [],
162 $version
163 );
164
165 } else {
166
167 wp_register_style(
168 $handle,
169 $url,
170 [],
171 $version
172 );
173 }
174 }
175 }
176
177 /**
178 * JS register
179 */
180 if ( ! empty( $assets['js'] ) ) {
181 foreach ( $assets['js'] as $js ) {
182
183 $handle = $widget;
184 $path = EASYELEMENTS_DIR_PATH . $js;
185
186 if ( file_exists( $path ) ) {
187 wp_register_script(
188 $handle,
189 EASYELEMENTS_DIR_URL . $js,
190 [ 'jquery' ],
191 filemtime( $path ),
192 true
193 );
194 }
195 }
196 }
197 }
198 }
199
200 function easyel_enqueue_widget_assets() {
201 if ( ! class_exists( '\Elementor\Plugin' ) ) return;
202
203 $widgets_assets = [
204 'eel-archive-post' => [
205 'css' => ['widgets/archive-post/css/archive-post.min.css'],
206 ],
207 'eel-blog-grid' => [
208 'css' => ['widgets/blog-grid/css/blog-grid.min.css'],
209 ],
210 'eel-breadcrumb' => [
211 'css' => ['widgets/breadcrumb/css/breadcrumb.min.css'],
212 ],
213 'eel-button' => [
214 'css' => ['widgets/button/css/button.min.css'],
215 ],
216 'eel-cf7' => [
217 'css' => ['widgets/cf7/css/cf7.min.css'],
218 ],
219 'eel-clients-logo-grid' => [
220 'css' => ['widgets/clients-logo-grid/css/clients-logo.min.css'],
221 ],
222 'eel-contact-box' => [
223 'css' => ['widgets/contact-box/css/contact-box.min.css'],
224 ],
225 'eel-countdown' => [
226 'css' => ['widgets/countdown/css/countdown.min.css'],
227 'js' => ['widgets/countdown/js/countdown.js'],
228 ],
229 'eel-counter' => [
230 'css' => ['widgets/counter/css/counter.min.css'],
231 'js' => ['widgets/counter/js/counter.js'],
232 ],
233 'eel-domain-search' => [
234 'css' => ['widgets/domain-search/css/domain-search.min.css'],
235 ],
236 'eel-excerpt' => [
237 'css' => ['widgets/excerpt/css/excerpt.min.css'],
238 ],
239 'eel-faq-accordion' => [
240 'css' => ['widgets/faq/css/faq.min.css'],
241 'js' => ['widgets/faq/js/faq.js'],
242 ],
243 'eel-feature-list' => [
244 'css' => ['widgets/feature-list/css/feature-list.min.css'],
245 ],
246 'eel-featured-image' => [
247 'css' => ['widgets/featured-image/css/featured-image.min.css'],
248 ],
249 'eel-gallery' => [
250 'css' => ['widgets/gallery/css/gallery.min.css'],
251 'js' => ['widgets/gallery/js/simple-gallery.js'],
252 ],
253 'eel-heading' => [
254 'css' => ['widgets/heading/css/heading.min.css'],
255 ],
256 'eel-icon-box' => [
257 'css' => ['widgets/icon-box/css/icon-box.min.css'],
258 ],
259 'eel-login-register' => [
260 'css' => ['widgets/login-register/css/login-register.min.css'],
261 'js' => ['widgets/login-register/js/login-register.js'],
262 ],
263 'eel-navigation-menu' => [
264 'css' => ['widgets/navigation-menu/css/navigation-menu.min.css'],
265 'js' => [
266 'widgets/navigation-menu/js/navigation-menu.min.js',
267 ],
268 ],
269 'eel-offcanvas' => [
270 'css' => ['widgets/offcanvas/css/offcanvas.min.css'],
271 'js' => ['widgets/offcanvas/js/offcanvas.js'],
272 ],
273 'eel-page-title' => [
274 'css' => ['widgets/page-title/css/page-title.min.css'],
275 ],
276 'eel-post-author-info' => [
277 'css' => ['widgets/post-author/css/post-author.min.css'],
278 ],
279 'eel-post-comments' => [
280 'css' => ['widgets/post-comments/css/post-comments.min.css'],
281 ],
282 'eel-post-content' => [
283 'css' => ['widgets/post-content/css/post-content.min.css'],
284 ],
285 'eel-post-meta' => [
286 'css' => ['widgets/post-meta/css/post-meta.min.css'],
287 ],
288 'eel-post-pagination' => [
289 'css' => ['widgets/post-pagination/css/post-pagination.min.css'],
290 ],
291 'eel-post-tags' => [
292 'css' => ['widgets/post-tag/css/post-tag.min.css'],
293 ],
294 'eel-post-title' => [
295 'css' => ['widgets/post-title/css/post-title.min.css'],
296 ],
297 'eel-pricing' => [
298 'css' => ['widgets/pricing-table/css/pricing.min.css'],
299 ],
300 'eel-process' => [
301 'css' => ['widgets/process-grid/css/process.min.css'],
302 ],
303 'eel-process-list' => [
304 'css' => ['widgets/process-list/css/process-list.min.css'],
305 ],
306 'easyel-progress-bar' => [
307 'css' => ['widgets/progress/css/progress.min.css'],
308 ],
309 'eel-scroll-to-top' => [
310 'css' => ['widgets/scroll-to-top/css/scroll.min.css'],
311 'js' => ['widgets/scroll-to-top/js/scroll.js'],
312 ],
313 'eel-search' => [
314 'css' => ['widgets/search/css/search.min.css'],
315 'js' => ['widgets/search/js/search.js'],
316 ],
317 'eel-service-list' => [
318 'css' => ['widgets/service-list/css/service-list.min.css'],
319 ],
320 'eel-site-logo' => [
321 'css' => ['widgets/site-logo/css/logo.min.css'],
322 ],
323 'eel-social-icon' => [
324 'css' => ['widgets/social-icon/css/social.min.css'],
325 ],
326 'eel-social-share' => [
327 'css' => ['widgets/social-share/css/social-share.min.css'],
328 ],
329 'eel-tab' => [
330 'css' => ['widgets/tab/css/tab.min.css'],
331 'js' => ['widgets/tab/js/tab.js'],
332 ],
333 'eel-table' => [
334 'css' => ['widgets/table/css/table.min.css'],
335 'js' => ['widgets/table/js/table.js'],
336 ],
337 'eel-team-grid' => [
338 'css' => ['widgets/team-grid/css/team-grid.min.css'],
339 'js' => ['widgets/team-grid/js/team.js'],
340 ],
341 'eel-testimonials' => [
342 'css' => ['widgets/testimonials-grid/css/testimonials.min.css'],
343 'js' => ['widgets/testimonials-grid/js/testimonial.js'],
344 ],
345 'eel-video-popup' => [
346 'css' => ['widgets/video/css/video.min.css'],
347 ],
348 'eel-single-nav' => [
349 'css' => ['widgets/single-nav/css/single-nav.min.css'],
350 ],
351 ];
352
353 return $widgets_assets;
354
355 }
356
357 }