PHP Class Timber\TextHelper

Mostra file Open project: jarednova/timber Class Usage Examples

Public Methods

Method Description
close_tags ( string $html ) : string
trim_characters ( string $text, integer $num_chars = 60, string | null $more = null ) : string Trims text to a certain number of characters.
trim_words ( string $text, integer $num_words = 55, string | null | false $more = null, string $allowed_tags = 'p a span b i br blockquote' ) : string

Method Details

close_tags() public static method

public static close_tags ( string $html ) : string
$html string
return string

trim_characters() public static method

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
Since: 1.2.0
Author: @CROSP
public static trim_characters ( string $text, integer $num_chars = 60, string | null $more = null ) : string
$text string Text to trim.
$num_chars integer Number of characters. Default is 60.
$more string | null Optional. What to append if $text needs to be trimmed. Default '…'.
return string trimmed text.

trim_words() public static method

public static trim_words ( string $text, integer $num_words = 55, string | null | false $more = null, string $allowed_tags = 'p a span b i br blockquote' ) : string
$text string
$num_words integer
$more string | null | false text to appear in "Read more...". Null to use default, false to hide
$allowed_tags string
return string