PluginProbe
Borderless – Addons and Templates for Elementor / 1.2.6
Borderless – Addons and Templates for Elementor v1.2.6
trunk 1.0.0 1.0.1 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.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 78 releases
borderless / modules / elementor / widgets / fancy-text.php

fancy-text.php in Borderless – Addons and Templates for Elementor 1.2.6, at modules/elementor/widgets/fancy-text.php

468 lines 13.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Borderless\Widgets;
4
5 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
6
7 use Elementor\Widget_Base;
8 use Elementor\Controls_Manager;
9 use Elementor\Group_Control_Image_Size;
10 use \Elementor\Group_Control_Typography;
11 use \Elementor\Core\Schemes\Typography;
12 use \Elementor\Repeater;
13 use Elementor\Utils;
14
15 class Fancy_Text extends Widget_Base {
16
17 public function __construct($data = [], $args = null) {
18 parent::__construct($data, $args);
19
20 wp_register_style( 'elementor-widget-fancy-text', BORDERLESS__STYLES . 'elementor-widget-fancy-text.css', false, BORDERLESS__VERSION);
21
22 wp_register_script( 'typewriterjs', BORDERLESS__SCRIPTS . 'typewriterjs.js', [ 'elementor-frontend' ], BORDERLESS__VERSION, true );
23
24 }
25
26 public function get_name() {
27 return 'fancy-text';
28 }
29
30 public function get_title() {
31 return esc_html__('Fancy Text', 'borderless');
32 }
33
34 public function get_icon() {
35 return 'fa fa-envelope-o';
36 }
37
38 public function get_categories() {
39 return [ 'borderless' ];
40 }
41
42 public function get_style_depends() {
43 return [ 'elementor-widget-fancy-text' ];
44 }
45
46 public function get_script_depends() {
47 return [ 'typewriterjs' ];
48 }
49
50 protected function _register_controls() {
51
52 /*-----------------------------------------------------------------------------------*/
53 /* *. Fancy Text - Content
54 /*-----------------------------------------------------------------------------------*/
55
56 $this->start_controls_section(
57 'borderless_section_fancy_text',
58 [
59 'label' => esc_html__( 'Fancy Text', 'borderless' ),
60 'tab' => Controls_Manager::TAB_CONTENT,
61 ]
62 );
63
64 $this->add_control(
65 'borderless_elementor_fancy_text_prefix',
66 [
67 'label' => __( 'Prefix', 'borderless' ),
68 'type' => \Elementor\Controls_Manager::TEXT,
69 'placeholder' => __( 'Enter your title', 'borderless' ),
70 'default' => esc_html__( 'This is the ', 'borderless'),
71 'dynamic' => [ 'active' => true ]
72 ]
73 );
74
75 $repeater = new Repeater();
76
77 $repeater->add_control(
78 'borderless_elementor_fancy_text_strings_text_field',
79 [
80 'label' => esc_html__( 'Fancy String', 'borderless'),
81 'type' => Controls_Manager::TEXT,
82 'label_block' => true,
83 'dynamic' => [ 'active' => true ]
84 ]
85 );
86
87 $this->add_control(
88 'borderless_elementor_fancy_text_strings',
89 [
90 'label' => __( 'Fancy Text', 'borderless'),
91 'type' => Controls_Manager::REPEATER,
92 'show_label' => true,
93 'fields' => $repeater->get_controls(),
94 'title_field' => '{{ borderless_elementor_fancy_text_strings_text_field }}',
95 'default' => [
96 [
97 'borderless_elementor_fancy_text_strings_text_field' => __( 'First string', 'borderless'),
98 ],
99 [
100 'borderless_elementor_fancy_text_strings_text_field' => __( 'Second string', 'borderless'),
101 ],
102 [
103 'borderless_elementor_fancy_text_strings_text_field' => __( 'Third string', 'borderless'),
104 ]
105 ],
106 ]
107 );
108
109 $this->add_control(
110 'borderless_elementor_fancy_text_suffix',
111 [
112 'label' => __( 'Suffix', 'borderless' ),
113 'type' => \Elementor\Controls_Manager::TEXT,
114 'placeholder' => __( 'Place your suffix text', 'borderless' ),
115 'default' => esc_html__( ' of the sentence.', 'borderless'),
116 'dynamic' => [ 'active' => true ]
117 ]
118 );
119
120 $this->end_controls_section();
121
122 /*-----------------------------------------------------------------------------------*/
123 /* *. Fancy Text Settings - Content
124 /*-----------------------------------------------------------------------------------*/
125
126 $this->start_controls_section(
127 'borderless_section_fancy_text_settings',
128 [
129 'label' => esc_html__( 'Fancy Text Settings', 'borderless' ),
130 'tab' => Controls_Manager::TAB_CONTENT,
131 ]
132 );
133
134 $this->add_responsive_control(
135 'borderless_elementor_fancy_text_alignment',
136 [
137 'label' => esc_html__( 'Alignment', 'borderless'),
138 'type' => Controls_Manager::CHOOSE,
139 'options' => [
140 'left' => [
141 'title' => esc_html__( 'Left', 'borderless'),
142 'icon' => 'fa fa-align-left',
143 ],
144 'center' => [
145 'title' => esc_html__( 'Center', 'borderless'),
146 'icon' => 'fa fa-align-center',
147 ],
148 'right' => [
149 'title' => esc_html__( 'Right', 'borderless'),
150 'icon' => 'fa fa-align-right',
151 ],
152 ],
153 'default' => 'center',
154 'selectors' => [
155 '{{WRAPPER}} .borderless-elementor-fancy-text-widget' => 'text-align: {{VALUE}}',
156 ],
157 ]
158 );
159
160 /*
161
162 $this->add_control(
163 'borderless_elementor_fancy_text_effect',
164 [
165 'label' => __( 'Direction', 'borderless' ),
166 'type' => \Elementor\Controls_Manager::SELECT,
167 'default' => 'typing',
168 'options' => [
169 'typing' => __( 'Typing', 'borderless' ),
170 'side-up' => __( 'Slide Up', 'borderless' ),
171 'zoom-out' => __( 'Zoom Out', 'borderless' ),
172 'rotate' => __( 'Rotate', 'borderless' ),
173 'auto-fade' => __( 'Auto Fade', 'borderless' ),
174 'custom' => __( 'Custom', 'borderless' ),
175 ],
176 ]
177 );
178
179 */
180
181 $this->add_control(
182 'borderless_elementor_fancy_text_type_speed',
183 [
184 'label' => __( 'Type Speed', 'borderless' ),
185 'type' => \Elementor\Controls_Manager::NUMBER,
186 'min' => 1,
187 'max' => 9999,
188 'step' => 1,
189 'default' => 50,
190 ]
191 );
192
193 $this->add_control(
194 'borderless_elementor_fancy_text_back_speed',
195 [
196 'label' => __( 'Back Speed', 'borderless' ),
197 'type' => \Elementor\Controls_Manager::NUMBER,
198 'min' => 1,
199 'max' => 9999,
200 'step' => 1,
201 'default' => 30,
202 ]
203 );
204
205 $this->add_control(
206 'borderless_elementor_fancy_text_pause_for',
207 [
208 'label' => __( 'Pause For', 'borderless' ),
209 'type' => \Elementor\Controls_Manager::NUMBER,
210 'min' => 1,
211 'max' => 9999,
212 'step' => 1,
213 'default' => 1500,
214 ]
215 );
216
217 $this->add_control(
218 'borderless_elementor_fancy_text_loop',
219 [
220 'label' => __( 'Loop', 'borderless' ),
221 'type' => \Elementor\Controls_Manager::SWITCHER,
222 'default' => 'yes',
223 ]
224 );
225
226 $this->add_control(
227 'borderless_elementor_fancy_text_show_cursor',
228 [
229 'label' => __( 'Show Cursor', 'borderless' ),
230 'type' => \Elementor\Controls_Manager::SWITCHER,
231 'default' => 'yes',
232 /*
233 'condition' => array(
234 'borderless_elementor_fancy_text_effect' => 'typing',
235 ),
236 */
237 ]
238 );
239
240 $this->add_control(
241 'borderless_elementor_fancy_text_cursor_mark',
242 [
243 'label' => __( 'Cursor Mark', 'borderless' ),
244 'type' => \Elementor\Controls_Manager::TEXT,
245 'placeholder' => __( 'Enter Mark', 'borderless' ),
246 'default' => esc_html__( '|', 'borderless'),
247 'dynamic' => [ 'active' => true ],
248 'condition' => array(
249 /* 'borderless_elementor_fancy_text_effect' => 'typing', */
250 'borderless_elementor_fancy_text_show_cursor' => 'yes',
251 ),
252 ]
253 );
254
255 $this->end_controls_section();
256
257 /*-----------------------------------------------------------------------------------*/
258 /* *. Fancy Text Prefix - Style
259 /*-----------------------------------------------------------------------------------*/
260
261 $this->start_controls_section(
262 'borderless_elementor_fancy_text_prefix_styles',
263 [
264 'label' => esc_html__( 'Prefix Text Styles', 'borderless'),
265 'tab' => Controls_Manager::TAB_STYLE
266 ]
267 );
268
269 $this->add_control(
270 'borderless_elementor_fancy_text_prefix_color',
271 [
272 'label' => esc_html__( 'Prefix Text Color', 'borderless'),
273 'type' => Controls_Manager::COLOR,
274 'selectors' => [
275 '{{WRAPPER}} .borderless-elementor-fancy-text-prefix' => 'color: {{VALUE}};',
276 ],
277 ]
278 );
279
280 $this->add_group_control(
281 Group_Control_Typography::get_type(),
282 [
283 'name' => 'borderless_elementor_fancy_text_prefix_typography',
284 'scheme' => Typography::TYPOGRAPHY_1,
285 'fields_options' => [
286 'typography' => ['default' => 'yes'],
287 'font_size' => ['default' => ['size' => 24]],
288 'font_weight' => ['default' => 600],
289 'line_height' => ['default' => ['size' => 1]],
290 ],
291 'selector' => '{{WRAPPER}} .borderless-elementor-fancy-text-prefix',
292 ]
293 );
294
295
296 $this->end_controls_section();
297
298 /*-----------------------------------------------------------------------------------*/
299 /* *. Fancy Text - Style
300 /*-----------------------------------------------------------------------------------*/
301
302 $this->start_controls_section(
303 'borderless_elementor_fancy_text_styles',
304 [
305 'label' => esc_html__( 'Fancy Text Styles', 'Borderless'),
306 'tab' => Controls_Manager::TAB_STYLE
307 ]
308 );
309
310 $this->add_control(
311 'borderless_elementor_fancy_text_color',
312 [
313 'label' => esc_html__( 'Fancy Text Color', 'borderless'),
314 'type' => Controls_Manager::COLOR,
315 'selectors' => [
316 '{{WRAPPER}} .borderless-elementor-fancy-text-strings .Typewriter__wrapper' => 'color: {{VALUE}};',
317 ],
318 ]
319 );
320
321 $this->add_control(
322 'borderless_elementor_fancy_text_cursor_color',
323 [
324 'label' => esc_html__( 'Fancy Text Cursor Color', 'borderless'),
325 'type' => Controls_Manager::COLOR,
326 'selectors' => [
327 '{{WRAPPER}} .borderless-elementor-fancy-text-strings .Typewriter__cursor' => 'color: {{VALUE}};',
328 ],
329 ]
330 );
331
332 $this->add_group_control(
333 Group_Control_Typography::get_type(),
334 [
335 'label' => esc_html__( 'Fancy Text Typography', 'borderless'),
336 'name' => 'borderless_elementor_fancy_text_typography',
337 'scheme' => Typography::TYPOGRAPHY_1,
338 'fields_options' => [
339 'typography' => ['default' => 'yes'],
340 'font_size' => ['default' => ['size' => 24]],
341 'font_weight' => ['default' => 600],
342 'line_height' => ['default' => ['size' => 1]],
343 ],
344 'selector' => '{{WRAPPER}} .borderless-elementor-fancy-text-strings .Typewriter__wrapper',
345 ]
346 );
347
348 $this->add_group_control(
349 Group_Control_Typography::get_type(),
350 [
351 'label' => esc_html__( 'Fancy Text Cursor Typography', 'borderless'),
352 'name' => 'borderless_elementor_fancy_text_cursor_typography',
353 'scheme' => Typography::TYPOGRAPHY_1,
354 'fields_options' => [
355 'typography' => ['default' => 'yes'],
356 'font_size' => ['default' => ['size' => 24]],
357 'font_weight' => ['default' => 600],
358 'line_height' => ['default' => ['size' => 1]],
359 ],
360 'selector' => '{{WRAPPER}} .borderless-elementor-fancy-text-strings .Typewriter__cursor',
361 ]
362 );
363
364
365 $this->end_controls_section();
366
367 /*-----------------------------------------------------------------------------------*/
368 /* *. Fancy Text Suffix - Style
369 /*-----------------------------------------------------------------------------------*/
370
371 $this->start_controls_section(
372 'borderless_elementor_fancy_text_suffix_styles',
373 [
374 'label' => esc_html__( 'Suffix Text Styles', 'Borderless'),
375 'tab' => Controls_Manager::TAB_STYLE
376 ]
377 );
378
379 $this->add_control(
380 'borderless_elementor_fancy_text_suffix_color',
381 [
382 'label' => esc_html__( 'Suffix Text Color', 'borderless'),
383 'type' => Controls_Manager::COLOR,
384 'selectors' => [
385 '{{WRAPPER}} .borderless-elementor-fancy-text-suffix' => 'color: {{VALUE}};',
386 ],
387 ]
388 );
389
390 $this->add_group_control(
391 Group_Control_Typography::get_type(),
392 [
393 'name' => 'borderless_elementor_fancy_text_suffix_typography',
394 'scheme' => Typography::TYPOGRAPHY_1,
395 'fields_options' => [
396 'typography' => ['default' => 'yes'],
397 'font_size' => ['default' => ['size' => 24]],
398 'font_weight' => ['default' => 600],
399 'line_height' => ['default' => ['size' => 1]],
400 ],
401 'selector' => '{{WRAPPER}} .borderless-elementor-fancy-text-suffix',
402 ]
403 );
404
405
406 $this->end_controls_section();
407
408 }
409
410 /*-----------------------------------------------------------------------------------*/
411 /* *. Render
412 /*-----------------------------------------------------------------------------------*/
413
414 protected function render() {
415
416 $settings = $this->get_settings_for_display();
417
418 /* Start Fancy Text Strings Content */
419
420 $strings = array();
421 foreach ( $settings['borderless_elementor_fancy_text_strings'] as $item ) {
422 if ( ! empty( $item['borderless_elementor_fancy_text_strings_text_field'] ) ) {
423 array_push( $strings, str_replace( '\'', '&#39;', $item['borderless_elementor_fancy_text_strings_text_field'] ) );
424 }
425 }
426 $strings = implode("|",$strings);
427
428 /* End Fancy Text Strings Content */
429
430 $this->add_render_attribute( 'fancy-text', 'data-fancy-text-strings', $strings );
431 $this->add_render_attribute( 'fancy-text', 'data-fancy-text-delay', $settings['borderless_elementor_fancy_text_type_speed'] );
432 $this->add_render_attribute( 'fancy-text', 'data-fancy-text-delete-speed', $settings['borderless_elementor_fancy_text_back_speed'] );
433 $this->add_render_attribute( 'fancy-text', 'data-fancy-text-pause-for', $settings['borderless_elementor_fancy_text_pause_for'] );
434 $this->add_render_attribute( 'fancy-text', 'data-fancy-text-cursor', $settings['borderless_elementor_fancy_text_cursor_mark'] );
435 $this->add_render_attribute( 'fancy-text', 'data-fancy-text-loop', $settings['borderless_elementor_fancy_text_loop'] );
436
437 ?>
438
439 <div class="borderless-elementor-fancy-text-widget">
440
441 <div class="borderless-elementor-fancy-text">
442
443 <?php if ( ! empty( $settings['borderless_elementor_fancy_text_prefix'] ) ) { ?>
444 <span class="borderless-elementor-fancy-text-prefix"><?php echo wp_kses( ( $settings['borderless_elementor_fancy_text_prefix'] ), true ); ?></span>
445 <?php } ?>
446
447 <?php if ( ! empty( $strings ) ) { ?>
448 <span class="borderless-elementor-fancy-text-strings" <?php echo $this->get_render_attribute_string( 'fancy-text' ) ?>></span>
449 <?php } ?>
450
451 <?php if ( ! empty( $settings['borderless_elementor_fancy_text_suffix'] ) ) { ?>
452 <span class="borderless-elementor-fancy-text-suffix"><?php echo wp_kses( ( $settings['borderless_elementor_fancy_text_suffix'] ), true ); ?></span>
453 <?php } ?>
454
455 </div>
456
457 </div>
458
459 <?php
460
461 }
462
463 protected function _content_template() {
464
465 }
466
467
468 }