Super Cleansing Cut/Paste into Tiny MCE in WordPress

Had someone cut/pasting from Google Docs into WordPress and it was ending up littered with internal style elements and super irritating span classes. I found this post which got me 95% of the way there and just added .removeAttr(‘style’) to get rid of the inline styles.

Now I can just re-cut/paste and get a clean chunk of text.

//fix cut paste drama from

* 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,b,strong,i,em,h2,h3,h4,h5,h6,ul,li,ol,a,href';
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];
// Strip all class and id attributes
// Return the clean HTML
args.content = stripped.html();
return $in;