acf_get_truncated()
This function will truncate and return a string
Хуков нет.
Возвращает
Строку.
Использование
acf_get_truncated( $text, $length );
- $text(строка) (обязательный)
- The text to truncate.
- $length(int)
- The number of characters to allow in the string.
По умолчанию: 64
Список изменений
| С версии 5.0.0 | Введена. |
Код acf_get_truncated() acf get truncated ACF 6.4.2
function acf_get_truncated( $text, $length = 64 ) {
$text = trim( $text );
$the_length = function_exists( 'mb_strlen' ) ? mb_strlen( $text ) : strlen( $text );
$cut_length = $length - 3;
$return = function_exists( 'mb_substr' ) ? mb_substr( $text, 0, $cut_length ) : substr( $text, 0, $cut_length );
if ( $the_length > $cut_length ) {
$return .= '...';
}
return $return;
}