Removing line breaks when in text view with wp_editor

While working on a custom plugin, I needed to add the wp_editor in the admin to let the user add its own content.

I want the user to be able to write custom rich texts with the "Visual" editor mode but I also want the user to be able to paste HTML codes in the "Text" view. For example, if he wants to paste his subscription HTML form, he could do that while switching to the "Text" mode.

The issue is when I paste some HTML in the "Text" mode, after saving, the code renders with line breaks br which completely changes the way the form should look.

My question is : can I prevent Wordpress from adding these line breaks if I paste some HTML code in the editor while in "Text" mode?

I've tried setting wpautop to false :

$editor_config = array(
    "wpautop" = false,
    "media_buttons" = true
);

wp_editor( $content, "my_editor", $editor_config ); 

... which doesn't change anything.

Topic wp-editor line-breaks wp-autop html-editor Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.