#15019 closed enhancement (fixed)
Filters / Actions for get_comments
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1 |
| Component: | Plugins | Version: | 3.1 |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
Currently in 3.1 (trunk) get_comments() has no filters or actions. I'd like to improve this by adding them following the same format as get_posts >> WP_Query::query uses. As you can see in my patch, it's very minimal, not too much going on here besides these main things:
- New action pre_get_comments to run similar to WP_Query::query pre_get_posts
- New filters / action for specific $post_where, $orderby, $oder, $limit (and some cache-enablers)
- New filter the_comments to modify what's returned in $comments similar to WP_Query::query the_posts
Attachments (4)
Change History (17)
sc0ttkclark — 3 years ago
comment:1
sc0ttkclark — 3 years ago
#1 is now a filter as per @nacin
comment:2
sc0ttkclark — 3 years ago
Just wanted to check in and see if there was anything further needed from me to get this into 3.1?
Do we really need the 'comments_orderby_request' series?
More importantly, note that the trend in WP_Query is to pass all query statements at once: #14997
comment:4
sc0ttkclark — 3 years ago
That was a straight copy / paste from another section, any idea what I should use as an example of the WP_Query for passing all query statements at once for filtering?
comment:6
sc0ttkclark — 3 years ago
Must have been working with a previous revision ;) Will adjust all corresponding patches.
Also, please try to make patches relative to the root WP folder. Currently, they are relative to wp-includes.
comment:8
sc0ttkclark — 3 years ago
Will do in the future, thanks for the best-practices update.
comment:9
sc0ttkclark — 3 years ago
- Keywords has-patch added
Refreshed and revised after IRC discussion with @scribu for best-practice methods.
sc0ttkclark — 3 years ago
Patch refreshed and revised with adjustments to the changes made by refresh - also fixed $post_where to be $where (for consistency) and resolved a bug with $author_email / $karma not adding a space before the AND in appending $where
comment:10
sc0ttkclark — 3 years ago
Attached new patch - Patch refreshed and revised with adjustments to the changes made by refresh - also fixed $post_where to be $where (for consistency) and resolved a bug with $author_email / $karma not adding a space before the AND in appending $where
comment:11
scribu — 3 years ago
- Milestone changed from Awaiting Review to 3.1
comment:12
scribu — 3 years ago
- Resolution set to fixed
- Status changed from new to closed

Initial Patch including the new filters / actions