PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.0.6
UiCore Elements – Free widgets and templates for Elementor v1.0.6
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.0.6, at includes/class-assets.php

169 lines 5.6 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', function() {
14 $this->register(true);
15 }, 1 );
16 } else {
17 add_action( 'wp_enqueue_scripts', [ $this, 'register' ], 5 );
18 }
19 }
20
21 /**
22 * Register our app scripts and styles
23 *
24 * @param bool $editor If the scripts are meant for the Elementor editor's. Defaults to false.
25 *
26 * @return void
27 */
28 public function register(bool $editor = false) {
29 $this->register_scripts( $this->get_scripts() );
30 $this->register_styles( $this->get_styles() );
31
32 // Elementor editor specific scripts
33 if($editor){
34 wp_enqueue_script('ui-nested-content', UICORE_ELEMENTS_ASSETS . '/js/utils/nested-content.js', [], UICORE_ELEMENTS_VERSION, true);
35 }
36 }
37
38 /**
39 * Register scripts
40 *
41 * @param array $scripts
42 *
43 * @return void
44 */
45 private function register_scripts( $scripts ) {
46 foreach ( $scripts as $handle => $script ) {
47 $deps = isset( $script['deps'] ) ? $script['deps'] : false;
48 $in_footer = isset( $script['in_footer'] ) ? $script['in_footer'] : false;
49 $version = isset( $script['version'] ) ? $script['version'] : UICORE_ELEMENTS_VERSION;
50
51 wp_register_script( $handle, $script['src'], $deps, $version, $in_footer );
52 }
53 }
54
55 /**
56 * Register styles
57 *
58 * @param array $styles
59 *
60 * @return void
61 */
62 public function register_styles( $styles ) {
63 foreach ( $styles as $handle => $style ) {
64 $deps = isset( $style['deps'] ) ? $style['deps'] : false;
65
66 wp_register_style( $handle, $style['src'], $deps, UICORE_ELEMENTS_VERSION );
67 }
68 }
69
70 /**
71 * Get all registered scripts
72 *
73 * @return array
74 */
75 public function get_scripts() {
76 $prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
77
78 $scripts = [
79 // libs
80 'ui-e-countup' => [
81 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/countUp.umd.js',
82 'version' => UICORE_ELEMENTS_VERSION,
83 'in_footer' => true
84 ],
85 'ui-e-odometer' => [
86 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/odometer.js',
87 'version' => UICORE_ELEMENTS_VERSION,
88 'in_footer' => true
89 ],
90 // utils
91 'ui-e-entrance' => [
92 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-entrances.js',
93 'version' => UICORE_ELEMENTS_VERSION,
94 'in_footer' => true
95 ],
96 'ui-e-ajax-request' => [
97 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/ajax-request.js',
98 'version' => UICORE_ELEMENTS_VERSION,
99 'in_footer' => true
100 ],
101 'ui-e-recaptcha' => [
102 'src' => 'https://www.google.com/recaptcha/api.js?render=explicit',
103 'version' => UICORE_ELEMENTS_VERSION,
104 'in_footer' => false
105 ],
106 'ui-e-recaptcha-v3' => [
107 'src' => 'https://www.google.com/recaptcha/api.js?render=' . get_option('uicore_elements_recaptcha_site_key'),
108 'version' => UICORE_ELEMENTS_VERSION,
109 'in_footer' => false
110 ],
111 'ui-e-repeater-custom-key' => [
112 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/repeater-custom-key.js',
113 'version' => UICORE_ELEMENTS_VERSION,
114 'in_footer' => true
115 ],
116 /*
117 'ui-e-nested-elements' => [
118 //'src' => \ELEMENTOR_ASSETS_URL . '/js/nested-elements.js',
119 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/nested-elements.js',
120 'version' => UICORE_ELEMENTS_VERSION,
121 //'deps' => ['elementor-common-modules'],
122 'in_footer' => true
123 ],
124 */
125 // components
126 'ui-e-counter' => [
127 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-counter.js',
128 'version' => UICORE_ELEMENTS_VERSION,
129 'deps' => ['ui-e-countup'],
130 'in_footer' => true
131 ],
132 'ui-e-carousel' => [
133 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-carousel.js',
134 'version' => UICORE_ELEMENTS_VERSION,
135 'deps' => ['elementor-frontend'],
136 'in_footer' => true
137 ],
138 ];
139
140 return $scripts;
141 }
142
143 /**
144 * Get registered styles
145 *
146 * @return array
147 */
148 public function get_styles() {
149
150 $styles = [
151 'ui-e-animation' => [
152 'src' => UICORE_ELEMENTS_ASSETS . '/css/utils/global-animations.css'
153 ],
154 'ui-e-entrance' => [
155 'src' => UICORE_ELEMENTS_ASSETS . '/css/utils/global-entrances.css'
156 ],
157 // 'uicore_animate-settings' => [
158 // 'src' => UICORE_ELEMENTS_ASSETS . '/css/settings.css'
159 // ],
160 // 'uicore_animate-admin' => [
161 // 'src' => UICORE_ELEMENTS_ASSETS . '/css/admin.css'
162 // ],
163 ];
164
165 return $styles;
166 }
167
168 }
169