bbp_format_buddypress_notifications( string $content, int $item_id, int $secondary_item_id, int $action_item_count, string $format, string $component_action_name, string $component_name, int $id )
Format the BuddyBar/Toolbar notifications
Description Description
Parameters Parameters
- $content
-
(Required) Component action. Deprecated. Do not do checks against this! Use the 6th parameter instead - $component_action_name.
- $item_id
-
(Required) Notification item ID.
- $secondary_item_id
-
(Required) Notification secondary item ID.
- $action_item_count
-
(Required) Number of notifications with the same action.
- $format
-
(Required) Format of return. Either 'string' or 'object'.
- $component_action_name
-
(Required) Canonical notification action.
- $component_name
-
(Required) Notification component ID.
- $id
-
(Required) Notification ID.
Source Source
File: includes/extend/buddypress/notifications.php
function bbp_format_buddypress_notifications( $content, $item_id, $secondary_item_id, $action_item_count, $format, $component_action_name, $component_name, $id ) {
// Bail if not the notification action we are looking for
if ( 'bbp_new_reply' !== $component_action_name ) {
return $content;
}
// New reply notifications
$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
);
// Cast to int
$action_item_count = (int) $action_item_count;
// Multiple
if ( $action_item_count > 1 ) {
$filter = 'bbp_multiple_new_subscription_notification';
$text = sprintf( esc_html__( 'You have %d new replies', 'bbpress' ), $action_item_count );
// Single
} else {
$filter = 'bbp_single_new_subscription_notification';
$text = ! empty( $secondary_item_id )
? sprintf( esc_html__( 'You have %d new reply to %2$s from %3$s', 'bbpress' ), $action_item_count, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) )
: sprintf( esc_html__( 'You have %d new reply to %s', 'bbpress' ), $action_item_count, $topic_title );
}
// WordPress Toolbar
if ( 'string' === $format ) {
$return = apply_filters( $filter, '<a href="' . esc_url( $topic_link ) . '" title="' . esc_attr__( 'Topic Replies', 'bbpress' ) . '">' . esc_html( $text ) . '</a>', $action_item_count, $text, $topic_link );
// Deprecated BuddyBar
} else {
$return = apply_filters( $filter, array(
'text' => $text,
'link' => $topic_link
), $topic_link, $action_item_count, $text, $topic_title );
}
do_action( 'bbp_format_buddypress_notifications', $component_action_name, $item_id, $secondary_item_id, $action_item_count, $format, $component_action_name, $component_name, $id );
return $return;
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |