在使用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)
站点信息
- 文章2312
- 用户1336
- 访客11622217
每日一句
Compliment yourself daily.
每天夸自己一句。
每天夸自己一句。
How to Ungroup Icons on Windows 11 Taskbar With a Registry Hack (and 2 More Ways)
反编译修改class文件变量
如何在大学成为一名优秀的程序员?
VMware NAT端口映射外网访问虚拟机linux
ubuntu下提取DSDT SSDT
使用HTML和CSS设计磨砂玻璃效果
解决android studio 4.4使用javah失败
vscode使用eslint自动代码格式化
c++浮点运算能力附安卓版
【源码】两种仪表盘
P2P中NAT之间的打洞可能性
jQuery的load方法Cannot read property 'indexOf' of undefined
【开源Roguelike游戏】素地牢源码
新会员