fresh//comments

Note that Fresh Comments 1.2.1 is out.

I written a little widget for WordPress during my weekend. I call it Fresh Comments after I search in the thesaurus for the word ‘recent’. It wasn’t the best widget around of course, but you can try it out and play around with it if you have got a blog that supports widgets. You can download WordPress’ widget plugin.

What is Fresh Comments 1.0

Fresh Comments 1.0 is a that displays the latest approved comments submitted by your visitors and also gives you – the owner – better control on how your recent comments are displayed. Go straight to download Fresh Comments.

Click on the icon to configure Fresh Comments.

(Click on the icon to configure Fresh Comments.)

To use it, you’ll need to placed in your wp-content/plugins folder and then activate it. Finally, check it out in your admin interface at Presentation -> Sidebar Widgets to add or remove Fresh Comments widget by dragging around.

The available options

Here are the tags that you can use:

  • Title – Give the widget a name to be displayed in your blog.
  • Before – This is where you can insert HTML before all fresh comments are displayed. Recommended that you put <ul> here.
  • After – This is where you can insert HTML after all fresh comments are displayed. Recommended that you put </ul> here.
  • No. of comments – Number of comments to be displayed in descending chronological order for your fresh comments section. (Only takes a value of ’1′ or more.)
  • No. of preview words – Displays only the number of words you specify as a comment preview. (Only takes a value of ’1′ or more.)
  • Format – Allows you to specify how you want each line of fresh comment to be generated. You can click on ‘(reset)’ to go back to the default format. Read more about the formatting options below.

Configuration screen of Fresh Comments.

(Above is the configuration screen of Fresh Comments 1.0)

Using the formatting tags

  • %comment_author%
  • %comment_author_url%
  • %comment_content%
  • %comment_preview% – Displays the first few words of the comments. The number of preview words is specified in the ‘No. of preview words’ option as mentioned above.
  • %post_title%
  • %comment_permalink% – This displays the URI of the comment in your post.
  • %post_permalink% – This displays the URI of your post.

Most of the tags are pretty much self explanatory. To add a tag, just click or highlight within the formatting textbox and then click on the tag you wish to insert.

Below are some examples of formats you can use:

Format:

<li><a href="%comment_permalink%">%comment_author% in %post_title%</a>: %comment_preview%</li>

Format to HTML:

<li><a href="http://beconfused.com/blog/2006/03/22/busy-week/#comment-9812">Mr. Dew in busy//week</a>: Well, it's okay. I don't think I can do much</li>

Displayed in browser:

<li><a href="http://beconfused.com/blog/2006/03/22/busy-week/#comment-9812">Mr. Dew in busy//week</a>: Well, it's okay. I don't think I can do much</li>

Other examples of formats:

<li><a TARGET="_blank" href="%comment_author_url%">%comment_author%</a> in <a href="%comment_permalink%">%post_title%</a>: <a href="%comment_permalink%">%comment_preview% [...]</a></li>

<li><a href="%comment_author_url%">%comment_author%</a> says, <a href="%comment_permalink%">"%comment_preview%..."</a></li>

Using Fresh Comment widget in your sidebar.

(Using Fresh Comment widget in your sidebar.)

Final words

I used what Alex King has found in phpMyAdmin‘s source codes to insert the tags to the textarea via JavaScript.

I also learn a lot from Automattic‘s Google search and del.icio.us widgets.

This is the first plugin that I released and the first widget I wrote. Please be more forgiving if it didn’t work out for you guys. Feel free to comment about anything. :)

Note that Fresh Comments 1.2.1 is out.

The source code for Fresh Comments 1.0 is distributed under GPL (General Public License), meaning that you can freely modify and distribute this source code.

[By the way, //beconfused doesn't use Fresh Comments 1.0 ironically as the layout doesn't support widgets but I'm creating a new layout to replace this current one and that'll definately support widgets.]