Timber Logo

You are reading the documentation for Timber v1.x. Switch to the documentation for Timber v2.x.


Class provides different text-related functions commonly used in WordPress development

Class Methods #

close_tags #

close_tags( string $html )

returns: string


ends_with #

ends_with( string $haystack, string $needle )

returns: boolean

Does the string in question (haystack)

end with the substring in question (needle)?


remove_tags #

remove_tags( mixed $string, array $tags=array() )

returns: void


starts_with #

starts_with( string $haystack, string $needle )

returns: boolean


trim_characters #

trim_characters( string $text, mixed/int $num_chars=60, string $more="…" )

returns: string trimmed text.

Trims text to a certain number of characters.

This function can be useful for excerpt of the post

As opposed to wp_trim_words trims characters that makes text to

take the same amount of space in each post for example

$textstringText to trim.
$num_charsmixed/intNumber of characters. Default is 60.
$morestringWhat to append if $text needs to be trimmed. Defaults to '…'.

trim_words #

trim_words( string $text, mixed/int $num_words=55, mixed/string/null/false $more=null, string $allowed_tags="p a span b i br blockquote" )

returns: string

$moremixed/string/null/falsetext to appear in "Read more...". Null to use default, false to hide