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

145 lines 4.4 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 'ui-e-flickity' => [
81 'src' => UICORE_ELEMENTS_ASSETS . '/js/lib/flickity.min.js',
82 'version' => UICORE_ELEMENTS_VERSION,
83 'in_footer' => true
84 ],
85 // utils
86 'ui-e-entrance' => [
87 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-entrances.js',
88 'version' => UICORE_ELEMENTS_VERSION,
89 'in_footer' => true
90 ],
91 'ui-e-ajax-request' => [
92 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/ajax-request.js',
93 'version' => UICORE_ELEMENTS_VERSION,
94 'in_footer' => true
95 ],
96 // components
97 'ui-e-counter' => [
98 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-counter.js',
99 'version' => UICORE_ELEMENTS_VERSION,
100 'deps' => ['ui-e-countup'],
101 'in_footer' => true
102 ],
103 'ui-e-testimonial' => [
104 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-testimonial.js',
105 'version' => UICORE_ELEMENTS_VERSION,
106 'in_footer' => true
107 ],
108 'ui-e-carousel' => [
109 'src' => UICORE_ELEMENTS_ASSETS . '/js/utils/global-carousel.js',
110 'version' => UICORE_ELEMENTS_VERSION,
111 'deps' => ['ui-e-flickity'],
112 'in_footer' => true
113 ],
114 ];
115
116 return $scripts;
117 }
118
119 /**
120 * Get registered styles
121 *
122 * @return array
123 */
124 public function get_styles() {
125
126 $styles = [
127 'ui-e-animation' => [
128 'src' => UICORE_ELEMENTS_ASSETS . '/css/utils/global-animations.css'
129 ],
130 'ui-e-entrance' => [
131 'src' => UICORE_ELEMENTS_ASSETS . '/css/utils/global-entrances.css'
132 ],
133 // 'uicore_animate-settings' => [
134 // 'src' => UICORE_ELEMENTS_ASSETS . '/css/settings.css'
135 // ],
136 // 'uicore_animate-admin' => [
137 // 'src' => UICORE_ELEMENTS_ASSETS . '/css/admin.css'
138 // ],
139 ];
140
141 return $styles;
142 }
143
144 }
145