Archive for the ‘WordPress’ Category

WordPress插件:Clean Archives Reloaded
Tuesday, June 13th, 2006

今天发现了Viper007Bond上的新插件,Clean Archives Reloaded

摘自Viper007Bond:

The main code in this plugin was originally written by Sebastian Schmieg for the archive page of his “Blix” theme.

The code was later converted to a plugin by Shawn Grimes.

The drawback of both of these versions though was the sheer number of queries required (around 1 per month + 2 per post — it added up quick). So, I decided to make it cache the output so that it was only regenerated when needed and otherwise just pulled with 1 query from the database. I was also given the idea by Chris O’Rourke to use moo.fx to make the months collapsable as many people’s archives pages were getting rather long.

效果见右上导航栏的Archives页面,或者Viper007Bond的Archives,比较cool.

WordPress中文文档翻译倡议
Sunday, June 4th, 2006

Zhang-Zi倡议广大WordPress中文用户把WP的文档翻译成中文,以方便大家。

希望广大网友能够参与到这个项目中来,在让他人得到好处的同时,也锻炼自己的英文阅读能力,同时对WordPress有更深入的理解。

倡议发表在http://zhiqiang.org/blog/322.html,有兴趣的快去看看。

Paged Threaded Comments plugin update
Saturday, June 3rd, 2006

前几天想到一个问题,如果把某个留言删除,它的回复怎么办呢?结果是回复没有从数据库中删除,但它们再也不会被显示了,这是因为列出留言时都是从comment_reply_ID为0即顶层的留言开始递归。 Brian’s Threaded CommentsKeyvan’s Paged Comments Plugin似乎都没有考虑这个问题。

WordPress文档中有一页plugin api,里面列出了delete_comment这个hook,正是我想要的。在源代码中看了一下,hook到它的函数是在从数据库删除留言之前被调用的,这也比较合理。于是写了一个函数repair_comment_reply_ID,取得要删除的留言的comment_reply_ID,并赋给所有comment_repley_ID为要删除comment_ID的留言。然后用add_action函数把它hook上去。

现在的行为是删除留言后,其回复作为更上层的留言的回复出现(如果没有则作为顶层留言)。另外加了些代码来显示thread个数,即在留言区域上方显示“# comments in # threads”这样的信息。

插件页面已更新:

WordPress Plugin: Trackback Validator Plugin
Friday, June 2nd, 2006

Blog在DoNews的时候,收到一些comment spam。如今换到自己的空间,comment spam不见了,全是trackback spam,实在想不出什么好的方法。

今天在Blogging Pro上看到了Trackback Validator Plugin的介绍,感觉原理很简单,可能也比较有效吧。这是Rice的一些人研究的,目前只是看Trackback的发送者有没有在它页面上链接你的日志,插件有一个选项把trackback spam发送给他们以供研究,可能以后会根据语义判断,或者会像Akismet一样?

插件主页在这里:Trackback Validator Plugin

去年就开始发布了,但似乎用的人不多,搜索出来的结果也不多。希望它能起到好的效果。

Paged Threaded Comments 插件
Tuesday, May 23rd, 2006

English page: http://www.qingbo.org/blog/?p=54

这个插件是Brian’s Threaded Comments和Keyvan的WordPress Paged Comments Plugin的结合。Trustin Lee曾经做了一个插件Threaded and Paged Comments Plugin for WordPress 1.5,但结构比较复杂,我把其中的关键SQL语句和函数取出,使得两个插件可以顺利地结合起来。现在两个插件被放在同一个目录下(除了comments-paged.php),结构较为整洁了。

下载(zip包,2006-06-08)

更新:

2006-10-07:

  • 修正了thread-event.js中一个Bug。现在点击“Reply to this comment”之后’+'和’-'图标如预想的那样显示,以前总是错误。
  • 修正了array_merge在PHP5中的问题。谢谢Andy

2006-06-08:

  • 修正了在更新Threaded Comments选项时的Bug。

2006-06-03:

  • 向delete_comment添加一个hook,在删除某留言时,它的回复都得到它的reply ID。之前留言被删除后回复不再显示。
  • 添加了代码在留言区域上方显示thread个数。效果见下面。

2006-05-24:

  • 将图标文件转换为gif格式,弥补IE6不支持透明PNG的问题。

