wp_kses_named_entities

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

WordPress Version: 5.5

/**
 * Callback for `wp_kses_normalize_entities()` regular expression.
 *
 * This function only accepts valid named entity references, which are finite,
 * case-sensitive, and highly scrutinized by HTML and XML validators.
 *
 * @since 3.0.0
 *
 * @global array $allowedentitynames
 *
 * @param array $matches preg_replace_callback() matches array.
 * @return string Correctly encoded entity.
 */
function wp_kses_named_entities($matches)
{
    global $allowedentitynames;
    if (empty($matches[1])) {
        return '';
    }
    $i = $matches[1];
    return (!in_array($i, $allowedentitynames, true)) ? "&{$i};" : "&{$i};";
}

WordPress Version: 5.1

/**
 * Callback for `wp_kses_normalize_entities()` regular expression.
 *
 * This function only accepts valid named entity references, which are finite,
 * case-sensitive, and highly scrutinized by HTML and XML validators.
 *
 * @since 3.0.0
 *
 * @global array $allowedentitynames
 *
 * @param array $matches preg_replace_callback() matches array.
 * @return string Correctly encoded entity.
 */
function wp_kses_named_entities($matches)
{
    global $allowedentitynames;
    if (empty($matches[1])) {
        return '';
    }
    $i = $matches[1];
    return (!in_array($i, $allowedentitynames)) ? "&{$i};" : "&{$i};";
}

WordPress Version: 4.3

/**
 * Callback for wp_kses_normalize_entities() regular expression.
 *
 * This function only accepts valid named entity references, which are finite,
 * case-sensitive, and highly scrutinized by HTML and XML validators.
 *
 * @since 3.0.0
 *
 * @global array $allowedentitynames
 *
 * @param array $matches preg_replace_callback() matches array
 * @return string Correctly encoded entity
 */
function wp_kses_named_entities($matches)
{
    global $allowedentitynames;
    if (empty($matches[1])) {
        return '';
    }
    $i = $matches[1];
    return (!in_array($i, $allowedentitynames)) ? "&{$i};" : "&{$i};";
}

WordPress Version: 3.7

/**
 * Callback for wp_kses_normalize_entities() regular expression.
 *
 * This function only accepts valid named entity references, which are finite,
 * case-sensitive, and highly scrutinized by HTML and XML validators.
 *
 * @since 3.0.0
 *
 * @param array $matches preg_replace_callback() matches array
 * @return string Correctly encoded entity
 */
function wp_kses_named_entities($matches)
{
    global $allowedentitynames;
    if (empty($matches[1])) {
        return '';
    }
    $i = $matches[1];
    return (!in_array($i, $allowedentitynames)) ? "&{$i};" : "&{$i};";
}