Permalink
Browse files

Comment class updates.

git-svn-id: http://svn.locallylost.com/themes/hybrid-core/trunk@1017 dba0f204-706d-4bc1-bc29-8b92e0485636
  • Loading branch information...
1 parent 855bb02 commit 8cc0e26bdc538751b3e5da259befa567733aa721 greenshady committed Apr 19, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 functions/context.php
View
@@ -223,22 +223,26 @@ function hybrid_comment_class( $class = '' ) {
$classes = get_comment_class( $class );
/* Get the comment type. */
- $classes[] = get_comment_type();
+ $comment_type = get_comment_type();
+
+ /* If the comment type is 'pingback' or 'trackback', add the 'ping' comment class. */
+ if ( 'pingback' == $comment_type || 'trackback' == $comment_type )
+ $classes[] = 'ping';
/* User classes to match user role and user. */
if ( $comment->user_id > 0 ) {
/* Create new user object. */
$user = new WP_User( $comment->user_id );
- /* Set a class with the user's role. */
+ /* Set a class with the user's role(s). */
if ( is_array( $user->roles ) ) {
foreach ( $user->roles as $role )
- $classes[] = "role-{$role}";
+ $classes[] = sanitize_html_class( "role-{$role}" );
}
/* Set a class with the user's name. */
- $classes[] = 'user-' . sanitize_html_class( $user->user_nicename, $user->ID );
+ $classes[] = sanitize_html_class( "user-{$user->user_nicename}", "user-{$user->ID}" );
}
/* If not a registered user */
@@ -259,6 +263,9 @@ function hybrid_comment_class( $class = '' ) {
if ( get_option( 'show_avatars' ) && in_array( $comment->comment_type, $avatar_comment_types ) )
$classes[] = 'has-avatar';
+ /* Make sure comment classes doesn't have any duplicates. */
+ $classes = array_unique( $classes );
+
/* Join all the classes into one string and echo them. */
$class = join( ' ', $classes );

0 comments on commit 8cc0e26

Please sign in to comment.