WordPress评论表情,大家都不陌生,就大前端的实现方法来说说简单自定义评论表情函数,真的很简单哦,亲!0 d: R, B$ L8 ^/ }
2 |* K' V" w( m; y4 E+ w% e
首先,下面的代码Copy到主题function.php文件:
% y8 I5 F4 [0 x% P8 L( k% E7 T3 }* S2 A- B/ j
9 b9 Z- Q: z8 Z/ y5 A l
& w( h1 ]. s0 W( Y0 E
//评论表情- <p>function mytheme_smilies(){</p><p>$a = array( 'mrgreen','razz','sad','smile','oops','grin','eek','???','cool','lol','mad','twisted','roll','wink','idea','arrow','neutral','cry','?','evil','shock','!' );</p><p>$b = array( 'mrgreen','razz','sad','smile','redface','biggrin','surprised','confused','cool','lol','mad','twisted','rolleyes','wink','idea','arrow','neutral','cry','question','evil','eek','exclaim' );</p><p>for( $i=0;$i<22;$i++ ){</p><p>echo '<a title="'.$a[$i].'" href="javascript:grin('."':".$a[$i].":'".')"><img src="'.get_bloginfo('template_url').'/img/smilies/icon_'.$b[$i].'.gif" /></a>';</p><p>}</p><p>}</p>
复制代码 //修改评论表情调用路径- <p>function mytheme_smilies_src ($img_src, $img, $siteurl){</p><p>return get_bloginfo('template_directory').'/img/smilies/'.$img;</p><p>}</p><p>add_filter('smilies_src','mytheme_smilies_src',1,10);</p><p></p>
复制代码 然后,在主题的comment.php中调用函数:mytheme_smilies();. }; A" r' W- y0 M2 a/ X$ b
1 `# F. m8 m/ {3 ?& C
当然,你的表情目录要对应主题目录/img/smilies,也可以通过更改以上php文件来定义表情存放目录。" y" U& _4 ^* i1 K
& P. b$ s+ F9 Y8 ^3 W9 q9 N
一切就绪,没了!是不是很简单呢? G2 N+ G! K- c; N4 z$ s" K- h
4 Z8 I& X/ H* ?2 w6 C8 t2 n
: L7 q y5 D5 A- l7 a; F; |; T
|