Paged Threaded Comments plugin update

前几天想到一个问题,如果把某个留言删除,它的回复怎么办呢?结果是回复没有从数据库中删除,但它们再也不会被显示了,这是因为列出留言时都是从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”这样的信息。

插件页面已更新:

This entry was posted on Saturday, June 3rd, 2006 at 10:41 am and is filed under Blogging, WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

1 Comment »

Comment by Yidiot
2006-06-03 11:45:28

这个要赞!

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)

Please copy the string IFdIqt to the field below: