//修改表情文件目录,防止更新时被删除。放在函数模板就ok
add_filter('smilies_src','custom_smilies_src',1,10);
function custom_smilies_src ($img_src, $img, $siteurl){
return $siteurl.'/smilies/'.$img;
}
add_filter('smilies_src','custom_smilies_src',1,10);
function custom_smilies_src ($img_src, $img, $siteurl){
return $siteurl.'/smilies/'.$img;
}
//自定义表情符号对应的文件名,放在函数模板
if ( !isset( $wpsmiliestrans ) ) {
$wpsmiliestrans = array(
':a:' => 'ico_a.gif',
':bai:' => 'ico_bai.gif',
':bishi:' => 'ico_bishi.gif',
':chahan:' => 'ico_chahan.gif',
':chengfeng:' => 'ico_chengfeng.gif',
':chijing:' => 'ico_chijing.gif',
':choumei:' => 'ico_choumei.gif',
':dama:' => 'ico_dama.gif',
':e:' => 'ico_e.gif',
);
}
//结束表情定义
if ( !isset( $wpsmiliestrans ) ) {
$wpsmiliestrans = array(
':a:' => 'ico_a.gif',
':bai:' => 'ico_bai.gif',
':bishi:' => 'ico_bishi.gif',
':chahan:' => 'ico_chahan.gif',
':chengfeng:' => 'ico_chengfeng.gif',
':chijing:' => 'ico_chijing.gif',
':choumei:' => 'ico_choumei.gif',
':dama:' => 'ico_dama.gif',
':e:' => 'ico_e.gif',
);
}
//结束表情定义
//如果表情比较多直接使用表情文件名为表情对应的标签名
//php代码
$s_path="../../smilies/";//你表情的路径
$s_filedata=glob("$s_path*.gif");
foreach($s_filedata as $s_id => $s_name){
$s_name=str_replace("$s_path","",$s_name);
$s_tage=str_replace(".gif","",$s_name);//如此循环替换你需要的名字就好
$s_tage=str_replace("ico_","",$s_name);
echo "':$s_tage:' => '$s_name'<br>";
}
//php代码
$s_path="../../smilies/";//你表情的路径
$s_filedata=glob("$s_path*.gif");
foreach($s_filedata as $s_id => $s_name){
$s_name=str_replace("$s_path","",$s_name);
$s_tage=str_replace(".gif","",$s_name);//如此循环替换你需要的名字就好
$s_tage=str_replace("ico_","",$s_name);
echo "':$s_tage:' => '$s_name'<br>";
}
//接下来生成所需要的图片代码
$s_path="../../smilies/";//你表情的路径
$s_url_path="https://loveyu.org/smilies/";//博客表情对于网址的路径
$s_filedata=glob("$s_path*.gif");
foreach($s_filedata as $s_id => $s_name){
$s_name=str_replace("$s_path","",$s_name);
$s_tage=str_replace(".gif","",$s_name);//如此循环替换你需要的名字就好
$s_tage=str_replace("ico_","",$s_name);
echo "<img src="$s_url_path$s_name" alt=":$s_tage:" onclick='grin(":$s_tage:")' class="wp-smiley-select" />
}
$s_path="../../smilies/";//你表情的路径
$s_url_path="https://loveyu.org/smilies/";//博客表情对于网址的路径
$s_filedata=glob("$s_path*.gif");
foreach($s_filedata as $s_id => $s_name){
$s_name=str_replace("$s_path","",$s_name);
$s_tage=str_replace(".gif","",$s_name);//如此循环替换你需要的名字就好
$s_tage=str_replace("ico_","",$s_name);
echo "<img src="$s_url_path$s_name" alt=":$s_tage:" onclick='grin(":$s_tage:")' class="wp-smiley-select" />
}
//插入表情的js代码
<style type="text/css">
img.wp-smiley-select {cursor: pointer;}
</style>
<script type="text/javascript">
function grin(tag) {
if (typeof tinyMCE != 'undefined') {
grin_tinymcecomments(tag);
} else {
grin_plain(tag);
}
}
function grin_tinymcecomments(tag) {
tinyMCE.execCommand('mceInsertContent', false, ' ' + tag + ' ');
}
function grin_plain(tag) {
var myField;
var myCommentTextarea = "comment";
tag = ' ' + tag + ' ';
if (document.getElementById(myCommentTextarea) && document.getElementById(myCommentTextarea).type == 'textarea') {
myField = document.getElementById(myCommentTextarea);
} 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();
}
}
function moreSmilies() {
document.getElementById('wp-smiley-more').style.display = 'inline';
document.getElementById('wp-smiley-toggle').innerHTML = '<a href="javascript:lessSmilies()">« less</a></span>';
}
function lessSmilies() {
document.getElementById('wp-smiley-more').style.display = 'none';
document.getElementById('wp-smiley-toggle').innerHTML = '<a href="javascript:moreSmilies()">more »</a>';
}
</script>
<style type="text/css">
img.wp-smiley-select {cursor: pointer;}
</style>
<script type="text/javascript">
function grin(tag) {
if (typeof tinyMCE != 'undefined') {
grin_tinymcecomments(tag);
} else {
grin_plain(tag);
}
}
function grin_tinymcecomments(tag) {
tinyMCE.execCommand('mceInsertContent', false, ' ' + tag + ' ');
}
function grin_plain(tag) {
var myField;
var myCommentTextarea = "comment";
tag = ' ' + tag + ' ';
if (document.getElementById(myCommentTextarea) && document.getElementById(myCommentTextarea).type == 'textarea') {
myField = document.getElementById(myCommentTextarea);
} 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();
}
}
function moreSmilies() {
document.getElementById('wp-smiley-more').style.display = 'inline';
document.getElementById('wp-smiley-toggle').innerHTML = '<a href="javascript:lessSmilies()">« less</a></span>';
}
function lessSmilies() {
document.getElementById('wp-smiley-more').style.display = 'none';
document.getElementById('wp-smiley-toggle').innerHTML = '<a href="javascript:moreSmilies()">more »</a>';
}
</script>
下载:洋葱头表情包
Hello!
试试效果!
肯定行的
乱闯进来的,留脚印
欢迎!
搜索过来的,马上试一下~
你这一说我倒想起我要把表情换一换
这样也行啊……
洋葱头多经典啊,百看不厌的。
关键是这是我精简出来的几个,发现使用率不高。把其他几个添加进来
洋葱头悠嘻猴都是经典,混论坛的对他们都有感情了。
这么好的东西一定要收藏!!!
搜藏啦
这一套表情不错 我一直想扒走 可惜没时间捣鼓
现在给你时间,十几分钟就可以搞定!
主要是想发不太一样 如果可以的话能不能把表情图标打包发我一份来
稍等!
看到这个我才想起来,很久都没更新wp版本了.
更新了也没啥用!估计wp更新已经到头了
这个表情不错.
非常可爱的表情!