WordPress.org

Make WordPress Core

Ticket #24054: 24054_is-member+role.patch

File 24054_is-member+role.patch, 1.5 KB (added by Viper007Bond, 7 years ago)

Adds both "comment-author-is-site-member" and "comment-author-role-ROLE" classes

  • wp-includes/comment-template.php

     
    306306        // Get the comment type (comment, trackback),
    307307        $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
    308308
    309         // If the comment author has an id (registered), then print the log in name
    310         if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
    311                 // For all registered users, 'byuser'
     309        // If the comment author has an id (registered)
     310        if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) {
     311                // For all registered users
    312312                $classes[] = 'byuser';
    313                 $classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id);
     313                $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
     314
     315                // For all members of this blog (useful for multi-site)
     316                if ( is_user_member_of_blog( $comment->user_id ) ) {
     317                        $classes[] = 'comment-author-is-site-member';
     318
     319                        if ( ! empty( $user->roles ) && ! empty( $user->roles[0] ) ) {
     320                                $classes[] = 'comment-author-role-' . sanitize_html_class( $user->roles[0] );
     321                        }
     322                }
     323
    314324                // For comment authors who are the author of the post
    315325                if ( $post = get_post($post_id) ) {
    316                         if ( $comment->user_id === $post->post_author )
     326                        if ( $comment->user_id === $post->post_author ) {
    317327                                $classes[] = 'bypostauthor';
     328                        }
    318329                }
    319330        }
    320331