PHP Класс Timber\TextHelper

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Описание методов

close_tags() публичный статический Метод

public static close_tags ( string $html ) : string
$html string
Результат string

trim_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
С версии: 1.2.0
Автор: @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 '…'.
Результат string trimmed text.

trim_words() публичный статический Метод

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
Результат string