BP_Email_Tokens::token__message( BP_Email $bp_email, array $formatted_tokens, array $tokens )
Generate the output for token message
Description
Parameters
- $bp_email
-
(Required)
- $formatted_tokens
-
(Required)
- $tokens
-
(Required)
Return
(string) html for the output
Source
File: bp-core/classes/class-bp-email-tokens.php
public function token__message( $bp_email, $formatted_tokens, $tokens ) { $output = ''; if ( 'messages-unread' != $bp_email->get( 'type' ) ) return $output; $settings = bp_email_get_appearance_settings(); $media_ids = false; $total_media_ids = 0; if ( bp_is_active( 'media' ) && bp_is_messages_media_support_enabled() && ! empty( $tokens['message_id'] ) ) { $media_ids = bp_messages_get_meta( $tokens['message_id'], 'bp_media_ids', true ); if ( ! empty( $media_ids ) ) { $media_ids = explode( ',', $media_ids ); $total_media_ids = count( $media_ids ); $media_ids = implode( ',', array_slice( $media_ids, 0, 5 ) ); } } $gif_data = false; if ( bp_is_active( 'media' ) && bp_is_messages_gif_support_enabled() && ! empty( $tokens['message_id'] ) ) { $gif_data = bp_messages_get_meta( $tokens['message_id'], '_gif_data', true ); } ob_start(); ?> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <?php if ( $this->_message_sender_id ): ?> <tr> <td> <table cellpadding="0" cellspacing="0" border="0" width="100%" style="width: 100%"> <tbody> <tr> <td valign="middle" width="65px" style="vertical-align: middle;"> <a style="display: block; width: 47px;" href="<?php echo esc_attr( bp_core_get_user_domain( $this->_message_sender_id ) ); ?>" target="_blank" rel="nofollow"> <?php $avatar_url = bp_core_fetch_avatar( array( 'item_id' => $this->_message_sender_id, 'width' => 100, 'height' => 100, 'type' => 'full', 'html' => false, ) ); ?> <img src="<?php echo esc_attr( $avatar_url ); ?>" width="47" height="47" border="0" style="margin:0; padding:0; border:none; display:block; max-width: 47px; border-radius: 50%;" /> </a> </td> <td width="88%" style="vertical-align: middle;"> <div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: <?php echo esc_attr( $settings['body_text_size'] . 'px' ); ?>; line-height: <?php echo esc_attr( $settings['body_text_size'] . 'px' ); ?>; letter-spacing: -0.24px;"> <a href="<?php echo esc_attr( bp_core_get_user_domain( $this->_message_sender_id ) ); ?>" target="_blank" rel="nofollow" style="color: <?php echo esc_attr( $settings['body_secondary_text_color'] ); ?> !important;"> <?php echo $tokens['sender.name']; ?> </a> </div> </td> </tr> </tbody> </table> </td> </tr> <tr> <td height="24px" style="font-size: 24px; line-height: 24px;"> </td> </tr> <?php endif; ?> <tr> <td> <table cellspacing="0" cellpadding="0" border="0" width="100%" style="background: <?php echo esc_attr( $settings['quote_bg'] ); ?>; border: 1px solid <?php echo esc_attr( $settings['body_border_color'] ); ?>; border-radius: 4px; border-collapse: separate !important"> <tbody> <tr> <td height="25px" style="font-size: 25px; line-height: 25px;"> </td> </tr> <tr> <td align="center"> <table cellpadding="0" cellspacing="0" border="0" width="86%" style="width: 86%;"> <tbody> <tr> <td> <div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: <?php echo esc_attr( $settings['body_text_size'] . 'px' ); ?>; letter-spacing: -0.24px; line-height: <?php echo esc_attr( floor( $settings['body_text_size'] * 1.625 ) . 'px' ) ?>;"> <?php echo nl2br( $tokens['usermessage'] ); ?> </div> <?php if ( ! empty( $media_ids ) && bp_has_media( array( 'include' => $media_ids, 'order_by' => 'menu_order', 'sort' => 'ASC' ) ) ) : ?> <div class="bb-activity-media-wrap" style="padding: 10px 0;"> <?php while ( bp_media() ) { bp_the_media(); ?> <div class="bb-activity-media-elem" style="display: inline-block; max-width: 120px; vertical-align: top; max-height: 120px; overflow: hidden; padding: 4px 0;"> <a href="<?php echo esc_attr( $tokens['message.url'] ); ?>"> <img src="<?php echo esc_attr( wp_get_attachment_image_url( bp_get_media_attachment_id() ) ); ?>" alt="<?php echo esc_attr( bp_get_media_title() ); ?>"/> </a> </div> <?php } ?> <?php if ( $total_media_ids > 5 ) : ?> <a href="<?php echo esc_attr( $tokens['message.url'] ); ?>"><?php sprintf( __( 'and %d more', 'buddyboss' ), $total_media_ids - 5 ); ?></a> <?php endif; ?> </div> <?php endif; ?> <?php if ( ! empty( $gif_data ) ) : ?> <div class="activity-attached-gif-container"> <div class="gif-image-container"> <a href="<?php echo esc_attr( $tokens['message.url'] ); ?>" class="gif-play-button"> <span class="dashicons dashicons-video-alt3"></span> <img src="<?php echo esc_url( wp_get_attachment_url( $gif_data['still'] ) ); ?>" /> </a> <span class="gif-icon"></span> </div> </div> <?php endif; ?> </td> </tr> </tbody> </table> </td> </tr> <tr> <td height="25px" style="font-size: 25px; line-height: 25px;"> </td> </tr> </tbody> </table> </td> </tr> <tr> <td height="24px" style="font-size: 24px; line-height: 24px;"> </td> </tr> <tr> <td> <a href="<?php echo esc_attr( $tokens['message.url'] ); ?>" target="_blank" rel="nofollow" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; color: <?php echo $settings['highlight_color']; ?>; text-decoration: none; display: block; border: 1px solid <?php echo $settings['highlight_color']; ?>; border-radius: 100px; width: 84px; text-align: center; height: 32px; line-height: 32px;"><?php _e( 'Reply', 'buddyboss' ); ?></a> </td> </tr> </table> <div class="spacer" style="font-size: 10px; line-height: 10px; height: 10px;"> </div> <?php $output = str_replace( array( "\r", "\n" ), '', ob_get_clean() ); return $output; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.