Created
May 17, 2016 19:07
-
-
Save CoeusCC/7203e190d908aa5eca15334d40ea6b62 to your computer and use it in GitHub Desktop.
Target TinyMCE instance in WordPress post editor and return an estimated word count
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
function countWordsInWpEditor() { | |
var html; | |
var text; | |
var words; | |
var focusedTextField = document.getElementById("tinymce"); | |
html = focusedTextField.innerHTML; | |
text = html.replace(/(<([^>]+)>)/ig,"") | |
words = text.split(" "); | |
return words.length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment