• Resolved yanick64

    (@yanick64)


    Hi there,

    Using the textarea_html doesn’t work. When I enter text and save it it doesn’t save the data, do you know what I did wrong?

    global $kc;
    $kc->add_map(
        array(
            'cs_text' => array(
                'name' => __('Text', 'cs'),
                'description' => __('Add a simpel textarea', 'cs'),
                'icon' => 'fa-align-left',
                'category' => 'Content',
                'params' => array(
                    array(
    					'name' => 'content',
                        'type' => 'textarea_html',
                    )
                )
            )
        )
    );
    
    add_shortcode('cs_text', 'cs_text');
    
    function cs_text($atts) {
        return $atts['content'];
    }

    Kind regards,
    Yanick

    https://wordpress.org/plugins/kingcomposer/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Yanick,

    Thank you for your question.

    We will check then inform you soon.

    Best regards,

    Anthony

    Plugin Author king-theme

    (@kingthemes)

    Hi!

    First of all, this field is special because its data format.

    This field required container shortcode such as [name]content[/content]

    so make sure that you added the config:

    is_contaner => true

    Please read careful our document http://docs.kingcomposer.com/available-param-types/textarea-html-field/

    Thread Starter yanick64

    (@yanick64)

    Hi, thanks for your quick response.

    <?php if (!defined('ABSPATH')) die('Forbidden');
    
    global $kc;
    $kc->add_map(
        array(
            'cs_text' => array(
                'name' => __('Text', 'cs'),
                'description' => __('Add a simpel textarea', 'cs'),
                'icon' => 'fa-align-left',
                'category' => 'Content',
    		 	'is_container' => true,
    
                'params' => array(
                    array(
    					'name' => 'content',
                        'type' => 'textarea_html',
                    )
                )
            )
        )
    );
    
    add_shortcode('cs_text', 'cs_text');
    
    function cs_text($atts) {
        return $atts['content'];
    }

    Somehow it still doesn’t work, when I enter text and click on “Save” in the popup and “Update” afterwards, the text isn’t saved. If I use another element with just a textfield parameter it works.

    Am I really dumb or is it a bug?

    Thread Starter yanick64

    (@yanick64)

    Oops, it says resolved but still it isn’t fixed? If I use the example from your documents it doesn’t work either.

    Plugin Author king-theme

    (@kingthemes)

    Hi Yanick!

    Please wait, I am checking and get back to you in 30 minutes.

    Plugin Author king-theme

    (@kingthemes)

    I’ve updated the plugin to version 2.2.1

    Now you can use the field “editor” instead

    global $kc;
    $kc->add_map(
        array(
            'cs_text' => array(
                'name' => __('Text', 'cs'),
                'description' => __('Add a simpel textarea', 'cs'),
                'icon' => 'fa-align-left',
                'category' => 'Content',
                'is_container' => true,
    
                'params' => array(
                    array(
    		    'name' => 'content1',  // now you can set arbitrary name
                        'type' => 'editor',  // use 'editor' type instead
                        'admin_label' => true, // show preview on builder
                    ),
                    array(
    		    'name' => 'content2',
                       // able to use multiple editor on one element
                        'type' => 'editor',
                        'admin_label' => true,
                    )
                )
            )
        )
    );
    
    add_shortcode('cs_text', 'cs_text');
    
    function cs_text($atts) {
    
       $content1 = base64_decode( $atts['content1'] );
       // To keep safety content format, we must encode by base64.
       // So you just decode before use
    
       return $content1;
    
    }
    Thread Starter yanick64

    (@yanick64)

    Super, works! Thanks!

    Only if you want to use the param name content it doesn’t work. Just so you know and maybe you can fix it.

    Plugin Author king-theme

    (@kingthemes)

    The name content is special kind, it returns shortcode content instead attributes.

    Example [kc content=”text 1″] text inner [/kc]

    It returns “text inner” not “text 1”

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Textarea don't work’ is closed to new replies.