PluginProbe ʕ •ᴥ•ʔ
Essential Addons for Elementor – Popular Elementor Templates & Widgets / 6.6.9
Essential Addons for Elementor – Popular Elementor Templates & Widgets v6.6.9
6.6.9 6.6.8 6.6.7 6.6.6 6.6.5 6.6.4 6.6.3 5.7.3 5.7.4 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.15 5.8.16 5.8.18 5.8.2 5.8.3 5.8.4 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.10 5.9.11 5.9.12 5.9.13 5.9.14 5.9.15 5.9.16 5.9.17 5.9.18 5.9.19 5.9.2 5.9.20 5.9.21 5.9.22 5.9.23 5.9.24 5.9.25 5.9.26 5.9.27 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.14 6.0.15 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.0 6.1.1 6.1.10 6.1.11 trunk 6.1.12 1.0.0 6.1.13 1.0.1 6.1.14 1.1.0 6.1.15 2.0 6.1.17 2.1 6.1.18 2.10.0 6.1.19 2.10.1 6.1.2 2.10.2 6.1.20 2.10.3 6.1.3 2.10.4 6.1.4 2.10.5 6.1.5 2.2.0 6.1.6 2.2.1 6.1.7 2.2.2 6.1.8 2.2.3 6.1.9 2.2.4 6.2.0 2.2.5 6.2.1 2.3.0 6.2.2 2.3.1 6.2.3 2.4.0 6.2.4 2.4.1 6.3.0 2.4.2 6.3.1 2.4.3 6.3.2 2.5.0 6.3.3 2.6.0 6.4.0 2.7.0 6.5.0 2.7.1 6.5.1 2.7.10 6.5.10 2.7.11 6.5.11 2.7.2 6.5.12 2.7.3 6.5.13 2.7.4 6.5.2 2.7.5 6.5.3 2.7.6 6.5.4 2.7.7 6.5.5 2.7.8 6.5.6 2.7.9 6.5.7 2.8.0 6.5.8 2.8.1 6.5.9 2.8.2 6.6.0 2.8.3 6.6.1 2.8.4 6.6.2 2.8.5 2.8.6 2.8.7 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.4.1 3.1.5 3.2.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1 3.7.2 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 5.0.0 5.0.1 5.0.10 5.0.11 5.0.12 5.0.13 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.4.6 5.5.5 5.6.5 5.7.2
essential-addons-for-elementor-lite / includes / Controls / EAEL_Gradient_Text.php
essential-addons-for-elementor-lite / includes / Controls Last commit date
EAEL_Background.php 1 year ago EAEL_Choose.php 8 months ago EAEL_Gradient_Text.php 6 days ago Select2.php 4 months ago index.php 3 years ago
EAEL_Gradient_Text.php
301 lines
1 <?php
2
3 namespace Essential_Addons_Elementor\Controls;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Base;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * EAEL Gradient Text group control.
14 *
15 * A self-contained group control that provides both a classic single-color
16 * picker and a full gradient builder for text, selected via an internal
17 * `color_type` CHOOSE field.
18 *
19 * Classic mode → outputs `color: {{VALUE}}` only.
20 * Gradient mode → outputs `background-image`, `-webkit-background-clip`,
21 * `background-clip: text`, and `color: transparent`.
22 * The first color (`color`) also emits `color: {{VALUE}}`
23 * as the automatic browser fallback (no separate field needed).
24 *
25 * Default behaviour (nothing passed in `fields_options`):
26 * classic mode, single color picker only.
27 *
28 * To default to gradient mode pass via `fields_options`:
29 * 'color_type' => [ 'default' => 'gradient' ]
30 *
31 * Usage:
32 *
33 * // Classic default (single color)
34 * $this->add_group_control(
35 * \Essential_Addons_Elementor\Controls\EAEL_Gradient_Text::get_type(),
36 * [
37 * 'name' => 'my_text',
38 * 'selector' => '{{WRAPPER}} .my-el',
39 * 'fields_options' => [
40 * 'color' => [ 'default' => '#4d4d4d' ],
41 * ],
42 * ]
43 * );
44 *
45 * // Gradient default
46 * $this->add_group_control(
47 * \Essential_Addons_Elementor\Controls\EAEL_Gradient_Text::get_type(),
48 * [
49 * 'name' => 'my_text',
50 * 'selector' => '{{WRAPPER}} .my-el',
51 * 'fields_options' => [
52 * 'color_type' => [ 'default' => 'gradient' ],
53 * 'color' => [ 'default' => '#4d4d4d' ],
54 * 'color_b' => [ 'default' => '#4d4d4d' ],
55 * ],
56 * ]
57 * );
58 *
59 * @since 6.6.0
60 */
61 class EAEL_Gradient_Text extends Group_Control_Base {
62
63 /**
64 * Holds the control fields.
65 *
66 * @since 6.6.0
67 * @access protected
68 * @static
69 *
70 * @var array
71 */
72 protected static $fields;
73
74 /**
75 * Return the unique type key for this group control.
76 *
77 * @since 6.6.0
78 * @access public
79 * @static
80 *
81 * @return string
82 */
83 public static function get_type() {
84 return 'eael-gradient-text';
85 }
86
87 /**
88 * Initialize the control fields.
89 *
90 * @since 6.6.0
91 * @access public
92 *
93 * @return array
94 */
95 public function init_fields() {
96 $fields = [];
97
98 // ── Color type picker ─────────────────────────────────────────────────
99 // Drives classic/gradient visibility. Default is 'classic' so the control
100 // behaves as a plain color picker unless opted into gradient mode.
101 $fields['color_type'] = [
102 'label' => esc_html__( 'Color Type', 'essential-addons-for-elementor-lite' ),
103 'type' => Controls_Manager::CHOOSE,
104 'options' => [
105 'classic' => [
106 'title' => esc_html__( 'Classic', 'essential-addons-for-elementor-lite' ),
107 'icon' => 'eicon-paint-brush',
108 ],
109 'gradient' => [
110 'title' => esc_html__( 'Gradient', 'essential-addons-for-elementor-lite' ),
111 'icon' => 'eicon-barcode',
112 ],
113 ],
114 'default' => 'classic',
115 'render_type' => 'ui',
116 ];
117
118 // ── First / only color ────────────────────────────────────────────────
119 // Shown in both modes.
120 // - Classic: its `color: {{VALUE}}` selector is the sole CSS output.
121 // - Gradient: acts as the first gradient stop AND as the automatic
122 // browser fallback (overridden by `color: transparent` in modern
123 // browsers that support background-clip: text).
124 $fields['color'] = [
125 'label' => esc_html__( 'Color', 'essential-addons-for-elementor-lite' ),
126 'type' => Controls_Manager::COLOR,
127 'default' => '',
128 'selectors' => [
129 '{{SELECTOR}}' => 'color: {{VALUE}};',
130 ],
131 ];
132
133 // ── Gradient-only fields ──────────────────────────────────────────────
134
135 $fields['color_stop'] = [
136 'label' => esc_html__( 'Location', 'essential-addons-for-elementor-lite' ),
137 'type' => Controls_Manager::SLIDER,
138 'size_units' => [ '%', 'custom' ],
139 'default' => [
140 'unit' => '%',
141 'size' => 0,
142 ],
143 'render_type' => 'ui',
144 'condition' => [
145 'color_type' => 'gradient',
146 ],
147 ];
148
149 $fields['color_b'] = [
150 'label' => esc_html__( 'Second Color', 'essential-addons-for-elementor-lite' ),
151 'type' => Controls_Manager::COLOR,
152 'default' => '#f2295b',
153 'render_type' => 'ui',
154 'condition' => [
155 'color_type' => 'gradient',
156 ],
157 ];
158
159 $fields['color_b_stop'] = [
160 'label' => esc_html__( 'Location', 'essential-addons-for-elementor-lite' ),
161 'type' => Controls_Manager::SLIDER,
162 'size_units' => [ '%', 'custom' ],
163 'default' => [
164 'unit' => '%',
165 'size' => 100,
166 ],
167 'render_type' => 'ui',
168 'condition' => [
169 'color_type' => 'gradient',
170 ],
171 ];
172
173 $fields['gradient_type'] = [
174 'label' => esc_html__( 'Type', 'essential-addons-for-elementor-lite' ),
175 'type' => Controls_Manager::SELECT,
176 'options' => [
177 'linear' => esc_html__( 'Linear', 'essential-addons-for-elementor-lite' ),
178 'radial' => esc_html__( 'Radial', 'essential-addons-for-elementor-lite' ),
179 ],
180 'default' => 'linear',
181 'render_type' => 'ui',
182 'condition' => [
183 'color_type' => 'gradient',
184 ],
185 ];
186
187 // Linear gradient — outputs full text-clip CSS.
188 $fields['gradient_angle'] = [
189 'label' => esc_html__( 'Angle', 'essential-addons-for-elementor-lite' ),
190 'type' => Controls_Manager::SLIDER,
191 'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ],
192 'default' => [
193 'unit' => 'deg',
194 'size' => 135,
195 ],
196 'selectors' => [
197 '{{SELECTOR}}' => implode( '; ', [
198 'background-image: linear-gradient({{SIZE}}{{UNIT}}, {{color.VALUE}} {{color_stop.SIZE}}{{color_stop.UNIT}}, {{color_b.VALUE}} {{color_b_stop.SIZE}}{{color_b_stop.UNIT}})',
199 '-webkit-background-clip: text',
200 'background-clip: text',
201 'color: transparent',
202 ] ),
203 ],
204 'condition' => [
205 'color_type' => 'gradient',
206 'gradient_type' => 'linear',
207 ],
208 ];
209
210 // Radial gradient — outputs full text-clip CSS.
211 $fields['gradient_position'] = [
212 'label' => esc_html__( 'Position', 'essential-addons-for-elementor-lite' ),
213 'type' => Controls_Manager::SELECT,
214 'options' => [
215 'center center' => esc_html__( 'Center Center', 'essential-addons-for-elementor-lite' ),
216 'center left' => esc_html__( 'Center Left', 'essential-addons-for-elementor-lite' ),
217 'center right' => esc_html__( 'Center Right', 'essential-addons-for-elementor-lite' ),
218 'top center' => esc_html__( 'Top Center', 'essential-addons-for-elementor-lite' ),
219 'top left' => esc_html__( 'Top Left', 'essential-addons-for-elementor-lite' ),
220 'top right' => esc_html__( 'Top Right', 'essential-addons-for-elementor-lite' ),
221 'bottom center' => esc_html__( 'Bottom Center', 'essential-addons-for-elementor-lite' ),
222 'bottom left' => esc_html__( 'Bottom Left', 'essential-addons-for-elementor-lite' ),
223 'bottom right' => esc_html__( 'Bottom Right', 'essential-addons-for-elementor-lite' ),
224 ],
225 'default' => 'center center',
226 'selectors' => [
227 '{{SELECTOR}}' => implode( '; ', [
228 'background-image: radial-gradient(at {{VALUE}}, {{color.VALUE}} {{color_stop.SIZE}}{{color_stop.UNIT}}, {{color_b.VALUE}} {{color_b_stop.SIZE}}{{color_b_stop.UNIT}})',
229 '-webkit-background-clip: text',
230 'background-clip: text',
231 'color: transparent',
232 ] ),
233 ],
234 'condition' => [
235 'color_type' => 'gradient',
236 'gradient_type' => 'radial',
237 ],
238 ];
239
240 return $fields;
241 }
242
243 /**
244 * Apply defaults from the `default` arg passed to add_group_control().
245 *
246 * - string → classic mode; value becomes color default.
247 * - array → gradient mode; keys 'color' and 'color_b' set respective defaults.
248 * - omitted → no change (controller field defaults apply as-is).
249 *
250 * @since 6.6.0
251 * @access protected
252 *
253 * @param array $fields Prepared fields array.
254 * @return array
255 */
256 protected function prepare_fields( $fields ) {
257 $args = $this->get_args();
258 $default = isset( $args['default'] ) ? $args['default'] : null;
259
260 if ( \is_string( $default ) && '' !== $default ) {
261 // Classic mode — single color default.
262 $fields['color']['default'] = $default;
263 } elseif ( \is_array( $default ) ) {
264 // Gradient mode.
265 $fields['color_type']['default'] = 'gradient';
266
267 if ( isset( $default['color'] ) ) {
268 $fields['color']['default'] = $default['color'];
269 }
270 if ( isset( $default['color_b'] ) ) {
271 $fields['color_b']['default'] = $default['color_b'];
272 }
273 if ( isset( $default['color_stop'] ) ) {
274 $fields['color_stop']['default'] = $default['color_stop'];
275 }
276 if ( isset( $default['color_b_stop'] ) ) {
277 $fields['color_b_stop']['default'] = $default['color_b_stop'];
278 }
279
280 }
281
282 return parent::prepare_fields( $fields );
283 }
284
285 /**
286 * Default options for this group control.
287 *
288 * Renders fields inline in the panel (no popover toggle button).
289 *
290 * @since 6.6.0
291 * @access protected
292 *
293 * @return array
294 */
295 protected function get_default_options() {
296 return [
297 'popover' => false,
298 ];
299 }
300 }
301