wp_html_split

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

WordPress Version: 6.1

/**
 * Separates HTML elements and comments from the text.
 *
 * @since 4.2.4
 *
 * @param string $input The text which has to be formatted.
 * @return string[] Array of the formatted text.
 */
function wp_html_split($input)
{
    return preg_split(get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE);
}

WordPress Version: 5.4

/**
 * Separate HTML elements and comments from the text.
 *
 * @since 4.2.4
 *
 * @param string $input The text which has to be formatted.
 * @return string[] Array of the formatted text.
 */
function wp_html_split($input)
{
    return preg_split(get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE);
}

WordPress Version: 4.4

/**
 * Separate HTML elements and comments from the text.
 *
 * @since 4.2.4
 *
 * @param string $input The text which has to be formatted.
 * @return array The formatted text.
 */
function wp_html_split($input)
{
    return preg_split(get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE);
}

WordPress Version: .10

/**
 * Separate HTML elements and comments from the text.
 *
 * @since 4.2.4
 *
 * @param string $input The text which has to be formatted.
 * @return array The formatted text.
 */
function wp_html_split($input)
{
    static $regex;
    if (!isset($regex)) {
        $comments = '!' . '(?:' . '-(?!->)' . '[^\-]*+' . ')*+' . '(?:-->)?';
        // End of comment. If not found, match all input.
        $cdata = '!\[CDATA\[' . '[^\]]*+' . '(?:' . '](?!]>)' . '[^\]]*+' . ')*+' . '(?:]]>)?';
        // End of comment. If not found, match all input.
        $regex = '/(' . '<' . '(?(?=!--)' . $comments . '|' . '(?(?=!\[CDATA\[)' . $cdata . '|' . '[^>]*>?' . ')' . ')' . ')/s';
    }
    return preg_split($regex, $input, -1, PREG_SPLIT_DELIM_CAPTURE);
}