PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.0.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.0.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / addons / basic / ma-gradient-headline / ma-gradient-headline.php

ma-gradient-headline.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.0.9, at addons/basic/ma-gradient-headline/ma-gradient-headline.php

576 lines 18.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Addons;
4
5 use MasterAddons\Inc\Classes\Base\Master_Widget;
6 use \Elementor\Controls_Stack;
7 use \Elementor\Controls_Manager;
8 use \Elementor\Group_Control_Typography;
9 use \Elementor\Core\Kits\Documents\Tabs\Global_Typography;
10 use \Elementor\Group_Control_Text_Shadow;
11
12 use MasterAddons\Inc\Classes\Helper;
13 use MasterAddons\Inc\Admin\Config;
14
15 if (!defined('ABSPATH')) exit; // If this file is called directly, abort.
16
17 class Gradient_Headline extends Master_Widget
18 {
19 use \MasterAddons\Inc\Traits\Widget_Notice;
20 use \MasterAddons\Inc\Traits\Widget_Assets_Trait;
21
22 public function get_name()
23 {
24 return 'ma-gradient-headline';
25 }
26
27 public function get_title()
28 {
29 return esc_html__('Gradient Headline', 'master-addons' );
30 }
31
32 public function get_icon()
33 {
34 return 'jltma-icon ' . Config::get_addon_icon($this->get_name());
35 }
36
37 public function get_keywords()
38 {
39 return ['heading', 'headlines', 'color headline', 'gradient', 'gradient heading', 'gradient headlines'];
40 }
41 protected function register_controls()
42 {
43 /**
44 * Master Addons: Gradient Heading Content Section
45 */
46
47 $this->start_controls_section(
48 'jltma_gradient_heading_content',
49 [
50 'label' => esc_html__('Content', 'master-addons' ),
51 ]
52 );
53
54 $this->add_control(
55 'jltma_gradient_heading_title',
56 [
57 'label' => esc_html__('Heading', 'master-addons' ),
58 'type' => Controls_Manager::TEXTAREA,
59 'label_block' => true,
60 'default' => esc_html__('Master Addons Gradient Headline', 'master-addons' ),
61 ]
62 );
63
64 $this->add_control(
65 'jltma_gradient_heading_link',
66 [
67 'label' => esc_html__('Heading URL', 'master-addons' ),
68 'type' => Controls_Manager::URL,
69 'placeholder' => esc_html__('https://master-addons.com', 'master-addons' ),
70 'label_block' => true,
71 'default' => [
72 'url' => '',
73 'is_external' => true,
74 ]
75 ]
76 );
77
78 $this->add_responsive_control(
79 'jltma_gradient_heading_alignment',
80 [
81 'label' => esc_html__('Alignment', 'master-addons' ),
82 'type' => Controls_Manager::CHOOSE,
83 'label_block' => false,
84 'options' => Helper::jltma_content_alignment(),
85 'default' => 'center',
86 'selectors' => [
87 '{{WRAPPER}} .jltma-gradient-headline' => 'text-align: {{VALUE}};',
88 ],
89 ]
90 );
91
92 $this->add_control(
93 'title_html_tag',
94 [
95 'label' => __('Title HTML Tag', 'master-addons' ),
96 'type' => Controls_Manager::CHOOSE,
97 'options' => Helper::jltma_heading_tags(),
98 'default' => 'h2',
99 'toggle' => false,
100 ]
101 );
102
103 $this->end_controls_section();
104
105 /*
106 * Master Addons: Gradient Style Colors
107 */
108 $this->start_controls_section(
109 'jltma_gradient_heading_styles',
110 [
111 'label' => esc_html__('Gradient Style', 'master-addons' ),
112 'tab' => Controls_Manager::TAB_STYLE
113 ]
114 );
115
116 $this->add_control(
117 'jltma_gradient_heading_color_type',
118 [
119 'label' => _x('Text Color', 'Background Control', 'master-addons' ),
120 'type' => Controls_Manager::CHOOSE,
121 'label_block' => false,
122 'render_type' => 'ui',
123 'default' => 'gradient',
124 'options' => [
125 'classic' => [
126 'title' => _x('Classic', 'Text Color Control', 'master-addons' ),
127 'icon' => 'eicon-paint-brush',
128 ],
129 'gradient' => [
130 'title' => _x('Gradient', 'Text Color Control', 'master-addons' ),
131 'icon' => 'eicon-barcode',
132 ],
133 ],
134 ]
135 );
136
137 $this->start_controls_tabs('jltma_gradient_heading_tabs');
138
139 $this->start_controls_tab(
140 'jltma_gradient_heading_status_normal',
141 [
142 'label' => __('Normal', 'master-addons' )
143 ]
144 );
145
146 $this->add_control(
147 'jltma_gradient_heading_color',
148 [
149 'label' => esc_html__('Color', 'master-addons' ),
150 'type' => Controls_Manager::COLOR,
151 'default' => '#9929ea',
152 'selectors' => [
153 '{{WRAPPER}} .jltma-gradient-headline' => 'color: {{VALUE}};',
154 ],
155 'condition' => [
156 'jltma_gradient_heading_color_type' => ['classic', 'gradient'],
157 ],
158
159 ]
160 );
161
162 $this->add_control(
163 'jltma_gradient_heading_color_stop',
164 [
165 'label' => _x('Location', 'Background Control', 'master-addons' ),
166 'type' => Controls_Manager::SLIDER,
167 'size_units' => ['%'],
168 'default' => [
169 'unit' => '%',
170 'size' => 30,
171 ],
172 'render_type' => 'ui',
173 'condition' => [
174 'jltma_gradient_heading_color_type' => ['gradient'],
175 ],
176 'of_type' => 'gradient',
177 ]
178 );
179 $this->add_control(
180 'jltma_gradient_heading_second_color',
181 [
182 'label' => esc_html__('Second Color', 'Background Control', 'master-addons' ),
183 'type' => Controls_Manager::COLOR,
184 'default' => '#FB083E',
185 'render_type' => 'ui',
186 'condition' => [
187 'jltma_gradient_heading_color_type' => ['gradient'],
188 ],
189 'of_type' => 'gradient',
190
191 ]
192 );
193
194 $this->add_control(
195 'jltma_gradient_heading_b_stop',
196 [
197 'label' => _x('Location', 'Background Control', 'master-addons' ),
198 'type' => Controls_Manager::SLIDER,
199 'size_units' => ['%'],
200 'default' => [
201 'unit' => '%',
202 'size' => 100,
203 ],
204 'render_type' => 'ui',
205 'condition' => [
206 'jltma_gradient_heading_color_type' => ['gradient'],
207 ],
208 'of_type' => 'gradient',
209 ]
210 );
211
212 $this->add_control(
213 'jltma_gradient_heading_type',
214 [
215 'label' => _x('Type', 'Background Control', 'master-addons' ),
216 'type' => Controls_Manager::SELECT,
217 'options' => [
218 'linear' => _x('Linear', 'Background Control', 'master-addons' ),
219 'radial' => _x('Radial', 'Background Control', 'master-addons' ),
220 ],
221 'default' => 'linear',
222 'render_type' => 'ui',
223 'condition' => [
224 'jltma_gradient_heading_color_type' => ['gradient'],
225 ],
226 'of_type' => 'gradient',
227 ]
228 );
229
230 $this->add_control(
231 'jltma_gradient_heading_angle',
232 [
233 'label' => _x('Angle', 'Background Control', 'master-addons' ),
234 'type' => Controls_Manager::SLIDER,
235 'size_units' => ['deg'],
236 'default' => [
237 'unit' => 'deg',
238 'size' => 180,
239 ],
240 'range' => [
241 'deg' => [
242 'step' => 10,
243 ],
244 ],
245 'selectors' => [
246 '{{WRAPPER}} .jltma-gradient-headline' => '-webkit-background-clip: text; -webkit-text-fill-color: transparent; background-color: transparent; background-image: linear-gradient({{SIZE}}{{UNIT}}, {{jltma_gradient_heading_color.VALUE}} {{jltma_gradient_heading_color_stop.SIZE}}{{jltma_gradient_heading_color_stop.UNIT}}, {{jltma_gradient_heading_second_color.VALUE}} {{jltma_gradient_heading_b_stop.SIZE}}{{jltma_gradient_heading_b_stop.UNIT}})',
247 ],
248 'condition' => [
249 'jltma_gradient_heading_color_type' => ['gradient'],
250 'jltma_gradient_heading_type' => 'linear',
251 ],
252 'of_type' => 'gradient',
253 ]
254 );
255
256 $this->add_control(
257 'jltma_gradient_heading_position',
258 [
259 'label' => _x('Position', 'Background Control', 'master-addons' ),
260 'type' => Controls_Manager::SELECT,
261 'options' => [
262 'center center' => _x('Center Center', 'Background Control', 'master-addons' ),
263 'center left' => _x('Center Left', 'Background Control', 'master-addons' ),
264 'center right' => _x('Center Right', 'Background Control', 'master-addons' ),
265 'top center' => _x('Top Center', 'Background Control', 'master-addons' ),
266 'top left' => _x('Top Left', 'Background Control', 'master-addons' ),
267 'top right' => _x('Top Right', 'Background Control', 'master-addons' ),
268 'bottom center' => _x('Bottom Center', 'Background Control', 'master-addons' ),
269 'bottom left' => _x('Bottom Left', 'Background Control', 'master-addons' ),
270 'bottom right' => _x('Bottom Right', 'Background Control', 'master-addons' ),
271 ],
272 'default' => 'center center',
273 'selectors' => [
274 '{{WRAPPER}} .jltma-gradient-headline' => '-webkit-background-clip: text; -webkit-text-fill-color: transparent; background-color: transparent; background-image: radial-gradient(at {{VALUE}}, {{jltma_gradient_heading_color.VALUE}} {{jltma_gradient_heading_color_stop.SIZE}}{{jltma_gradient_heading_color_stop.UNIT}}, {{jltma_gradient_heading_second_color.VALUE}} {{jltma_gradient_heading_b_stop.SIZE}}{{jltma_gradient_heading_b_stop.UNIT}})',
275 ],
276 'condition' => [
277 'jltma_gradient_heading_color_type' => ['gradient'],
278 'jltma_gradient_heading_type' => 'radial',
279 ],
280 'of_type' => 'gradient',
281 ]
282 );
283
284 $this->add_group_control(
285 Group_Control_Typography::get_type(),
286 [
287 'name' => 'jltma_gradient_heading_title_typo',
288 'selector' => '{{WRAPPER}} .jltma-gradient-headline',
289 'global' => [
290 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
291 ],
292 ]
293 );
294
295 $this->add_control(
296 'jltma_gradient_heading_title_blend_mode',
297 [
298 'label' => __('Blend Mode', 'master-addons' ),
299 'type' => Controls_Manager::SELECT,
300 'options' => [
301 '' => __('Normal', 'master-addons' ),
302 'multiply' => __('Multiply', 'master-addons' ),
303 'screen' => __('Screen', 'master-addons' ),
304 'overlay' => __('Overlay', 'master-addons' ),
305 'darken' => __('Darken', 'master-addons' ),
306 'lighten' => __('Lighten', 'master-addons' ),
307 'color-dodge' => __('Color Dodge', 'master-addons' ),
308 'saturation' => __('Saturation', 'master-addons' ),
309 'color' => __('Color', 'master-addons' ),
310 'difference' => __('Difference', 'master-addons' ),
311 'exclusion' => __('Exclusion', 'master-addons' ),
312 'hue' => __('Hue', 'master-addons' ),
313 'luminosity' => __('Luminosity', 'master-addons' )
314 ],
315 'selectors' => [
316 '{{WRAPPER}} .jltma-gradient-headline' => 'mix-blend-mode: {{VALUE}};',
317 ],
318 'separator' => 'none',
319 'condition' => [
320 'jltma_gradient_heading_color_type' => ['gradient'],
321 ]
322 ]
323 );
324
325 $this->add_group_control(
326 Group_Control_Text_Shadow::get_type(),
327 array(
328 'name' => 'jltma_gradient_heading_text_shadow',
329 'label' => __('Text Shadow', 'master-addons' ),
330 'selector' => '{{WRAPPER}} .jltma-gradient-headline',
331 )
332 );
333
334 $this->end_controls_tab();
335
336 $this->start_controls_tab(
337 'jltma_gradient_heading_status_hover',
338 [
339 'label' => __('Hover', 'master-addons' )
340 ]
341 );
342
343 $this->add_control(
344 'jltma_gradient_heading_hover_color',
345 [
346 'label' => esc_html__('Color', 'master-addons' ),
347 'type' => Controls_Manager::COLOR,
348 'default' => '#1fb5ac',
349 'selectors' => [
350 '{{WRAPPER}} .jltma-gradient-headline:hover' => 'color: {{VALUE}};',
351 ],
352 'condition' => [
353 'jltma_gradient_heading_color_type' => ['classic', 'gradient'],
354 ],
355
356 ]
357 );
358
359 $this->add_control(
360 'jltma_gradient_heading_hover_color_stop',
361 [
362 'label' => _x('Location', 'Background Control', 'master-addons' ),
363 'type' => Controls_Manager::SLIDER,
364 'size_units' => ['%'],
365 'default' => [
366 'unit' => '%',
367 'size' => 0,
368 ],
369 'render_type' => 'ui',
370 'condition' => [
371 'jltma_gradient_heading_color_type' => ['gradient'],
372 ],
373 'of_type' => 'gradient',
374 ]
375 );
376
377 $this->add_control(
378 'jltma_gradient_heading_hover_second_color',
379 [
380 'label' => esc_html__('Second Color', 'Background Control', 'master-addons' ),
381 'type' => Controls_Manager::COLOR,
382 'default' => '#1fb5ac',
383 'render_type' => 'ui',
384 'condition' => [
385 'jltma_gradient_heading_color_type' => ['gradient'],
386 ],
387 'of_type' => 'gradient',
388
389 ]
390 );
391
392 $this->add_control(
393 'jltma_gradient_heading_hover_b_stop',
394 [
395 'label' => _x('Location', 'Background Control', 'master-addons' ),
396 'type' => Controls_Manager::SLIDER,
397 'size_units' => ['%'],
398 'default' => [
399 'unit' => '%',
400 'size' => 100,
401 ],
402 'render_type' => 'ui',
403 'condition' => [
404 'jltma_gradient_heading_color_type' => ['gradient'],
405 ],
406 'of_type' => 'gradient',
407 ]
408 );
409
410 $this->add_control(
411 'jltma_gradient_heading_hover_type',
412 [
413 'label' => _x('Type', 'Background Control', 'master-addons' ),
414 'type' => Controls_Manager::SELECT,
415 'options' => [
416 'linear' => _x('Linear', 'Background Control', 'master-addons' ),
417 'radial' => _x('Radial', 'Background Control', 'master-addons' ),
418 ],
419 'default' => 'linear',
420 'render_type' => 'ui',
421 'condition' => [
422 'jltma_gradient_heading_color_type' => ['gradient'],
423 ],
424 'of_type' => 'gradient',
425 ]
426 );
427
428 $this->add_control(
429 'jltma_gradient_heading_hover_angle',
430 [
431 'label' => _x('Angle', 'Background Control', 'master-addons' ),
432 'type' => Controls_Manager::SLIDER,
433 'size_units' => ['deg'],
434 'default' => [
435 'unit' => 'deg',
436 'size' => 180,
437 ],
438 'range' => [
439 'deg' => [
440 'step' => 10,
441 ],
442 ],
443 'selectors' => [
444 '{{WRAPPER}} .jltma-gradient-headline:hover' => '-webkit-background-clip: text; -webkit-text-fill-color: transparent; background-color: transparent; background-image: linear-gradient({{SIZE}}{{UNIT}}, {{jltma_gradient_heading_color.VALUE}} {{jltma_gradient_heading_color_stop.SIZE}}{{jltma_gradient_heading_color_stop.UNIT}}, {{jltma_gradient_heading_second_color.VALUE}} {{jltma_gradient_heading_b_stop.SIZE}}{{jltma_gradient_heading_b_stop.UNIT}})',
445 ],
446 'condition' => [
447 'jltma_gradient_heading_color_type' => ['gradient'],
448 'jltma_gradient_heading_type' => 'linear',
449 ],
450 'of_type' => 'gradient',
451 ]
452 );
453
454 $this->add_control(
455 'jltma_gradient_heading_hover_position',
456 [
457 'label' => _x('Position', 'Background Control', 'master-addons' ),
458 'type' => Controls_Manager::SELECT,
459 'options' => [
460 'center center' => _x('Center Center', 'Background Control', 'master-addons' ),
461 'center left' => _x('Center Left', 'Background Control', 'master-addons' ),
462 'center right' => _x('Center Right', 'Background Control', 'master-addons' ),
463 'top center' => _x('Top Center', 'Background Control', 'master-addons' ),
464 'top left' => _x('Top Left', 'Background Control', 'master-addons' ),
465 'top right' => _x('Top Right', 'Background Control', 'master-addons' ),
466 'bottom center' => _x('Bottom Center', 'Background Control', 'master-addons' ),
467 'bottom left' => _x('Bottom Left', 'Background Control', 'master-addons' ),
468 'bottom right' => _x('Bottom Right', 'Background Control', 'master-addons' ),
469 ],
470 'default' => 'center center',
471 'selectors' => [
472 '{{WRAPPER}} .jltma-gradient-headline:hover' => '-webkit-background-clip: text; -webkit-text-fill-color: transparent; background-color: transparent; background-image: radial-gradient(at {{VALUE}}, {{jltma_gradient_heading_color.VALUE}} {{jltma_gradient_heading_color_stop.SIZE}}{{jltma_gradient_heading_color_stop.UNIT}}, {{jltma_gradient_heading_second_color.VALUE}} {{jltma_gradient_heading_b_stop.SIZE}}{{jltma_gradient_heading_b_stop.UNIT}})',
473 ],
474 'condition' => [
475 'jltma_gradient_heading_color_type' => ['gradient'],
476 'jltma_gradient_heading_type' => 'radial',
477 ],
478 'of_type' => 'gradient',
479 ]
480 );
481
482 $this->add_group_control(
483 Group_Control_Typography::get_type(),
484 [
485 'name' => 'jltma_gradient_heading_hover_title_typo',
486 'selector' => '{{WRAPPER}} .jltma-gradient-headline:hover',
487 'global' => [
488 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
489 ],
490 ]
491 );
492
493 $this->add_control(
494 'jltma_gradient_heading_hover_title_blend_mode',
495 [
496 'label' => __('Blend Mode', 'master-addons' ),
497 'type' => Controls_Manager::SELECT,
498 'options' => [
499 '' => __('Normal', 'master-addons' ),
500 'multiply' => __('Multiply', 'master-addons' ),
501 'screen' => __('Screen', 'master-addons' ),
502 'overlay' => __('Overlay', 'master-addons' ),
503 'darken' => __('Darken', 'master-addons' ),
504 'lighten' => __('Lighten', 'master-addons' ),
505 'color-dodge' => __('Color Dodge', 'master-addons' ),
506 'saturation' => __('Saturation', 'master-addons' ),
507 'color' => __('Color', 'master-addons' ),
508 'difference' => __('Difference', 'master-addons' ),
509 'exclusion' => __('Exclusion', 'master-addons' ),
510 'hue' => __('Hue', 'master-addons' ),
511 'luminosity' => __('Luminosity', 'master-addons' )
512 ],
513 'selectors' => [
514 '{{WRAPPER}} .jltma-gradient-headline:hover' => 'mix-blend-mode: {{VALUE}};',
515 ],
516 'separator' => 'none',
517 'condition' => [
518 'jltma_gradient_heading_color_type' => ['gradient'],
519 ]
520 ]
521 );
522
523 $this->add_group_control(
524 Group_Control_Text_Shadow::get_type(),
525 array(
526 'name' => 'jltma_gradient_heading_text_hover_shadow',
527 'label' => __('Text Shadow', 'master-addons' ),
528 'selector' => '{{WRAPPER}} .jltma-gradient-headline:hover',
529 )
530 );
531
532 $this->end_controls_tab();
533 $this->end_controls_tabs();
534
535 $this->end_controls_section();
536 }
537
538 protected function render()
539 {
540 $settings = $this->get_settings_for_display();
541
542 // Whitelist allowed HTML tags to prevent XSS
543 $allowed_tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'span', 'p'];
544 $title_tag = in_array($settings['title_html_tag'], $allowed_tags, true)
545 ? $settings['title_html_tag']
546 : 'h2';
547
548 $this->add_inline_editing_attributes('jltma_gradient_heading_title', 'basic');
549 $this->add_render_attribute('jltma_gradient_heading_title', 'class', 'jltma-gradient-headline');
550
551 $title = $settings['jltma_gradient_heading_title'];
552
553 if (!empty($settings['jltma_gradient_heading_link']['url'])) {
554 $this->add_link_attributes('link', $settings['jltma_gradient_heading_link']);
555
556 $title = sprintf('<a %1$s>%2$s</a>', $this->get_render_attribute_string('link'), $this->parse_text_editor($title));
557 }
558
559 printf(
560 '<%1$s %2$s>%3$s</%1$s>',
561 esc_html($title_tag),
562 $this->get_render_attribute_string('jltma_gradient_heading_title'),
563 $title
564 );
565 }
566
567 protected function content_template()
568 {
569 ?>
570 <# view.addInlineEditingAttributes( 'jltma_gradient_heading_title' , 'basic' ); view.addRenderAttribute( 'jltma_gradient_heading_title' , 'class' , 'jltma-gradient-headline' ); var title=_.isEmpty(settings.jltma_gradient_heading_link.url) ? settings.jltma_gradient_heading_title : '<a href="' +settings.jltma_gradient_heading_link.url+'">'+settings.jltma_gradient_heading_title+'</a>';
571 #>
572 <{{ settings.title_html_tag }} {{{ view.getRenderAttributeString( 'jltma_gradient_heading_title' ) }}}>{{{ title }}}</{{ settings.title_html_tag }}>
573 <?php
574 }
575 }
576