为主题添加评论表情

1.创建smiley.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script type="text/javascript" language="javascript">     
/* <![CDATA[ */    
    function grin(tag) {     
        var myField;     
        tag = ' ' + tag + ' ';     
        if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {     
            myField = document.getElementById('comment');     
        } else {     
            return false;     
        }     
        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();     
        }     
    }     
/* ]]> */    
</script>     
<div id="smilelink">     
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_mrgreen.gif" title="嘿黑" alt="嘿黑" /></a>  
<a onclick="javascript:grin(':evil:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_evil.gif" title="抠鼻" alt="抠鼻" /></a>  
<a onclick="javascript:grin(':shock:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_eek.gif" title="吓到了" alt="吓到了" /></a>  
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_exclaim.gif" title="嘿黑" alt="嘿黑" /></a>  
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_idea.gif" title="嘿黑" alt="嘿黑" /></a>  
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_lol.gif" title="嘿黑" alt="嘿黑" /></a>  
<a onclick="javascript:grin(':oops:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_redface.gif" title="可爱" alt="可爱" /></a>  
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_mad.gif" title="嘿黑" alt="嘿黑" /></a>  
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_razz.gif" title="嘿黑" alt="嘿黑" /></a>  
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_rolleyes.gif" title="嘿黑" alt="嘿黑" /></a>  
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_smile.gif" title="嘿黑" alt="嘿黑" /></a>  
 
<a onclick="javascript:grin(':?:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_question.gif" title="疑问" alt="疑问" /></a>  
<a onclick="javascript:grin(':sad:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_sad.gif" title="伤心" alt="伤心" /></a>  
<a onclick="javascript:grin(':grin:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_biggrin.gif" title="奸笑" alt="奸笑" /></a>  
<a onclick="javascript:grin(':eek:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_surprised.gif" title="震惊" alt="震惊" /></a>  
<a onclick="javascript:grin(':???:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_confused.gif" title="撇嘴" alt="撇嘴" /></a>  
<a onclick="javascript:grin(':cool:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_cool.gif" title="酷" alt="酷" /></a>  
<a onclick="javascript:grin(':twisted:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_twisted.gif" title="狂怒" alt="狂怒" /></a>  
<a onclick="javascript:grin(':wink:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_wink.gif" title="鼓掌" alt="鼓掌" /></a>  
<a onclick="javascript:grin(':arrow:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_arrow.gif" title="⊙﹏⊙b汗" alt="⊙﹏⊙b汗" /></a>   
<a onclick="javascript:grin(':neutral:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_neutral.gif" title="鄙视" alt="鄙视" /></a>  
<a onclick="javascript:grin(':mrgreen:')"><img src="/wp-content/themes/当前主题名/img/smilies/icon_cry.gif" title="嘿黑" alt="嘿黑" /></a>  
 
</div>

2.修改comment.php文件:

找到:<!-- <span data-type="comment-insert-smilie" class="muted comt-smilie"><i class="icon-thumbs-up icon12"></i> 表情 -->

1
<!-- <span data-type="comment-insert-smilie" class="muted comt-smilie"><i class="icon-thumbs-up icon12"></i> 表情</span> -->

改为:<?php include(TEMPLATEPATH . '/smiley.php'); ?>

1
<?php include(TEMPLATEPATH . '/smiley.php'); ?>


>>原创文章,欢迎转载。转载请注明:转载自Mlldxe's Blog,谢谢!
>>原文链接地址:为主题添加评论表情
点赞
  1. BigCoke说道:
    Google Chrome Windows 7

    不是有owo表情吗,要这么麻烦 :huaji2:

    1. _犬's说道:
      Safari iPhone iOS 10.3.3

      :yi: 同样的效果

  2. waxxh说道:
    Google Chrome Windows 7

    很棒,收了收了 :xiaoyan:

发表评论

电子邮件地址不会被公开。 必填项已用*标注