Skip to:
Content

BuddyPress.org

Changeset 8604


Ignore:
Timestamp:
07/12/2014 01:03:23 AM (10 years ago)
Author:
boonebgorges
Message:

Introduce bp_get_the_thread_message_css_class()

This centralized function assembles CSS classes for message divs within a
single private message thread. In addition to the existing zebra-striping
classes, classes have been introduced for 'sent-by-[userid]' and 'sent-by-me'.

Fixes #5238

Props sgr33n for an initial patch

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-template.php

    r8482 r8604  
    15141514
    15151515/**
     1516 * Output the CSS classes for messages within a single thread.
     1517 *
     1518 * @since BuddyPress (2.1.0)
     1519 */
     1520function bp_the_thread_message_css_class() {
     1521    echo bp_get_the_thread_message_css_class();
     1522}
     1523    /**
     1524     * Generate the CSS classes for messages within a single thread.
     1525     *
     1526     * @since BuddyPress (2.1.0)
     1527     *
     1528     * @return string
     1529     */
     1530    function bp_get_the_thread_message_css_class() {
     1531        global $thread_template;
     1532
     1533        $classes = array();
     1534
     1535        // Zebra-striping
     1536        $classes[] = bp_get_the_thread_message_alt_class();
     1537
     1538        // ID of the sender
     1539        $classes[] = 'sent-by-' . intval( $thread_template->message->sender_id );
     1540
     1541        // Whether the sender is the same as the logged-in user
     1542        if ( bp_loggedin_user_id() == $thread_template->message->sender_id ) {
     1543            $classes[] = 'sent-by-me';
     1544        }
     1545
     1546        $classes = apply_filters( 'bp_get_the_thread_message_css_class', $classes );
     1547
     1548        return implode( ' ', $classes );
     1549    }
     1550
     1551/**
    15161552 * Output the CSS class used for message zebra striping.
    15171553 */
  • trunk/src/bp-templates/bp-legacy/buddypress/members/single/messages/single.php

    r7965 r8604  
    2929        <?php while ( bp_thread_messages() ) : bp_thread_the_message(); ?>
    3030
    31             <div class="message-box <?php bp_the_thread_message_alt_class(); ?>">
     31            <div class="message-box <?php bp_the_thread_message_css_class(); ?>">
    3232
    3333                <div class="message-metadata">
Note: See TracChangeset for help on using the changeset viewer.