Automattic\WooCommerce\Internal\Email

EmailHeaders::sanitize_reply_to_name │ public static │ WC 11.3.0

Clean a customer-provided name for use in a Reply-to header.

Line breaks are collapsed to spaces and commas removed, since wp_mail() splits Reply-to values on commas. The line break removal runs again after sanitize_text_field(), since its sanitize_text_field runs last and could reintroduce them.

Method of the class: EmailHeaders{}

No Hooks.

Returns

string.

Usage

$result = EmailHeaders::sanitize_reply_to_name( $name ): string;
$name(string) (required)
Name to clean.

Changelog

Since 11.3.0 Introduced.

EmailHeaders::sanitize_reply_to_name() code WC 11.3.0

public static function sanitize_reply_to_name( string $name ): string {
	$name = str_replace( array( "\r", "\n" ), ' ', sanitize_text_field( $name ) );
	return trim( str_replace( ',', '', $name ) );
}