PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
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
← All changes | includes/utils/animation-component.php +54 -39 1.0.141.3.17 View file →
@@ -1,11 +1,14 @@
1 1 <?php
2 +
2 3 namespace UiCoreElements\Utils;
4 +
3 5 use Elementor\Controls_Manager;
4 6
5 7 defined('ABSPATH') || exit();
6 8
7 -trait Animation_Trait {
9 +trait Animation_Trait
10 +{
8 11
9 12 private $animation;
10 13
11 14 /**
@@ -15,28 +18,40 @@
15 18 * @param array $conditions Control conditions. (optional)
16 19 * @param array $filter Removes requested animations from the options. (optional)
17 20 * @param string|null $custom_slug A custom slug for the control. If null, use $name as slug, formating it. (optional)
18 21 * @param bool $use_new Include new animations not globally available. (optional)
22 + * @param string $prefix_class Let you add a custom prefix, but be cautious, the classname `ui-e-item-anim-{animation} will be part of the prefix classname. (optional)
19 23 *
20 24 * @return void
21 25 */
22 - function TRAIT_register_hover_animation_control($name, $conditions = [], $filter = [], $custom_slug = null, $use_new = false)
26 + function TRAIT_register_hover_animation_control($name, $conditions = [], $filter = [], $custom_slug = null, $use_new = false, $prefix_class = null)
23 27 {
24 28 // Custom slug or name converted to slug
25 - // TODO: use sanitize_title() instead of the 3 functions combined above
26 - $slug = isset($custom_slug) ? $custom_slug : strtolower(preg_replace('/\s+/', '_', preg_replace('/[^a-zA-Z0-9\s]/', '', $name)));
29 + $slug = isset($custom_slug)
30 + ? $custom_slug
31 + // using sanitize_title() would create incompatibility problems since it uses hyphens, not underscores
32 + : strtolower(preg_replace('/\s+/', '_', preg_replace('/[^a-zA-Z0-9\s]/', '', $name)));
27 33
28 - $this->add_control(
29 - $slug,
30 - [
31 - 'label' => esc_html__( $name, 'uicore-elements' ),
32 - 'type' => Controls_Manager::SELECT,
33 - 'default' => '',
34 - 'label_block' => true,
35 - 'options' => $this->uicore_get_animations($filter, $use_new),
36 - 'condition' => $conditions
37 - ]
38 - );
34 + // Mandatory params
35 + $params = [
36 + /* translators: %s: control title */
37 + 'label' => esc_html(sprintf('%s', $name), 'uicore-elements'),
38 + 'type' => Controls_Manager::SELECT,
39 + 'default' => '',
40 + 'content_classes' => 'elementor-control-field-select-small',
41 + 'options' => $this->uicore_get_animations($filter, $use_new),
42 + ];
43 +
44 + // Optional params
45 + if (isset($conditions)) {
46 + $params['condition'] = $conditions;
47 + }
48 + if (isset($prefix_class)) {
49 + $params['prefix_class'] = $prefix_class;
50 + $params['render_type'] = 'template';
51 + }
52 +
53 + $this->add_control($slug, $params);
39 54 }
40 55 // Entrance Animations Controls.
41 56 function TRAIT_register_entrance_animations_controls()
42 57 {
@@ -46,9 +61,9 @@
46 61 'label' => esc_html__('Animate each Item', 'uicore-elements'),
47 62 'type' => Controls_Manager::SWITCHER,
48 63 'default' => '',
49 64 'return_value' => 'ui-e-grid-animate',
50 - 'render_type' => 'none',
65 + 'render_type' => 'none',
51 66 'frontend_available' => true,
52 67 ]
53 68 );
54 69 $this->add_control(
@@ -53,18 +68,18 @@
53 68 );
54 69 $this->add_control(
55 70 'animate_item_type',
56 71 [
57 - 'label' => __( 'Animation', 'uicore-elements' ),
72 + 'label' => __('Animation', 'uicore-elements'),
58 73 'type' => Controls_Manager::SELECT,
59 74 'default' => 'fadeInUp',
60 75 'options' => [
61 - 'fadeInUp' => __( 'Fade In Up', 'uicore-elements' ),
62 - 'fadeInDown' => __( 'Fade In Down', 'uicore-elements' ),
63 - 'fadeInLeft' => __( 'Fade In Left', 'uicore-elements' ),
64 - 'fadeInRight' => __( 'Fade In Right', 'uicore-elements' ),
65 - 'fadeIn' => __( 'Fade In', 'uicore-elements' ),
66 - 'zoomIn' => __( 'Zoom In', 'uicore-elements' ),
76 + 'fadeInUp' => __('Fade In Up', 'uicore-elements'),
77 + 'fadeInDown' => __('Fade In Down', 'uicore-elements'),
78 + 'fadeInLeft' => __('Fade In Left', 'uicore-elements'),
79 + 'fadeInRight' => __('Fade In Right', 'uicore-elements'),
80 + 'fadeIn' => __('Fade In', 'uicore-elements'),
81 + 'zoomIn' => __('Zoom In', 'uicore-elements'),
67 82 ],
68 83 'condition' => array(
69 84 'animate_items' => 'ui-e-grid-animate',
70 85 ),
@@ -73,14 +88,14 @@
73 88 );
74 89 $this->add_control(
75 90 'animate_item_speed',
76 91 [
77 - 'label' => __( 'Speed', 'uicore-elements' ),
92 + 'label' => __('Speed', 'uicore-elements'),
78 93 'type' => Controls_Manager::SLIDER,
79 94 'condition' => array(
80 95 'animate_items' => 'ui-e-grid-animate',
81 96 ),
82 - 'default'=> [
97 + 'default' => [
83 98 'unit' => 'px',
84 99 'size' => 1500,
85 100 ],
86 101 'range' => [
@@ -96,12 +111,12 @@
96 111 ]
97 112 );
98 113 $this->add_control(
99 114 'animate_item_delay',
100 - [
101 - 'label' => __( 'Animation Delay', 'uicore-elements' ),
115 + [
116 + 'label' => __('Animation Delay', 'uicore-elements'),
102 117 'type' => Controls_Manager::SLIDER,
103 - 'default'=> [
118 + 'default' => [
104 119 'unit' => 'px',
105 120 'size' => 200,
106 121 ],
107 122 'range' => [
@@ -120,15 +135,15 @@
120 135 ]
121 136 );
122 137 $this->add_control(
123 138 'animate_item_stagger',
124 - [
125 - 'label' => __( 'Stagger', 'uicore-elements' ),
139 + [
140 + 'label' => __('Stagger', 'uicore-elements'),
126 141 'type' => Controls_Manager::SLIDER,
127 142 'condition' => array(
128 143 'animate_items' => 'ui-e-grid-animate',
129 144 ),
130 - 'default'=> [
145 + 'default' => [
131 146 'unit' => 'px',
132 147 'size' => 16,
133 148 ],
134 149 'range' => [
@@ -143,16 +158,16 @@
143 158 ],
144 159 ]
145 160 );
146 161 $this->add_control(
147 - 'hr',
148 - [
149 - 'type' => \Elementor\Controls_Manager::DIVIDER,
162 + 'hr',
163 + [
164 + 'type' => \Elementor\Controls_Manager::DIVIDER,
150 165 'condition' => array(
151 166 'animate_items' => 'ui-e-grid-animate',
152 167 ),
153 - ]
154 - );
168 + ]
169 + );
155 170 }
156 171
157 172 /**
158 173 * Retrieves the animations list available for the widget.
@@ -180,9 +195,9 @@
180 195 $list = [];
181 196 $animation_list = wp_parse_args($this->animation, $animation_list);
182 197
183 198 // Add new animations if requested
184 - if( $use_new ){
199 + if ($use_new) {
185 200 $animation_list = array_merge($animation_list, $new_animations);
186 201 }
187 202
188 203 // Filter the list of animations
@@ -192,9 +207,9 @@
192 207
193 208 // Format the list of animations, with translated strings, to be used as elementor option's array
194 209 foreach ($animation_list as $key => $value) {
195 210 $slug = $key !== '' ? "ui-e-item-anim-$key" : '';
196 - $list[$slug] = esc_html__($value, 'uicore-elements');
211 + $list[$slug] = esc_html(sprintf('%s', $value), 'uicore-elements');
197 212 }
198 213
199 214 return $list;
200 215 }
@@ -224,5 +239,5 @@
224 239 'options' => $animations
225 240 ]
226 241 );
227 242 }
228 -}
243 +}