wp_kses_normalize_entities2()WP 1.0.0

Callback for wp_kses_normalize_entities() expression.

This function helps wp_kses_normalize_entities() only accept 16-bit values and nothing more for &#number; entities.

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_entities2( $matches );
$matches(array) (required)
preg_replace_callback() matches array.

Changelog

Since 1.0.0 Introduced.

wp_kses_normalize_entities2() code WP 6.5.2

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

	$i = $matches[1];

	if ( valid_unicode( $i ) ) {
		$i = str_pad( ltrim( $i, '0' ), 3, '0', STR_PAD_LEFT );
		$i = "&#$i;";
	} else {
		$i = "&#$i;";
	}

	return $i;
}