Class: wordcounter

wp.utils. wordcounter


new wordcounter(settings)

Word counting utility
Parameters:
Name Type Description
settings Object Optional. Key-value object containing overrides for settings.
Properties
Name Type Description
HTMLRegExp RegExp Optional. Regular expression to find HTML elements.
HTMLcommentRegExp RegExp Optional. Regular expression to find HTML comments.
spaceRegExp RegExp Optional. Regular expression to find irregular space characters.
HTMLEntityRegExp RegExp Optional. Regular expression to find HTML entities.
connectorRegExp RegExp Optional. Regular expression to find connectors that split words.
removeRegExp RegExp Optional. Regular expression to find remove unwanted characters to reduce false-positives.
astralRegExp RegExp Optional. Regular expression to find unwanted characters when searching for non-words.
wordsRegExp RegExp Optional. Regular expression to find words by spaces.
characters_excluding_spacesRegExp RegExp Optional. Regular expression to find characters which are non-spaces.
characters_including_spacesRegExp RegExp Optional. Regular expression to find characters including spaces.
shortcodesRegExp RegExp Optional. Regular expression to find shortcodes.
l10n Object Optional. Localization object containing specific configuration for the current localization.
Properties
Name Type Description
type String Optional. Method of finding words to count.
shortcodes Array Optional. Array of shortcodes that should be removed from the text.
Source:
Returns:
Type
void

Methods


<static> WordCounter#count(text, type)

Counts the number of words (or other specified type) in the specified text.
Parameters:
Name Type Description
text String Text to count elements in.
type String Optional. Specify type to use.
Since:
  • 2.6.0
Source:
Returns:
The number of items counted.
Type
Number