mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Editor: word count: exclude shortcodes
Props desaiuditd, adamsilverstein, azaozz and iseulde. Fixes #27386. See #30966. git-svn-id: https://develop.svn.wordpress.org/trunk@33299 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
( function() {
|
||||
function WordCounter( settings ) {
|
||||
var key;
|
||||
var key,
|
||||
shortcodes;
|
||||
|
||||
if ( settings ) {
|
||||
for ( key in settings ) {
|
||||
@@ -9,6 +10,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shortcodes = this.settings.l10n.shortcodes;
|
||||
|
||||
if ( shortcodes && shortcodes.length ) {
|
||||
this.settings.shortcodesRegExp = new RegExp( '\\[\\/?(?:' + shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'gi' );
|
||||
}
|
||||
}
|
||||
|
||||
WordCounter.prototype.settings = {
|
||||
@@ -65,6 +72,11 @@
|
||||
text = text + '\n';
|
||||
|
||||
text = text.replace( this.settings.HTMLRegExp, '\n' );
|
||||
|
||||
if ( this.settings.shortcodesRegExp ) {
|
||||
text = text.replace( this.settings.shortcodesRegExp, '\n' );
|
||||
}
|
||||
|
||||
text = text.replace( this.settings.spaceRegExp, ' ' );
|
||||
|
||||
if ( type === 'words' ) {
|
||||
|
||||
Reference in New Issue
Block a user