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

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