Changeset 5512 for trunk/src/includes/extend/buddypress/notifications.php
- Timestamp:
- 09/11/2014 03:41:54 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/extend/buddypress/notifications.php
r5232 r5512 41 41 function bbp_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { 42 42 43 // Bail if not the notification action we are looking for 44 if ( 'bbp_new_reply' !== $action ) { 45 return $action; 46 } 47 43 48 // New reply notifications 44 if ( 'bbp_new_reply' === $action ) { 45 $topic_id = bbp_get_reply_topic_id( $item_id ); 46 $topic_title = bbp_get_topic_title( $topic_id ); 47 $topic_link = wp_nonce_url( add_query_arg( array( 'action' => 'bbp_mark_read', 'topic_id' => $topic_id ), bbp_get_reply_url( $item_id ) ), 'bbp_mark_topic_' . $topic_id ); 48 $title_attr = __( 'Topic Replies', 'bbpress' ); 49 $topic_id = bbp_get_reply_topic_id( $item_id ); 50 $topic_title = bbp_get_topic_title( $topic_id ); 51 $topic_link = wp_nonce_url( add_query_arg( array( 'action' => 'bbp_mark_read', 'topic_id' => $topic_id ), bbp_get_reply_url( $item_id ) ), 'bbp_mark_topic_' . $topic_id ); 52 $title_attr = __( 'Topic Replies', 'bbpress' ); 49 53 50 if ( (int) $total_items > 1 ) { 51 $text = sprintf( __( 'You have %d new replies', 'bbpress' ), (int) $total_items ); 52 $filter = 'bbp_multiple_new_subscription_notification'; 54 if ( (int) $total_items > 1 ) { 55 $text = sprintf( __( 'You have %d new replies', 'bbpress' ), (int) $total_items ); 56 $filter = 'bbp_multiple_new_subscription_notification'; 57 } else { 58 if ( !empty( $secondary_item_id ) ) { 59 $text = sprintf( __( 'You have %d new reply to %2$s from %3$s', 'bbpress' ), (int) $total_items, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) ); 53 60 } else { 54 if ( !empty( $secondary_item_id ) ) { 55 $text = sprintf( __( 'You have %d new reply to %2$s from %3$s', 'bbpress' ), (int) $total_items, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) ); 56 } else { 57 $text = sprintf( __( 'You have %d new reply to %s', 'bbpress' ), (int) $total_items, $topic_title ); 58 } 59 $filter = 'bbp_single_new_subscription_notification'; 61 $text = sprintf( __( 'You have %d new reply to %s', 'bbpress' ), (int) $total_items, $topic_title ); 60 62 } 63 $filter = 'bbp_single_new_subscription_notification'; 64 } 61 65 62 63 64 66 // WordPress Toolbar 67 if ( 'string' === $format ) { 68 $return = apply_filters( $filter, '<a href="' . esc_url( $topic_link ) . '" title="' . esc_attr( $title_attr ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $text, $topic_link ); 65 69 66 67 68 69 70 71 72 70 // Deprecated BuddyBar 71 } else { 72 $return = apply_filters( $filter, array( 73 'text' => $text, 74 'link' => $topic_link 75 ), $topic_link, (int) $total_items, $text, $topic_title ); 76 } 73 77 74 78 do_action( 'bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items ); 75 79 76 return $return; 77 } 80 return $return; 78 81 } 79 82 add_filter( 'bp_notifications_get_notifications_for_user', 'bbp_format_buddypress_notifications', 10, 5 );
Note: See TracChangeset
for help on using the changeset viewer.