Remove hidden formatting when user paste text from MS Word into TinyMCE

I am interpreting the question to mean that you already have Word markup in your post and so you need to clean that up via PHP. If so…

  1. You can see the code that cleans up Word content here:
    http://core.trac.wordpress.org/browser/trunk/src/wp-includes/js/tinymce/plugins/paste/editor_plugin_src.js#L375
    That is Javascript. With some work, you could convert that to PHP.
  2. PHP Tidy, if available, will clean that up.
  3. I believe that HTML Tidy can do it.
  4. strip_tags will just get rid of the code. (Tested)
  5. wp_kses will get rid of much of it but will take some tweaking to
    work well, at least as indicated by my simple test. Maybe with the right arguments it can do what you want.

Leave a Comment