How to disable TinyMCE from removing span tags

Question

I am posting Word generated HTML to WordPress via XMLRPC. Before I go to post.php, the format is correctly preserved in the database. TinyMCE performs its magic and I lose quite a few formatting details.
The main issue i am seeing is that <span> tag with style information surrounding other elements are stripped out. I have verified that these tags are indeed removed by TinyMCE and not Kses.
Is there a way to prevent TinyMCE from altering the HTML? I have tried

add_filter('tiny_mce_before_init', 'tinymce_init');

function tinymce_init( $init ) {
    $init['extended_valid_elements'] .= ', span[style|id|nam|class|lang]';
$init['verify_html'] = false;
    return $init;
}

which didn’t help. According to TinyMCE documentation, “verify_html”

This option enables or disables the element cleanup functionality. If you set this option to false, all element cleanup will be skipped but other cleanup functionality such as URL conversion will still be executed.

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/how-to-disable-tinymce-from-removing-span-tags/">

How to disable TinyMCE from removing span tags</a>
0
ltfishie 2 months 0 Answers 79 views 0

Leave an answer