members_format_notifications( string $action, int $item_id, int $secondary_item_id, int $total_items, string $format = 'string' )
Notification formatting callback for bp-members notifications.
Parameters Parameters
- $action
-
(string) (Required) The kind of notification being rendered.
- $item_id
-
(int) (Required) The primary item ID.
- $secondary_item_id
-
(int) (Required) The secondary item ID.
- $total_items
-
(int) (Required) The total number of members-related notifications waiting for the user.
- $format
-
(string) (Optional) 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar. Default: 'string'.
Default value: 'string'
Return Return
(array|string)
Source Source
File: bp-members/bp-members-notifications.php
function members_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { switch ( $action ) { case 'accepted_invitation': // Set up the string and the filter. if ( (int) $total_items > 1 ) { $link = bp_get_notifications_permalink(); $amount = 'multiple'; // This is the inviter whose invitation was accepted. if ( 0 !== (int) $secondary_item_id ) { /* translators: %d: the number of new users */ $text = sprintf( __( '%d members accepted your membership invitations', 'buddypress' ), (int) $total_items ); // This is someone who also invited that user to join. } else { /* translators: %d: the number of new users */ $text = sprintf( __( '%d members are now members of the site', 'buddypress' ), (int) $total_items ); } } else { $link = add_query_arg( 'welcome', 1, bp_core_get_user_domain( $item_id ) ); $amount = 'single'; // This is the inviter whose invitation was accepted. if ( 0 !== (int) $secondary_item_id ) { /* translators: %s: new user name */ $text = sprintf( __( '%s accepted your membership invitation', 'buddypress' ), bp_core_get_user_displayname( $item_id ) ); // This is someone who also invited that user to join. } else { /* translators: %s: new user name */ $text = sprintf( __( '%s is now a member of the site', 'buddypress' ), bp_core_get_user_displayname( $item_id ) ); } } break; } // Return either an HTML link or an array, depending on the requested format. if ( 'string' == $format ) { /** * Filters the format of members notifications based on type and amount * of notifications pending. * * This is a variable filter that has several versions. * The possible versions are: * - bp_members_single_accepted_invitation_notification * - bp_members_multiple_accepted_invitation_notification * * @since 8.0.0 * * @param string|array $value Depending on format, an HTML link to new requests profile tab or array with link and text. * @param int $total_items The total number of messaging-related notifications waiting for the user. * @param int $item_id The primary item ID. * @param int $secondary_item_id The secondary item ID. */ $return = apply_filters( 'bp_members_' . $amount . '_'. $action . '_notification', '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $item_id, $secondary_item_id ); } else { /** This filter is documented in bp-members/bp-members-notifications.php */ $return = apply_filters( 'bp_members_' . $amount . '_'. $action . '_notification', array( 'link' => $link, 'text' => $text ), (int) $total_items, $item_id, $secondary_item_id ); } /** * Fires at the end of the bp-members notification format callback. * * @since 8.0.0 * * @param string $action The kind of notification being rendered. * @param int $item_id The primary item ID. * @param int $secondary_item_id The secondary item ID. * @param int $total_items The total number of members-related notifications * waiting for the user. * @param array|string $return Notification text string or array of link and text. */ do_action( 'members_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return ); return $return; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
8.0.0 | Introduced. |