fbpx

Text Editor HTML getting striped on save/switch

You might face an issue when using the Text editor widget. The issue will be your p tag, br tags getting removed on the update, or on switching between the text and HTML version in the TinyMca editor of the Text editor widget of Elemailer.

This is not a bug from our end but rather something related to the WordPress system itself. This is the expected behavior of the text widget, which is essentially the TinyMCE text editor widget. In order for it to work as expected, including embeds and shortcodes, the wpautop() filter is removed.

You can try one of the solutions provided below:

1. You can try and install the Advanced Editor Tools (former TinyMCE Advanced) plugin and enable the option to Keep paragraph tags in the Classic block and the Classic Editor. This will prevent WordPress from sanitizing the content of the Text Editor widget in Elemailer as well as Elementor itself if you use for page editing.

2. Use the below code in your child theme’s function.php or in any PHP code snippet plugin which will trigger the function


add_filter('tiny_mce_before_init','tags_tinymce_fix');


    /**
     * keep <p> tags in Falang & Classic editor
     *
     * @from 1.3.5
     * @update 1.3.20 keep nbsp and shy
     */
    function tags_tinymce_fix($init)
    {
        $init['remove_redundant_brs'] = false;// don't remove redundant BR
        $init['wpautop'] = true;//wpautop = yes
        $init['indent'] = true;
        $init['tadv_noautop'] = true;
        $init['forced_root_block'] = false;//no p tags around the whole block
        $init['entities'] .= ',160,nbsp,173,shy'; //keep nbsp and shy
        $init['entity_encoding'] = 'named';
        $init['remove_linebreaks'] = false;
        $init['convert_newlines_to_brs'] = false;// don't convert newline characters to br tags

        return $init;
    }

3. Don’t use the text editor widget, rather use the HTML widget as that doesn’t strip out HTML at all ( only available in Elemailer paid version )