| @@ -5,10 +5,10 @@ | ||
| 5 | 5 | use Elementor\Controls_Manager; |
| 6 | 6 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 7 | 7 | use Elementor\Group_Control_Typography; |
| 8 | 8 | use Elementor\Modules\Shapes\Module as Shapes_Module; |
| 9 | +use Elementor\Utils; | |
| 9 | 10 | use Elementor\Group_Control_Text_Stroke; |
| 10 | -use Elementor\Plugin; | |
| 11 | 11 | use Elementor\Widget_Base; |
| 12 | 12 | |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 14 | exit; // Exit if accessed directly. |
| @@ -17,8 +17,9 @@ | ||
| 17 | 17 | /** |
| 18 | 18 | * Elementor WordArt widget. |
| 19 | 19 | * |
| 20 | 20 | * Elementor widget that displays text along SVG path. |
| 21 | + * | |
| 21 | 22 | */ |
| 22 | 23 | class TextPath extends Widget_Base { |
| 23 | 24 | |
| 24 | 25 | const DEFAULT_PATH_FILL = '#E8178A'; |
| @@ -29,17 +30,14 @@ | ||
| 29 | 30 | * Retrieve Text Path widget name. |
| 30 | 31 | * |
| 31 | 32 | * @return string Widget name. |
| 32 | 33 | * @access public |
| 34 | + * | |
| 33 | 35 | */ |
| 34 | 36 | public function get_name() { |
| 35 | 37 | return 'text-path'; |
| 36 | 38 | } |
| 37 | 39 | |
| 38 | - public function get_group_name() { | |
| 39 | - return 'shapes'; | |
| 40 | - } | |
| 41 | - | |
| 42 | 40 | /** |
| 43 | 41 | * Get widget title. |
| 44 | 42 | * |
| 45 | 43 | * Retrieve Text Path widget title. |
| @@ -45,8 +43,9 @@ | ||
| 45 | 43 | * Retrieve Text Path widget title. |
| 46 | 44 | * |
| 47 | 45 | * @return string Widget title. |
| 48 | 46 | * @access public |
| 47 | + * | |
| 49 | 48 | */ |
| 50 | 49 | public function get_title() { |
| 51 | 50 | return esc_html__( 'Text Path', 'elementor' ); |
| 52 | 51 | } |
| @@ -57,8 +56,9 @@ | ||
| 57 | 56 | * Retrieve Text Path widget icon. |
| 58 | 57 | * |
| 59 | 58 | * @return string Widget icon. |
| 60 | 59 | * @access public |
| 60 | + * | |
| 61 | 61 | */ |
| 62 | 62 | public function get_icon() { |
| 63 | 63 | return 'eicon-wordart'; |
| 64 | 64 | } |
| @@ -69,8 +69,9 @@ | ||
| 69 | 69 | * Retrieve the list of keywords the widget belongs to. |
| 70 | 70 | * |
| 71 | 71 | * @return array Widget keywords. |
| 72 | 72 | * @access public |
| 73 | + * | |
| 73 | 74 | */ |
| 74 | 75 | public function get_keywords() { |
| 75 | 76 | return [ 'text path', 'word path', 'text on path', 'wordart', 'word art' ]; |
| 76 | 77 | } |
| @@ -75,26 +76,8 @@ | ||
| 75 | 76 | return [ 'text path', 'word path', 'text on path', 'wordart', 'word art' ]; |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | /** |
| 79 | - * Get style dependencies. | |
| 80 | - * | |
| 81 | - * Retrieve the list of style dependencies the widget requires. | |
| 82 | - * | |
| 83 | - * @since 3.24.0 | |
| 84 | - * @access public | |
| 85 | - * | |
| 86 | - * @return array Widget style dependencies. | |
| 87 | - */ | |
| 88 | - public function get_style_depends(): array { | |
| 89 | - return [ 'widget-text-path' ]; | |
| 90 | - } | |
| 91 | - | |
| 92 | - public function has_widget_inner_wrapper(): bool { | |
| 93 | - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 94 | - } | |
| 95 | - | |
| 96 | - /** | |
| 97 | 80 | * Register content controls under content tab. |
| 98 | 81 | */ |
| 99 | 82 | protected function register_content_tab() { |
| 100 | 83 | $this->start_controls_section( |
| @@ -144,11 +127,12 @@ | ||
| 144 | 127 | 'dynamic' => [ |
| 145 | 128 | 'active' => true, |
| 146 | 129 | ], |
| 147 | 130 | 'description' => sprintf( |
| 148 | - '%1$s <a target="_blank" href="https://go.elementor.com/text-path-create-paths/">%2$s</a>', | |
| 149 | - esc_html__( 'Want to create custom text paths with SVG?', 'elementor' ), | |
| 150 | - esc_html__( 'Learn more', 'elementor' ) | |
| 131 | + /* translators: 1: Link open tag, 2: Link close tag. */ | |
| 132 | + esc_html__( 'Want to create custom text paths with SVG? %1$sLearn More%2$s', 'elementor' ), | |
| 133 | + '<a target="_blank" href="https://go.elementor.com/text-path-create-paths/">', | |
| 134 | + '</a>' | |
| 151 | 135 | ), |
| 152 | 136 | ] |
| 153 | 137 | ); |
| 154 | 138 | |
| @@ -249,9 +233,9 @@ | ||
| 249 | 233 | 'size', |
| 250 | 234 | [ |
| 251 | 235 | 'label' => esc_html__( 'Size', 'elementor' ), |
| 252 | 236 | 'type' => Controls_Manager::SLIDER, |
| 253 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], | |
| 237 | + 'size_units' => [ '%', 'px' ], | |
| 254 | 238 | 'range' => [ |
| 255 | 239 | '%' => [ |
| 256 | 240 | 'min' => 0, |
| 257 | 241 | 'max' => 100, |
| @@ -257,19 +241,23 @@ | ||
| 257 | 241 | 'max' => 100, |
| 258 | 242 | 'step' => 10, |
| 259 | 243 | ], |
| 260 | 244 | 'px' => [ |
| 245 | + 'min' => 0, | |
| 261 | 246 | 'max' => 800, |
| 262 | 247 | 'step' => 50, |
| 263 | 248 | ], |
| 264 | 249 | ], |
| 265 | 250 | 'default' => [ |
| 251 | + 'unit' => 'px', | |
| 266 | 252 | 'size' => 500, |
| 267 | 253 | ], |
| 268 | 254 | 'tablet_default' => [ |
| 255 | + 'unit' => 'px', | |
| 269 | 256 | 'size' => 500, |
| 270 | 257 | ], |
| 271 | 258 | 'mobile_default' => [ |
| 259 | + 'unit' => 'px', | |
| 272 | 260 | 'size' => 500, |
| 273 | 261 | ], |
| 274 | 262 | 'selectors' => [ |
| 275 | 263 | '{{WRAPPER}}' => '--width: {{SIZE}}{{UNIT}};', |
| @@ -281,17 +269,27 @@ | ||
| 281 | 269 | 'rotation', |
| 282 | 270 | [ |
| 283 | 271 | 'label' => esc_html__( 'Rotate', 'elementor' ), |
| 284 | 272 | 'type' => Controls_Manager::SLIDER, |
| 285 | - 'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ], | |
| 273 | + 'size_units' => [ 'deg' ], | |
| 274 | + 'range' => [ | |
| 275 | + 'deg' => [ | |
| 276 | + 'min' => 0, | |
| 277 | + 'max' => 360, | |
| 278 | + 'step' => 1, | |
| 279 | + ], | |
| 280 | + ], | |
| 286 | 281 | 'default' => [ |
| 287 | 282 | 'unit' => 'deg', |
| 283 | + 'size' => '', | |
| 288 | 284 | ], |
| 289 | 285 | 'tablet_default' => [ |
| 290 | 286 | 'unit' => 'deg', |
| 287 | + 'size' => '', | |
| 291 | 288 | ], |
| 292 | 289 | 'mobile_default' => [ |
| 293 | 290 | 'unit' => 'deg', |
| 291 | + 'size' => '', | |
| 294 | 292 | ], |
| 295 | 293 | 'selectors' => [ |
| 296 | 294 | '{{WRAPPER}}' => '--rotate: {{SIZE}}{{UNIT}};', |
| 297 | 295 | ], |
| @@ -345,30 +343,26 @@ | ||
| 345 | 343 | 'word_spacing', |
| 346 | 344 | [ |
| 347 | 345 | 'label' => esc_html__( 'Word Spacing', 'elementor' ), |
| 348 | 346 | 'type' => Controls_Manager::SLIDER, |
| 349 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 347 | + 'size_units' => [ 'px' ], | |
| 350 | 348 | 'range' => [ |
| 351 | 349 | 'px' => [ |
| 352 | 350 | 'min' => -20, |
| 353 | 351 | 'max' => 20, |
| 352 | + 'step' => 1, | |
| 354 | 353 | ], |
| 355 | - 'em' => [ | |
| 356 | - 'min' => -1, | |
| 357 | - 'max' => 1, | |
| 358 | - ], | |
| 359 | - 'rem' => [ | |
| 360 | - 'min' => -1, | |
| 361 | - 'max' => 1, | |
| 362 | - ], | |
| 363 | 354 | ], |
| 364 | 355 | 'default' => [ |
| 356 | + 'unit' => 'px', | |
| 365 | 357 | 'size' => '', |
| 366 | 358 | ], |
| 367 | 359 | 'tablet_default' => [ |
| 360 | + 'unit' => 'px', | |
| 368 | 361 | 'size' => '', |
| 369 | 362 | ], |
| 370 | 363 | 'mobile_default' => [ |
| 364 | + 'unit' => 'px', | |
| 371 | 365 | 'size' => '', |
| 372 | 366 | ], |
| 373 | 367 | 'selectors' => [ |
| 374 | 368 | '{{WRAPPER}}' => '--word-spacing: {{SIZE}}{{UNIT}};', |
| @@ -378,9 +372,9 @@ | ||
| 378 | 372 | |
| 379 | 373 | $this->add_control( |
| 380 | 374 | 'start_point', |
| 381 | 375 | [ |
| 382 | - 'label' => esc_html__( 'Starting Point', 'elementor' ) . ' (%)', | |
| 376 | + 'label' => esc_html__( 'Starting Point', 'elementor' ), | |
| 383 | 377 | 'type' => Controls_Manager::SLIDER, |
| 384 | 378 | 'size_units' => [ '%' ], |
| 385 | 379 | 'range' => [ |
| 386 | 380 | 'px' => [ |
| @@ -458,13 +452,19 @@ | ||
| 458 | 452 | 'hover_transition', |
| 459 | 453 | [ |
| 460 | 454 | 'label' => esc_html__( 'Transition Duration', 'elementor' ), |
| 461 | 455 | 'type' => Controls_Manager::SLIDER, |
| 462 | - 'size_units' => [ 's', 'ms', 'custom' ], | |
| 463 | 456 | 'default' => [ |
| 457 | + 'size' => 0.3, | |
| 464 | 458 | 'unit' => 's', |
| 465 | - 'size' => 0.3, | |
| 466 | 459 | ], |
| 460 | + 'range' => [ | |
| 461 | + 's' => [ | |
| 462 | + 'min' => 0, | |
| 463 | + 'max' => 3, | |
| 464 | + 'step' => 0.1, | |
| 465 | + ], | |
| 466 | + ], | |
| 467 | 467 | 'selectors' => [ |
| 468 | 468 | '{{WRAPPER}}' => '--transition: {{SIZE}}{{UNIT}}', |
| 469 | 469 | ], |
| 470 | 470 | ] |
| @@ -538,23 +538,18 @@ | ||
| 538 | 538 | 'stroke_width_normal', |
| 539 | 539 | [ |
| 540 | 540 | 'label' => esc_html__( 'Width', 'elementor' ), |
| 541 | 541 | 'type' => Controls_Manager::SLIDER, |
| 542 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 543 | 542 | 'default' => [ |
| 544 | 543 | 'size' => 1, |
| 544 | + 'unit' => 'px', | |
| 545 | 545 | ], |
| 546 | 546 | 'range' => [ |
| 547 | 547 | 'px' => [ |
| 548 | - 'min' => 1, | |
| 548 | + 'min' => 0, | |
| 549 | 549 | 'max' => 20, |
| 550 | + 'step' => 1, | |
| 550 | 551 | ], |
| 551 | - 'em' => [ | |
| 552 | - 'max' => 2, | |
| 553 | - ], | |
| 554 | - 'rem' => [ | |
| 555 | - 'max' => 2, | |
| 556 | - ], | |
| 557 | 552 | ], |
| 558 | 553 | 'selectors' => [ |
| 559 | 554 | '{{WRAPPER}}' => '--stroke-width: {{SIZE}}{{UNIT}}', |
| 560 | 555 | ], |
| @@ -609,23 +604,18 @@ | ||
| 609 | 604 | 'stroke_width_hover', |
| 610 | 605 | [ |
| 611 | 606 | 'label' => esc_html__( 'Width', 'elementor' ), |
| 612 | 607 | 'type' => Controls_Manager::SLIDER, |
| 613 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 614 | 608 | 'default' => [ |
| 615 | 609 | 'size' => '', |
| 610 | + 'unit' => 'px', | |
| 616 | 611 | ], |
| 617 | 612 | 'range' => [ |
| 618 | 613 | 'px' => [ |
| 619 | - 'min' => 1, | |
| 614 | + 'min' => 0, | |
| 620 | 615 | 'max' => 20, |
| 616 | + 'step' => 1, | |
| 621 | 617 | ], |
| 622 | - 'em' => [ | |
| 623 | - 'max' => 2, | |
| 624 | - ], | |
| 625 | - 'rem' => [ | |
| 626 | - 'max' => 2, | |
| 627 | - ], | |
| 628 | 618 | ], |
| 629 | 619 | 'selectors' => [ |
| 630 | 620 | '{{WRAPPER}}' => '--stroke-width-hover: {{SIZE}}{{UNIT}}', |
| 631 | 621 | ], |
| @@ -636,13 +626,19 @@ | ||
| 636 | 626 | 'stroke_transition', |
| 637 | 627 | [ |
| 638 | 628 | 'label' => esc_html__( 'Transition Duration', 'elementor' ), |
| 639 | 629 | 'type' => Controls_Manager::SLIDER, |
| 640 | - 'size_units' => [ 's', 'ms', 'custom' ], | |
| 641 | 630 | 'default' => [ |
| 631 | + 'size' => 0.3, | |
| 642 | 632 | 'unit' => 's', |
| 643 | - 'size' => 0.3, | |
| 644 | 633 | ], |
| 634 | + 'range' => [ | |
| 635 | + 's' => [ | |
| 636 | + 'min' => 0, | |
| 637 | + 'max' => 3, | |
| 638 | + 'step' => 0.1, | |
| 639 | + ], | |
| 640 | + ], | |
| 645 | 641 | 'selectors' => [ |
| 646 | 642 | '{{WRAPPER}}' => '--stroke-transition: {{SIZE}}{{UNIT}}', |
| 647 | 643 | ], |
| 648 | 644 | ] |
| @@ -687,11 +683,10 @@ | ||
| 687 | 683 | |
| 688 | 684 | // Add Text Path attributes. |
| 689 | 685 | $this->add_render_attribute( 'text_path', [ |
| 690 | 686 | 'class' => 'e-text-path', |
| 691 | - 'data-text' => htmlentities( esc_attr( $settings['text'] ) ), | |
| 687 | + 'data-text' => esc_attr( $settings['text'] ), | |
| 692 | 688 | 'data-url' => esc_url( $path_url ), |
| 693 | - 'data-link-url' => esc_url( $settings['link']['url'] ?? '' ), | |
| 694 | 689 | ] ); |
| 695 | 690 | |
| 696 | 691 | // Add hover animation. |
| 697 | 692 | if ( ! empty( $settings['hover_animation'] ) ) { |