Add comment type support to comments connector#558
Merged
frankiejarrett merged 2 commits intodevelopfrom Jun 4, 2014
Merged
Conversation
Contributor
|
@lukecarbis I'm not sure we should be using cf. https://github.com/WordPress/WordPress/blob/master/wp-includes/comment-template.php#L875-L877 Perhaps adding some new methods here is the answer, similar to what we do for attachment types in Media. /**
* Return translated comment type labels
*
* @return array Comment type label translations
*/
public static function get_comment_type_labels() {
return array(
'comment' => __( 'Comment', 'default' ),
'trackback' => __( 'Trackback', 'default' ),
'pingback' => __( 'Pingback', 'default' ),
);
}
/**
* Return the comment type label for a given comment ID
*
* @param int $comment_id ID of the comment
* @return string The comment type label
*/
public static function get_comment_type_label( $comment_id ) {
$comment_type = get_comment_type( $comment_id );
if ( empty( $comment_type ) ) {
$comment_type = 'comment';
}
$comment_type_labels = self::get_comment_type_labels();
$label = isset( $comment_type_labels[ $comment_type ] ) ? $comment_type_labels[ $comment_type ] : $comment_type;
return $label;
}Then in the callbacks do: $comment_type = mb_strtolower( self::get_comment_type_label( $comment_id ) ); |
Contributor
Author
|
/five thanks @fjarrett, great suggestion. WordPress core should have a better way of handling this. See Trac #4916 and Trac #12668. |
Contributor
|
This is working great. Nicely done, @lukecarbis! /five |
frankiejarrett
added a commit
that referenced
this pull request
Jun 4, 2014
Add comment type support to comments connector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows other comment types like:
... to be accurately logged by Stream.