convert_smilies

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

WordPress Version: 6.5

/**
 * Converts text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 *
 * @global string|array $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated.
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // Capture the tags as well as in between.
        $stop = count($textarr);
        // Loop stuff.
        // Ignore processing of specific tags.
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag.
            if ('' === $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block.
            if ('' === $ignore_block_element && strlen($content) > 0 && '<' !== $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // Did we exit ignore block?
            if ('' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // Return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: 6.1

/**
 * Converts text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 *
 * @global string|array $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated.
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // Capture the tags as well as in between.
        $stop = count($textarr);
        // Loop stuff.
        // Ignore proessing of specific tags.
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag.
            if ('' === $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block.
            if ('' === $ignore_block_element && strlen($content) > 0 && '<' !== $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // Did we exit ignore block?
            if ('' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // Return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: 5.5

/**
 * Convert text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 *
 * @global string|array $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated.
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // Capture the tags as well as in between.
        $stop = count($textarr);
        // Loop stuff.
        // Ignore proessing of specific tags.
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag.
            if ('' === $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block.
            if ('' === $ignore_block_element && strlen($content) > 0 && '<' !== $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // Did we exit ignore block?
            if ('' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // Return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: 5.4

/**
 * Convert text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 *
 * @global string|array $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated.
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // Capture the tags as well as in between.
        $stop = count($textarr);
        // Loop stuff.
        // Ignore proessing of specific tags.
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag.
            if ('' == $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block.
            if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // Did we exit ignore block?
            if ('' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // Return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: .20

/**
 * Convert text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 *
 * @global string|array $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // capture the tags as well as in between
        $stop = count($textarr);
        // loop stuff
        // Ignore proessing of specific tags
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag
            if ('' == $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block
            if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // did we exit ignore block
            if ('' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: 2.2

/**
 * Convert text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 *
 * @global string|array $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // capture the tags as well as in between
        $stop = count($textarr);
        // loop stuff
        // Ignore proessing of specific tags
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag
            if ('' == $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block
            if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // did we exit ignore block
            if ('' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: .10

/**
 * Convert text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 *
 * @global string|array $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // capture the tags as well as in between
        $stop = count($textarr);
        // loop stuff
        // Ignore proessing of specific tags
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag
            if ('' == $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block
            if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // did we exit ignore block
            if ('' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: 4.3

/**
 * Convert text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 *
 * @global string|array $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // capture the tags as well as in between
        $stop = count($textarr);
        // loop stuff
        // Ignore proessing of specific tags
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag
            if ('' == $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block
            if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // did we exit ignore block
            if ('' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: 3.8

/**
 * Convert text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 * @uses $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated
        $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // capture the tags as well as in between
        $stop = count($textarr);
        // loop stuff
        // Ignore proessing of specific tags
        $tags_to_ignore = 'code|pre|style|script|textarea';
        $ignore_block_element = '';
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            // If we're in an ignore block, wait until we find its closing tag
            if ('' == $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')>/', $content, $matches)) {
                $ignore_block_element = $matches[1];
            }
            // If it's not a tag and not in ignore block
            if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            // did we exit ignore block
            if ('' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content) {
                $ignore_block_element = '';
            }
            $output .= $content;
        }
    } else {
        // return default text.
        $output = $text;
    }
    return $output;
}

WordPress Version: 3.7

/**
 * Convert text equivalent of smilies to images.
 *
 * Will only convert smilies if the option 'use_smilies' is true and the global
 * used in the function isn't empty.
 *
 * @since 0.71
 * @uses $wp_smiliessearch
 *
 * @param string $text Content to convert smilies from text.
 * @return string Converted content with text smilies replaced with images.
 */
function convert_smilies($text)
{
    global $wp_smiliessearch;
    $output = '';
    if (get_option('use_smilies') && !empty($wp_smiliessearch)) {
        // HTML loop taken from texturize function, could possible be consolidated
        $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // capture the tags as well as in between
        $stop = count($textarr);
        // loop stuff
        for ($i = 0; $i < $stop; $i++) {
            $content = $textarr[$i];
            if (strlen($content) > 0 && '<' != $content[0]) {
                // If it's not a tag
                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
            }
            $output .= $content;
        }
    } else {
        // return default text.
        $output = $text;
    }
    return $output;
}