wc_sanitize_coupon_code()WC 3.6.0

Sanitize a coupon code.

Uses sanitize_post_field since coupon codes are stored as post_titles - the sanitization and escaping must match.

Due to the unfiltered_html captability that some (admin) users have, we need to account for slashes.

Хуков нет.

Возвращает

Строку.

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

wc_sanitize_coupon_code( $value );
$value(строка) (обязательный)
Coupon code to format.

Список изменений

С версии 3.6.0 Введена.

Код wc_sanitize_coupon_code() WC 9.3.3

function wc_sanitize_coupon_code( $value ) {
	$value = wp_kses( sanitize_post_field( 'post_title', $value ?? '', 0, 'db' ), 'entities' );
	return current_user_can( 'unfiltered_html' ) ? $value : stripslashes( $value );
}