#21344 closed enhancement (fixed)
Add hook "restrict_manage_comments" to class-wp-comments-list-table.php for additional filtering by plugins
Reported by: | hardy101 | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 3.4.1 |
Component: | Comments | Keywords: | has-patch needs-codex |
Focuses: | Cc: |
Description
The comments list (class-wp-comments-list-table.php) in wp-admin needs a hook to allow plugins to do additional filtering of comments, just like class-wp-posts-list-table.php on line 220.
do_action( 'restrict_manage_posts' );
The new line of code would be in class-wp-comments-list-table.php:
do_action( 'restrict_manage_comments' );
A one-line patch (attached) does the trick.
Attachments (2)
Change History (9)
#1
follow-up:
↓ 2
@
12 years ago
- Milestone changed from Awaiting Review to 3.5
Yes, I found myself needing such a hook several times in the past.
But I think the hook should be placed in the prepare_items() method, not between HTML tags.
#2
in reply to:
↑ 1
@
12 years ago
Scribu,
Agreed - I just thought I'd parallel the current behavior and do the one-line patch for simplicity. I'll look into a patch for prepare_items()
#3
@
12 years ago
The problem with adding the proposed hook to prepare_items() is that we actually need to be able to output a form element on edit-comments.php just prior to the "Filter" button. (e.g. add a select list that lets us filter by user_id).
class-wp-comments-list-table.php does it's own form element via extra_tablenav(), where our hook would also live.
The way it works now, to build edit-comments.php's page:
display()
calls
display_tablenav()
and class-wp-comments-list-table.php overrides
extra_tablenav()
to add a "comment_type" select list, then
display()
continues to build the rest of the rows in the edit-comments.php table.
Our simple hook (see attached "comments-table-hook-patch.diff") would allow us to place our own form element(s) prior to the filter button for a clean look. The "manage_comments_nav" filter is too late and would put our new form elements after the Filter button, which makes for an odd UX.
So after some additional thought, I still vote for putting the hook in class-wp-comments-list-table.php -> extra_tablenav() like the posts list currently does.
#4
follow-up:
↓ 5
@
12 years ago
Right, I was actually thinking of a hook for altering the query arguments passed to get_comments(). Nevermind.
#5
in reply to:
↑ 4
@
12 years ago
Cool. Attaching a screenshot for people that want visualize the scenario. Shout-out to WP royalty.
Replying to scribu:
Right, I was actually thinking of a hook for altering the query arguments passed to get_comments(). Nevermind.
Allow plugins to do additional filtering of comment list in class-wp-comments-list-table.php