Skip to:
Content

bbPress.org

Changeset 7362


Ignore:
Timestamp:
11/16/2025 11:21:45 PM (3 weeks ago)
Author:
johnjamesjacoby
Message:

Topics/Replies: Add CSS class for user roles in topics/replies.

This commit improves the ability target specific author roles anywhere single topic or reply author meta is shown.

Props douglsmith, mikachan, netweb, robinwpdeveloper, rudlinkon, sirlouen.

In trunk, for 2.7.

Fixes #2692.

Location:
trunk/src/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/template.php

    r7360 r7362  
    13891389    ), 'get_reply_author_role' );
    13901390
    1391     $reply_id    = bbp_get_reply_id( $r['reply_id'] );
    1392     $role        = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) );
     1391    $reply_id = bbp_get_reply_id( $r['reply_id'] );
     1392    $role     = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) );
     1393    $css_role = sanitize_key( $role );
     1394
     1395    // Add role as CSS class to default 'before' value.
     1396    if ( empty( $args['before'] ) ) {
     1397        $r['before'] = '<div class="bbp-author-role bbp-role-' . esc_attr( $css_role ) . '">';
     1398    }
    13931399
    13941400    // Backwards compatibilty with old 'class' argument
  • trunk/src/includes/topics/template.php

    r7360 r7362  
    16051605        $topic_id = bbp_get_topic_id( $r['topic_id'] );
    16061606        $role     = bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) );
     1607        $css_role = sanitize_key( $role );
     1608
     1609        // Add role as CSS class to default 'before' value.
     1610        if ( empty( $args['before'] ) ) {
     1611            $r['before'] = '<div class="bbp-author-role bbp-role-' . esc_attr( $css_role ) . '">';
     1612        }
    16071613
    16081614        // Backwards compatibilty with old 'class' argument
Note: See TracChangeset for help on using the changeset viewer.