phpwordpresselementor

Turn the description input field of Elementor's Call-To-Action Widget into a WYSIWYG-field


as the title says, I'm trying to hook into Elementor's exisiting CTA-widget and turn the existing input field into a WYSIWYG-field by looking at the widget's structure etc. within elementor pro directory. But somehow nothing happens. If I change it in the plugins source file it works, but sure I want to override it through my functions.php.

I've done this for the slides Widget before and that worked well. What am I missing here?

/*
 * Set Elementor > CTA widget description as wysiwyg Text Editor
 */
add_action( 'elementor/element/call-to-action/section_content/before_section_end', function( $widget, $args ) {
    $cta_control = \Elementor\Plugin::instance()->controls_manager->get_control_from_stack( $widget->get_unique_name(), 'call-to-action' );

    if ( is_wp_error( $cta_control ) ) {
        return;
    }

    $cta_control['fields']['description']['type'] = \Elementor\Controls_Manager::WYSIWYG;

    $widget->update_control( 'call-to-action', $cta_control );
},10 ,2 );

Any help appreciated. Thank you.


Solution

  • it looks your code is fine i change little bit try this

    add_action( 'elementor/element/call-to-action/section_content/before_section_end', function( $widget ) {
        $widget->update_control(
            'description',
            [
                'type' => \Elementor\Controls_Manager::WYSIWYG,
            ]
        );
    }, 10, 1 );