in ‘wp-admin/js/post.js’ you cam take this part and change it in your plugin:
/**
* TinyMCE word count display
*/
( function( $, counter ) {
$( function() {
var $content = $( '#content' ),
$count = $( '#wp-word-count' ).find( '.word-count' ),
prevCount = 0,
contentEditor;
/**
* Get the word count from TinyMCE and display it
*/
function update() {
var text, count;
if ( ! contentEditor || contentEditor.isHidden() ) {
text = $content.val();
} else {
text = contentEditor.getContent( { format: 'raw' } );
}
count = counter.count( text );
if ( count !== prevCount ) {
$count.text( count );
}
prevCount = count;
}
/**
* Bind the word count update triggers.
*
* When a node change in the main TinyMCE editor has been triggered.
* When a key has been released in the plain text content editor.
*/
$( document ).on( 'tinymce-editor-init', function( event, editor ) {
if ( editor.id !== 'content' ) {
return;
}
contentEditor = editor;
editor.on( 'nodechange keyup', _.debounce( update, 1000 ) );
} );
$content.on( 'input keyup', _.debounce( update, 1000 ) );
update();
} );
} )( jQuery, new wp.utils.WordCounter() );
The idea is that we will change one of the settings of ‘wp.utils.WordCounter()’.
The plugin will be something like this:
function myplugin_countStopWords(){ ?>
<script>
var settings = {
removeRegExp: new RegExp( [
'[',
// Basic Latin (extract)
'\u0021-\u0040\u005B-\u0060\u007B-\u007E',
// Latin-1 Supplement (extract)
'\u0080-\u00BF\u00D7\u00F7',
'\u2000-\u2BFF',
'of','the','this','that',
// Supplemental Punctuation
'\u2E00-\u2E7F',
']'
].join( '' ), 'g' )
};
( function( $, counter ) {
$( function() {
var $content = $( '#content' ),
$count = $( '#wp-word-count' ).find( '.word-count' ),
prevCount = 0,
contentEditor;
/**
* Get the word count from TinyMCE and display it
*/
function update() {
var text, count;
if ( ! contentEditor || contentEditor.isHidden() ) {
text = $content.val();
} else {
text = contentEditor.getContent( { format: 'raw' } );
}
count = counter.count( text );
if ( count !== prevCount ) {
$count.text( count );
}
prevCount = count;
}
/**
* Bind the word count update triggers.
*
* When a node change in the main TinyMCE editor has been triggered.
* When a key has been released in the plain text content editor.
*/
$( document ).on( 'tinymce-editor-init', function( event, editor ) {
if ( editor.id !== 'content' ) {
return;
}
contentEditor = editor;
editor.on( 'nodechange keyup', _.debounce( update, 1000 ) );
} );
$content.on( 'input keyup', _.debounce( update, 1000 ) );
update();
} );
} )( jQuery, new wp.utils.WordCounter(settings) );
</script>
<?php }
add_action( 'after_wp_tiny_mce', 'myplugin_countStopWords');