| @@ -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,9 +269,9 @@ | ||
| 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', 'grad', 'rad', 'turn' ], | |
| 286 | 274 | 'default' => [ |
| 287 | 275 | 'unit' => 'deg', |
| 288 | 276 | ], |
| 289 | 277 | 'tablet_default' => [ |
| @@ -345,30 +333,26 @@ | ||
| 345 | 333 | 'word_spacing', |
| 346 | 334 | [ |
| 347 | 335 | 'label' => esc_html__( 'Word Spacing', 'elementor' ), |
| 348 | 336 | 'type' => Controls_Manager::SLIDER, |
| 349 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 337 | + 'size_units' => [ 'px' ], | |
| 350 | 338 | 'range' => [ |
| 351 | 339 | 'px' => [ |
| 352 | 340 | 'min' => -20, |
| 353 | 341 | 'max' => 20, |
| 342 | + 'step' => 1, | |
| 354 | 343 | ], |
| 355 | - 'em' => [ | |
| 356 | - 'min' => -1, | |
| 357 | - 'max' => 1, | |
| 358 | - ], | |
| 359 | - 'rem' => [ | |
| 360 | - 'min' => -1, | |
| 361 | - 'max' => 1, | |
| 362 | - ], | |
| 363 | 344 | ], |
| 364 | 345 | 'default' => [ |
| 346 | + 'unit' => 'px', | |
| 365 | 347 | 'size' => '', |
| 366 | 348 | ], |
| 367 | 349 | 'tablet_default' => [ |
| 350 | + 'unit' => 'px', | |
| 368 | 351 | 'size' => '', |
| 369 | 352 | ], |
| 370 | 353 | 'mobile_default' => [ |
| 354 | + 'unit' => 'px', | |
| 371 | 355 | 'size' => '', |
| 372 | 356 | ], |
| 373 | 357 | 'selectors' => [ |
| 374 | 358 | '{{WRAPPER}}' => '--word-spacing: {{SIZE}}{{UNIT}};', |
| @@ -378,9 +362,9 @@ | ||
| 378 | 362 | |
| 379 | 363 | $this->add_control( |
| 380 | 364 | 'start_point', |
| 381 | 365 | [ |
| 382 | - 'label' => esc_html__( 'Starting Point', 'elementor' ) . ' (%)', | |
| 366 | + 'label' => esc_html__( 'Starting Point', 'elementor' ), | |
| 383 | 367 | 'type' => Controls_Manager::SLIDER, |
| 384 | 368 | 'size_units' => [ '%' ], |
| 385 | 369 | 'range' => [ |
| 386 | 370 | 'px' => [ |
| @@ -458,9 +442,9 @@ | ||
| 458 | 442 | 'hover_transition', |
| 459 | 443 | [ |
| 460 | 444 | 'label' => esc_html__( 'Transition Duration', 'elementor' ), |
| 461 | 445 | 'type' => Controls_Manager::SLIDER, |
| 462 | - 'size_units' => [ 's', 'ms', 'custom' ], | |
| 446 | + 'size_units' => [ 's', 'ms' ], | |
| 463 | 447 | 'default' => [ |
| 464 | 448 | 'unit' => 's', |
| 465 | 449 | 'size' => 0.3, |
| 466 | 450 | ], |
| @@ -538,23 +522,18 @@ | ||
| 538 | 522 | 'stroke_width_normal', |
| 539 | 523 | [ |
| 540 | 524 | 'label' => esc_html__( 'Width', 'elementor' ), |
| 541 | 525 | 'type' => Controls_Manager::SLIDER, |
| 542 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 543 | 526 | 'default' => [ |
| 544 | 527 | 'size' => 1, |
| 528 | + 'unit' => 'px', | |
| 545 | 529 | ], |
| 546 | 530 | 'range' => [ |
| 547 | 531 | 'px' => [ |
| 548 | - 'min' => 1, | |
| 532 | + 'min' => 0, | |
| 549 | 533 | 'max' => 20, |
| 534 | + 'step' => 1, | |
| 550 | 535 | ], |
| 551 | - 'em' => [ | |
| 552 | - 'max' => 2, | |
| 553 | - ], | |
| 554 | - 'rem' => [ | |
| 555 | - 'max' => 2, | |
| 556 | - ], | |
| 557 | 536 | ], |
| 558 | 537 | 'selectors' => [ |
| 559 | 538 | '{{WRAPPER}}' => '--stroke-width: {{SIZE}}{{UNIT}}', |
| 560 | 539 | ], |
| @@ -609,23 +588,18 @@ | ||
| 609 | 588 | 'stroke_width_hover', |
| 610 | 589 | [ |
| 611 | 590 | 'label' => esc_html__( 'Width', 'elementor' ), |
| 612 | 591 | 'type' => Controls_Manager::SLIDER, |
| 613 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 614 | 592 | 'default' => [ |
| 615 | 593 | 'size' => '', |
| 594 | + 'unit' => 'px', | |
| 616 | 595 | ], |
| 617 | 596 | 'range' => [ |
| 618 | 597 | 'px' => [ |
| 619 | - 'min' => 1, | |
| 598 | + 'min' => 0, | |
| 620 | 599 | 'max' => 20, |
| 600 | + 'step' => 1, | |
| 621 | 601 | ], |
| 622 | - 'em' => [ | |
| 623 | - 'max' => 2, | |
| 624 | - ], | |
| 625 | - 'rem' => [ | |
| 626 | - 'max' => 2, | |
| 627 | - ], | |
| 628 | 602 | ], |
| 629 | 603 | 'selectors' => [ |
| 630 | 604 | '{{WRAPPER}}' => '--stroke-width-hover: {{SIZE}}{{UNIT}}', |
| 631 | 605 | ], |
| @@ -636,9 +610,9 @@ | ||
| 636 | 610 | 'stroke_transition', |
| 637 | 611 | [ |
| 638 | 612 | 'label' => esc_html__( 'Transition Duration', 'elementor' ), |
| 639 | 613 | 'type' => Controls_Manager::SLIDER, |
| 640 | - 'size_units' => [ 's', 'ms', 'custom' ], | |
| 614 | + 'size_units' => [ 's', 'ms' ], | |
| 641 | 615 | 'default' => [ |
| 642 | 616 | 'unit' => 's', |
| 643 | 617 | 'size' => 0.3, |
| 644 | 618 | ], |
| @@ -687,11 +661,10 @@ | ||
| 687 | 661 | |
| 688 | 662 | // Add Text Path attributes. |
| 689 | 663 | $this->add_render_attribute( 'text_path', [ |
| 690 | 664 | 'class' => 'e-text-path', |
| 691 | - 'data-text' => htmlentities( esc_attr( $settings['text'] ) ), | |
| 665 | + 'data-text' => esc_attr( $settings['text'] ), | |
| 692 | 666 | 'data-url' => esc_url( $path_url ), |
| 693 | - 'data-link-url' => esc_url( $settings['link']['url'] ?? '' ), | |
| 694 | 667 | ] ); |
| 695 | 668 | |
| 696 | 669 | // Add hover animation. |
| 697 | 670 | if ( ! empty( $settings['hover_animation'] ) ) { |