Changeset 13035 for trunk/src/bp-messages/bp-messages-notifications.php
- Timestamp:
- 08/10/2021 04:16:30 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-notifications.php
r12893 r13035 35 35 $amount = 'multiple'; 36 36 37 /* translators: % s: number of new messages */37 /* translators: %d: number of new messages */ 38 38 $text = sprintf( __( 'You have %d new messages', 'buddypress' ), $total_items ); 39 39 … … 42 42 $message = new BP_Messages_Message( $item_id ); 43 43 $thread_id = $message->thread_id; 44 $link = ( ! empty( $thread_id ) ) 45 ? bp_get_message_thread_view_link( $thread_id ) 46 : false; 44 $link = ''; 45 46 if ( ! empty( $thread_id ) ) { 47 $link = bp_get_message_thread_view_link( $thread_id ); 48 } 47 49 48 50 if ( ! empty( $secondary_item_id ) ) { … … 57 59 if ( 'string' === $format ) { 58 60 if ( ! empty( $link ) ) { 59 $ret urn= '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>';61 $retval = '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>'; 60 62 } else { 61 $ret urn= esc_html( $text );63 $retval = esc_html( $text ); 62 64 } 63 65 64 /** 65 * Filters the new message notification text before the notification is created. 66 * 67 * This is a dynamic filter. Possible filter names are: 68 * - 'bp_messages_multiple_new_message_notification'. 69 * - 'bp_messages_single_new_message_notification'. 70 * 71 * @param string $return Notification text. 72 * @param int $total_items Number of messages referred to by the notification. 73 * @param string $text The raw notification test (ie, not wrapped in a link). 74 * @param int $item_id ID of the associated item. 75 * @param int $secondary_item_id ID of the secondary associated item. 76 */ 77 $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', $return, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 66 /** This filter is documented in wp-includes/deprecated.php */ 67 $retval = apply_filters_deprecated( 68 'bp_messages_' . $amount . '_new_message_notification', 69 array( $retval, $total_items, $text, $link, $item_id, $secondary_item_id ), 70 '10.0.0', 71 'bp_messages_' . $amount . '_new_message_' . $format . '_notification' 72 ); 78 73 } else { 79 /** This filter is documented in bp-messages/bp-messages-notifications.php */ 80 $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', array( 74 $retval = array( 81 75 'text' => $text, 82 'link' => $link 83 ), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 84 } 76 'link' => $link, 77 ); 78 79 /** This filter is documented in wp-includes/deprecated.php */ 80 $retval = apply_filters_deprecated( 81 'bp_messages_' . $amount . '_new_message_notification', 82 array( 83 $retval, 84 $link, // This extra `$link` variable is the reason why we deprecated the filter. 85 $total_items, 86 $text, 87 $link, 88 $item_id, 89 $secondary_item_id, 90 ), 91 '10.0.0', 92 'bp_messages_' . $amount . '_new_message_' . $format . '_notification' 93 ); 94 } 95 96 /** 97 * Filters the new message notification text before the notification is created. 98 * 99 * This is a dynamic filter. Possible filter names are: 100 * - 'bp_messages_multiple_new_message_string_notification'. 101 * - 'bp_messages_single_new_message_string_notification'. 102 * - 'bp_messages_multiple_new_message_array_notification'. 103 * - 'bp_messages_single_new_message_array_notification'. 104 * 105 * @param array|string $retval An array containing the text and the link of the Notification or simply its text. 106 * @param int $total_items Number of messages referred to by the notification. 107 * @param string $text The raw notification text (ie, not wrapped in a link). 108 * @param string $link The link of the notification. 109 * @param int $item_id ID of the associated item. 110 * @param int $secondary_item_id ID of the secondary associated item. 111 */ 112 $retval = apply_filters( 113 'bp_messages_' . $amount . '_new_message_' . $format . '_notification', 114 $retval, 115 $total_items, 116 $text, 117 $link, 118 $item_id, 119 $secondary_item_id 120 ); 85 121 86 122 // Custom notification action for the Messages component 87 123 } else { 88 124 if ( 'string' === $format ) { 89 $ret urn= $text;125 $retval = $text; 90 126 } else { 91 $ret urn= array(127 $retval = array( 92 128 'text' => $text, 93 129 'link' => $link … … 101 137 if ( has_filter( 'bp_messages_single_new_message_notification' ) ) { 102 138 if ( 'string' === $format ) { 103 /** This filter is documented in bp-messages/bp-messages-notifications.php */ 104 $return = apply_filters( 'bp_messages_single_new_message_notification', $return, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 105 106 // Notice that there are seven parameters instead of six? Ugh... 139 /** This filter is documented in wp-includes/deprecated.php */ 140 $retval = apply_filters_deprecated( 141 'bp_messages_' . $amount . '_new_message_notification', 142 array( $retval, $total_items, $text, $link, $item_id, $secondary_item_id ), 143 '10.0.0', 144 "bp_messages_{$action}_notification" 145 ); 146 107 147 } else { 108 /** This filter is documented in bp-messages/bp-messages-notifications.php */ 109 $return = apply_filters( 'bp_messages_single_new_message_notification', $return, $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 148 /** This filter is documented in wp-includes/deprecated.php */ 149 $retval = apply_filters_deprecated( 150 'bp_messages_' . $amount . '_new_message_notification', 151 array( $retval, $link, $total_items, $text, $link, $item_id, $secondary_item_id ), 152 '10.0.0', 153 "bp_messages_{$action}_notification" 154 ); 110 155 } 111 156 } … … 125 170 * notifications; 'array' for WP Toolbar. Default: 'string'. 126 171 */ 127 $ret urn = apply_filters( "bp_messages_{$action}_notification", $return, $item_id, $secondary_item_id, $total_items, $format );172 $retval = apply_filters( "bp_messages_{$action}_notification", $retval, $item_id, $secondary_item_id, $total_items, $format ); 128 173 } 129 174 … … 140 185 do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 141 186 142 return $ret urn;187 return $retval; 143 188 } 144 189
Note: See TracChangeset
for help on using the changeset viewer.