Created
March 18, 2016 17:57
-
-
Save mixcas/94f237c2dec6781b720e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment