WC_Settings_API::validate_safe_text_field()publicWC 1.0

Sanitize 'Safe Text' fields.

These fields are similar to regular text fields, but a much smaller set of HTML tags are allowed. By default, this means <br>, <img>, <p> and <span> tags.

Note: this is a sanitization method, rather than a validation method (the name is due to some historic naming choices).

Method of the class: WC_Settings_API{}

No Hooks.

Return

String.

Usage

$WC_Settings_API = new WC_Settings_API();
$WC_Settings_API->validate_safe_text_field( $key, ?string $value ): string;
$key(string) (required)
Field key (currently unused).
?string $value (required)
-

WC_Settings_API::validate_safe_text_field() code WC 8.7.0

public function validate_safe_text_field( string $key, ?string $value ): string {
	return wc_get_container()->get( HtmlSanitizer::class )->sanitize( (string) $value, HtmlSanitizer::LOW_HTML_BALANCED_TAGS_NO_LINKS );
}