Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails

WCEmailTemplateChangeSummary::truncate_textprivate staticWC 1.0

UTF-8-safe truncation to {@see self::COPY_TRUNCATE_CHARS}.

Method of the class: WCEmailTemplateChangeSummary{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = WCEmailTemplateChangeSummary::truncate_text( $text ): string;
$text(string) (required)
Cleaned inner-text candidate.

WCEmailTemplateChangeSummary::truncate_text() code WC 10.9.1

private static function truncate_text( string $text ): string {
	$limit = self::COPY_TRUNCATE_CHARS;
	if ( function_exists( 'mb_strlen' ) && function_exists( 'mb_substr' ) ) {
		if ( mb_strlen( $text ) <= $limit ) {
			return $text;
		}
		return rtrim( mb_substr( $text, 0, $limit ) ) . '…';
	}
	if ( strlen( $text ) <= $limit ) {
		return $text;
	}
	return rtrim( substr( $text, 0, $limit ) ) . '…';
}