Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/06/2011 07:35:51 PM (13 years ago)
Author:
boonebgorges
Message:

Adds WP Admin Bar notification support for Activity component. References #3294

File:
1 edited

Legend:

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

    r4611 r4621  
    113113 *
    114114 * @package BuddyPress Activity
    115  * @param $action The type of activity item. Just 'new_at_mention' for now
    116  * @param $item_id The activity id
    117  * @param $secondary_item_id In the case of at-mentions, this is the mentioner's id
    118  * @param $total_items The total number of notifications to format
    119  */
    120 function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
     115 * @param str $action The type of activity item. Just 'new_at_mention' for now
     116 * @param int $item_id The activity id
     117 * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's id
     118 * @param int $total_items The total number of notifications to format
     119 * @param str $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise
     120 */
     121function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    121122    global $bp;
    122123
     
    129130
    130131            if ( (int)$total_items > 1 ) {
    131                 return apply_filters( 'bp_activity_multiple_at_mentions_notification', '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . sprintf( __( 'You have %1$d new activity mentions', 'buddypress' ), (int)$total_items ) . '</a>', $at_mention_link, $total_items, $activity_id, $poster_user_id );
     132                $text = sprintf( __( 'You have %1$d new activity mentions', 'buddypress' ), (int)$total_items );
     133                $filter = 'bp_activity_multiple_at_mentions_notification';
    132134            } else {
    133135                $user_fullname = bp_core_get_user_displayname( $poster_user_id );
    134 
    135                 return apply_filters( 'bp_activity_single_at_mentions_notification', '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . sprintf( __( '%1$s mentioned you in an activity update', 'buddypress' ), $user_fullname ) . '</a>', $at_mention_link, $total_items, $activity_id, $poster_user_id );
     136                $text =  sprintf( __( '%1$s mentioned you in an activity update', 'buddypress' ), $user_fullname );
     137                $filter = 'bp_activity_single_at_mentions_notification';
    136138            }
    137139        break;
    138140    }
     141               
     142    if ( 'string' == $format ) {
     143        $return = apply_filters( $filter, '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . $text . '</a>', $at_mention_link, (int)$total_items, $activity_id, $poster_user_id );
     144    } else {
     145        $return = apply_filters( $filter, array(
     146            'text' => $text,
     147            'link' => $at_mention_link
     148        ), $at_mention_link, (int)$total_items, $activity_id, $poster_user_id );
     149    }
    139150
    140151    do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    141152
    142     return false;
     153    return $return;
    143154}
    144155
Note: See TracChangeset for help on using the changeset viewer.