最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp editor - Removing line breaks when in text view with wp_editor

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论