File Editor
Directories:
.. (Back)
Files:
accordion.js
accordion.min.js
bookmarklet.js
bookmarklet.min.js
color-picker.js
color-picker.min.js
comment.js
comment.min.js
common.js
common.min.js
custom-background.js
custom-background.min.js
custom-header.js
customize-controls.js
customize-controls.min.js
customize-nav-menus.js
customize-nav-menus.min.js
customize-widgets.js
customize-widgets.min.js
dashboard.js
dashboard.min.js
edit-comments.js
edit-comments.min.js
editor-expand.js
editor-expand.min.js
editor.js
editor.min.js
farbtastic.js
gallery.js
gallery.min.js
image-edit.js
image-edit.min.js
inline-edit-post.js
inline-edit-post.min.js
inline-edit-tax.js
inline-edit-tax.min.js
iris.min.js
language-chooser.js
language-chooser.min.js
link.js
link.min.js
media-gallery.js
media-gallery.min.js
media-upload.js
media-upload.min.js
media.js
media.min.js
nav-menu.js
nav-menu.min.js
password-strength-meter.js
password-strength-meter.min.js
plugin-install.js
plugin-install.min.js
post.js
post.min.js
postbox.js
postbox.min.js
press-this.js
press-this.min.js
revisions.js
revisions.min.js
set-post-thumbnail.js
set-post-thumbnail.min.js
svg-painter.js
svg-painter.min.js
tags-box.js
tags-box.min.js
tags.js
tags.min.js
theme.js
theme.min.js
updates.js
updates.min.js
user-profile.js
user-profile.min.js
user-suggest.js
user-suggest.min.js
widgets.js
widgets.min.js
word-count.js
word-count.min.js
wp-fullscreen-stub.js
wp-fullscreen-stub.min.js
xfn.js
xfn.min.js
Create New File
Create
Edit File: word-count.js
( function() { function WordCounter( settings ) { var key, shortcodes; if ( settings ) { for ( key in settings ) { if ( settings.hasOwnProperty( key ) ) { this.settings[ key ] = settings[ key ]; } } } shortcodes = this.settings.l10n.shortcodes; if ( shortcodes && shortcodes.length ) { this.settings.shortcodesRegExp = new RegExp( '\\[\\/?(?:' + shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' ); } } WordCounter.prototype.settings = { HTMLRegExp: /<\/?[a-z][^>]*?>/gi, HTMLcommentRegExp: /<!--[\s\S]*?-->/g, spaceRegExp: / | /gi, HTMLEntityRegExp: /&\S+?;/g, connectorRegExp: /--|\u2014/g, removeRegExp: new RegExp( [ '[', // Basic Latin (extract) '\u0021-\u0040\u005B-\u0060\u007B-\u007E', // Latin-1 Supplement (extract) '\u0080-\u00BF\u00D7\u00F7', // General Punctuation // Superscripts and Subscripts // Currency Symbols // Combining Diacritical Marks for Symbols // Letterlike Symbols // Number Forms // Arrows // Mathematical Operators // Miscellaneous Technical // Control Pictures // Optical Character Recognition // Enclosed Alphanumerics // Box Drawing // Block Elements // Geometric Shapes // Miscellaneous Symbols // Dingbats // Miscellaneous Mathematical Symbols-A // Supplemental Arrows-A // Braille Patterns // Supplemental Arrows-B // Miscellaneous Mathematical Symbols-B // Supplemental Mathematical Operators // Miscellaneous Symbols and Arrows '\u2000-\u2BFF', // Supplemental Punctuation '\u2E00-\u2E7F', ']' ].join( '' ), 'g' ), astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, wordsRegExp: /\S\s+/g, characters_excluding_spacesRegExp: /\S/g, characters_including_spacesRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g, l10n: window.wordCountL10n || {} }; WordCounter.prototype.count = function( text, type ) { var count = 0; type = type || this.settings.l10n.type; if ( type !== 'characters_excluding_spaces' && type !== 'characters_including_spaces' ) { type = 'words'; } if ( text ) { text = text + '\n'; text = text.replace( this.settings.HTMLRegExp, '\n' ); text = text.replace( this.settings.HTMLcommentRegExp, '' ); if ( this.settings.shortcodesRegExp ) { text = text.replace( this.settings.shortcodesRegExp, '\n' ); } text = text.replace( this.settings.spaceRegExp, ' ' ); if ( type === 'words' ) { text = text.replace( this.settings.HTMLEntityRegExp, '' ); text = text.replace( this.settings.connectorRegExp, ' ' ); text = text.replace( this.settings.removeRegExp, '' ); } else { text = text.replace( this.settings.HTMLEntityRegExp, 'a' ); text = text.replace( this.settings.astralRegExp, 'a' ); } text = text.match( this.settings[ type + 'RegExp' ] ); if ( text ) { count = text.length; } } return count; }; window.wp = window.wp || {}; window.wp.utils = window.wp.utils || {}; window.wp.utils.WordCounter = WordCounter; } )();
Save Changes
Rename File
Rename