Automattic\WooCommerce\Internal\Abilities

AbilitiesTracking::normalize_value │ private static │ WC 1.0

Convert a value to lowercase words separated by underscores, as Tracks property values expect.

Метод класса: AbilitiesTracking{}

Хуков нет.

Возвращает

string. The normalized value, or 'none' when nothing is left.

Использование

$result = AbilitiesTracking::normalize_value( $value, ?int $max_length ): string;
$value(строка) (обязательный)
The value.
?int $max_length
.
По умолчанию: 64

Код AbilitiesTracking::normalize_value() WC 11.3.0

private static function normalize_value( string $value, ?int $max_length = 64 ): string {
	$value = trim( (string) preg_replace( '/[^a-z0-9]+/', '_', strtolower( $value ) ), '_' );
	if ( '' === $value ) {
		return self::NONE;
	}
	return null === $max_length ? $value : (string) substr( $value, 0, $max_length );
}