Automattic\WooCommerce\Internal\Settings

OptionSanitizer::sanitize_price_separator_setting │ public │ WC 11.2.0

Rejects thousand and decimal separators that contain a number. On rejection it adds a settings error and returns the stored separator, or an empty string when nothing is stored.

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

Хуков нет.

Возвращает

string.

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

$OptionSanitizer = new OptionSanitizer();
$OptionSanitizer->sanitize_price_separator_setting( $option_id, $raw_value );
$option_id(строка) (обязательный)
Name of the option being saved.
$raw_value(разное) (обязательный)
Raw request value, null when the field was not submitted.

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

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

Код OptionSanitizer::sanitize_price_separator_setting() WC 11.2.2

public function sanitize_price_separator_setting( $option_id, $raw_value ) {
	if ( is_string( $raw_value ) ) {
		$separator = wp_kses( $raw_value, array() );
		$decoded   = html_entity_decode( $separator, ENT_QUOTES | ENT_HTML5, 'UTF-8' );

		if ( 0 === preg_match( '/\p{N}/u', $decoded ) ) {
			return $separator;
		}
	}

	if ( null !== $raw_value ) {
		\WC_Admin_Settings::add_error( __( 'Thousand and decimal separators cannot contain numbers.', 'woocommerce' ) );
	}

	$stored = get_option( $option_id, '' );

	return is_string( $stored ) ? $stored : '';
}