安装步骤:

  1. 解压zip包,得到一个PagedThreadedComments目录和一个comments-paged.php文件。
  2. 将PagedThreadedComments目录上传至WordPress插件目录下(wp-content/plugins/)。
  3. 将comments-paged.php文件上传至你使用的主题目录下(wp-content/themes/yourtheme/)。
  4. 在该主题目录中,编辑每个加了留言功能的页面模板(如single.php),把comments_template()调用替换为
    if (function_exists('paged_comments_template')) paged_comments_template();
    else comments_template();
  5. 在WordPress面板中激活Paged Threaded Comments插件。
  6. 现在应该已经可以使用,如果与主题不搭配,请修改插件目录中的thread-style.css

默认最后一页显示最近的10个thread,最新的排在最上面。在paged-comments-config.php中可以修改这个行为,以及其它一些选项。Thread的嵌套深度请在WP面板选项中修改。

仅在WordPress 2.02中测试过。如果有什么问题,请留言或发邮件给我。

许多朋友问怎么用Gravatar。Brian的插件中使用$c作为循环变量,所以与许多插件不兼容。有时间或许我会修改它使之与其它插件相兼容,不过这里有个方案可以凑合:

  • 这个文件解压到你的插件目录,并激活它。这是一个修改过的gravatar.php。
  • 在comments-paged.php的合适位置添加这样的代码: <img src=’<?php gravatar($c->comment_author_email); ?>’ />

当然需要一些CSS或HTML来美化它:)

Paged Threaded Comments plugin
Tuesday, May 23rd, 2006

中文页面: http://www.qingbo.org/blog/?p=55

This plugin is a combination of Brian’s Threaded Comments and Keyvan’s WordPress Paged Comments Plugin. Trustin Lee has written a plugin Threaded and Paged Comments Plugin for WordPress 1.5, but the structure is complicated. I borrowed the SQL statements and functions of it, and made the two plugins work together. Now the structure is tidier, since the plugin files are put into one directory, except the comments-paged.php file.

Download(zip file, 2006-06-08)

Update:

2006-10-07:

  • Fixed a bug in thread-event.js. Now afer clicking "Reply to this comment", the ‘+’ and ‘-’ pictures display as they should be.
  • Fixed the array_merge problem with PHP5. Thanks to Andy.

2006-06-08:

  • Fixed a bug with the updating of Threaded Comments options.

2006-06-03:

  • Added a hook to delete_comment so that when the parent comment is deleted, the child gets the reply ID of it. Previously, the replies no longer display when the parent is deleted.
  • Added the code to display the number of threads above comments area. See the effect below.

2006-05-24:

  • Converted icon files to gif format to solve the problem that IE6 doesn’t support transparent PNG file.

Installation:

  1. Unzip the archive. There should be a PagedThreadedComments directory and a comments-paged.php file.
  2. Upload PagedThreadedComments directory to WordPress plugin directory (wp-content/plugins/)。
  3. Upload comments-paged.php file to the theme directory you are currently using(wp-content/themes/yourtheme/)。
  4. In this theme directory, edit every template file that is comments-enabled (such as single.php). And the comments_template() function call should be replaced by the following code:
    if (function_exists('paged_comments_template')) paged_comments_template();
     else comments_template();
  5. Activate Paged Threaded Comments plugin in the WordPress admin panel.
  6. Now the plugin should work. If the comments style does not fit your theme, modify the file thread-style.css in the plugin directory.

By default, the last page shows 10 threads, with the latest on the top. You can change this behaviour and modify other options in paged-comments-config.php. If you want to modify the max nesting level, please go to WP admin panel.

Only tested in WordPress 2.02-2.04. Any problems, please leave a comment, or directly send a mail to me.

Many people asked me how to use gravatar. Brian used $c in the comment loop, and that’s why it’s not compatible with gravatar. When time allows, I’ll modify the plugin to let it be compatible with other plugins, but for now here is a "dirty" solution:

  • Extract this file to your plugins directory, and activate the plugin. This is a modified version of gravatar.php.
  • Inside write-comment function of comments-paged.php, add codes like <img src=’<?php gravatar($c->comment_author_email); ?>’ />
    in an appropriate place.

Of course, you need some CSS or HTML to beautify it:)