smilies_init

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

WordPress Version: 6.4

/**
 * Converts smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // Don't bother setting up smilies if they are disabled.
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => "🙂",
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => "🙄",
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => "🙁",
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => "🙁",
            ':-)' => "🙂",
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => "🙁",
            ':)' => "🙂",
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    /**
     * Filters all the smilies.
     *
     * This filter must be added before `smilies_init` is run, as
     * it is normally only run once to setup the smilies regex.
     *
     * @since 4.7.0
     *
     * @param string[] $wpsmiliestrans List of the smilies' hexadecimal representations, keyed by their smily code.
     */
    $wpsmiliestrans = apply_filters('smilies', $wpsmiliestrans);
    if (count($wpsmiliestrans) === 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern".
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // New subpattern?
        if ($firstchar !== $subchar) {
            if ('' !== $subchar) {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern".
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern".
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 6.3

/**
 * Converts smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // Don't bother setting up smilies if they are disabled.
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => "🙂",
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => "🙄",
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => "🙁",
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => "🙁",
            ':-)' => "🙂",
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => "🙁",
            ':)' => "🙂",
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    /**
     * Filters all the smilies.
     *
     * This filter must be added before `smilies_init` is run, as
     * it is normally only run once to setup the smilies regex.
     *
     * @since 4.7.0
     *
     * @param string[] $wpsmiliestrans List of the smilies' hexadecimal representations, keyed by their smily code.
     */
    $wpsmiliestrans = apply_filters('smilies', $wpsmiliestrans);
    if (count($wpsmiliestrans) === 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern".
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // New subpattern?
        if ($firstchar != $subchar) {
            if ('' !== $subchar) {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern".
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern".
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 6.1

/**
 * Converts smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // Don't bother setting up smilies if they are disabled.
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => "🙂",
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => "🙄",
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => "🙁",
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => "🙁",
            ':-)' => "🙂",
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => "🙁",
            ':)' => "🙂",
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    /**
     * Filters all the smilies.
     *
     * This filter must be added before `smilies_init` is run, as
     * it is normally only run once to setup the smilies regex.
     *
     * @since 4.7.0
     *
     * @param string[] $wpsmiliestrans List of the smilies' hexadecimal representations, keyed by their smily code.
     */
    $wpsmiliestrans = apply_filters('smilies', $wpsmiliestrans);
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern".
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // New subpattern?
        if ($firstchar != $subchar) {
            if ('' !== $subchar) {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern".
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern".
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 5.5

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // Don't bother setting up smilies if they are disabled.
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => "🙂",
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => "🙄",
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => "🙁",
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => "🙁",
            ':-)' => "🙂",
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => "🙁",
            ':)' => "🙂",
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    /**
     * Filters all the smilies.
     *
     * This filter must be added before `smilies_init` is run, as
     * it is normally only run once to setup the smilies regex.
     *
     * @since 4.7.0
     *
     * @param string[] $wpsmiliestrans List of the smilies' hexadecimal representations, keyed by their smily code.
     */
    $wpsmiliestrans = apply_filters('smilies', $wpsmiliestrans);
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern".
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // New subpattern?
        if ($firstchar != $subchar) {
            if ('' !== $subchar) {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern".
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern".
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 5.4

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // Don't bother setting up smilies if they are disabled.
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => "🙂",
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => "🙄",
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => "🙁",
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => "🙁",
            ':-)' => "🙂",
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => "🙁",
            ':)' => "🙂",
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    /**
     * Filters all the smilies.
     *
     * This filter must be added before `smilies_init` is run, as
     * it is normally only run once to setup the smilies regex.
     *
     * @since 4.7.0
     *
     * @param string[] $wpsmiliestrans List of the smilies' hexadecimal representations, keyed by their smily code.
     */
    $wpsmiliestrans = apply_filters('smilies', $wpsmiliestrans);
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern".
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // New subpattern?
        if ($firstchar != $subchar) {
            if ('' != $subchar) {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern".
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern".
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 4.7

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => "🙂",
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => "🙄",
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => "🙁",
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => "🙁",
            ':-)' => "🙂",
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => "🙁",
            ':)' => "🙂",
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    /**
     * Filters all the smilies.
     *
     * This filter must be added before `smilies_init` is run, as
     * it is normally only run once to setup the smilies regex.
     *
     * @since 4.7.0
     *
     * @param array $wpsmiliestrans List of the smilies.
     */
    $wpsmiliestrans = apply_filters('smilies', $wpsmiliestrans);
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern"
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern"
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern"
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 4.6

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => "🙂",
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => "🙄",
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => "🙁",
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => "🙁",
            ':-)' => "🙂",
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => "🙁",
            ':)' => "🙂",
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern"
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern"
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern"
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 4.5

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => "🙂",
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => 'rolleyes.png',
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => "🙁",
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => "🙁",
            ':-)' => "🙂",
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => "🙁",
            ':)' => "🙂",
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern"
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern"
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern"
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 4.2

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'mrgreen.png',
            ':neutral:' => "😐",
            ':twisted:' => "😈",
            ':arrow:' => "➡",
            ':shock:' => "😯",
            ':smile:' => 'simple-smile.png',
            ':???:' => "😕",
            ':cool:' => "😎",
            ':evil:' => "👿",
            ':grin:' => "😀",
            ':idea:' => "💡",
            ':oops:' => "😳",
            ':razz:' => "😛",
            ':roll:' => 'rolleyes.png',
            ':wink:' => "😉",
            ':cry:' => "😥",
            ':eek:' => "😮",
            ':lol:' => "😆",
            ':mad:' => "😡",
            ':sad:' => 'frownie.png',
            '8-)' => "😎",
            '8-O' => "😯",
            ':-(' => 'frownie.png',
            ':-)' => 'simple-smile.png',
            ':-?' => "😕",
            ':-D' => "😀",
            ':-P' => "😛",
            ':-o' => "😮",
            ':-x' => "😡",
            ':-|' => "😐",
            ';-)' => "😉",
            // This one transformation breaks regular text with frequency.
            //     '8)' => "\xf0\x9f\x98\x8e",
            '8O' => "😯",
            ':(' => 'frownie.png',
            ':)' => 'simple-smile.png',
            ':?' => "😕",
            ':D' => "😀",
            ':P' => "😛",
            ':o' => "😮",
            ':x' => "😡",
            ':|' => "😐",
            ';)' => "😉",
            ':!:' => "❗",
            ':?:' => "❓",
        );
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern"
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern"
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern"
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 4.0

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'icon_mrgreen.gif',
            ':neutral:' => 'icon_neutral.gif',
            ':twisted:' => 'icon_twisted.gif',
            ':arrow:' => 'icon_arrow.gif',
            ':shock:' => 'icon_eek.gif',
            ':smile:' => 'icon_smile.gif',
            ':???:' => 'icon_confused.gif',
            ':cool:' => 'icon_cool.gif',
            ':evil:' => 'icon_evil.gif',
            ':grin:' => 'icon_biggrin.gif',
            ':idea:' => 'icon_idea.gif',
            ':oops:' => 'icon_redface.gif',
            ':razz:' => 'icon_razz.gif',
            ':roll:' => 'icon_rolleyes.gif',
            ':wink:' => 'icon_wink.gif',
            ':cry:' => 'icon_cry.gif',
            ':eek:' => 'icon_surprised.gif',
            ':lol:' => 'icon_lol.gif',
            ':mad:' => 'icon_mad.gif',
            ':sad:' => 'icon_sad.gif',
            '8-)' => 'icon_cool.gif',
            '8-O' => 'icon_eek.gif',
            ':-(' => 'icon_sad.gif',
            ':-)' => 'icon_smile.gif',
            ':-?' => 'icon_confused.gif',
            ':-D' => 'icon_biggrin.gif',
            ':-P' => 'icon_razz.gif',
            ':-o' => 'icon_surprised.gif',
            ':-x' => 'icon_mad.gif',
            ':-|' => 'icon_neutral.gif',
            ';-)' => 'icon_wink.gif',
            // This one transformation breaks regular text with frequency.
            //     '8)' => 'icon_cool.gif',
            '8O' => 'icon_eek.gif',
            ':(' => 'icon_sad.gif',
            ':)' => 'icon_smile.gif',
            ':?' => 'icon_confused.gif',
            ':D' => 'icon_biggrin.gif',
            ':P' => 'icon_razz.gif',
            ':o' => 'icon_surprised.gif',
            ':x' => 'icon_mad.gif',
            ':|' => 'icon_neutral.gif',
            ';)' => 'icon_wink.gif',
            ':!:' => 'icon_exclaim.gif',
            ':?:' => 'icon_question.gif',
        );
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern"
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern"
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern"
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}

WordPress Version: 3.8

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'icon_mrgreen.gif',
            ':neutral:' => 'icon_neutral.gif',
            ':twisted:' => 'icon_twisted.gif',
            ':arrow:' => 'icon_arrow.gif',
            ':shock:' => 'icon_eek.gif',
            ':smile:' => 'icon_smile.gif',
            ':???:' => 'icon_confused.gif',
            ':cool:' => 'icon_cool.gif',
            ':evil:' => 'icon_evil.gif',
            ':grin:' => 'icon_biggrin.gif',
            ':idea:' => 'icon_idea.gif',
            ':oops:' => 'icon_redface.gif',
            ':razz:' => 'icon_razz.gif',
            ':roll:' => 'icon_rolleyes.gif',
            ':wink:' => 'icon_wink.gif',
            ':cry:' => 'icon_cry.gif',
            ':eek:' => 'icon_surprised.gif',
            ':lol:' => 'icon_lol.gif',
            ':mad:' => 'icon_mad.gif',
            ':sad:' => 'icon_sad.gif',
            '8-)' => 'icon_cool.gif',
            '8-O' => 'icon_eek.gif',
            ':-(' => 'icon_sad.gif',
            ':-)' => 'icon_smile.gif',
            ':-?' => 'icon_confused.gif',
            ':-D' => 'icon_biggrin.gif',
            ':-P' => 'icon_razz.gif',
            ':-o' => 'icon_surprised.gif',
            ':-x' => 'icon_mad.gif',
            ':-|' => 'icon_neutral.gif',
            ';-)' => 'icon_wink.gif',
            // This one transformation breaks regular text with frequency.
            //     '8)' => 'icon_cool.gif',
            '8O' => 'icon_eek.gif',
            ':(' => 'icon_sad.gif',
            ':)' => 'icon_smile.gif',
            ':?' => 'icon_confused.gif',
            ':D' => 'icon_biggrin.gif',
            ':P' => 'icon_razz.gif',
            ':o' => 'icon_surprised.gif',
            ':x' => 'icon_mad.gif',
            ':|' => 'icon_neutral.gif',
            ';)' => 'icon_wink.gif',
            ':!:' => 'icon_exclaim.gif',
            ':?:' => 'icon_question.gif',
        );
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $wp_smiliessearch = '/((?:\s|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=\s|$))|((?:\s|^)';
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=\s|$))/m';
}

WordPress Version: 3.7

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(
            ':mrgreen:' => 'icon_mrgreen.gif',
            ':neutral:' => 'icon_neutral.gif',
            ':twisted:' => 'icon_twisted.gif',
            ':arrow:' => 'icon_arrow.gif',
            ':shock:' => 'icon_eek.gif',
            ':smile:' => 'icon_smile.gif',
            ':???:' => 'icon_confused.gif',
            ':cool:' => 'icon_cool.gif',
            ':evil:' => 'icon_evil.gif',
            ':grin:' => 'icon_biggrin.gif',
            ':idea:' => 'icon_idea.gif',
            ':oops:' => 'icon_redface.gif',
            ':razz:' => 'icon_razz.gif',
            ':roll:' => 'icon_rolleyes.gif',
            ':wink:' => 'icon_wink.gif',
            ':cry:' => 'icon_cry.gif',
            ':eek:' => 'icon_surprised.gif',
            ':lol:' => 'icon_lol.gif',
            ':mad:' => 'icon_mad.gif',
            ':sad:' => 'icon_sad.gif',
            '8-)' => 'icon_cool.gif',
            '8-O' => 'icon_eek.gif',
            ':-(' => 'icon_sad.gif',
            ':-)' => 'icon_smile.gif',
            ':-?' => 'icon_confused.gif',
            ':-D' => 'icon_biggrin.gif',
            ':-P' => 'icon_razz.gif',
            ':-o' => 'icon_surprised.gif',
            ':-x' => 'icon_mad.gif',
            ':-|' => 'icon_neutral.gif',
            ';-)' => 'icon_wink.gif',
            // This one transformation breaks regular text with frequency.
            //     '8)' => 'icon_cool.gif',
            '8O' => 'icon_eek.gif',
            ':(' => 'icon_sad.gif',
            ':)' => 'icon_smile.gif',
            ':?' => 'icon_confused.gif',
            ':D' => 'icon_biggrin.gif',
            ':P' => 'icon_razz.gif',
            ':o' => 'icon_surprised.gif',
            ':x' => 'icon_mad.gif',
            ':|' => 'icon_neutral.gif',
            ';)' => 'icon_wink.gif',
            ':!:' => 'icon_exclaim.gif',
            ':?:' => 'icon_question.gif',
        );
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $wp_smiliessearch = '/(?:\s|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')|(?:\s|^)';
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?:\s|$)/m';
}