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

150 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UiCoreElements;
3
4 /**
5 * Scripts and Styles Class
6 */
7 class Assets {
8
9 function __construct() {
10 if ( is_admin() ) {
11 add_action( 'admin_enqueue_scripts', [ $this, 'register' ], 5 );
12 } else {
13 add_action( 'wp_enqueue_scripts', [ $this, 'register' ], 5 );
14 }
15 add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'register' ], 1 );
16 }
17
18 /**
19 * Register our app scripts and styles
20 *
21 * @return void
22 */
23 public function register() {
24 $this->register_scripts( $this->get_scripts() );
25 $this->register_styles( $this->get_styles() );
26 }
27
28 /**
29 * Register scripts
30 *
31 * @param array $scripts
32 *
33 * @return void
34 */
35 private function register_scripts( $scripts ) {
36 foreach ( $scripts as $handle => $script ) {
37 $deps = isset( $script['deps'] ) ? $script['deps'] : false;
38 $in_footer = isset( $script['in_footer'] ) ? $script['in_footer'] : false;
39 $version = isset( $script['version'] ) ? $script['version'] : UICORE_ELEMENTS_VERSION;
40
41 wp_register_script( $handle, $script['src'], $deps, $version, $in_footer );
42 }
43 }
44
45 /**
46 * Register styles
47 *
48 * @param array $styles
49 *
50 * @return void
51 */
52 public function register_styles( $styles ) {
53 foreach ( $styles as $handle => $style ) {
54 $deps = isset( $style['deps'] ) ? $style['deps'] : false;
55
56 wp_register_style( $handle, $style['src'], $deps, UICORE_ELEMENTS_VERSION );
57 }
58 }
59
60 /**
61 * Get all registered scripts
62 *
63 * @return array
64 */
65 public function get_scripts() {
66 $prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
67
68 $scripts = [
69 // libs
70 'ui-e-countup' => [
71 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/countUp.umd.js',
72 'version' => UICORE_ELEMENTS_VERSION,
73 'in_footer' => true
74 ],
75 'ui-e-odometer' => [
76 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/odometer.js',
77 'version' => UICORE_ELEMENTS_VERSION,
78 'in_footer' => true
79 ],
80 // utils
81 'ui-e-entrance' => [
82 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-entrances.js',
83 'version' => UICORE_ELEMENTS_VERSION,
84 'in_footer' => true
85 ],
86 'ui-e-ajax-request' => [
87 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/ajax-request.js',
88 'version' => UICORE_ELEMENTS_VERSION,
89 'in_footer' => true
90 ],
91 'ui-e-recaptcha' => [
92 'src' => 'https://www.google.com/recaptcha/api.js?render=explicit',
93 'version' => UICORE_ELEMENTS_VERSION,
94 'in_footer' => false
95 ],
96 'ui-e-recaptcha-v3' => [
97 'src' => 'https://www.google.com/recaptcha/api.js?render=' . get_option('uicore_elements_recaptcha_site_key'),
98 'version' => UICORE_ELEMENTS_VERSION,
99 'in_footer' => false
100 ],
101 'ui-e-repeater-custom-key' => [
102 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/repeater-custom-key.js',
103 'version' => UICORE_ELEMENTS_VERSION,
104 'in_footer' => true
105 ],
106 // components
107 'ui-e-counter' => [
108 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-counter.js',
109 'version' => UICORE_ELEMENTS_VERSION,
110 'deps' => ['ui-e-countup'],
111 'in_footer' => true
112 ],
113 'ui-e-carousel' => [
114 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-carousel.js',
115 'version' => UICORE_ELEMENTS_VERSION,
116 'deps' => ['elementor-frontend'],
117 'in_footer' => true
118 ],
119 ];
120
121 return $scripts;
122 }
123
124 /**
125 * Get registered styles
126 *
127 * @return array
128 */
129 public function get_styles() {
130
131 $styles = [
132 'ui-e-animation' => [
133 'src' => UICORE_ELEMENTS_ASSETS . '/css/utils/global-animations.css'
134 ],
135 'ui-e-entrance' => [
136 'src' => UICORE_ELEMENTS_ASSETS . '/css/utils/global-entrances.css'
137 ],
138 // 'uicore_animate-settings' => [
139 // 'src' => UICORE_ELEMENTS_ASSETS . '/css/settings.css'
140 // ],
141 // 'uicore_animate-admin' => [
142 // 'src' => UICORE_ELEMENTS_ASSETS . '/css/admin.css'
143 // ],
144 ];
145
146 return $styles;
147 }
148
149 }
150