Changeset 6262 for trunk/src/includes/extend/buddypress/notifications.php
- Timestamp:
- 01/27/2017 05:40:54 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/extend/buddypress/notifications.php
r6180 r6262 13 13 // Hooks 14 14 add_filter( 'bp_notifications_get_registered_components', 'bbp_filter_notifications_get_registered_components', 10 ); 15 add_filter( 'bp_notifications_get_notifications_for_user', 'bbp_format_buddypress_notifications', 10, 5);15 add_filter( 'bp_notifications_get_notifications_for_user', 'bbp_format_buddypress_notifications', 10, 8 ); 16 16 add_action( 'bbp_new_reply', 'bbp_buddypress_add_notification', 10, 7 ); 17 17 add_action( 'bbp_get_request', 'bbp_buddypress_mark_notifications', 1 ); … … 50 50 * @package bbPress 51 51 * 52 * @param string $action The kind of notification being rendered 53 * @param int $item_id The primary item id 54 * @param int $secondary_item_id The secondary item id 55 * @param int $total_items The total number of messaging-related notifications waiting for the user 56 * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar 57 */ 58 function bbp_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { 52 * @param string $content Component action. Deprecated. Do not do checks against this! Use 53 * the 6th parameter instead - $component_action_name. 54 * @param int $item_id Notification item ID. 55 * @param int $secondary_item_id Notification secondary item ID. 56 * @param int $action_item_count Number of notifications with the same action. 57 * @param string $format Format of return. Either 'string' or 'object'. 58 * @param string $component_action_name Canonical notification action. 59 * @param string $component_name Notification component ID. 60 * @param int $id Notification ID. 61 */ 62 function bbp_format_buddypress_notifications( $content, $item_id, $secondary_item_id, $action_item_count, $format, $component_action_name, $component_name, $id ) { 59 63 60 64 // Bail if not the notification action we are looking for 61 if ( 'bbp_new_reply' !== $ action) {62 return $ action;65 if ( 'bbp_new_reply' !== $component_action_name ) { 66 return $component_action_name; 63 67 } 64 68 … … 66 70 $topic_id = bbp_get_reply_topic_id( $item_id ); 67 71 $topic_title = bbp_get_topic_title( $topic_id ); 68 $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 ); 69 $title_attr = __( 'Topic Replies', 'bbpress' ); 70 71 if ( (int) $total_items > 1 ) { 72 $text = sprintf( __( 'You have %d new replies', 'bbpress' ), (int) $total_items ); 72 $topic_link = wp_nonce_url( 73 add_query_arg( 74 array( 75 'action' => 'bbp_mark_read', 76 'topic_id' => $topic_id 77 ), 78 bbp_get_reply_url( $item_id ) 79 ), 80 'bbp_mark_topic_' . $topic_id 81 ); 82 83 // Cast to int 84 $action_item_count = (int) $action_item_count; 85 86 // Multiple 87 if ( $action_item_count > 1 ) { 73 88 $filter = 'bbp_multiple_new_subscription_notification'; 89 $text = sprintf( __( 'You have %d new replies', 'bbpress' ), $action_item_count ); 90 91 // Single 74 92 } else { 75 if ( ! empty( $secondary_item_id ) ) {76 $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 ) );77 } else {78 $text = sprintf( __( 'You have %d new reply to %s', 'bbpress' ), (int) $total_items, $topic_title );79 }80 93 $filter = 'bbp_single_new_subscription_notification'; 94 $text = ! empty( $secondary_item_id ) 95 ? sprintf( __( '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 ) ) 96 : sprintf( __( 'You have %d new reply to %s', 'bbpress' ), $action_item_count, $topic_title ); 81 97 } 82 98 83 99 // WordPress Toolbar 84 100 if ( 'string' === $format ) { 85 $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 );101 $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 ); 86 102 87 103 // Deprecated BuddyBar … … 90 106 'text' => $text, 91 107 'link' => $topic_link 92 ), $topic_link, (int) $total_items, $text, $topic_title );93 } 94 95 do_action( 'bbp_format_buddypress_notifications', $ action, $item_id, $secondary_item_id, $total_items);108 ), $topic_link, $action_item_count, $text, $topic_title ); 109 } 110 111 do_action( 'bbp_format_buddypress_notifications', $component_action_name, $item_id, $secondary_item_id, $action_item_count, $format, $component_action_name, $component_name, $id ); 96 112 97 113 return $return;
Note: See TracChangeset
for help on using the changeset viewer.