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

160 lines 5.0 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/utils/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
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 // utils
93 'ui-e-entrance' => [
94 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-entrances.js',
95 'version' => UICORE_ELEMENTS_VERSION,
96 'in_footer' => true
97 ],
98 'ui-e-masonry' => [
99 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-masonry.js',
100 'version' => UICORE_ELEMENTS_VERSION,
101 'in_footer' => true
102 ],
103 'ui-e-ajax-request' => [
104 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/ajax-request.js',
105 'version' => UICORE_ELEMENTS_VERSION,
106 'in_footer' => true
107 ],
108 'ui-e-recaptcha' => [
109 'src' => 'https://www.google.com/recaptcha/api.js?render=explicit',
110 'version' => UICORE_ELEMENTS_VERSION,
111 'in_footer' => false
112 ],
113 'ui-e-recaptcha-v3' => [
114 'src' => 'https://www.google.com/recaptcha/api.js?render=' . get_option('uicore_elements_recaptcha_site_key'),
115 'version' => UICORE_ELEMENTS_VERSION,
116 'in_footer' => false
117 ],
118 'ui-e-repeater-custom-key' => [
119 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/repeater-custom-key.js',
120 'version' => UICORE_ELEMENTS_VERSION,
121 'in_footer' => true
122 ],
123 // components
124 'ui-e-counter' => [
125 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-counter.js',
126 'version' => UICORE_ELEMENTS_VERSION,
127 'deps' => ['ui-e-countup'],
128 'in_footer' => true
129 ],
130 'ui-e-carousel' => [
131 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-carousel.js',
132 'version' => UICORE_ELEMENTS_VERSION,
133 'in_footer' => true
134 ],
135 ];
136
137 return $scripts;
138 }
139
140 /**
141 * Get registered styles
142 *
143 * @return array
144 */
145 public function get_styles() {
146
147 $styles = [
148 'ui-e-animation' => [
149 'src' => UICORE_ELEMENTS_ASSETS . '/css/utils/global-animations.css'
150 ],
151 'ui-e-entrance' => [
152 'src' => UICORE_ELEMENTS_ASSETS . '/css/utils/global-entrances.css'
153 ],
154 ];
155
156 return $styles;
157 }
158
159 }
160