bbp_format_buddypress_notifications( string $action, int $item_id, int $secondary_item_id, int $total_items, string $format = 'string' )
Format the BuddyBar/Toolbar notifications
Description
Parameters
- $action
-
(Required) The kind of notification being rendered
- $item_id
-
(Required) The primary item id
- $secondary_item_id
-
(Required) The secondary item id
- $total_items
-
(Required) The total number of messaging-related notifications waiting for the user
- $format
-
(Optional) 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
Default value: 'string'
Source
File: bp-forums/notifications.php
function bbp_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { // New reply notifications if ( 'bbp_new_reply' === $action ) { $topic_id = bbp_get_reply_topic_id( $item_id ); $topic_title = bbp_get_topic_title( $topic_id ); $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 ); $title_attr = __( 'Discussion Replies', 'buddyboss' ); if ( (int) $total_items > 1 ) { $text = sprintf( __( 'You have %d new replies', 'buddyboss' ), (int) $total_items ); $filter = 'bbp_multiple_new_subscription_notification'; } else { if ( !empty( $secondary_item_id ) ) { $text = sprintf( __( 'You have %d new reply to %2$s from %3$s', 'buddyboss' ), (int) $total_items, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) ); } else { $text = sprintf( __( 'You have %d new reply to %s', 'buddyboss' ), (int) $total_items, $topic_title ); } $filter = 'bbp_single_new_subscription_notification'; } // WordPress Toolbar if ( 'string' === $format ) { $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 ); // Deprecated BuddyBar } else { $return = apply_filters( $filter, array( 'text' => $text, 'link' => $topic_link ), $topic_link, (int) $total_items, $text, $topic_title ); } /** * @todo add title/description * * @since BuddyBoss 1.0.0 */ do_action( 'bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items ); return $return; } }
Changelog
Version | Description |
---|---|
bbPress (r5155) | 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.