PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.18
UiCore Elements – Free widgets and templates for Elementor v1.3.18
1.3.18 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 All 42 releases
← All changes | includes/widgets/highlighted-text.php +619 -570 1.0.0 → 1.3.18 View file →
@@ -1,570 +1,619 @@
1 -<?php
2 -namespace UiCoreElements;
3 -
4 -use Elementor\Controls_Manager;
5 -use Elementor\Repeater;
6 -use Elementor\Group_Control_Typography;
7 -use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
8 -use UiCoreElements\UiCoreWidget;
9 -
10 -defined('ABSPATH') || exit();
11 -
12 -/**
13 - * Highlighted Text
14 - *
15 - * @author Andrei Voica <[email protected]>
16 - * @since 1.0.3
17 - */
18 -class HighlightedText extends UiCoreWidget
19 -{
20 - public function __construct($data = [], $args = null)
21 - {
22 - parent::__construct($data, $args);
23 - }
24 -
25 - public function get_name()
26 - {
27 - return 'highlighted-text';
28 - }
29 - public function get_categories()
30 - {
31 - return ['uicore'];
32 - }
33 -
34 - public function get_title()
35 - {
36 - return __('Highlighted Text', 'uicore-elements');
37 - }
38 -
39 - public function get_icon()
40 - {
41 - return 'eicon-animated-headline ui-e-widget';
42 - }
43 -
44 - public function get_keywords()
45 - {
46 - return [ 'headline', 'heading', 'animation', 'title', 'text' ];
47 - }
48 -
49 - public function get_styles() {
50 - return [
51 - 'highlighted-text'
52 - ];
53 - }
54 -
55 - public function get_scripts()
56 - {
57 - return [
58 - 'highlighted-text' => [
59 - 'condition' => [
60 - 'shape_animation' => 'animate',
61 - ],
62 - // 'deps' => [
63 - // 'uicore-frontend',
64 - // ],
65 - ]
66 - ];
67 - }
68 -
69 - protected function register_controls()
70 - {
71 - $this->start_controls_section(
72 - 'text_elements',
73 - [
74 - 'label' => __( 'Text', 'uicore-elements' ),
75 - ]
76 - );
77 - $repeater = new Repeater();
78 -
79 - $repeater->add_control(
80 - 'type',
81 - [
82 - 'label' => esc_html__( 'Type', 'uicore-elements' ),
83 - 'type' => \Elementor\Controls_Manager::SELECT,
84 - 'default' => 'text',
85 - 'options' => [
86 - 'text' => esc_html__( 'Text', 'uicore-elements' ),
87 - 'icon' => esc_html__( 'Icon', 'uicore-elements' ),
88 - 'image' => esc_html__( 'Image', 'uicore-elements' ),
89 - ],
90 - 'selectors' => [
91 - '{{WRAPPER}} .uicore-repeater-selector' => 'border-style: {{VALUE}};',
92 - ],
93 - 'render_type' => 'template',
94 - ]
95 - );
96 -
97 - $repeater->add_control(
98 - 'text',
99 - [
100 - 'label' => __( 'Text', 'uicore-elements' ),
101 - 'type' => Controls_Manager::TEXT,
102 - 'label_block' => true,
103 - 'placeholder' => __( 'Some Text', 'uicore-elements' ),
104 - 'default' => __( 'Some Text', 'uicore-elements' ),
105 - 'condition' => [ 'type' => 'text' ],
106 - ]
107 - );
108 -
109 - $repeater->add_control(
110 - 'headline_style',
111 - [
112 - 'label' => __( 'Highlight Style', 'uicore-elements' ),
113 - 'type' => Controls_Manager::SELECT,
114 - 'default' => 'none',
115 - 'options' => [
116 - 'none' => __( 'None', 'uicore-elements' ),
117 - 'color' => __( 'No Stroke', 'uicore-elements' ),
118 - 'stroke1' => __( 'Stroke 1', 'uicore-elements' ),
119 - 'stroke2' => __( 'Stroke 2', 'uicore-elements' ),
120 - 'stroke3' => __( 'Stroke 3', 'uicore-elements' ),
121 - 'stroke4' => __( 'Stroke 4', 'uicore-elements' ),
122 - 'stroke5' => __( 'Stroke 5', 'uicore-elements' ),
123 - 'stroke6' => __( 'Stroke 6', 'uicore-elements' ),
124 - 'stroke7' => __( 'Stroke 7', 'uicore-elements' ),
125 - 'stroke8' => __( 'Stroke 8', 'uicore-elements' ),
126 - 'stroke9' => __( 'Stroke 9', 'uicore-elements' ),
127 - ],
128 - 'render_type' => 'template',
129 - 'condition' => [ 'type' => 'text' ],
130 - ]
131 - );
132 -
133 - $repeater->add_control(
134 - 'icon',
135 - [
136 - 'label' => esc_html__( 'Icon', 'uicore-elements' ),
137 - 'type' => \Elementor\Controls_Manager::ICONS,
138 - 'default' => [
139 - 'value' => 'fas fa-circle',
140 - 'library' => 'fa-solid',
141 - ],
142 - 'recommended' => [
143 - 'fa-solid' => [
144 - 'circle',
145 - 'dot-circle',
146 - 'square-full',
147 - ],
148 - 'fa-regular' => [
149 - 'circle',
150 - 'dot-circle',
151 - 'square-full',
152 - ],
153 - ],
154 - 'condition' => [ 'type' => 'icon' ],
155 - ]
156 - );
157 -
158 - $repeater->add_control(
159 - 'icon_color',
160 - [
161 - 'label' => esc_html__( 'Color', 'uicore-elements' ),
162 - 'type' => \Elementor\Controls_Manager::COLOR,
163 - 'selectors' => [
164 - '{{WRAPPER}} {{CURRENT_ITEM}}' => 'color: {{VALUE}} !important', //falback for icon as a font
165 - '{{WRAPPER}} {{CURRENT_ITEM}}' => 'fill: {{VALUE}} !important', // icon as a inline svg
166 -
167 - ],
168 - 'condition' => [ 'type' => 'icon' ],
169 - ]
170 - );
171 -
172 - $repeater->add_control(
173 - 'image',
174 - [
175 - 'label' => esc_html__( 'Choose Image', 'uicore-elements' ),
176 - 'type' => \Elementor\Controls_Manager::MEDIA,
177 - 'default' => [
178 - 'url' => \Elementor\Utils::get_placeholder_image_src(),
179 - ],
180 - 'condition' => [ 'type' => 'image' ],
181 - ]
182 - );
183 -
184 - $repeater->add_control(
185 - 'size',
186 - [
187 - 'label' => __('Size', 'uicore-elements'),
188 - 'type' => \Elementor\Controls_Manager::SLIDER,
189 - 'default' => [
190 - 'size' => 100,
191 - 'unit' => '%',
192 - ],
193 - 'range' => [
194 - 'px' => [
195 - 'min' => 0,
196 - 'max' => 100,
197 - ],
198 - ],
199 - 'selectors' => [
200 - '{{WRAPPER}} {{CURRENT_ITEM}}' => '--ui-e-asset-size: calc({{SIZE}} / 100);',
201 - ],
202 - 'condition' => [ 'type' => ['icon', 'image'] ],
203 - ]
204 - );
205 -
206 - $this->add_control(
207 - 'content',
208 - [
209 - 'label' => __( 'Content', 'uicore-elements' ),
210 - 'type' => Controls_Manager::REPEATER,
211 - 'fields' => $repeater->get_controls(),
212 - 'default' => [
213 - [
214 - 'text' => __( 'This is my awesome', 'uicore-elements' ),
215 - 'headline_style' => 'none',
216 - ],
217 - [
218 - 'text' => __( 'highlight', 'uicore-elements' ),
219 - 'headline_style' => 'stroke1',
220 - ],
221 - [
222 - 'text' => __( 'text.', 'uicore-elements' ),
223 - 'headline_style' => 'none',
224 - ],
225 - ],
226 - 'title_field' => '{{{ type == "text" ? text : type }}}',
227 - 'render_type' => 'template',
228 - ]
229 - );
230 -
231 - $this->add_responsive_control(
232 - 'alignment',
233 - [
234 - 'label' => __( 'Alignment', 'uicore-elements' ),
235 - 'type' => Controls_Manager::CHOOSE,
236 - 'options' => [
237 - 'left' => [
238 - 'title' => __( 'Left', 'uicore-elements' ),
239 - 'icon' => 'eicon-text-align-left',
240 - ],
241 - 'center' => [
242 - 'title' => __( 'Center', 'uicore-elements' ),
243 - 'icon' => 'eicon-text-align-center',
244 - ],
245 - 'right' => [
246 - 'title' => __( 'Right', 'uicore-elements' ),
247 - 'icon' => 'eicon-text-align-right',
248 - ],
249 - ],
250 - 'default' => 'center',
251 - 'selectors' => [
252 - '{{WRAPPER}}' => 'text-align: {{VALUE}}',
253 - ],
254 - ]
255 - );
256 -
257 - $this->add_control(
258 - 'tag',
259 - [
260 - 'label' => __( 'HTML Tag', 'uicore-elements' ),
261 - 'type' => Controls_Manager::SELECT,
262 - 'options' => [
263 - 'h1' => 'H1',
264 - 'h2' => 'H2',
265 - 'h3' => 'H3',
266 - 'h4' => 'H4',
267 - 'h5' => 'H5',
268 - 'h6' => 'H6',
269 - 'div' => 'div',
270 - 'span' => 'span',
271 - 'p' => 'p',
272 - ],
273 - 'default' => 'h2',
274 - ]
275 - );
276 -
277 - $this->end_controls_section();
278 -
279 - $this->start_controls_section(
280 - 'section_style_marker',
281 - [
282 - 'label' => __( 'Shape', 'uicore-elements' ),
283 - 'tab' => Controls_Manager::TAB_STYLE,
284 - ]
285 - );
286 -
287 - $this->add_control(
288 - 'marker_color',
289 - [
290 - 'label' => __( 'Color', 'uicore-elements' ),
291 - 'type' => Controls_Manager::COLOR,
292 - 'global' => [
293 - 'default' => Global_Colors::COLOR_PRIMARY,
294 - ],
295 - 'selectors' => [
296 - '{{WRAPPER}} .ui-e-headline-text path' => 'stroke: {{VALUE}}',
297 - ],
298 - ]
299 - );
300 -
301 - $this->add_control(
302 - 'stroke_width',
303 - [
304 - 'label' => __( 'Width', 'uicore-elements' ),
305 - 'type' => Controls_Manager::SLIDER,
306 - 'range' => [
307 - 'px' => [
308 - 'min' => 1,
309 - 'max' => 100,
310 - ],
311 - ],
312 - 'default' => [
313 - 'size' => '40',
314 - 'unit' => 'px'
315 - ],
316 - 'selectors' => [
317 - '{{WRAPPER}} .ui-e-headline-text path' => 'stroke-width: {{SIZE}}',
318 - ],
319 - ]
320 - );
321 -
322 - $this->add_control(
323 - 'vertical_offset',
324 - [
325 - 'label' => __( 'Vertical Offset', 'uicore-elements' ),
326 - 'type' => Controls_Manager::SLIDER,
327 - 'range' => [
328 - '%' => [
329 - 'min' => -100,
330 - 'max' => 100,
331 - ],
332 - 'px' => [
333 - 'min' => -100,
334 - 'max' => 100,
335 - ],
336 - ],
337 - 'default' => [
338 - 'size' => '0',
339 - 'unit' => '%',
340 - ],
341 - 'size_units'=>['%', 'px'],
342 - 'selectors' => [
343 - '{{WRAPPER}} .ui-e-headline-text svg' => 'bottom: {{SIZE}}{{UNIT}}',
344 - ],
345 - ]
346 - );
347 - $this->add_control(
348 - 'shape_animation',
349 - [
350 - 'label' => __( 'Animation', 'uicore-elements' ),
351 - 'type' => Controls_Manager::SWITCHER,
352 - 'label_on' => __( 'On', 'uicore-elements' ),
353 - 'label_off' => __( 'Off', 'uicore-elements' ),
354 - 'default' => 'animate',
355 - 'separator' => 'before',
356 - 'return_value' =>'animate',
357 - 'prefix_class' => 'ui-e-a-',
358 - ]
359 - );
360 -
361 - $this->add_control(
362 - 'shape_animation_delay',
363 - [
364 - 'label' => __( 'Animation Delay', 'uicore-elements' ) . ' (ms)',
365 - 'type' => Controls_Manager::NUMBER,
366 - 'default' => '',
367 - 'min' => 0,
368 - 'step' => 100,
369 - 'condition' => [
370 - 'shape_animation' => 'animate',
371 - ],
372 - 'render_type' => 'template'
373 - ]
374 - );
375 -
376 -
377 - $this->end_controls_section();
378 -
379 - $this->start_controls_section(
380 - 'section_style_text',
381 - [
382 - 'label' => __( 'Headline', 'uicore-elements' ),
383 - 'tab' => Controls_Manager::TAB_STYLE,
384 - ]
385 - );
386 -
387 - $this->add_control(
388 - 'title_color',
389 - [
390 - 'label' => __( 'Text Color', 'uicore-elements' ),
391 - 'type' => Controls_Manager::COLOR,
392 - 'selectors' => [
393 - '{{WRAPPER}} .ui-e-highlight-icon, {{WRAPPER}} .ui-e-headline-text' => 'color: {{VALUE}}',
394 - ],
395 - ]
396 - );
397 -
398 -
399 - $this->add_group_control(
400 - Group_Control_Typography::get_type(),
401 - [
402 - 'name' => 'title_typography',
403 - 'selector' => '{{WRAPPER}} .ui-e-highlight-icon, {{WRAPPER}} .ui-e-headline-text, {{WRAPPER}} .ui-e-highlight-image',
404 - ]
405 - );
406 -
407 - $this->add_control(
408 - 'higlighted_title_color',
409 - [
410 - 'label' => __( 'Highlighted Text Color', 'uicore-elements' ),
411 - 'type' => Controls_Manager::COLOR,
412 - 'selectors' => [
413 - '{{WRAPPER}} .ui-e-headline-highlighted' => 'color: {{VALUE}}',
414 - ],
415 - ]
416 - );
417 - $this->add_group_control(
418 - Group_Control_Typography::get_type(),
419 - [
420 - 'name' => 'higlighted_title_typography',
421 - 'selector' => '{{WRAPPER}} .ui-e-headline-highlighted',
422 - ]
423 - );
424 -
425 -
426 - $this->end_controls_section();
427 -
428 -
429 - }
430 -
431 -
432 - protected function get_svg($return,$type='')
433 - {
434 - $paths = [
435 - 'none'=> null,
436 - 'color'=> null,
437 - 'stroke1'=>"<path d='M15.2,133.3L15.2,133.3c121.9-7.6,244-9.9,366.1-6.8c34.6,0.9,69.1,2.3,103.7,4'/>",
438 -
439 - 'stroke2'=>"<path d='M479,122c-13.3-1-26.8-1-40.4-2.3c-31.8-1.2-63.7,0.4-95.3,0.6c-38.5,1.5-77,2.3-115.5,5.2
440 - c-41.6,1.2-83.3,5-124.9,5.2c-5.4,0.4-11,1-16.4,0.8c-21.9-0.4-44.1,1.9-65.6-3.5'/>",
441 -
442 - 'stroke3'=>"<path d='M15,133.4c19-12.7,48.1-11.4,69.2-8.2
443 - c6.3,1.1,12.9,2.1,19.2,3.4c16.5,3.2,33.5,6.3,50.6,5.5c12.7-0.6,24.9-3.4,36.7-6.1c11-2.5,22.4-5.1,34.2-5.9
444 - c24.3-1.9,48.5,3.4,71.9,8.4c27.6,6.1,53.8,11.8,80.4,6.8c9.9-1.9,19.2-5.3,28.3-8.4c8.2-3,16.9-5.9,25.9-8
445 - c20.3-4.4,45.8-1.1,53.6,12.2'/>",
446 -
447 - 'stroke4'=>"<path d='M18,122.6c42.3-4.6,87.4-5.1,130.3-1.6'/>
448 - <path d='M166.7,121.3c29.6,1.6,60,3.3,90.1,1.8c12.4-0.5,24.8-1.6,36.9-2.7c7.3-0.7,14.8-1.3,22.3-1.8
449 - c55.5-4.2,112.6-1.8,166,1.1'/>
450 - <path d='M57.8,133c30.8-0.7,62,1.1,92.1,2.7c30.5,1.8,62,3.6,93.2,2.7c20.4-0.5,41.1-2.4,61.1-4
451 - c37.6-3.1,76.5-6.4,113.7-2'/>",
452 -
453 - 'stroke5'=>"<path d='M53.4,135.8c-12.8-1.5-25.6-1.3-38.3,0.7'/>
454 - <path d='M111.2,136c-12.2-0.2-24.4-0.5-36.7-0.8'/>
455 - <path d='M163.3,135.2c-12.2,0.2-24.4,0.5-36.6,0.8'/>
456 - <path d='M217.8,134.7c-12.5,0.6-24.9,1.2-37.4,1.8'/>
457 - <path d='M274.7,135.5c-12.8,0.1-25.5,0.1-38.3,0.2'/>
458 - <path d='M327.6,135.1c-13.6-0.8-27.2-0.3-40.7,1.4'/>
459 - <path d='M378.8,134.7c-12.2,0.6-24.4,1.2-36.6,1.8'/>
460 - <path d='M432.5,136.4c-12.2-0.6-24.4-1.1-36.6-1.7'/>
461 - <path d='M487.9,136.1c-11.6-1.3-23.3-1.4-35-0.2'/>",
462 -
463 - 'stroke6'=>"<path d='M14.4,111.6c0,0,202.9-33.7,471.2,0c0,0-194-8.9-397.3,24.7c0,0,141.9-5.9,309.2,0'/>",
464 -
465 - 'stroke7'=>"<path d='M15.2 133.3H485'/>",
466 - 'stroke8'=>'<path d="M1.65186 148.981C1.65186 148.981 73.8781 98.5943 206.859 93.0135C339.841 87.4327 489.874 134.065 489.874 134.065"/>',
467 - 'stroke9'=>'<path d="M7 74.5C7 74.5 104 127 252 117C400 107 494.5 49 494.5 49C494.5 49 473.5 59 461.5 74.5C449.5 90 449.5 107 449.5 107"/>
468 - <path d="M20.5 101.5C20.5 101.5 93 133.5 180.5 142.5C268 151.5 347 127.5 347 127.5"/>'
469 - ];
470 -
471 - if($return === 'list'){
472 - foreach($paths as $name => $path){
473 - if($name === 'none'){
474 - $svg[$name] = "";
475 - }else{
476 - $svg[$name] = '<span class="uicore-svg-wrapper"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 150" preserveAspectRatio="none">'.$path.'</svg></span>';
477 - }
478 - }
479 - }else{
480 - if($type === 'none'){
481 - $svg = "";
482 - }else{
483 - $svg = '<span class="uicore-svg-wrapper"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 150" preserveAspectRatio="none">'.$paths[$type].'</svg></span>';
484 - }
485 - }
486 -
487 - return $svg;
488 - }
489 -
490 - protected function render()
491 - {
492 - $settings = $this->get_settings_for_display();
493 - $tag = $settings['tag'];
494 - $content = $settings['content'];
495 - $delay = $settings['shape_animation_delay'];
496 - ?>
497 - <<?php esc_html($tag); echo $delay ? ' data-delay="'.esc_attr($delay).'"' : ''; ?> class="ui-e--highlighted-text" >
498 - <?php
499 -
500 -
501 - foreach($content as $item){
502 - $svg_markup = null;
503 - switch ($item['type']) {
504 - case 'text':
505 - if($item['headline_style'] === 'none'){
506 - echo '<span class="ui-e-headline-text">' . esc_html($item['text']) . '</span>';
507 - }else{
508 - $svg_markup = $this->get_svg('single',$item['headline_style']);
509 - echo '<span class="ui-e-headline-text ui-e-headline-'.esc_attr($item['headline_style']).'">
510 - <span class="whitespace"> </span><span><span class="ui-e-headline-text ui-e-headline-highlighted">'.esc_html($item['text']) .'</span>' . esc_html($svg_markup) .'</span><span class="whitespace"> </span></span>';
511 - }
512 - break;
513 - case 'icon':
514 - echo "<span class='ui-e-highlight-icon elementor-repeater-item-" . esc_attr($item['_id']) . "'>";
515 - \Elementor\Icons_Manager::render_icon($item['icon'], ['aria-hidden' => 'true', 'class'=>'char']);
516 - echo "</span>";
517 - break;
518 - case 'image':
519 - echo '<span class="ui-e-highlight-image elementor-repeater-item-' . esc_attr($item['_id']) . '">'.wp_get_attachment_image($item['image']['id'], "medium", false, ["loading" => false, "class"=>'char']).'</span>';
520 - break;
521 - default:
522 - break;
523 - }
524 -
525 - }
526 - ?>
527 - </<?php esc_html($tag); ?>>
528 - <?php
529 -
530 - }
531 - protected function content_template() {
532 - ?>
533 - <#
534 - var svgs = <?php echo wp_json_encode($this->get_svg('list')); ?>;
535 - #>
536 - <{{{ settings.tag }}} class="ui-e--highlighted-text">
537 - <#
538 - settings.content.forEach( function (item){
539 - switch (item.type) {
540 - case 'text':
541 - if(item.headline_style === 'none'){
542 - #><span class="ui-e-headline-text">{{{ item.text }}}</span><#
543 - }else{
544 - #><span class="ui-e-headline-text {{{ 'ui-e-headline-' + item.headline_style }}}"><span class="whitespace"> </span><span><span class="ui-e-headline-highlighted">{{{ item.text }}}</span>{{{svgs[item.headline_style]}}}</span><span class="whitespace"> </span></span><#
545 - }
546 - break;
547 - case 'icon':
548 - #><span class="char ui-e-highlight-icon elementor-repeater-item-{{{ item._id }}}">{{{ elementor.helpers.renderIcon( view, item.icon, { 'aria-hidden': true }, 'i' , 'value' ) }}}</span><#
549 - break;
550 - case 'image':
551 - var image = {
552 - id: item.image.id,
553 - url: item.image.url,
554 - size: item.thumbnail_size,
555 - dimension: item.thumbnail_custom_dimension,
556 - model: view.getEditModel()
557 - };
558 - var image_url = elementor.imagesManager.getImageUrl( image );
559 - #><span class="ui-e-highlight-image elementor-repeater-item-{{{ item._id }}}"><img class="char" src="{{{ image_url }}}" /></span><#
560 - break;
561 - default:
562 - break;
563 - }
564 - });
565 - #>
566 - </{{{ settings.tag }}}>
567 - <?php
568 - }
569 -}
570 -\Elementor\Plugin::instance()->widgets_manager->register(new HighlightedText());
1 +<?php
2 +
3 +namespace UiCoreElements;
4 +
5 +use Elementor\Controls_Manager;
6 +use Elementor\Repeater;
7 +use Elementor\Group_Control_Typography;
8 +use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
9 +use UiCoreElements\UiCoreWidget;
10 +
11 +defined('ABSPATH') || exit();
12 +
13 +/**
14 + * Highlighted Text
15 + *
16 + * @author Andrei Voica <[email protected]>
17 + * @since 1.0.3
18 + */
19 +class HighlightedText extends UiCoreWidget
20 +{
21 + public function __construct($data = [], $args = null)
22 + {
23 + parent::__construct($data, $args);
24 + }
25 +
26 + public function get_name()
27 + {
28 + return 'highlighted-text';
29 + }
30 + public function get_categories()
31 + {
32 + return ['uicore'];
33 + }
34 +
35 + public function get_title()
36 + {
37 + return __('Highlighted Text', 'uicore-elements');
38 + }
39 +
40 + public function get_icon()
41 + {
42 + return 'eicon-animated-headline ui-e-widget';
43 + }
44 +
45 + public function get_keywords()
46 + {
47 + return ['headline', 'heading', 'animation', 'title', 'text'];
48 + }
49 +
50 + public function get_styles()
51 + {
52 + return [
53 + 'highlighted-text'
54 + ];
55 + }
56 +
57 + public function get_scripts()
58 + {
59 + return [
60 + 'highlighted-text' => [
61 + 'condition' => [
62 + 'shape_animation' => 'animate',
63 + ],
64 + ]
65 + ];
66 + }
67 + public function has_widget_inner_wrapper(): bool
68 + {
69 + // TODO: remove after Optmized Markup experiment is merged to the core
70 + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
71 + }
72 +
73 + protected function register_controls()
74 + {
75 + $this->start_controls_section(
76 + 'text_elements',
77 + [
78 + 'label' => __('Text', 'uicore-elements'),
79 + ]
80 + );
81 + $repeater = new Repeater();
82 +
83 + $repeater->add_control(
84 + 'type',
85 + [
86 + 'label' => esc_html__('Type', 'uicore-elements'),
87 + 'type' => \Elementor\Controls_Manager::SELECT,
88 + 'default' => 'text',
89 + 'options' => [
90 + 'text' => esc_html__('Text', 'uicore-elements'),
91 + 'icon' => esc_html__('Icon', 'uicore-elements'),
92 + 'image' => esc_html__('Image', 'uicore-elements'),
93 + ],
94 + 'selectors' => [
95 + '{{WRAPPER}} .uicore-repeater-selector' => 'border-style: {{VALUE}};',
96 + ],
97 + 'render_type' => 'template',
98 + ]
99 + );
100 +
101 + $repeater->add_control(
102 + 'text',
103 + [
104 + 'label' => __('Text', 'uicore-elements'),
105 + 'type' => Controls_Manager::TEXT,
106 + 'label_block' => true,
107 + 'placeholder' => __('Some Text', 'uicore-elements'),
108 + 'default' => __('Some Text', 'uicore-elements'),
109 + 'condition' => ['type' => 'text'],
110 + 'dynamic' => ['active' => true],
111 + ]
112 + );
113 +
114 + $repeater->add_control(
115 + 'headline_style',
116 + [
117 + 'label' => __('Highlight Style', 'uicore-elements'),
118 + 'type' => Controls_Manager::SELECT,
119 + 'default' => 'none',
120 + 'options' => [
121 + 'none' => __('None', 'uicore-elements'),
122 + 'color' => __('No Stroke', 'uicore-elements'),
123 + 'stroke1' => __('Stroke 1', 'uicore-elements'),
124 + 'stroke2' => __('Stroke 2', 'uicore-elements'),
125 + 'stroke3' => __('Stroke 3', 'uicore-elements'),
126 + 'stroke4' => __('Stroke 4', 'uicore-elements'),
127 + 'stroke5' => __('Stroke 5', 'uicore-elements'),
128 + 'stroke6' => __('Stroke 6', 'uicore-elements'),
129 + 'stroke7' => __('Stroke 7', 'uicore-elements'),
130 + 'stroke8' => __('Stroke 8', 'uicore-elements'),
131 + 'stroke9' => __('Stroke 9', 'uicore-elements'),
132 + ],
133 + 'render_type' => 'template',
134 + 'condition' => ['type' => 'text'],
135 + ]
136 + );
137 +
138 + $repeater->add_control(
139 + 'icon',
140 + [
141 + 'label' => esc_html__('Icon', 'uicore-elements'),
142 + 'type' => \Elementor\Controls_Manager::ICONS,
143 + 'default' => [
144 + 'value' => 'fas fa-circle',
145 + 'library' => 'fa-solid',
146 + ],
147 + 'recommended' => [
148 + 'fa-solid' => [
149 + 'circle',
150 + 'dot-circle',
151 + 'square-full',
152 + ],
153 + 'fa-regular' => [
154 + 'circle',
155 + 'dot-circle',
156 + 'square-full',
157 + ],
158 + ],
159 + 'condition' => ['type' => 'icon'],
160 + ]
161 + );
162 +
163 + $repeater->add_control(
164 + 'icon_color',
165 + [
166 + 'label' => esc_html__('Color', 'uicore-elements'),
167 + 'type' => \Elementor\Controls_Manager::COLOR,
168 + 'selectors' => [
169 + '{{WRAPPER}} {{CURRENT_ITEM}}.ui-e-highlight-icon, {{WRAPPER}} {{CURRENT_ITEM}}' => 'color: {{VALUE}}; fill: {{VALUE}}', //icon as a font + svg
170 +
171 + ],
172 + 'condition' => ['type' => ['icon', 'text']],
173 + ]
174 + );
175 + $repeater->add_group_control(
176 + \Elementor\Group_Control_Background::get_type(),
177 + [
178 + 'name' => 'background_color',
179 + 'condition' => ['type' => ['icon', 'text']],
180 + 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}}.ui-e-highlight-icon, {{WRAPPER}} {{CURRENT_ITEM}} .ui-e-headline-text',
181 + ]
182 + );
183 + $repeater->add_control(
184 + 'background_color_as_text',
185 + [
186 + 'label' => esc_html__('Use Background Color as Text Color', 'uicore-elements'),
187 + 'type' => \Elementor\Controls_Manager::SWITCHER,
188 + 'default' => false,
189 + 'render_type' => 'template',
190 + 'condition' => ['type' => ['icon', 'text']],
191 + 'selectors' => [
192 + '{{WRAPPER}} {{CURRENT_ITEM}}.ui-e-highlight-icon, {{WRAPPER}} {{CURRENT_ITEM}} .ui-e-headline-text' => 'background-color: transparent;-webkit-background-clip: text;background-clip: text;-webkit-text-fill-color: transparent;',
193 + ],
194 + ]
195 + );
196 + $repeater->add_control(
197 + 'stroke_color',
198 + [
199 + 'label' => esc_html__('Stroke Color', 'uicore-elements'),
200 + 'type' => \Elementor\Controls_Manager::COLOR,
201 + 'selectors' => [
202 + '{{WRAPPER}} {{CURRENT_ITEM}} svg path' => 'stroke: {{VALUE}}',
203 +
204 + ],
205 + 'condition' => ['headline_style!' => ['none', 'color']],
206 + ]
207 + );
208 +
209 + $repeater->add_control(
210 + 'image',
211 + [
212 + 'label' => esc_html__('Choose Image', 'uicore-elements'),
213 + 'type' => \Elementor\Controls_Manager::MEDIA,
214 + 'default' => [
215 + 'url' => \Elementor\Utils::get_placeholder_image_src(),
216 + ],
217 + 'condition' => ['type' => 'image'],
218 + ]
219 + );
220 +
221 + $repeater->add_control(
222 + 'size',
223 + [
224 + 'label' => __('Size', 'uicore-elements'),
225 + 'type' => \Elementor\Controls_Manager::SLIDER,
226 + 'default' => [
227 + 'size' => 100,
228 + 'unit' => '%',
229 + ],
230 + 'range' => [
231 + '%' => [
232 + 'min' => 0,
233 + 'max' => 150,
234 + ],
235 + ],
236 + 'selectors' => [
237 + '{{WRAPPER}} {{CURRENT_ITEM}}' => '--ui-e-asset-size: calc({{SIZE}} / 100);',
238 + ],
239 + 'condition' => ['type' => ['icon', 'image']],
240 + ]
241 + );
242 +
243 + $this->add_control(
244 + 'content',
245 + [
246 + 'label' => __('Content', 'uicore-elements'),
247 + 'type' => Controls_Manager::REPEATER,
248 + 'fields' => $repeater->get_controls(),
249 + 'default' => [
250 + [
251 + 'text' => __('This is my awesome ', 'uicore-elements'),
252 + 'headline_style' => 'none',
253 + ],
254 + [
255 + 'text' => __('highlight', 'uicore-elements'),
256 + 'headline_style' => 'stroke1',
257 + ],
258 + [
259 + 'text' => __(' text.', 'uicore-elements'),
260 + 'headline_style' => 'none',
261 + ],
262 + ],
263 + 'title_field' => '{{{ type == "text" ? text : type }}}',
264 + 'render_type' => 'template',
265 + ]
266 + );
267 +
268 + $this->add_responsive_control(
269 + 'alignment',
270 + [
271 + 'label' => __('Alignment', 'uicore-elements'),
272 + 'type' => Controls_Manager::CHOOSE,
273 + 'options' => [
274 + 'left' => [
275 + 'title' => __('Left', 'uicore-elements'),
276 + 'icon' => 'eicon-text-align-left',
277 + ],
278 + 'center' => [
279 + 'title' => __('Center', 'uicore-elements'),
280 + 'icon' => 'eicon-text-align-center',
281 + ],
282 + 'right' => [
283 + 'title' => __('Right', 'uicore-elements'),
284 + 'icon' => 'eicon-text-align-right',
285 + ],
286 + ],
287 + 'default' => 'center',
288 + 'selectors' => [
289 + '{{WRAPPER}}' => 'text-align: {{VALUE}}',
290 + ],
291 + ]
292 + );
293 +
294 + $this->add_control(
295 + 'tag',
296 + [
297 + 'label' => __('HTML Tag', 'uicore-elements'),
298 + 'type' => Controls_Manager::SELECT,
299 + 'options' => [
300 + 'h1' => 'H1',
301 + 'h2' => 'H2',
302 + 'h3' => 'H3',
303 + 'h4' => 'H4',
304 + 'h5' => 'H5',
305 + 'h6' => 'H6',
306 + 'div' => 'div',
307 + 'span' => 'span',
308 + 'p' => 'p',
309 + ],
310 + 'default' => 'h2',
311 + ]
312 + );
313 +
314 + $this->end_controls_section();
315 +
316 + $this->start_controls_section(
317 + 'section_style_marker',
318 + [
319 + 'label' => __('Shape', 'uicore-elements'),
320 + 'tab' => Controls_Manager::TAB_STYLE,
321 + ]
322 + );
323 +
324 + $this->add_control(
325 + 'marker_color',
326 + [
327 + 'label' => __('Color', 'uicore-elements'),
328 + 'type' => Controls_Manager::COLOR,
329 + 'default' => 'var(--e-global-color-uicore_primary)',
330 + 'selectors' => [
331 + '{{WRAPPER}} .ui-e-headline-text path' => 'stroke: {{VALUE}}',
332 + ],
333 + ]
334 + );
335 +
336 + $this->add_control(
337 + 'stroke_width',
338 + [
339 + 'label' => __('Width', 'uicore-elements'),
340 + 'type' => Controls_Manager::SLIDER,
341 + 'range' => [
342 + 'px' => [
343 + 'min' => 1,
344 + 'max' => 100,
345 + ],
346 + ],
347 + 'default' => [
348 + 'size' => '40',
349 + 'unit' => 'px'
350 + ],
351 + 'selectors' => [
352 + '{{WRAPPER}} .ui-e-headline-text path' => 'stroke-width: {{SIZE}}',
353 + ],
354 + ]
355 + );
356 +
357 + $this->add_control(
358 + 'vertical_offset',
359 + [
360 + 'label' => __('Vertical Offset', 'uicore-elements'),
361 + 'type' => Controls_Manager::SLIDER,
362 + 'range' => [
363 + '%' => [
364 + 'min' => -100,
365 + 'max' => 100,
366 + ],
367 + 'px' => [
368 + 'min' => -100,
369 + 'max' => 100,
370 + ],
371 + ],
372 + 'default' => [
373 + 'size' => '0',
374 + 'unit' => '%',
375 + ],
376 + 'size_units' => ['%', 'px'],
377 + 'selectors' => [
378 + '{{WRAPPER}} .ui-e-headline-text svg' => 'bottom: {{SIZE}}{{UNIT}}',
379 + ],
380 + ]
381 + );
382 + $this->add_control(
383 + 'shape_animation',
384 + [
385 + 'label' => __('Animation', 'uicore-elements'),
386 + 'type' => Controls_Manager::SWITCHER,
387 + 'label_on' => __('On', 'uicore-elements'),
388 + 'label_off' => __('Off', 'uicore-elements'),
389 + 'default' => 'animate',
390 + 'separator' => 'before',
391 + 'return_value' => 'animate',
392 + 'prefix_class' => 'ui-e-a-',
393 + ]
394 + );
395 +
396 + $this->add_control(
397 + 'shape_animation_delay',
398 + [
399 + 'label' => __('Animation Delay', 'uicore-elements') . ' (ms)',
400 + 'type' => Controls_Manager::NUMBER,
401 + 'default' => '',
402 + 'min' => 0,
403 + 'step' => 100,
404 + 'condition' => [
405 + 'shape_animation' => 'animate',
406 + ],
407 + 'render_type' => 'template'
408 + ]
409 + );
410 +
411 +
412 + $this->end_controls_section();
413 +
414 + $this->start_controls_section(
415 + 'section_style_text',
416 + [
417 + 'label' => __('Headline', 'uicore-elements'),
418 + 'tab' => Controls_Manager::TAB_STYLE,
419 + ]
420 + );
421 +
422 + $this->add_control(
423 + 'title_color',
424 + [
425 + 'label' => __('Text Color', 'uicore-elements'),
426 + 'type' => Controls_Manager::COLOR,
427 + 'selectors' => [
428 + '{{WRAPPER}} .ui-e-highlight-icon, {{WRAPPER}} .ui-e-headline-text' => 'color: {{VALUE}}',
429 + ],
430 + ]
431 + );
432 +
433 +
434 + $this->add_group_control(
435 + Group_Control_Typography::get_type(),
436 + [
437 + 'name' => 'title_typography',
438 + 'selector' => '{{WRAPPER}} .ui-e-highlight-icon, {{WRAPPER}} .ui-e-headline-text, {{WRAPPER}} .ui-e-highlight-image',
439 + ]
440 + );
441 +
442 + $this->add_control(
443 + 'higlighted_title_color',
444 + [
445 + 'label' => __('Highlighted Text Color', 'uicore-elements'),
446 + 'type' => Controls_Manager::COLOR,
447 + 'selectors' => [
448 + '{{WRAPPER}} .ui-e-headline-highlighted' => 'color: {{VALUE}}',
449 + ],
450 + ]
451 + );
452 + $this->add_group_control(
453 + Group_Control_Typography::get_type(),
454 + [
455 + 'name' => 'higlighted_title_typography',
456 + 'selector' => '{{WRAPPER}} .ui-e-headline-highlighted',
457 + ]
458 + );
459 +
460 +
461 + $this->end_controls_section();
462 + }
463 +
464 +
465 + protected function get_svg($return, $type = '')
466 + {
467 + $paths = [
468 + 'none' => null,
469 + 'color' => null,
470 + 'stroke1' => "<path d='M15.2,133.3L15.2,133.3c121.9-7.6,244-9.9,366.1-6.8c34.6,0.9,69.1,2.3,103.7,4'/>",
471 +
472 + 'stroke2' => "<path d='M479,122c-13.3-1-26.8-1-40.4-2.3c-31.8-1.2-63.7,0.4-95.3,0.6c-38.5,1.5-77,2.3-115.5,5.2
473 + c-41.6,1.2-83.3,5-124.9,5.2c-5.4,0.4-11,1-16.4,0.8c-21.9-0.4-44.1,1.9-65.6-3.5'/>",
474 +
475 + 'stroke3' => "<path d='M15,133.4c19-12.7,48.1-11.4,69.2-8.2
476 + c6.3,1.1,12.9,2.1,19.2,3.4c16.5,3.2,33.5,6.3,50.6,5.5c12.7-0.6,24.9-3.4,36.7-6.1c11-2.5,22.4-5.1,34.2-5.9
477 + c24.3-1.9,48.5,3.4,71.9,8.4c27.6,6.1,53.8,11.8,80.4,6.8c9.9-1.9,19.2-5.3,28.3-8.4c8.2-3,16.9-5.9,25.9-8
478 + c20.3-4.4,45.8-1.1,53.6,12.2'/>",
479 +
480 + 'stroke4' => "<path d='M18,122.6c42.3-4.6,87.4-5.1,130.3-1.6'/>
481 + <path d='M166.7,121.3c29.6,1.6,60,3.3,90.1,1.8c12.4-0.5,24.8-1.6,36.9-2.7c7.3-0.7,14.8-1.3,22.3-1.8
482 + c55.5-4.2,112.6-1.8,166,1.1'/>
483 + <path d='M57.8,133c30.8-0.7,62,1.1,92.1,2.7c30.5,1.8,62,3.6,93.2,2.7c20.4-0.5,41.1-2.4,61.1-4
484 + c37.6-3.1,76.5-6.4,113.7-2'/>",
485 +
486 + 'stroke5' => "<path d='M53.4,135.8c-12.8-1.5-25.6-1.3-38.3,0.7'/>
487 + <path d='M111.2,136c-12.2-0.2-24.4-0.5-36.7-0.8'/>
488 + <path d='M163.3,135.2c-12.2,0.2-24.4,0.5-36.6,0.8'/>
489 + <path d='M217.8,134.7c-12.5,0.6-24.9,1.2-37.4,1.8'/>
490 + <path d='M274.7,135.5c-12.8,0.1-25.5,0.1-38.3,0.2'/>
491 + <path d='M327.6,135.1c-13.6-0.8-27.2-0.3-40.7,1.4'/>
492 + <path d='M378.8,134.7c-12.2,0.6-24.4,1.2-36.6,1.8'/>
493 + <path d='M432.5,136.4c-12.2-0.6-24.4-1.1-36.6-1.7'/>
494 + <path d='M487.9,136.1c-11.6-1.3-23.3-1.4-35-0.2'/>",
495 +
496 + 'stroke6' => "<path d='M14.4,111.6c0,0,202.9-33.7,471.2,0c0,0-194-8.9-397.3,24.7c0,0,141.9-5.9,309.2,0'/>",
497 +
498 + 'stroke7' => "<path d='M15.2 133.3H485'/>",
499 + 'stroke8' => '<path d="M1.65186 148.981C1.65186 148.981 73.8781 98.5943 206.859 93.0135C339.841 87.4327 489.874 134.065 489.874 134.065"/>',
500 + 'stroke9' => '<path d="M7 74.5C7 74.5 104 127 252 117C400 107 494.5 49 494.5 49C494.5 49 473.5 59 461.5 74.5C449.5 90 449.5 107 449.5 107"/>
501 + <path d="M20.5 101.5C20.5 101.5 93 133.5 180.5 142.5C268 151.5 347 127.5 347 127.5"/>'
502 + ];
503 +
504 + if ($return === 'list') {
505 + foreach ($paths as $name => $path) {
506 + if ($name === 'none') {
507 + $svg[$name] = "";
508 + } else {
509 + $svg[$name] = '<span class="uicore-svg-wrapper"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 150" preserveAspectRatio="none">' . $path . '</svg></span>';
510 + }
511 + }
512 + } else {
513 + if ($type === 'none') {
514 + $svg = "";
515 + } else {
516 + $svg = '<span class="uicore-svg-wrapper"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 150" preserveAspectRatio="none">' . $paths[$type] . '</svg></span>';
517 + }
518 + }
519 +
520 + return $svg;
521 + }
522 +
523 + protected function render()
524 + {
525 + $settings = $this->get_settings_for_display();
526 + $tag = $settings['tag'];
527 + $content = $settings['content'];
528 + $delay = $settings['shape_animation_delay'];
529 +?>
530 + <<?php echo Helper::esc_tag($tag);
531 + echo $delay ? ' data-delay="' . esc_attr($delay) . '"' : ''; ?> class="ui-e--highlighted-text">
532 + <?php
533 +
534 +
535 + foreach ($content as $item) {
536 + $svg_markup = null;
537 + switch ($item['type']) {
538 + case 'text':
539 + if ($item['headline_style'] === 'none') {
540 + echo '<span class="ui-e-headline-text elementor-repeater-item-'
541 + . esc_attr($item['_id']) . '">'
542 + . Helper::esc_string($item['text']) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
543 + . '</span>';
544 + } else {
545 + $svg_markup = $this->get_svg('single', $item['headline_style']);
546 + echo '<span class="ui-e-headline-text elementor-repeater-item-'
547 + . esc_attr($item['_id'])
548 + . ' ui-e-headline-' . esc_attr($item['headline_style']) . '">
549 + <span class="whitespace"></span>
550 + <span>
551 + <span class="ui-e-headline-text ui-e-headline-highlighted">'
552 + . Helper::esc_string($item['text']) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
553 + . '</span>'
554 + . Helper::esc_svg($svg_markup) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
555 + . '</span> <span class="whitespace"> </span></span>';
556 + }
557 + break;
558 + case 'icon':
559 + echo "<span class='ui-e-highlight-icon elementor-repeater-item-" . esc_attr($item['_id']) . "'>";
560 + \Elementor\Icons_Manager::render_icon($item['icon'], ['aria-hidden' => 'true', 'class' => 'char']);
561 + echo "</span>";
562 + break;
563 + case 'image':
564 + echo '<span class="ui-e-highlight-image elementor-repeater-item-' . esc_attr($item['_id']) . '">' . wp_get_attachment_image($item['image']['id'], "medium", false, ["loading" => false, "class" => 'char']) . '</span>';
565 + break;
566 + default:
567 + break;
568 + }
569 + }
570 + ?>
571 + </<?php echo Helper::esc_tag($tag); ?>>
572 + <?php
573 +
574 + }
575 + protected function content_template()
576 + {
577 + ?>
578 + <#
579 + var svgs=<?php echo wp_json_encode($this->get_svg('list')); ?>;
580 + #>
581 + <{{{ settings.tag }}} class="ui-e--highlighted-text">
582 + <#
583 + settings.content.forEach( function (item){
584 + switch (item.type) {
585 + case 'text' :
586 + if(item.headline_style==='none' ){
587 + #><span class="ui-e-headline-text elementor-repeater-item-{{{ item._id }}}">{{{ item.text }}}</span>
588 + <#
589 + }else{
590 + #><span class="ui-e-headline-text {{{ 'ui-e-headline-' + item.headline_style }}} elementor-repeater-item-{{{ item._id }}}"><span class="whitespace"> </span><span><span class="ui-e-headline-text ui-e-headline-highlighted">{{{ item.text }}}</span>{{{svgs[item.headline_style]}}}</span><span class="whitespace"> </span></span>
591 + <#
592 + }
593 + break;
594 + case 'icon' :
595 + #><span class="char ui-e-highlight-icon elementor-repeater-item-{{{ item._id }}}">{{{ elementor.helpers.renderIcon( view, item.icon, { 'aria-hidden': true }, 'i' , 'value' ) }}}</span>
596 + <#
597 + break;
598 + case 'image' :
599 + var image={
600 + id: item.image.id,
601 + url: item.image.url,
602 + size: item.thumbnail_size,
603 + dimension: item.thumbnail_custom_dimension,
604 + model: view.getEditModel()
605 + };
606 + var image_url=elementor.imagesManager.getImageUrl( image );
607 + #><span class="ui-e-highlight-image elementor-repeater-item-{{{ item._id }}}"><img class="char" src="{{{ image_url }}}" /></span>
608 + <#
609 + break;
610 + default:
611 + break;
612 + }
613 + });
614 + #>
615 + </{{{ settings.tag }}}>
616 + <?php
617 + }
618 +}
619 +\Elementor\Plugin::instance()->widgets_manager->register(new HighlightedText());