#11880 closed enhancement (fixed)
Avatars in Custom Comment Type
Reported by: | usermrpapa | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 2.9.1 |
Component: | Comments | Keywords: | has-patch, tested |
Focuses: | Cc: |
Description
currently, its possible to define a custom comment type and have them displayed interspersed within normal WP comments or in its own section.
However, since the comment_type is custom, the get_avatar() function wont show avatars because of an explicit check for comment_type of comment. A comment in the code says dont show avatars for pingbacks or trackbacks which makes sense, but it also ruins the chance to show avatars for custom comment types. Also, the check and abort is before the avatar filter, so no chance to override.
Sure would be nice if this statement:
if ( isset($id_or_email->comment_type) && '' != $id_or_email->comment_type && 'comment' != $id_or_email->comment_type )
didnt explicitly check for comment_type of 'comment' only and instead checked for types not wanted (ie pingback or trackback).
will try to work up a patch tonight.
Attachments (1)
Change History (11)
#2
@
15 years ago
while pluggable, really hate it as its a maintainability issue... hate checking every version to see if there is a needed change...
not sure I follow the filter comment on comment_type... in the if statement?
#3
@
15 years ago
If we change this, any custom comment type will suddenly have gravar support, *and* there will be no way to turn it off without overriding get_avatar().
Something like:
if ( isset($id_or_email->comment_type) && '' != $id_or_email->comment_type && ! in_array( $id_or_email->comment_type, apply_filters( 'get_avatar_comment_types', array( 'comment' ), $id_or_email->comment_type ) ) )
Kind of messy, but it allows for a plugin to add to a whitelist of comment types that should support get_avatar().
#4
@
15 years ago
thought thats what you might be saying. will play with that tonight and then work up a patch if it goes well. Thanks!
#5
@
15 years ago
- Keywords has-patch added
works nicely in letting custom comment types display avatar. patch against trunk r12716 attached...
#7
@
15 years ago
Looks good, I would probably split it into two lines of code instead of wrapping it for clarity. Also, the code currently in core could simply use !empty(). This logic should work:
// No avatar for pingbacks or trackbacks $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); if ( !empty( $id_or_email->comment_type ) && !in_array( 'get_avatar_comment_types', $allowed_comment_types ) ) return false;
Should probably be a filter that passes the comment_type.
That said, this function is actually pluggable, you could replace the entire get_avatar() function when implementing your custom comment type.