How to prevent Wordpress TinyMCE from stripping url having no link text

本小妞迷上赌 提交于 2019-12-12 20:48:37

问题


I'm using a custom button on the TinyMCE editor on my wordpress site to insert a list of urls without having to type the markup. The problem is that TinyMCE automatically removes the urls that do not have a link text. For example, if the custom button is programmed to insert

<a href="http://example.com"></a>

well, nothing is inserted.

But if I make the button insert

<a href="http://example.com">Example.com</a>

it works. I do not want a link text as I need an image link by using background image sprite instead of by using html img tag.

Is there any way I could prevent tinymce stripping links that have no link text?


回答1:


Try this:

function myformatTinyMCE($in) {
    $in['verify_html']=false;
    return $in;
}
add_filter('tiny_mce_before_init', 'myformatTinyMCE' );

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.



来源:https://stackoverflow.com/questions/18313031/how-to-prevent-wordpress-tinymce-from-stripping-url-having-no-link-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!