Friday, February 23, 2007

Recent Comment Plugin

I have been using Raoul's Simple Recent Comments plugin with some minor mods to it.   I tried to improve on it and asked question in forum, didn't get anywhere at the end.

Raoul's plugin isn't simple and with fairly complicated sql query using clauses like "LEFT OUTER JOIN", "WHERE", "ORDER BY" and "LIMIT" etc.

Now I have rewritten it from the ground up getting hints from WordPress's \wp-admin\index.php file.    This is the file first loaded when you logged in.    I can see recent comments listed there.

My plugin is now very simple with 2 reusable functions written, one to truncate the comment, using PHP's explode and implode, and the other one to calculate time different between when comment was posted and "now".    I can find good use of these functions elsewhere.    Raoul's plugin uses "SUBSTRING(comment_content,1,$src_length) AS com_excerpt" which is far too hard for beginner like me.

On the sidebar I have put them side-by-side for a test.    My [tag]plugin[/tag] is named [tag]ezComments[/tag].

PS: there is an issue on the time different my time zone here and where the server is located.    I could manually adjust to this but there should be a better way I guess.

1 comment: