欢迎来到好人卡资源网,专注网络技术资源收集,我们不仅是网络资源的搬运工,也生产原创资源。寻找资源请留言

【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细

网站源码 sky995 3个月前 (08-26) 118次浏览 0个评论
本博客主题之前是没有表情包评论的功能的,本人之前想着网上找一下typecho表情包的插件,可惜的是本人试过很多typecho的表情包插件效果均不理想,不符合我的要求,偶然之间了解到OwO表情包技术,之前没有过于深入研究,直接照着官网的案例搬了上来。可是发现....插入表情的时候带上了
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细

<code><span class="tag"><img</span> <span class="atn">src</span><span class="pun">=</span><span class="atv">"/OwO/quyin/吐血.png"</span> <span class="atn">alt</span><span class="pun">=</span><span class="atv">""</span> <span class="atn">class</span><span class="pun">=</span><span class="atv">"OwO-img-quyin"</span><span class="tag">></span></code>

这样完整的img标签,占用了许多的评论框空间,由于本人之前一直没时间处理,后面有时间处理的时候发现,网上居然一篇完整详细的typecho任意主题适配OwO的教程都没有...
最后花了两个小时手撕别的用这个OwO表情包技术的主题,最后分析完成后记录在本博客,以便后续大家能更快接入此技术,提高博客用户体验

教程开始(略长)

将OwO核心文件上传至服务器

【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细
这里打包给各位下载,放到任意目录即可
(这里本人是直接放到博客的根目录)
下载地址:OwO_tjcJEB.rar

header里引用核心js和css

typecho官方默认主题的header文件在:
/usr/themes/default/header.php
先上个图:
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细

<code class=" language-html">    <span class="token comment"><span class="com"><!--OwO标签js核心引入 开始--></span></span>
    <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">script</span> <span class="token attr-name"><span class="atn">src</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">/OwO/OwO.min.js</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">script</span><span class="token punctuation"><span class="tag">></span></span></span>
    <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">link</span> <span class="token attr-name"><span class="atn">href</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">/OwO/OwO.min.css</span><span class="token punctuation"><span class="atv">"</span></span></span> <span class="token attr-name"><span class="atn">rel</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">stylesheet</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span>
    <span class="token comment"><span class="com"><!--OwO标签js核心引入 结束--></span></span></code>
HTML

发现了吗,这里的引用要对应之前上传核心文件到网站服务器根目录中的js和css要对应,这里在引用这个OwO之前需要jQuery的技术,没有的话在前面加一个(如果你博客已经引用过jQuery就不用重复引用,不过请注意引用的先后顺序,确保jQuery引用在OwO引用之前):

<code class=" language-html">    <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">script</span> <span class="token attr-name"><span class="atn">src</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">//blog.wm404.com/usr/themes/wmsafe-dux/css/jquery.min.js</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">script</span><span class="token punctuation"><span class="tag">></span></span></span>
    <span class="token comment"><span class="com"><!--OwO标签js核心引入 开始--></span></span>
    <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">script</span> <span class="token attr-name"><span class="atn">src</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">/OwO/OwO.min.js</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">script</span><span class="token punctuation"><span class="tag">></span></span></span>
    <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">link</span> <span class="token attr-name"><span class="atn">href</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">/OwO/OwO.min.css</span><span class="token punctuation"><span class="atv">"</span></span></span> <span class="token attr-name"><span class="atn">rel</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">stylesheet</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span>
    <span class="token comment"><span class="com"><!--OwO标签js核心引入 结束--></span></span></code>
HTML

打开typecho主题的评论核心文件

官方默认的是:/usr/themes/default/comments.php
一般都是主题下方的comments.php文件

添加核心js代码和div

先上个图:
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细

