PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.0-dev3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | core/page-assets/loader.php +18 -78 4.2.03.23.0-dev3 View file →
@@ -2,14 +2,11 @@
2 2 namespace Elementor\Core\Page_Assets;
3 3
4 4 use Elementor\Core\Base\Module;
5 5 use Elementor\Plugin;
6 -use Elementor\Control_Animation;
7 -use Elementor\Control_Exit_Animation;
8 -use Elementor\Control_Hover_Animation;
9 6
10 7 if ( ! defined( 'ABSPATH' ) ) {
11 - exit; // Exit if accessed directly.
8 + exit; // Exit if accessed directly
12 9 }
13 10
14 11 /**
15 12 * Elementor assets loader.
@@ -18,81 +15,28 @@
18 15 *
19 16 * @since 3.3.0
20 17 */
21 18 class Loader extends Module {
22 - private array $assets = [];
19 + private $assets;
23 20
24 - public function get_name(): string {
21 + public function get_name() {
25 22 return 'assets-loader';
26 23 }
27 24
28 - private function init_assets(): void {
29 - $assets = [
30 - 'styles' => $this->init_styles(),
25 + private function init_assets() {
26 + $this->assets = [
27 + 'styles' => [
28 + 'e-animations' => [
29 + 'src' => $this->get_css_assets_url( 'animations', 'assets/lib/animations/', true ),
30 + 'version' => ELEMENTOR_VERSION,
31 + 'dependencies' => [],
32 + ],
33 + ],
31 34 'scripts' => [],
32 35 ];
33 -
34 - $this->assets = $assets;
35 36 }
36 37
37 - private function init_styles(): array {
38 - $styles = [
39 - 'e-shapes' => [
40 - 'src' => $this->get_css_assets_url( 'shapes', 'assets/css/conditionals/' ),
41 - 'version' => ELEMENTOR_VERSION,
42 - 'dependencies' => [],
43 - ],
44 - 'e-swiper' => [
45 - 'src' => $this->get_css_assets_url( 'e-swiper', 'assets/css/conditionals/' ),
46 - 'version' => ELEMENTOR_VERSION,
47 - 'dependencies' => [ 'swiper' ],
48 - ],
49 - 'swiper' => [
50 - 'src' => $this->get_css_assets_url( 'swiper', 'assets/lib/swiper/v8/css/' ),
51 - 'version' => '8.4.5',
52 - 'dependencies' => [],
53 - ],
54 - ];
55 -
56 - return array_merge( $styles, $this->get_animation_styles() );
57 - }
58 -
59 - private function get_animations(): array {
60 - $grouped_animations = Control_Animation::get_default_animations();
61 - $grouped_animations['hover'] = Control_Hover_Animation::get_default_animations();
62 - $exit_animations = Control_Exit_Animation::get_default_animations();
63 -
64 - $grouped_animations = array_merge( $grouped_animations, $exit_animations );
65 -
66 - $animations = [];
67 -
68 - foreach ( $grouped_animations as $group_label => $group ) {
69 - foreach ( $group as $animation_key => $animation_label ) {
70 - $animations[ $animation_key ] = $group_label;
71 - }
72 - }
73 -
74 - return $animations;
75 - }
76 -
77 - private function get_animation_styles(): array {
78 - $animations = $this->get_animations();
79 - $styles = [];
80 -
81 - foreach ( $animations as $animation => $group_label ) {
82 - $style_prefix = 'hover' === $group_label ? 'e-animation-' : '';
83 -
84 - $styles[ 'e-animation-' . $animation ] = [
85 - 'src' => $this->get_css_assets_url( $style_prefix . $animation, 'assets/lib/animations/styles/' ),
86 - 'version' => ELEMENTOR_VERSION,
87 - 'dependencies' => [],
88 - ];
89 - }
90 -
91 - return $styles;
92 - }
93 -
94 - public function get_assets(): array {
38 + public function get_assets() {
95 39 if ( ! $this->assets ) {
96 40 $this->init_assets();
97 41 }
98 42
@@ -99,14 +43,14 @@
99 43 return $this->assets;
100 44 }
101 45
102 46 /**
103 - * @param array $assets_data {
47 + * @param array $assets {
104 48 * @type array 'styles'
105 49 * @type array 'scripts'
106 50 * }
107 51 */
108 - public function enable_assets( array $assets_data ): void {
52 + public function enable_assets( array $assets_data ) {
109 53 if ( ! $this->assets ) {
110 54 $this->init_assets();
111 55 }
112 56
@@ -128,9 +72,9 @@
128 72 * @type array 'styles'
129 73 * @type array 'scripts'
130 74 * }
131 75 */
132 - public function add_assets( array $assets ): void {
76 + public function add_assets( array $assets ) {
133 77 if ( ! $this->assets ) {
134 78 $this->init_assets();
135 79 }
136 80
@@ -139,18 +83,14 @@
139 83
140 84 /**
141 85 * @deprecated 3.22.0
142 86 */
143 - public function enqueue_assets(): void {
87 + public function enqueue_assets() {
144 88 $assets = $this->get_assets();
145 89 $is_preview_mode = Plugin::$instance->preview->is_preview_mode();
146 90
147 91 foreach ( $assets as $assets_type => $assets_type_data ) {
148 92 foreach ( $assets_type_data as $asset_name => $asset_data ) {
149 - if ( empty( $asset_data['src'] ) ) {
150 - continue;
151 - }
152 -
153 93 if ( ! empty( $asset_data['enabled'] ) || $is_preview_mode ) {
154 94 if ( 'scripts' === $assets_type ) {
155 95 wp_enqueue_script( $asset_name, $asset_data['src'], $asset_data['dependencies'], $asset_data['version'], true );
156 96 } else {
@@ -160,9 +100,9 @@
160 100 }
161 101 }
162 102 }
163 103
164 - private function register_assets(): void {
104 + private function register_assets() {
165 105 $assets = $this->get_assets();
166 106
167 107 foreach ( $assets as $assets_type => $assets_type_data ) {
168 108 foreach ( $assets_type_data as $asset_name => $asset_data ) {