diff --git a/wp-admin/js/word-count.js b/wp-admin/js/word-count.js index 0740bb6ef1..bdf4adefae 100644 --- a/wp-admin/js/word-count.js +++ b/wp-admin/js/word-count.js @@ -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' ) { diff --git a/wp-admin/js/word-count.min.js b/wp-admin/js/word-count.min.js index 8b1472b528..8e8ec0b9fb 100644 --- a/wp-admin/js/word-count.min.js +++ b/wp-admin/js/word-count.min.js @@ -1 +1 @@ -!function(){function a(a){var b;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b])}a.prototype.settings={HTMLRegExp:/<\/?[a-z][^>]*?>/gi,spaceRegExp:/ | /gi,connectorRegExp:/--|\u2014/gi,removeRegExp:new RegExp(["[","!-@[-`{-~","\x80-\xbf\xd7\xf7","\u2000-\u2bff","\u2e00-\u2e7f","]"].join(""),"g"),wordsRegExp:/\S\s+/g,charactersRegExp:/\S/g,allRegExp:/[^\f\n\r\t\v\u00ad\u2028\u2029]/g,l10n:window.wordCountL10n||{}},a.prototype.count=function(a,b){var c=0;return b=b||this.settings.l10n.type||"words",a&&(a+="\n",a=a.replace(this.settings.HTMLRegExp,"\n"),a=a.replace(this.settings.spaceRegExp," "),"words"===b&&(a=a.replace(this.settings.connectorRegExp," "),a=a.replace(this.settings.removeRegExp,"")),a=a.match(this.settings[b+"RegExp"]),a&&(c=a.length)),c},window.wp=window.wp||{},window.wp.utils=window.wp.utils||{},window.wp.utils.WordCounter=a}(); \ No newline at end of file +!function(){function a(a){var b,c;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b]);c=this.settings.l10n.shortcodes,c&&c.length&&(this.settings.shortcodesRegExp=new RegExp("\\[\\/?(?:"+c.join("|")+")[^\\]]*?\\]","gi"))}a.prototype.settings={HTMLRegExp:/<\/?[a-z][^>]*?>/gi,spaceRegExp:/ | /gi,connectorRegExp:/--|\u2014/gi,removeRegExp:new RegExp(["[","!-@[-`{-~","\x80-\xbf\xd7\xf7","\u2000-\u2bff","\u2e00-\u2e7f","]"].join(""),"g"),wordsRegExp:/\S\s+/g,charactersRegExp:/\S/g,allRegExp:/[^\f\n\r\t\v\u00ad\u2028\u2029]/g,l10n:window.wordCountL10n||{}},a.prototype.count=function(a,b){var c=0;return b=b||this.settings.l10n.type||"words",a&&(a+="\n",a=a.replace(this.settings.HTMLRegExp,"\n"),this.settings.shortcodesRegExp&&(a=a.replace(this.settings.shortcodesRegExp,"\n")),a=a.replace(this.settings.spaceRegExp," "),"words"===b&&(a=a.replace(this.settings.connectorRegExp," "),a=a.replace(this.settings.removeRegExp,"")),a=a.match(this.settings[b+"RegExp"]),a&&(c=a.length)),c},window.wp=window.wp||{},window.wp.utils=window.wp.utils||{},window.wp.utils.WordCounter=a}(); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 1c45846f2d..e95d075cbe 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -400,7 +400,8 @@ function wp_default_scripts( &$scripts ) { /* translators: If your word count is based on single characters (East Asian characters), enter 'characters', or 'all' to include spaces. Otherwise, enter 'words'. Do not translate into your own language. */ - 'type' => _x( 'words', 'word count: words, characters or all?' ) + 'type' => _x( 'words', 'word count: words, characters or all?' ), + 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array() ) ); $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 9509ffb084..d45724ff59 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-beta3-33298'; +$wp_version = '4.3-beta3-33299'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.