<code class=" language-html"><span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">div</span> <span class="token attr-name"><span class="atn">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">OwO</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token style-attr language-css"><span class="token attr-name"> <span class="atn">style</span></span><span class="token punctuation"><span class="pun">=</span><span class="atv">"</span></span><span class="token attr-value"><span class="token property"><span class="pln">padding</span><span class="pun">-</span><span class="pln">top</span></span><span class="token punctuation"><span class="pun">:</span></span><span class="lit">5px</span><span class="token punctuation"><span class="pun">;</span></span><span class="token property"><span class="pln">padding</span><span class="pun">-</span><span class="pln">left</span></span><span class="token punctuation"><span class="pun">:</span></span><span class="lit">5px</span></span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">div</span><span class="token punctuation"><span class="tag">></span></span></span>
                        <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">script</span><span class="token punctuation"><span class="tag">></span></span></span><span class="token script language-javascript">
                            <span class="token keyword"><span class="kwd">var</span></span> <span class="typ">OwO_demo</span> <span class="token operator"><span class="pun">=</span></span> <span class="token keyword"><span class="kwd">new</span></span> <span class="token class-name"><span class="typ">OwO</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token punctuation"><span class="pun">{</span></span><span class="pln">
                                logo</span><span class="token punctuation"><span class="pun">:</span></span> <span class="token string"><span class="str">'OwO'</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="pln">
                                container</span><span class="token punctuation"><span class="pun">:</span></span> <span class="token object"><span class="pln">document</span></span><span class="token punctuation"><span class="pun">.</span></span><span class="token function"><span class="pln">getElementsByClassName</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token string"><span class="str">'OwO'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">[</span></span><span class="token number"><span class="lit">0</span></span><span class="token punctuation"><span class="pun">]</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="pln">
                                target</span><span class="token punctuation"><span class="pun">:</span></span> <span class="token object"><span class="pln">document</span></span><span class="token punctuation"><span class="pun">.</span></span><span class="token function"><span class="pln">getElementsByClassName</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token string"><span class="str">'OwO-textarea'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">[</span></span><span class="token number"><span class="lit">0</span></span><span class="token punctuation"><span class="pun">]</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="pln">
                                api</span><span class="token punctuation"><span class="pun">:</span></span> <span class="token string"><span class="str">'/OwO/OwO.json'</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="pln">
                                position</span><span class="token punctuation"><span class="pun">:</span></span> <span class="token string"><span class="str">'up'</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="pln">
                                width</span><span class="token punctuation"><span class="pun">:</span></span> <span class="token string"><span class="str">'100%'</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="pln">
                                maxHeight</span><span class="token punctuation"><span class="pun">:</span></span> <span class="token string"><span class="str">'250px'</span></span>
                            <span class="token punctuation"><span class="pun">}</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
                        </span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">script</span><span class="token punctuation"><span class="tag">></span></span></span></code>
HTML

这里讲解一下,那个div就是样式,OwO会自动找寻class引用为OwO的div,将它作为一个容器,然后动态加入相关html子标签,只要将代码像我这样贴上去,保存后,你就可以到随便一篇文章里评论那边就能面看到效果了。
贴个图:
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细

