PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.0
UiCore Elements – Free widgets and templates for Elementor v1.2.0
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / includes / class-assets.php

class-assets.php in UiCore Elements – Free widgets and templates for Elementor 1.2.0, at includes/class-assets.php

213 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UiCoreElements;
3 use Elementor\Plugin;
4
5 /**
6 * Scripts and Styles Class
7 */
8 class Assets {
9
10 function __construct() {
11 if ( is_admin() ) {
12 add_action( 'admin_enqueue_scripts', [ $this, 'register' ], 5 );
13 add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue' ], 5 );
14 } else {
15 add_action( 'wp_enqueue_scripts', [ $this, 'register' ], 5 );
16 }
17 }
18
19 /**
20 * Register our app scripts and styles
21 *
22 * @return void
23 */
24 public function register() {
25 $this->register_scripts( $this->get_scripts() );
26 $this->register_styles( $this->get_styles() );
27 }
28
29 /**
30 * Enqueue our app scripts directly in the Elementor editor
31 *
32 * @return void
33 */
34 public function enqueue() {
35 if ( Plugin::instance()->editor->is_edit_mode() ) {
36 wp_enqueue_script('ui-nested-elements', UICORE_ELEMENTS_ASSETS . '/js/components/nested-elements.js', [], UICORE_ELEMENTS_VERSION, true);
37 }
38 }
39
40 /**
41 * Register scripts
42 *
43 * @param array $scripts
44 *
45 * @return void
46 */
47 private function register_scripts( $scripts ) {
48 foreach ( $scripts as $handle => $script ) {
49 $deps = isset( $script['deps'] ) ? $script['deps'] : false;
50 $in_footer = isset( $script['in_footer'] ) ? $script['in_footer'] : false;
51 $version = isset( $script['version'] ) ? $script['version'] : UICORE_ELEMENTS_VERSION;
52
53 wp_register_script( $handle, $script['src'], $deps, $version, $in_footer );
54 }
55 }
56
57 /**
58 * Register styles
59 *
60 * @param array $styles
61 *
62 * @return void
63 */
64 public function register_styles( $styles ) {
65 foreach ( $styles as $handle => $style ) {
66 $deps = isset( $style['deps'] ) ? $style['deps'] : false;
67
68 wp_register_style( $handle, $style['src'], $deps, UICORE_ELEMENTS_VERSION );
69 }
70 }
71
72 /**
73 * Get all registered scripts
74 *
75 * @return array
76 */
77 public function get_scripts() {
78 $prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
79
80 $scripts = [
81 // Libs that extend current scripts
82 'ui-e-countup' => [
83 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/countUp.umd.js',
84 'version' => UICORE_ELEMENTS_VERSION,
85 'in_footer' => true
86 ],
87 'ui-e-odometer' => [
88 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/odometer.js',
89 'version' => UICORE_ELEMENTS_VERSION,
90 'in_footer' => true
91 ],
92 'ui-e-swiper' => [
93 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/swiper.js',
94 'version' => '11.2.1',
95 'in_footer' => true
96 ],
97 'ui-e-special-effects' => [
98 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/carousel-effects/special-effects.js',
99 'version' => UICORE_ELEMENTS_VERSION,
100 'in_footer' => true
101 ],
102 'ui-e-circular-avatar-carousel' => [
103 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/carousel-effects/circular_avatar.js',
104 'version' => UICORE_ELEMENTS_VERSION,
105 'in_footer' => true
106 ],
107 'ui-e-stacked-carousel' => [
108 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/carousel-effects/stacked.js',
109 'version' => UICORE_ELEMENTS_VERSION,
110 'in_footer' => true
111 ],
112
113 // Utils and non-compiled assets
114 'ui-e-recaptcha' => [
115 'src' => 'https://www.google.com/recaptcha/api.js?render=explicit',
116 'version' => UICORE_ELEMENTS_VERSION,
117 'in_footer' => false
118 ],
119 'ui-e-recaptcha-v3' => [
120 'src' => 'https://www.google.com/recaptcha/api.js?render=' . get_option('uicore_elements_recaptcha_site_key'),
121 'version' => UICORE_ELEMENTS_VERSION,
122 'in_footer' => false
123 ],
124
125 // Components compiled for enqueue
126 'ui-e-entrance' => [
127 'src' => UICORE_ELEMENTS_ASSETS . '/js/components/global-entrances.js',
128 'version' => UICORE_ELEMENTS_VERSION,
129 'in_footer' => true
130 ],
131 'ui-e-masonry' => [
132 'src' => UICORE_ELEMENTS_ASSETS . '/js/components/global-masonry.js',
133 'version' => UICORE_ELEMENTS_VERSION,
134 'in_footer' => true
135 ],
136 'ui-e-ajax-request' => [
137 'src' => UICORE_ELEMENTS_ASSETS . '/js/components/ajax-request.js',
138 'version' => UICORE_ELEMENTS_VERSION,
139 'in_footer' => true
140 ],
141 'ui-e-counter' => [
142 'src' => UICORE_ELEMENTS_ASSETS . '/js/components/global-counter.js',
143 'version' => UICORE_ELEMENTS_VERSION,
144 'deps' => ['ui-e-countup'],
145 'in_footer' => true
146 ],
147 'ui-e-carousel' => [
148 'src' => UICORE_ELEMENTS_ASSETS . '/js/components/global-carousel.js',
149 'version' => UICORE_ELEMENTS_VERSION,
150 'deps' => ['ui-e-swiper'],
151 'in_footer' => true
152 ],
153 'ui-e-repeater-custom-key' => [
154 'src' => UICORE_ELEMENTS_ASSETS . '/js/components/repeater-custom-key.js',
155 'version' => UICORE_ELEMENTS_VERSION,
156 'in_footer' => true
157 ],
158 'ui-e-testimonial' => [
159 'src' => UICORE_ELEMENTS_ASSETS . '/js/components/global-testimonial.js',
160 'version' => UICORE_ELEMENTS_VERSION,
161 'in_footer' => true
162 ]
163 ];
164
165 return $scripts;
166 }
167
168 /**
169 * Get registered styles
170 *
171 * @return array
172 */
173 public function get_styles() {
174
175 // Singular files widgets may enqueue
176 $styles = [
177 // Animation related
178 'ui-e-animation' => [
179 'src' => UICORE_ELEMENTS_ASSETS . '/css/components/global-animations.css'
180 ],
181 'ui-e-entrance' => [
182 'src' => UICORE_ELEMENTS_ASSETS . '/css/components/global-entrances.css'
183 ],
184
185 // Layout related
186 'ui-e-grid' => [
187 'src' => UICORE_ELEMENTS_ASSETS . '/css/components/grid.css'
188 ],
189 'ui-e-legacy-grid' =>[
190 'src' => UICORE_ELEMENTS_ASSETS . '/css/components/legacy-grid.css'
191 ],
192 'ui-e-carousel' => [
193 'src' => UICORE_ELEMENTS_ASSETS . '/css/components/carousel.css',
194 'deps' => ['swiper', 'e-swiper'],
195 ],
196
197 // Specifics
198 'ui-e-post-meta' => [
199 'src' => UICORE_ELEMENTS_ASSETS . '/css/components/meta.css'
200 ],
201 'ui-e-filters' => [
202 'src' => UICORE_ELEMENTS_ASSETS . '/css/components/filters.css'
203 ],
204 'ui-e-counter-motion' => [
205 'src' => UICORE_ELEMENTS_ASSETS . '/css/components/counter-motion.css'
206 ]
207 ];
208
209 return $styles;
210 }
211
212 }
213