添加自定义表情包【已实装】

此篇文章全文转载:原文链接

转载这篇文章主要是方便博主自己,因为改动了主题的源文件,主题更新后文件会被替换,这样就可以根据自己的教程,快速魔改。

源代码更改:

  • 找到 /wp-content/themes/zibll/inc/functions/ 文件夹,打开你的 functions.php ,搜索 “//表情”
图片[1] - 添加自定义表情包【已实装】 - 云晓晨CatchYXC
  • 自定义扩展名+文件夹分类(其他方法请看原文)

将原表情代码注释,添加新表情包代码:

//表情    -------   自定义表情包开始  Start
    if ('smilie' == $type) {
        $but              = '<a class="but btn-input-expand input-smilie mr6" href="javascript:;"><i class="fa fa-fw fa-smile-o"></i><span class="hide-sm">表情</span></a>';
// array变成二维数组,design:表情统称,suffix:表情格式后缀,name:就是原来的名字
        $smilie_icon_args = array(
                array(
                        'design' => 'Emjio',    //分类文件夹名称
                        'suffix' => '.gif',
                        'name' => array('aoman', 'baiyan', 'bishi', 'bizui', 'cahan', 'ciya', 'dabing', 'daku', 'deyi', 'doge', 'fadai', 'fanu', 'fendou', 'ganga', 'guzhang', 'haixiu', 'hanxiao', 'zuohengheng', 'zhuakuang', 'zhouma', 'zhemo', 'zhayanjian', 'zaijian', 'yun', 'youhengheng', 'yiwen', 'yinxian', 'xu', 'xieyanxiao', 'xiaoku', 'xiaojiujie', 'xia', 'wunai', 'wozuimei', 'weixiao', 'weiqu', 'tuosai', 'tu', 'touxiao', 'tiaopi', 'shui', 'se', 'saorao', 'qiudale', 'se', 'qinqin', 'qiaoda', 'piezui', 'penxue', 'nanguo', 'liulei', 'liuhan', 'lenghan', 'leiben', 'kun', 'kuaikule', 'ku', 'koubi', 'kelian', 'keai', 'jingya', 'jingxi', 'jingkong', 'jie', 'huaixiao', 'haqian', 'aini', 'OK', 'qiang', 'quantou', 'shengli', 'woshou', 'gouyin', 'baoquan', 'aixin', 'bangbangtang', 'xiaoyanger', 'xigua', 'hexie', 'pijiu', 'lanqiu', 'juhua', 'hecai', 'haobang', 'caidao', 'baojin', 'chi', 'dan', 'kulou', 'shuai', 'shouqiang', 'yangtuo', 'youling')
                ),
                array(
                        'design' => 'Heo',
                        'suffix' => '.png',
                        'name' => array('3d眼镜','EDG','LPL','beluga','不好意思','不服吗','亲亲','伞兵','倚墙笑','值得肯定','偷偷看','傻笑','再见','出家人','击剑','加班','勉强笑','危险','发红包','吃手','吃瓜','吐血','吵架','呦吼','呲牙笑','哈士奇','哈士奇失去意识','哈士奇失望','哭泣','唱歌','喜欢','嘿哈','大笑','失去信号','失望','头秃','奋斗','好奇','好的','害羞','小丑','小偷','尬笑','尴尬','应援','开心','引起不适','微笑','思考','恶心','恶魔','恶魔恐惧','惊吓','惊吓白眼','惊讶','惬意','感动','愤怒','我看好你','手机相机','打咩','打牌','托腮','扶额','抠鼻','抬眼镜','拜托','捂嘴笑','捂脸','擦汗','放鞭炮','敬礼','整理发型','斗鸡眼','智慧的眼神','月饼','有没有搞错','正确','没招','波吉','泪奔','流汗微笑','流鼻涕','深思','滑稽','滑稽吃瓜','滑稽喝水','滑稽奶茶','滑稽柠檬','滑稽狂汗','滑稽被子','烦恼','熊熊','熊猫','熊猫唱歌','熊猫喜欢','熊猫失望','熊猫意外','熬夜','爆炸','牛年进宝','狂热','狗头','狗头围脖','狗头失望','狗头意外','狗头胖次','狗头花','狗头草','猪头','猪头意外','生病','电话','疑问','疼痛','痛哭','看穿一切','眩晕','睡觉','禁言','笑哭','纠结','绿帽','缺牙笑','翻白眼','老虎意外','耍酷','胡子','菜狗','菜狗花','蒙面滑稽','虎年进宝','被打','裂开','警告','读书','财神红包','超爱','这是啥','送福','送花','错误','阴险','难以置信','面具','饥渴','鬼脸','黑线','鼓掌')
                ),
                array(
                        'design' => 'Cat',
                        'suffix' => '.png',
                        'name' => array('ablobcatheart','ablobcatheartbroken','blobcatheart','blobcatheartpride','blobcatlove','blobcatkissheart','blobcatsnuggle','comfyuee','comfyslep','comfynight','blobcatcomfysweat','blobcatcomfy','blobcatcomftears','blobcatfacepalm','blobcat0_0','blobcatangry','blobbanhammerr','blobcatt','blobcatblush','blobcatcoffee','blobcatcry','blobcatdead','blobcatdied','blobcatdisturbed','blobcatfearful','blobcatfingerguns','blobcatflip','blobcatflower','blobcatgay','blobcatgooglycry','blobcatneutral','blobcatopenmouth','blobcatsadreach','blobcatscared','blobcatnomblobcat','blobcatpresentred','blobcatread','blobcatsipsweat','blobcatsnapped','blobcatthink','blobcattriumph','blobcatumm','blobcatverified','blobcatbox','blobcatcaged','blobcatgooglytrash','blobcatheadphones','blobcathighfive','blobcatmelt','blobcatmeltthumb','blobcatnotlikethis','blobcatsaitama','blobcatyandere','blobcatpeek2','blobcatpeekaboo','blobcatphoto','ablobcatattentionreverse','ablobcatreachrev','ablobcatwave','blobcatalt','blobcatpolice','blobcatshocked','ablobcatrainbow')
                ),
    );
        $smilie_icon      = '';
        $img_url          = ZIB_TEMPLATE_DIRECTORY_URI . '/img/smilies/';
        $lazy_attr        = zib_is_lazy('lazy_other', true) ? 'class="lazyload" data-' : '';
        $but_t            = '';
        foreach ($smilie_icon_args as $smilie_t){
            foreach ($smilie_t['name'] as $smilie_i) {
                $smilie_icon .= '<a class="smilie-icon ' .$smilie_t['design']. ' d-smilie" href="javascript:;" data-smilie="' . $smilie_t['design'].'/'.$smilie_i.$smilie_t['suffix'] . '"><img ' . $lazy_attr . 'src="' . $img_url. $smilie_t['design'].'/' . $smilie_i .$smilie_t['suffix']. '" alt="[' . $smilie_i . ']" /></a>';
            }
            $but_t .= '<a class="but btn-input-expand input-smilie mr6" style="flex-shrink: 0;margin-bottom: 2px;margin-top: 2px;"onclick=\'$(".d-smilie").attr("style","display:none");$(".'.$smilie_t['design'].'").attr("style","display:inline-block")\' href="javascript:;""><span>'.$smilie_t['design'].'</span></a>';
        }
        $first='<script>$(".smilie-icon").attr("style","display:none");$(".'.$smilie_icon_args[0]['design'].'").attr("style","display:inline-block")</script>';
        $dropdown = '<div class="dropdown-smilie scroll-y mini-scrollbar" style="width:300px">' . $smilie_icon . '</div><div class="mini-scrollbar" style="display: flex;overflow-x: auto;overflow-y: hidden;width: 300px;">' . $but_t .$first. '</div>';
}
  • 然后找到 inc\functions\message\class 文件夹,打开 message-class.php,大约在141行,你们看看是匹配正则表达式 g=.*? 什么的
//'. ZIB_TEMPLATE_DIRECTORY_URI . '可以换成你的cdn链接

$con = preg_replace('/\[g=(.*?)\]/', '<img class="smilie-icon" src="'. ZIB_TEMPLATE_DIRECTORY_URI . '/img/smilies/$1">',$con);
图片[2] - 添加自定义表情包【已实装】 - 云晓晨CatchYXC
  • 最后找到 inc\functions 文件夹,打开 zib-comments-list.php ,大约在337行,还是那个正则表达式限制了后缀,和上一步同理
图片[3] - 添加自定义表情包【已实装】 - 云晓晨CatchYXC

代码更改就结束了。

下载表情包:

放入以下路径(如果使用博主这个方法,以前表情包均需改变路径)

图片[4] - 添加自定义表情包【已实装】 - 云晓晨CatchYXC
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 共20条

请登录后发表评论

    • 头像晚饭嘛0
    • 头像晚饭嘛0
    • 头像晚饭嘛0
    • 头像晚饭嘛0
    • 头像没有楼的楼长0
    • 头像羽熙0
    • 头像TeacherDu0
    • 头像棋 | qi1.zone0
    • 头像obaby0