wc_sanitize_tooltip()WC 2.3.10

Sanitize a string destined to be a tooltip.

No Hooks.

Return

String.

Usage

wc_sanitize_tooltip( $var );
$var(string) (required)
Data to sanitize.

Changelog

Since 2.3.10 Introduced.
Since 2.3.10 Tooltips are encoded with htmlspecialchars to prevent XSS. Should not be used in conjunction with esc_attr()

wc_sanitize_tooltip() code WC 8.7.0

function wc_sanitize_tooltip( $var ) {
	return htmlspecialchars(
		wp_kses(
			html_entity_decode( $var ?? '' ),
			array(
				'br'     => array(),
				'em'     => array(),
				'strong' => array(),
				'small'  => array(),
				'span'   => array(),
				'ul'     => array(),
				'li'     => array(),
				'ol'     => array(),
				'p'      => array(),
			)
		)
	);
}