How to prevent Wordpress TinyMCE from stripping ur

2019-07-20 09:00发布

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条回答
\"骚年 ilove
2楼-- · 2019-07-20 10:00

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.

查看更多
登录 后发表回答