函数php清理WordPress中粘贴的文本



函数php清理WordPress中粘贴的文本,不清理数据

这个脚本非常棒,

add_filter('tiny_mce_before_init','configure_tinymce');
/**
* Customize TinyMCE's configuration
*
* @param   array
* @return  array
*/
function configure_tinymce($in) {
$in['paste_preprocess'] = "function(plugin, args){
// Strip all HTML tags except those we have whitelisted
var whitelist = 'p,span,b,strong,i,em,h3,h4,h5,h6,ul,li,ol';
var stripped = jQuery('<div>' + args.content + '</div>');
var els = stripped.find('*').not(whitelist);
for (var i = els.length - 1; i >= 0; i--) {
var e = els[i];
jQuery(e).replaceWith(e.innerHTML);
}
// Strip all class and id attributes
stripped.find('*').removeAttr('id').removeAttr('class');
// Return the clean HTML
args.content = stripped.html();
}";
return $in;
}

代码来自此网站

但是如何清除HTML标签中的数据=示例

<h4 data-uw-styling-context="true">» title</h4>

关于如何以同样的方式清理数据信息,有什么想法吗?

所以我自己想出了解决方案非常简单的是,只需要添加需要删除的数据类型data-uw样式上下文

stripped.find('*').removeAttr('id').removeAttr('class').removeAttr('data-uw-styling-context');

最新更新