htmlentities2

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

WordPress Version: 6.3

/**
 * Converts entities, while preserving already-encoded entities.
 *
 * @link https://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
 *
 * @since 1.2.2
 *
 * @param string $text The text to be converted.
 * @return string Converted text.
 */
function htmlentities2($text)
{
    $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
    $translation_table[chr(38)] = '&';
    return preg_replace('/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr($text, $translation_table));
}

WordPress Version: 6.1

/**
 * Converts entities, while preserving already-encoded entities.
 *
 * @link https://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
 *
 * @since 1.2.2
 *
 * @param string $myHTML The text to be converted.
 * @return string Converted text.
 */
function htmlentities2($myHTML)
{
    $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
    $translation_table[chr(38)] = '&';
    return preg_replace('/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr($myHTML, $translation_table));
}

WordPress Version: 5.4

/**
 * Convert entities, while preserving already-encoded entities.
 *
 * @link https://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
 *
 * @since 1.2.2
 *
 * @param string $myHTML The text to be converted.
 * @return string Converted text.
 */
function htmlentities2($myHTML)
{
    $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
    $translation_table[chr(38)] = '&';
    return preg_replace('/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr($myHTML, $translation_table));
}

WordPress Version: 5.1

/**
 * Convert entities, while preserving already-encoded entities.
 *
 * @link https://secure.php.net/htmlentities Borrowed from the PHP Manual user notes.
 *
 * @since 1.2.2
 *
 * @param string $myHTML The text to be converted.
 * @return string Converted text.
 */
function htmlentities2($myHTML)
{
    $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
    $translation_table[chr(38)] = '&';
    return preg_replace('/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr($myHTML, $translation_table));
}

WordPress Version: 4.6

/**
 * Convert entities, while preserving already-encoded entities.
 *
 * @link https://secure.php.net/htmlentities Borrowed from the PHP Manual user notes.
 *
 * @since 1.2.2
 *
 * @param string $myHTML The text to be converted.
 * @return string Converted text.
 */
function htmlentities2($myHTML)
{
    $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
    $translation_table[chr(38)] = '&';
    return preg_replace("/&(?![A-Za-z]{0,4}\\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table));
}

WordPress Version: 3.7

/**
 * Convert entities, while preserving already-encoded entities.
 *
 * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
 *
 * @since 1.2.2
 *
 * @param string $myHTML The text to be converted.
 * @return string Converted text.
 */
function htmlentities2($myHTML)
{
    $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
    $translation_table[chr(38)] = '&';
    return preg_replace("/&(?![A-Za-z]{0,4}\\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table));
}