wp_kses_normalize_entities3

The timeline below displays how wordpress function wp_kses_normalize_entities3 has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.1

/**
 * Callback for `wp_kses_normalize_entities()` for regular expression.
 *
 * This function helps `wp_kses_normalize_entities()` to only accept valid Unicode
 * numeric entities in hex form.
 *
 * @since 2.7.0
 * @access private
 * @ignore
 *
 * @param array $matches `preg_replace_callback()` matches array.
 * @return string Correctly encoded entity.
 */
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') . ';');
}

WordPress Version: 4.8

/**
 * Callback for wp_kses_normalize_entities() for regular expression.
 *
 * This function helps wp_kses_normalize_entities() to only accept valid Unicode
 * numeric entities in hex form.
 *
 * @since 2.7.0
 * @access private
 *
 * @param array $matches preg_replace_callback() matches array
 * @return string Correctly encoded entity
 */
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') . ';');
}

WordPress Version: 3.7

/**
 * Callback for wp_kses_normalize_entities() for regular expression.
 *
 * This function helps wp_kses_normalize_entities() to only accept valid Unicode
 * numeric entities in hex form.
 *
 * @access private
 *
 * @param array $matches preg_replace_callback() matches array
 * @return string Correctly encoded entity
 */
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') . ';');
}