namespace Elementor\Modules\Shapes\Widgets;
use Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Group_Control_Typography;
use Elementor\Modules\Shapes\Module as Shapes_Module;
use Elementor\Group_Control_Text_Stroke;
use Elementor\Widget_Base;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
* Elementor WordArt widget.
* Elementor widget that displays text along SVG path.
class TextPath extends Widget_Base {
const DEFAULT_PATH_FILL = '#E8178A';
* Retrieve Text Path widget name.
* @return string Widget name.
public function get_name() {
public function get_group_name() {
* Retrieve Text Path widget title.
* @return string Widget title.
public function get_title() {
return esc_html__( 'Text Path', 'elementor' );
* Retrieve Text Path widget icon.
* @return string Widget icon.
public function get_icon() {
* Retrieve the list of keywords the widget belongs to.
* @return array Widget keywords.
public function get_keywords() {
return [ 'text path', 'word path', 'text on path', 'wordart', 'word art' ];
* Get style dependencies.
* Retrieve the list of style dependencies the widget requires.
* @return array Widget style dependencies.
public function get_style_depends(): array {
return [ 'widget-text-path' ];
public function has_widget_inner_wrapper(): bool {
return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
* Register content controls under content tab.
protected function register_content_tab() {
$this->start_controls_section(
'section_content_text_path',
'label' => esc_html__( 'Text Path', 'elementor' ),
'tab' => Controls_Manager::TAB_CONTENT,
'label' => esc_html__( 'Text', 'elementor' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Add Your Curvy Text Here', 'elementor' ),
'frontend_available' => true,
'label' => esc_html__( 'Path Type', 'elementor' ),
'type' => Controls_Manager::SELECT,
'options' => Shapes_Module::get_paths(),
'label' => esc_html__( 'SVG', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'description' => sprintf(
'%1$s <a target="_blank" href="https://go.elementor.com/text-path-create-paths/">%2$s</a>',
esc_html__( 'Want to create custom text paths with SVG?', 'elementor' ),
esc_html__( 'Learn more', 'elementor' )
'label' => esc_html__( 'Link', 'elementor' ),
'type' => Controls_Manager::URL,
'placeholder' => esc_html__( 'Paste URL or type', 'elementor' ),
'frontend_available' => true,
$this->add_responsive_control(
'label' => esc_html__( 'Alignment', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Left', 'elementor' ),
'icon' => 'eicon-text-align-left',
'title' => esc_html__( 'Center', 'elementor' ),
'icon' => 'eicon-text-align-center',
'title' => esc_html__( 'Right', 'elementor' ),
'icon' => 'eicon-text-align-right',
'{{WRAPPER}}' => '--alignment: {{VALUE}}',
'frontend_available' => true,
'label' => esc_html__( 'Text Direction', 'elementor' ),
'type' => Controls_Manager::SELECT,
'' => esc_html__( 'Default', 'elementor' ),
'rtl' => esc_html__( 'RTL', 'elementor' ),
'ltr' => esc_html__( 'LTR', 'elementor' ),
'{{WRAPPER}}' => '--direction: {{VALUE}}',
'frontend_available' => true,
'label' => esc_html__( 'Show Path', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'On', 'elementor' ),
'label_off' => esc_html__( 'Off', 'elementor' ),
'return_value' => self::DEFAULT_PATH_FILL,
'{{WRAPPER}}' => '--path-stroke: {{VALUE}}; --path-fill: transparent;',
$this->end_controls_section();
* Register style controls under style tab.
protected function register_style_tab() {
* Text Path styling section.
$this->start_controls_section(
'section_style_text_path',
'label' => esc_html__( 'Text Path', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
$this->add_responsive_control(
'label' => esc_html__( 'Size', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'{{WRAPPER}}' => '--width: {{SIZE}}{{UNIT}};',
$this->add_responsive_control(
'label' => esc_html__( 'Rotate', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ],
'{{WRAPPER}}' => '--rotate: {{SIZE}}{{UNIT}};',
'label' => esc_html__( 'Text', 'elementor' ),
'type' => Controls_Manager::HEADING,
$this->add_group_control(
Group_Control_Typography::get_type(),
'name' => 'text_typography',
'selector' => '{{WRAPPER}}',
'default' => Global_Typography::TYPOGRAPHY_TEXT,
'size_units' => [ 'px' ],
// Text decoration isn't an inherited property, so it's required to explicitly
// target the specific `textPath` element.
'{{WRAPPER}} textPath' => 'text-decoration: {{VALUE}};',
$this->add_group_control(
Group_Control_Text_Stroke::get_type(),
'selector' => '{{WRAPPER}} textPath',
$this->add_responsive_control(
'label' => esc_html__( 'Word Spacing', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', 'em', 'rem', 'custom' ],
'{{WRAPPER}}' => '--word-spacing: {{SIZE}}{{UNIT}};',
'label' => esc_html__( 'Starting Point', 'elementor' ) . ' (%)',
'type' => Controls_Manager::SLIDER,
'frontend_available' => true,
$this->start_controls_tabs( 'text_style' );
$this->start_controls_tab(
'label' => esc_html__( 'Normal', 'elementor' ),
'label' => esc_html__( 'Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'{{WRAPPER}}' => '--text-color: {{VALUE}};',
$this->end_controls_tab();
$this->start_controls_tab(
'label' => esc_html__( 'Hover', 'elementor' ),
'label' => esc_html__( 'Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'{{WRAPPER}}' => '--text-color-hover: {{VALUE}};',
'label' => esc_html__( 'Hover Animation', 'elementor' ),
'type' => Controls_Manager::HOVER_ANIMATION,
'label' => esc_html__( 'Transition Duration', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 's', 'ms', 'custom' ],
'{{WRAPPER}}' => '--transition: {{SIZE}}{{UNIT}}',
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
$this->start_controls_section(
'label' => esc_html__( 'Path', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
$this->start_controls_tabs( 'path_style' );
$this->start_controls_tab(