免插件为wp编辑器添加wp表情修正版[同时支持可视化编辑器和HTML编辑器] » 荒野无灯weblog

Keep It Simple, Stupid.

荒野无灯weblog

免插件为wp编辑器添加wp表情修正版[同时支持可视化编辑器和HTML编辑器]

先看图,呵呵,有图有真相:
:mrgreen:
这次的音乐是:
可惜不是你 – <梁静茹>


还是老规矩,在functions.php中添加:

    if (strpos($_SERVER['REQUEST_URI'], 'post.php') || strpos($_SERVER['REQUEST_URI'], 'post-new.php') || strpos($_SERVER['REQUEST_URI'], 'page-new.php') || strpos($_SERVER['REQUEST_URI'], 'page.php')) 
{
    function ihacklog_add_smiley()
    {
        echo <<

        function grin(tag) 
        {
        var myField;
        tag = ' ' + tag + ' ';
        if (document.getElementById('content') && document.getElementById('content').style.display != 'none' && document.getElementById('content').type == 'textarea') 
        {
            myField = document.getElementById('content');

            if (document.selection) 
            {
            myField.focus();
            sel = document.selection.createRange();
            sel.text = tag;
            myField.focus();
            }
            else 
                if (myField.selectionStart || myField.selectionStart == '0') 
                {
                var startPos = myField.selectionStart;
                var endPos = myField.selectionEnd;
                var cursorPos = endPos;
                myField.value = myField.value.substring(0, startPos) + tag + myField.value.substring(endPos, myField.value.length);
                cursorPos += tag.length;
                myField.focus();
                myField.selectionStart = cursorPos;
                myField.selectionEnd = cursorPos;
                }
                else 
                {
                myField.value += tag;
                myField.focus();
                }
        } 
        else 
        {
        tinyMCE.execCommand('mceInsertContent', false, tag);
        }
    }

    var smiley='

疑惑冷笑伤心邪恶感叹微笑红脸咧嘴笑吃惊惊讶困惑耍酷大笑抓狂痛苦转眼珠眨眼好主意自然哭绿脸先生

'; jQuery('#quicktags').before(smiley); EOT; } add_action('admin_footer','ihacklog_add_smiley'); }

2010/07/10更新

Tagged in : 免插件,编辑器,表情,smiley

All Comments (0)
Gravatar image
No Comments