Skip to content

Instantly share code, notes, and snippets.

@joeldrapper
Last active November 23, 2016 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joeldrapper/3122047dc0611898c769 to your computer and use it in GitHub Desktop.
Save joeldrapper/3122047dc0611898c769 to your computer and use it in GitHub Desktop.
Cleanup WordPress
function cleanup () {
var textContent = jQuery('.wp-editor-area').val();
textContent = textContent
.replace(/(\<center\>)(["a-z,.!?':;@£$%=\[\]{}^&*()_”“–—‘’\-\+0-9 \n]*)(\<\/center\>)/ig, "<blockquote>$2</blockquote>")
.replace(/(\<img.+\/\>)/g, "\n\n")
.replace(/(\<i\>)(.*)(\<\/i\>)/g, "<em>$2</em>")
.replace(/(\<b\>)(.*)(\<\/b\>)/g, "<strong>$2</strong>");
jQuery('.wp-editor-area').val(textContent);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment