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?        

Common

NameReturnSummary 
WireTextTools::collapse(string $str)
mixed stringCollapse string to plain text that all exists on a single long line without destroying words/punctuation. 
WireTextTools::diffMarkup(string $old, string $new)
stringGiven two strings ($old and $new) return a diff string in HTML markup 
WireTextTools::findPlaceholders(string $str)
array boolFind and return all {placeholder} tags found in given string 
WireTextTools::findReplaceEscapeChars($str, array $escapeChars)
arrayFind escaped characters in $str, replace them with a placeholder, and return the placeholders 
WireTextTools::fixUnclosedTags(string $str)
stringRemove (or close) unclosed HTML tags from given string 
WireTextTools::getPunctuationChars()
array stringGet array of punctuation characters 
WireTextTools::getVisibleLength(string $str)
intReturn visible length of string, which is length not counting markup or entities 
WireTextTools::getWordAlternates(string $word)
arrayGet alternate words for given word 
WireTextTools::hasPlaceholders(string $str)
boolDoes the string have any {placeholder} tags in it? 
WireTextTools::populatePlaceholders(string $str, $vars)
stringGiven a string ($str) and values ($vars), populate placeholder “{tags}” in the string with the values 
WireTextTools::truncate(string $str, $maxLength)
stringTruncate 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::stripos(string $haystack, string $needle)
bool false intFind the position of the first occurrence of a case-insensitive substring in a string 
WireTextTools::stristr(string $haystack, string $needle)
false stringFind the first occurrence of a string (case insensitive) 
WireTextTools::strlen(string $str)
intGet string length 
WireTextTools::strpos(string $haystack, string $needle)
bool false intFind position of first occurrence of string in a string 
WireTextTools::strrchr(string $haystack, string $needle)
false stringFind the last occurrence of a character in a string 
WireTextTools::strripos(string $haystack, string $needle)
bool false intFind the position of the last occurrence of a case-insensitive substring in a string 
WireTextTools::strrpos(string $haystack, string $needle)
bool false intFind the position of the last occurrence of a substring in a string 
WireTextTools::strstr(string $haystack, string $needle)
false stringFind the first occurrence of a string 
WireTextTools::strtolower(string $str)
stringMake a string lowercase 
WireTextTools::strtoupper(string $str)
stringMake a string uppercase 
WireTextTools::substr(string $str, int $start)
stringGet part of a string 
WireTextTools::substrCount(string $haystack, string $needle)
intCount the number of substring occurrences 
WireTextTools::trim(string $str)
stringStrip 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.163

Twitter updates

  • This week ProcessWire version 3.0.166 is released on the dev branch. In this post we’ll cover all that’s new relative to the previous version, 3.0.165. Plus we’ll check out the latest new versions of ProCache and FormBuilder— More
    11 September 2020
  • Weekly update – 28 August 2020 – New secure files option defined per-template: More
    28 August 2020
  • ProcessWire 3.0.165 core updates (master and dev branch) and reCAPTCHA for FormBuilder module— More
    21 August 2020

Latest news

  • ProcessWire Weekly #331
    In the 331st issue of ProcessWire Weekly we're going to check out the latest core and Pro module updates (ProcessWire 3.0.166, ProCache 4.0.1, and Form Builder v44), introduce the Wireframe API module, and more. Read on!
    Weekly.pw / 12 September 2020
  • ProcessWire 3.0.166 core updates and more
    This week ProcessWire version 3.0.166 is released on the dev branch. In this post we’ll cover all that’s new relative to the previous version, 3.0.165. Plus we’ll check out the latest new versions of ProCache and FormBuilder.
    Blog / 11 September 2020
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani