Strip Google Span Tags When you Cut/Paste into the WordPress Editor

You may note that when you cut/paste from Google Docs into the WordPress editor you get a bunch of span tag and inline CSS garbage. It’s awful . . . so you could paste into the plain text editor . . . but you may also find that you want to keep a bunch of the other HTML in there like links and lists and stuff. via GIPHY Jonathan Nicol figured this out way back in 2015 and I keep having to re-Google it or remember which theme I had it in so I’m putting it here to help me find it more easily. You can see my slightly tweaked version below. All credit to Jonathan and thanks to him for documenting it publically.


Clean Google Doc Cut/Paste into WordPress Editor

If you cut/paste from a Google Doc into the WordPress WYSIWYG editor you get more than I want. Mainly a bunch of inline CSS that sets the font weight (see below). This is a pain because it’s going to take priority in CSS land and undoing it by hand is a hassle. Some internet wandering led me to Jonathan Nicol’s fix for some span elements and bit of adjustment allowed me to also deal with the inline CSS elements. The extra nice aspect of this as a fix is that it only applies on paste actions so you can still write the stuff in the HTML editor if you want.