[wp-hackers] Extending comment filter in comments admin

Ravi Narayan Sarma ravi-lists at g8o.net
Sun Dec 27 16:24:42 UTC 2009

On Dec 24, 2009, at 7:19 PM, Mike Schinkel wrote:
> Sounds like a great plugin Ravi, hope you can get it working.

Thank you Mike. I am done with my first cut of the plugin. While I waited for the plugin approval process, I also managed to code in some of the features mentioned below. Currently the plugin does the following:

* Adds options to the Comments Admin page, for each comment, to mark it as Todo, Replied, or Ignore.

* Comment blocks are given a background colour based on their state (default = Todo).

* Comments with a response from the post author are background coloured (light blue right now) to indicate that. Soon there will be an option to bulk mark all such comments as “Replied”.

* Comments by post authors are automatically coloured “ignored” (though not marked so).

* When new comments are added their parent (if any) is marked as responded if the response is by the post author. Currently this happens even if the original comment is by post author himself (i.e., author responding to himself ;-)), which perhaps should not be the case.

* A bulk mark option/link in the plugin admin page lets you mark existing comments as responded to by author (background colour = light blue) — this has to be used with care of course, in case your blog has thousands of comments. Mine has hundreds and that went through pretty quick.

I have to say, where it is clear/documented/available, the WP filter/action mechanism is a splendid mechanism to inject code. All of the above functionality was achieved in less than 400 lines of code (include CSS, JavaScript, comments and blank lines). Admittedly this is plugin is a 0.8 release so its not fully fleshed out. Nonetheless, that’s a great API for developers.

Another thing: as I went about my effort, I fixed (or so I believe) a few issues in the Codex (e.g: the second arg to wp_comment() was marked as required, though the code suggests its optional). A question regarding the Codex (fodder for the wp-docs list if one exists?) — are Discussion/Talk pages used much in practise? I left a comment on the Discussion page for one of the Codex pages, so I want to make sure it catches some responsible person’s attention.


> Happy Holidays hackers!
> -Mike
> On Dec 24, 2009, at 7:06 PM, Ravi Narayan Sarma wrote:
>> Hello all,
>> so I have been struggling along with my “comment response tracker” plugin; the plan is: in the comments admin page (edit-comments.php) I offer a few options to let the user mark a comment as “todo”, “replied” or “ignore”. Comments that are “todo” are displayed with some sort of background colouring. Also, the current response status is highlighted among the three choices. That’s all been hacked up to the best of my abilities.
>> Now, I figured, wouldn’t it be sweet to let the user “Filter” comments by the response status? Turns out there is a convenient hook “admin_comment_types_dropdown” that lets me extend the filter options offered to the user. The current set of options (“Comments”, “Pings”) is passed down to me and I add in “Todo”, “Replied”, “Ignored” to this list. So far so good. But the next step has me stymied. It seems that _wp_get_comment_list() is where the the status criteria is applied, but there seems to be no hook to influence this process. But then, why would there be an “admin_comment_types_dropdown” hook? Perhaps I am looking in the wrong place.
>> Well, how about another direction… also available is a “manage_comments_nav” action to extend this menu. Akismet uses this to add a “Check for Spam” button. Should I perhaps be following suit, and extend the menu to offer my filtering options, rather than extend the Filter options?
>> Any suggestions would help alleviate my OCD!
>> 	— ravi

More information about the wp-hackers mailing list