Visual editor messes with code!

[ad_1]

I recently started using the classic tinymce editor after ages. For some reason, switching between the “visual” and “text” tabs completely messes with my layout. I have designed a report output that has some inline JS, CSS, and HTML. Anytime I (or one of the other site users) opens the visual tab it garbles the output, adds all kinds of crazy tags, renders the JS invalid, straight up removes some HTML elements, etc. After some searching, it seemed like the “autop” function might be the “culprit”, so I added this code to my site plugin:

add_filter(‘tiny_mce_before_init’, function($options) {
$options[‘wpautop’] = false;
return $options;
});

It didn’t do jack. Finally I have disabled the visual editor with this filter:

add_filter(‘user_can_richedit’, ‘__return_false’);

I like checking the output in the visual editor but it’s not worth having to reformat everything multiple times. I don’t want to disable autop site-wide because it has a purpose and the frontend output isn’t affected if I don’t use the visual editor (plus it may not even be the culprit). Has anyone else faced this issue?

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer