wp_kses_normalize_entities3()WP 2.7.0

Callback for wp_kses_normalize_entities() regular expression.

This function helps wp_kses_normalize_entities() only accept valid Unicode numeric entities in hex form.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Return

String. Correctly encoded entity.

Usage

wp_kses_normalize_entities3( $matches );
$matches(array) (required)
preg_replace_callback() matches array.

Changelog

Since 2.7.0 Introduced.

wp_kses_normalize_entities3() code WP 6.5.2

function wp_kses_normalize_entities3( $matches ) {
	if ( empty( $matches[1] ) ) {
		return '';
	}

	$hexchars = $matches[1];

	return ( ! valid_unicode( hexdec( $hexchars ) ) ) ? "&#x$hexchars;" : '&#x' . ltrim( $hexchars, '0' ) . ';';
}