<code><span class="kwd">var</span> <span class="typ">OwO_demo</span> <span class="pun">=</span> <span class="kwd">new</span> <span class="typ">OwO</span><span class="pun">({</span><span class="pln">
    logo</span><span class="pun">:</span> <span class="str">'OwO'</span><span class="pun">,</span><span class="pln">
    container</span><span class="pun">:</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementsByClassName</span><span class="pun">(</span><span class="str">'OwO'</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">],</span><span class="pln">
    target</span><span class="pun">:</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementsByClassName</span><span class="pun">(</span><span class="str">'OwO-textarea'</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">],</span><span class="pln">
    api</span><span class="pun">:</span> <span class="str">'/OwO/OwO.json'</span><span class="pun">,</span><span class="pln">
    position</span><span class="pun">:</span> <span class="str">'up'</span><span class="pun">,</span><span class="pln">
    width</span><span class="pun">:</span> <span class="str">'100%'</span><span class="pun">,</span><span class="pln">
    maxHeight</span><span class="pun">:</span> <span class="str">'250px'</span>
<span class="pun">});</span></code>

上面的“api”后面的地址,必须放你OwO.json的完整路径,只适配根目录往下找,或者引用http(s)的OwO.json,不知道的不用深究跟我保持一样就行,其他的都保持默认就行,其中“position”表示点击那个按钮展开的表情包是在上面展开还是下面展开,这里的up表示向上展开,像down就是向下展开。

然后加入核心自定义方法

官方默认路径:/usr/themes/default/functions.php
打开这个functions.php,往里面加上以下的代码

<code class=" language-php"><span class="token keyword"><span class="kwd">function</span></span> <span class="token function"><span class="pln">themeInit</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$archive</span></span><span class="token punctuation"><span class="pun">)</span></span>
<span class="token punctuation"><span class="pun">{</span></span>

    <span class="token keyword"><span class="kwd">if</span></span> <span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$archive</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="kwd">is</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">'single'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">{</span></span>
        <span class="token variable"><span class="pln">$archive</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">content</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="typ">ParseReply</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$archive</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">content</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token punctuation"><span class="pun">}</span></span>
<span class="token punctuation"><span class="pun">}</span></span>

<span class="token comment"><span class="com">/* 格式化 */</span></span>
<span class="token keyword"><span class="kwd">function</span></span> <span class="token function"><span class="typ">ParseReply</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$content</span></span><span class="token punctuation"><span class="pun">)</span></span>
<span class="token punctuation"><span class="pun">{</span></span>
    <span class="token variable"><span class="pln">$content</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="pln">preg_replace_callback</span></span><span class="token punctuation"><span class="pun">(</span></span>
        <span class="token single-quoted-string string"><span class="str">'/\:\@\(\s*(吐血|滑稽|吃惊|生气|哭泣|die|疑问|肥皂|扶额|哼|大笑|偷看|卖萌|OK|吓死宝宝惹|摇头|睡觉|无语|吃瓜|机智)\s*\)/is'</span></span><span class="token punctuation"><span class="pun">,</span></span>
        <span class="token single-quoted-string string"><span class="str">'ParseQuYinBiaoqingCallback'</span></span><span class="token punctuation"><span class="pun">,</span></span>
        <span class="token variable"><span class="pln">$content</span></span>
    <span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token keyword"><span class="kwd">return</span></span> <span class="token variable"><span class="pln">$content</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span>
<span class="token keyword"><span class="kwd">function</span></span> <span class="token function"><span class="typ">ParseQuYinBiaoqingCallback</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$match</span></span><span class="token punctuation"><span class="pun">)</span></span>
<span class="token punctuation"><span class="pun">{</span></span>

    <span class="token keyword"><span class="kwd">return</span></span> <span class="token single-quoted-string string"><span class="str">'<img class="owo" style="width:66px;height:66px" src="'</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'/OwO/quyin/'</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token function"><span class="pln">urlencode</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$match</span></span><span class="token punctuation"><span class="pun">[</span></span><span class="token number"><span class="lit">1</span></span><span class="token punctuation"><span class="pun">]</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'.png">'</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span></code>
PHP

上图:
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细
其中:

<code><span class="pln">$content </span><span class="pun">=</span><span class="pln"> preg_replace_callback</span><span class="pun">(</span>
        <span class="str">'/\:\@\(\s*(吐血|滑稽|吃惊|生气|哭泣|die|疑问|肥皂|扶额|哼|大笑|偷看|卖萌|OK|吓死宝宝惹|摇头|睡觉|无语|吃瓜|机智)\s*\)/is'</span><span class="pun">,</span>
        <span class="str">'ParseQuYinBiaoqingCallback'</span><span class="pun">,</span><span class="pln">
        $content
    </span><span class="pun">);</span></code>

这里其实是正则,也就匹配OwO.json中的:
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细
不知道小伙伴有没有发现其中的“:@(”,这个就是匹配上面那个正则代码中的“/\:\@(\s*(”,其中的“@”符号是不是很醒目,这个其实就是适配多个表情包用的,像如果你后续要加新的表情包,那么就不要在跟这个“@”符号一样了,可以设置成“&”等等,最后适配代码加上:

<code class=" language-php"><span class="token comment"><span class="com">/* 格式化 */</span></span>
<span class="token keyword"><span class="kwd">function</span></span> <span class="token function"><span class="typ">ParseReply</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$content</span></span><span class="token punctuation"><span class="pun">)</span></span>
<span class="token punctuation"><span class="pun">{</span></span>
    <span class="token variable"><span class="pln">$content</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="pln">preg_replace_callback</span></span><span class="token punctuation"><span class="pun">(</span></span>
        <span class="token single-quoted-string string"><span class="str">'/\:\@\(\s*(吐血|滑稽|吃惊|生气|哭泣|die|疑问|肥皂|扶额|哼|大笑|偷看|卖萌|OK|吓死宝宝惹|摇头|睡觉|无语|吃瓜|机智)\s*\)/is'</span></span><span class="token punctuation"><span class="pun">,</span></span>
        <span class="token single-quoted-string string"><span class="str">'ParseQuYinBiaoqingCallback'</span></span><span class="token punctuation"><span class="pun">,</span></span>
        <span class="token variable"><span class="pln">$content</span></span>
    <span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token variable"><span class="pln">$content</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="pln">preg_replace_callback</span></span><span class="token punctuation"><span class="pun">(</span></span>
        <span class="token single-quoted-string string"><span class="str">'/\:\&\(\s*(吐血|滑稽|吃惊|生气|哭泣|die|疑问|肥皂|扶额|哼|大笑|偷看|卖萌|OK|吓死宝宝惹|摇头|睡觉|无语|吃瓜|机智)\s*\)/is'</span></span><span class="token punctuation"><span class="pun">,</span></span>
        <span class="token single-quoted-string string"><span class="str">'ParseXXXXXXXBiaoqingCallback'</span></span><span class="token punctuation"><span class="pun">,</span></span>
        <span class="token variable"><span class="pln">$content</span></span>
    <span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token keyword"><span class="kwd">return</span></span> <span class="token variable"><span class="pln">$content</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span>
<span class="token keyword"><span class="kwd">function</span></span> <span class="token function"><span class="typ">ParseXXXXXXXBiaoqingCallback</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$match</span></span><span class="token punctuation"><span class="pun">)</span></span>
<span class="token punctuation"><span class="pun">{</span></span>

    <span class="token keyword"><span class="kwd">return</span></span> <span class="token single-quoted-string string"><span class="str">'<img class="owo" style="width:66px;height:66px" src="'</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'/OwO/XXXXXXX/'</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token function"><span class="pln">urlencode</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$match</span></span><span class="token punctuation"><span class="pun">[</span></span><span class="token number"><span class="lit">1</span></span><span class="token punctuation"><span class="pun">]</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'.png">'</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span></code>
PHP

其中的XXXXXXX就是你表情包的标识了,这个是唯一的,要对应图片上面一层的文件夹名,这里提一嘴,文件夹名字不要有特殊字符和空格保持全英文就好
另外ParseQuYinBiaoqingCallback这个是回调方法,如果你新增一组表情包,那么就要在新增新的正则表达式后要重新新增一个方法来适配这个回调函数,不懂的照抄,其实有点编程水准的小伙伴可以仔细看看这些东西的关联关系,我相信你很快就能明白了!

评论输出时替换成img

最后一步就是在访问文章下滑到评论那边后,将评论的内容适配转换成html的表情img,这样才可以展示成图片给用户观看,不然就是一组“: @(吐血) 这是亿条评论”,而没有图片。
打开comments.php
官方默认主题地址:/usr/themes/default/comments.php
将下方代码:

<code class=" language-php"><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span>
<span class="token keyword"><span class="kwd">function</span></span> <span class="token function"><span class="pln">threadedComments</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token punctuation"><span class="pun">,</span></span> <span class="token variable"><span class="pln">$options</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">{</span></span>
    <span class="token variable"><span class="pln">$commentClass</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token single-quoted-string string"><span class="str">'commentlist'</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token keyword"><span class="kwd">if</span></span> <span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">authorId</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">{</span></span>
        <span class="token keyword"><span class="kwd">if</span></span> <span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">authorId</span></span> <span class="token operator"><span class="pun">==</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">ownerId</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">{</span></span>
            <span class="token variable"><span class="pln">$commentClass</span></span> <span class="token punctuation"><span class="pun">.</span></span><span class="token operator"><span class="pun">=</span></span> <span class="token single-quoted-string string"><span class="str">' comment-by-author'</span></span><span class="token punctuation"><span class="pun">;</span></span>
        <span class="token punctuation"><span class="pun">}</span></span> <span class="token keyword"><span class="kwd">else</span></span> <span class="token punctuation"><span class="pun">{</span></span>
            <span class="token variable"><span class="pln">$commentClass</span></span> <span class="token punctuation"><span class="pun">.</span></span><span class="token operator"><span class="pun">=</span></span> <span class="token single-quoted-string string"><span class="str">' comment-by-user'</span></span><span class="token punctuation"><span class="pun">;</span></span>
        <span class="token punctuation"><span class="pun">}</span></span>
    <span class="token punctuation"><span class="pun">}</span></span>

    <span class="token variable"><span class="pln">$commentLevelClass</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">levels</span></span> <span class="token operator"><span class="pun">></span></span> <span class="token number"><span class="lit">0</span></span> <span class="token operator"><span class="pun">?</span></span> <span class="token single-quoted-string string"><span class="str">' comment-child'</span></span>%20<span%20class="token punctuation"><span class="pun">:</span></span> <span class="token single-quoted-string string"><span class="str">' comment-parent'</span></span><span class="token punctuation"><span class="pun">;</span></span>

    <span class="token keyword"><span class="kwd">if</span></span> <span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">url</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">{</span></span>
        <span class="token variable"><span class="pln">$author</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token single-quoted-string string"><span class="str">'<a href="'</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">url</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'" target="_blank"'</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">' rel="external nofollow">'</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">author</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'</a>'</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token punctuation"><span class="pun">}</span></span> <span class="token keyword"><span class="kwd">else</span></span> <span class="token punctuation"><span class="pun">{</span></span>
        <span class="token variable"><span class="pln">$author</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">author</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token punctuation"><span class="pun">}</span></span>
<span class="token delimiter important"><span class="pun">?></span></span></span>

    <span class="token tag"><span class="token punctuation"><span class="pln"><</span></span><span class="pln">li</span> <span class="token attr-name"><span class="pln">id</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">theId</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token punctuation"><span class="pln">"</span></span></span> <span class="token attr-name"><span class="pln">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="pln">comment byuser comment-author-admin bypostauthor depth-</span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token keyword"><span class="pln">echo</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">levels</span></span><span class="token operator"><span class="pun">+</span></span><span class="token number"><span class="lit">1</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="pln"> comment-body</span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span>
    <span class="token keyword"><span class="kwd">if</span></span> <span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">levels</span></span> <span class="token operator"><span class="pun">></span></span> <span class="token number"><span class="lit">0</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">{</span></span>
        <span class="token keyword"><span class="pln">echo</span></span> <span class="token single-quoted-string string"><span class="str">' comment-child'</span></span><span class="token punctuation"><span class="pun">;</span></span>
        <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">levelsAlt</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">' comment-level-odd'</span></span><span class="token punctuation"><span class="pun">,</span></span> <span class="token single-quoted-string string"><span class="str">' comment-level-even'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token punctuation"><span class="pun">}</span></span> <span class="token keyword"><span class="kwd">else</span></span> <span class="token punctuation"><span class="pun">{</span></span>
        <span class="token keyword"><span class="pln">echo</span></span> <span class="token single-quoted-string string"><span class="str">' comment-parent'</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token punctuation"><span class="pun">}</span></span>
    <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">alt</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">' odd'</span></span><span class="token punctuation"><span class="pun">,</span></span> <span class="token single-quoted-string string"><span class="str">' even'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token punctuation"><span class="pln">"</span></span></span><span class="token punctuation"><span class="pln">></span></span></span>
<span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span>
    <span class="token variable"><span class="pln">$host</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token single-quoted-string string"><span class="str">'//sdn.geekzu.org'</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token variable"><span class="pln">$url</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token single-quoted-string string"><span class="str">'/avatar/'</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token variable"><span class="pln">$size</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token single-quoted-string string"><span class="str">'50'</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token variable"><span class="pln">$rating</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="typ">Helper</span><span class="token punctuation"><span class="pun">:</span></span><span class="token punctuation"><span class="pun">:</span></span><span class="token function"><span class="pln">options</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">commentsAvatarRating</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token variable"><span class="pln">$hash</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="pln">md5</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token function"><span class="pln">strtolower</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">mail</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token variable"><span class="pln">$avatar</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token variable"><span class="pln">$host</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token variable"><span class="pln">$url</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token variable"><span class="pln">$hash</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'?s='</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token variable"><span class="pln">$size</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'&r='</span></span>%20<span%20class="token punctuation"><span class="pun">.</span></span> <span class="token variable"><span class="pln">$rating</span></span> <span class="token punctuation"><span class="pun">.</span></span> <span class="token single-quoted-string string"><span class="str">'&d=mm'</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token variable"><span class="pln">$avatar</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="pln">isqq</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">mail</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token delimiter important"><span class="pun">?></span></span></span>
        <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">div</span> <span class="token attr-name"><span class="atn">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">comt-avatar</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span><span class="token tag"><span class="token punctuation"><span class="pln"><</span></span><span class="pln">img</span> <span class="token attr-name"><span class="pln">alt</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="token punctuation"><span class="pln">"</span></span></span> <span class="token attr-name"><span class="pln">data-src</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token keyword"><span class="pln">echo</span></span> <span class="token variable"><span class="pln">$avatar</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token punctuation"><span class="pln">"</span></span></span> <span class="token attr-name"><span class="pln">srcset</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token keyword"><span class="pln">echo</span></span> <span class="token variable"><span class="pln">$avatar</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token punctuation"><span class="pln">"</span></span></span> <span class="token attr-name"><span class="pln">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="pln">avatar photo</span><span class="token punctuation"><span class="pln">"</span></span></span> <span class="token attr-name"><span class="pln">height</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="pln">50</span><span class="token punctuation"><span class="pln">"</span></span></span> <span class="token attr-name"><span class="pln">width</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="pln">50</span><span class="token punctuation"><span class="pln">"</span></span></span> <span class="token attr-name"><span class="pln">src</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token variable"><span class="pln">$aoptions</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="typ">Typecho_Widget</span><span class="token punctuation"><span class="pun">:</span></span><span class="token punctuation"><span class="pun">:</span></span><span class="token function"><span class="pln">widget</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">'Widget_Options'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token variable"><span class="pln">$aoptions</span></span> <span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">themeUrl</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token double-quoted-string string"><span class="str">"img/avatar-default.png"</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token punctuation"><span class="pln">"</span></span></span><span class="token punctuation"><span class="pln">></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">div</span><span class="token punctuation"><span class="tag">></span></span></span>
        <span class="token tag"><span class="token punctuation"><span class="pln"><</span></span><span class="pln">div</span> <span class="token attr-name"><span class="pln">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="pln">comt-main</span><span class="token punctuation"><span class="pln">"</span></span></span> <span class="token attr-name"><span class="pln">id</span></span><span class="token attr-value"><span class="token punctuation"><span class="pln">=</span></span><span class="token punctuation"><span class="pln">"</span></span><span class="pln">div-</span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">theId</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token punctuation"><span class="pln">"</span></span></span><span class="token punctuation"><span class="pln">></span></span></span>
            <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">div</span> <span class="token attr-name"><span class="atn">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">comt-meta</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token style-attr language-css"><span class="token attr-name"> <span class="atn">style</span></span><span class="token punctuation"><span class="pun">=</span><span class="atv">"</span></span><span class="token attr-value"><span class="token property"><span class="pln">margin</span></span><span class="token punctuation"><span class="pun">:</span></span><span class="lit">0</span><span class="token punctuation"><span class="pun">;</span></span></span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span><span class="pln">名称:</span><span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">span</span> <span class="token attr-name"><span class="atn">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">comt-author</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token keyword"><span class="pln">echo</span></span> <span class="token variable"><span class="pln">$author</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">span</span><span class="token punctuation"><span class="tag">></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">div</span><span class="token punctuation"><span class="tag">></span></span></span>
            <span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> 
                <span class="token comment"><span class="com">//$comments->content();</span></span>
                <span class="token comment"><span class="com">//输出的评论将表情包替换成img表情</span></span>
                <span class="token keyword"><span class="pln">echo</span></span> <span class="token function"><span class="typ">ParseReply</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">content</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
            <span class="token delimiter important"><span class="pun">?></span></span></span>
            <span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">div</span> <span class="token attr-name"><span class="atn">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">comt-meta</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span>
                <span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">useragent</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$agentConfig</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token keyword"><span class="kwd">null</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span><span class="token delimiter important"><span class="pun">?></span></span></span><span class="pln"> | </span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">date</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">'Y-m-d'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token entity" title=" "><span class="pln">&nbsp;</span></span><span class="token entity" title=" "><span class="pln">&nbsp;</span></span><span class="token entity" title=" "><span class="pln">&nbsp;</span></span><span class="token entity" title=" "><span class="pln">&nbsp;</span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">reply</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">'回复'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span>
            <span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">div</span><span class="token punctuation"><span class="tag">></span></span></span>
        <span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">div</span><span class="token punctuation"><span class="tag">></span></span></span>
    <span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token keyword"><span class="kwd">if</span></span> <span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token property"><span class="pln">children</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token punctuation"><span class="pun">{</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"><</span></span><span class="tag">ul</span> <span class="token attr-name"><span class="atn">class</span></span><span class="token attr-value"><span class="token punctuation"><span class="pun">=</span></span><span class="token punctuation"><span class="atv">"</span></span><span class="atv">children</span><span class="token punctuation"><span class="atv">"</span></span></span><span class="token punctuation"><span class="tag">></span></span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token variable"><span class="pln">$comments</span></span><span class="token operator"><span class="pun">-</span></span><span class="token operator"><span class="pun">></span></span><span class="token function"><span class="pln">threadedComments</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$options</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span><span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">ul</span><span class="token punctuation"><span class="tag">></span></span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token punctuation"><span class="pun">}</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span>
    <span class="token tag"><span class="token punctuation"><span class="tag"></</span></span><span class="tag">li</span><span class="token punctuation"><span class="tag">></span></span></span><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span> <span class="token punctuation"><span class="pun">}</span></span> <span class="token delimiter important"><span class="pun">?></span></span></span></code>
PHP

加入到这里:
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细
其中最关键的代码其实在这里
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细
这里的意思就是在评论输出的时候将评论带有“: @(吐血)”这类的文字转换成img标签的图片,其实用户评论的时候后台接收的POST评论数据都是文字来的,只是前台在输出的时候替换了!其他主题可以参考此处整理,万变不离其宗的

还有不明白的可以联系QQ1845440070咨询

补充

如果要适配表情包输出的大小,请在主题css样式中添加

<code><span class="pun">.</span><span class="typ">OwO</span> <span class="pun">.</span><span class="pln">biaoqing</span><span class="pun">.表情包名字</span> <span class="pun">{</span><span class="pln">
    margin</span><span class="pun">-</span><span class="pln">bottom</span><span class="pun">:</span> <span class="pun">-</span><span class="lit">0.125rem</span><span class="pun">;</span><span class="pln">
    min</span><span class="pun">-</span><span class="pln">height</span><span class="pun">:</span> <span class="lit">3.5rem</span><span class="pun">;</span><span class="pln">
    height</span><span class="pun">:</span> <span class="lit">1em</span><span class="pun">;</span>
<span class="pun">}</span>
<span class="com">/*修改表情框内表情预览大小,根据实际情况自行测试修改*/</span></code>

其中表情包名字可以自己F12看看:
【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细

补充2 不支持中文图片引用

有些虚拟机是不支持中文引用的,需要改成英文的图片名称才可以,宝塔的话是支持中文引用的,但还是推荐用英文,因为英文的兼容性高,这里附上英文适配的OwO压缩包!
OwO_3s42dK.zip
再然后,那个方法要改一下,因为都变成英文的了,方法也要跟着适配,不能用之前的中文了

<code class=" language-php"><span class="token comment"><span class="com">/* 格式化 */</span></span>
<span class="token keyword"><span class="kwd">function</span></span> <span class="token function"><span class="typ">ParseReply</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$content</span></span><span class="token punctuation"><span class="pun">)</span></span>
<span class="token punctuation"><span class="pun">{</span></span>
    <span class="token variable"><span class="pln">$content</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="pln">preg_replace_callback</span></span><span class="token punctuation"><span class="pun">(</span></span>
        <span class="token single-quoted-string string"><span class="str">'/\:\@\(\s*(tuxue|huaji|chijing|shengqi|kuqi|die|yiwen|feizao|fule|heng|daxiao|toukan|maimeng|OK|xiasi|yaotou|shuijiao|wuyu|chigua|jizhi)\s*\)/is'</span></span><span class="token punctuation"><span class="pun">,</span></span>
        <span class="token single-quoted-string string"><span class="str">'ParseQuYinBiaoqingCallback'</span></span><span class="token punctuation"><span class="pun">,</span></span>
        <span class="token variable"><span class="pln">$content</span></span>
    <span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
    <span class="token keyword"><span class="kwd">return</span></span> <span class="token variable"><span class="pln">$content</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span></code>
PHP

至此,自定义OwO表情包就结束了

最后

希望大家保存一颗学习的心,引用易大师的一句名言:真正的大师永远怀揣着一颗学徒的心,互相交流互相进步才是正道,因为只有相同类型的人才会混迹在一起,所以我希望圈里的人保持一颗高品的心。


好人卡资源网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:【typecho】typecho新增OwO自定义表情包,适配所有主题,全网最详细
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址