在使用wordpress的侧边栏中很多同学会发现有的wordpress有这样一个功能 ' . '' . get_avatar($count, 58) . ' ';
}
return $mostactive;
} 原主题这个小工具是显示不了最近访客的,百度一下看到歧路亡羊博客里面有介绍实现,但是不能抓取到QQ或者其它新浪的头像。于是我自己整了一套,就是上面的代码。 接下来是小工具代码:

//读者墙
function zsofa_most_active_friends($friends_num = 10) {
global $wpdb;
$counts = $wpdb->get_results("SELECT * FROM (SELECT * FROM $wpdb->comments) AS tempcmt GROUP BY comment_author_email ORDER BY comment_date DESC LIMIT $friends_num");
foreach ($counts as $count) {
$c_url = $count->comment_author_url;
if ($c_url == '') $c_url = get_bloginfo('url');
$mostactive .= '//读者墙reader
class readerWidget extends WP_Widget {
function readerWidget(){
$widget_ops = array('classname'=>'widget_reader','description'=>'侧边栏显示读者墙');
$control_ops = array('width'=>250,'height'=>300);
$this->WP_Widget(false, '[FO]读者墙', $widget_ops, $control_ops);
}
function form($instance){
$instance = wp_parse_args((array)$instance,array('title'=>'读者墙','readerNum'=>'24'));//默认值
$title = htmlspecialchars($instance['title']);
$readerNum = htmlspecialchars($instance['readerNum']);
echo '';
echo '';
}
function update($new_instance,$old_instance){
$instance = $old_instance;
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
$instance['readerNum'] = strip_tags(stripslashes($new_instance['readerNum']));
return $instance;
}
function widget($args, $instance){
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('活跃读者','yang') : $instance['title']);//小工具前台标题
$title = $title;
$readerNum = $instance['readerNum'];
echo $before_widget; //id开始框
if( $title ) echo $before_title . $title . $after_title; //标题
if (function_exists('zsofa_most_active_friends')) { echo "- " . zsofa_most_active_friends($readerNum) . "
register_widget('readerWidget'); OK了,大功告成! 收藏的用户(0) X
正在加载信息~
推荐阅读
最新回复 (0)
站点信息
- 文章2313
- 用户1336
- 访客11757018
每日一句
Life is short; Live it!
人生苦短,活出精彩。
人生苦短,活出精彩。
信鸽推送报错NSObject checkTargetOtherLinkFlagForObjc
简单利用Clover四叶草安装U盘安装黑苹果
学习使用Java注解
OllyDbg中如何找出B模块中所有调用了A模块的C方法的地方
解决SSH客户端中文乱码
10年后,Android应用程序仍然比iOS应用程序差
C++11特性里面的thread
XPosed微信自动生成二维码
解决android studio "found an invalid color"的问题
T9社区注册方法【勼适様鲃女尔懟死】
Thinkpad x1 Extreme黑苹果10.14.5安装完成
基于大白主题增加图片本地化的功能
Linux系统查看CPU使用率的几个命令
新会员