Skip to:
Content

BuddyPress.org

Changeset 4622


Ignore:
Timestamp:
07/06/2011 08:02:44 PM (13 years ago)
Author:
boonebgorges
Message:

Introduces bp_get_messages_slug() and bp_messages_slug() template tags. Ports Messages Component notification items to the WP Admin Bar. References #3294

Location:
trunk/bp-messages
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages/bp-messages-functions.php

    r4605 r4622  
    212212 */
    213213
    214 function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
     214/**
     215 * Format the BuddyBar/admin bar notifications for the Messages component
     216 *
     217 * @package BuddyPress
     218 *
     219 * @param str $action The kind of notification being rendered
     220 * @param int $item_id The primary item id
     221 * @param int $secondary_item_id The secondary item id
     222 * @param int $total_items The total number of messaging-related notifications waiting for the user
     223 * @param str $format 'string' for BuddyBar-compatible notifications; 'array' for WP Admin Bar
     224 */
     225function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    215226    global $bp;
    216227
    217228    if ( 'new_message' == $action ) {
    218         if ( (int)$total_items > 1 )
    219             return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    220         else
    221             return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
     229        $link  = bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox';
     230        $title = __( 'Inbox', 'buddypress' );
     231       
     232        if ( (int)$total_items > 1 ) {
     233            $text = sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items );
     234            $filter = 'bp_messages_multiple_new_message_notification';
     235        } else {
     236            $text = sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items );
     237            $filter = 'bp_messages_single_new_message_notification';
     238        }
     239    }
     240
     241    if ( 'string' == $format ) {
     242        $return = apply_filters( $filter, '<a href="' . $link . '" title="' . $title . '">' . $text . '</a>', (int)$total_items, $text, $link );
     243    } else {
     244        $return = apply_filters( $filter, array(
     245            'text' => $text,
     246            'link' => $at_mention_link
     247        ), $at_mention_link, (int)$total_items, $text, $link );
    222248    }
    223249
    224250    do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    225251
    226     return false;
     252    return $return;
    227253}
    228254?>
  • trunk/bp-messages/bp-messages-template.php

    r4605 r4622  
    496496    }
    497497
     498/**
     499 * Output the messages component slug
     500 *
     501 * @package BuddyPress
     502 * @subpackage Messages Template
     503 * @since BuddyPress 1.3
     504 *
     505 * @uses bp_get_messages_slug()
     506 */
     507function bp_messages_slug() {
     508    echo bp_get_messages_slug();
     509}
     510    /**
     511     * Return the messages component slug
     512     *
     513     * @package BuddyPress
     514     * @subpackage Messages Template
     515     * @since BuddyPress 1.3
     516     */
     517    function bp_get_messages_slug() {
     518        global $bp;
     519        return apply_filters( 'bp_get_messages_slug', $bp->messages->slug );
     520    }
     521
    498522function bp_message_get_notices() {
    499523    global $userdata;
Note: See TracChangeset for help on using the changeset viewer.