WireTextTools class

Specific text and markup tools for ProcessWire $sanitizer and elsewhere.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the WireTextTools class also inherits all the methods and properties of: Wire.

Show class?     Show args?       Only hookable?    

Common

NameReturnSummary 
WireTextTools::collapse(string $str)
string

Collapse string to plain text that all exists on a single long line without destroying words/punctuation.

 
WireTextTools::diffMarkup(string $old, string $new)
string

Given two strings ($old and $new) return a diff string in HTML markup

 
WireTextTools::findPlaceholders(string $str)
array bool

Find and return all {placeholder} tags found in given string

 
WireTextTools::findReplaceEscapeChars($str, array $escapeChars)
array

Find escaped characters in $str, replace them with a placeholder, and return the placeholders

 
WireTextTools::fixUnclosedTags(string $str)
string

Remove (or close) unclosed HTML tags from given string

 
WireTextTools::getPunctuationChars()
array

Get array of punctuation characters

 
WireTextTools::getVisibleLength(string $str)
int

Return visible length of string, which is length not counting markup or entities

 
WireTextTools::getWordAlternates(string $word)
array

Get alternate words for given word

 
WireTextTools::hasPlaceholders(string $str)
bool

Does the string have any {placeholder} tags in it?

 
WireTextTools::markupToText(string $str)
string

Convert HTML markup to readable text

 
WireTextTools::populatePlaceholders(string $str, $vars)
string

Given a string ($str) and values ($vars), populate placeholder “{tags}” in the string with the values

 
WireTextTools::truncate(string $str, $maxLength)
string

Truncate string to given maximum length without breaking words

 

For hooks

These methods are only useful for hooking and should not be called directly.

PHP function alternates

NameReturnSummary 
WireTextTools::ltrim(string $str)
string

Strip whitespace (or other characters) from the beginning of string only (aka left trim)

 
WireTextTools::rtrim(string $str)
string

Strip whitespace (or other characters) from the end of string only (aka right trim)

 
WireTextTools::stripos(string $haystack, string $needle)
bool false int

Find the position of the first occurrence of a case-insensitive substring in a string

 
WireTextTools::stristr(string $haystack, string $needle)
false string

Find the first occurrence of a string (case insensitive)

 
WireTextTools::strlen(string $str)
int

Get string length

 
WireTextTools::strpos(string $haystack, string $needle)
bool false int

Find position of first occurrence of string in a string

 
WireTextTools::strrchr(string $haystack, string $needle)
false string

Find the last occurrence of a character in a string

 
WireTextTools::strripos(string $haystack, string $needle)
bool false int

Find the position of the last occurrence of a case-insensitive substring in a string

 
WireTextTools::strrpos(string $haystack, string $needle)
bool false int

Find the position of the last occurrence of a substring in a string

 
WireTextTools::strstr(string $haystack, string $needle)
false string

Find the first occurrence of a string

 
WireTextTools::strtolower(string $str)
string

Make a string lowercase

 
WireTextTools::strtoupper(string $str)
string

Make a string uppercase

 
WireTextTools::substr(string $str, int $start)
string

Get part of a string

 
WireTextTools::substrCount(string $haystack, string $needle)
int

Count the number of substring occurrences

 
WireTextTools::trim(string $str)
string

Strip whitespace (or other characters) from the beginning and end of a string

 

Additional methods and properties

In addition to the methods and properties above, WireTextTools also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.252