Changeset 10304 for trunk/src/bp-messages/bp-messages-notifications.php
- Timestamp:
- 10/22/2015 06:12:16 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-notifications.php
r10139 r10304 27 27 function messages_notification_new_message( $raw_args = array() ) { 28 28 29 // Cast possible $message object as an array 29 // Cast possible $message object as an array. 30 30 if ( is_object( $raw_args ) ) { 31 31 $args = (array) $raw_args; … … 34 34 } 35 35 36 // These should be extracted below 36 // These should be extracted below. 37 37 $recipients = array(); 38 38 $email_subject = $email_content = ''; 39 39 $sender_id = 0; 40 40 41 // Barf 41 // Barf. 42 42 extract( $args ); 43 43 44 // Get the sender display name 44 // Get the sender display name. 45 45 $sender_name = bp_core_get_user_displayname( $sender_id ); 46 46 47 // Bail if no recipients 47 // Bail if no recipients. 48 48 if ( ! empty( $recipients ) ) { 49 49 … … 54 54 } 55 55 56 // User data and links 56 // User data and links. 57 57 $ud = get_userdata( $recipient->user_id ); 58 58 59 // Bail if user cannot be found 59 // Bail if user cannot be found. 60 60 if ( empty( $ud ) ) { 61 61 continue; … … 66 66 $settings_link = bp_core_get_user_domain( $recipient->user_id ) . $settings_slug . '/notifications/'; 67 67 68 // Sender info 68 // Sender info. 69 69 $sender_name = stripslashes( $sender_name ); 70 70 $subject = stripslashes( wp_filter_kses( $subject ) ); 71 71 $content = stripslashes( wp_filter_kses( $message ) ); 72 72 73 // Set up and send the message 73 // Set up and send the message. 74 74 $email_to = $ud->user_email; 75 75 $email_subject = bp_get_email_subject( array( 'text' => sprintf( __( 'New message from %s', 'buddypress' ), $sender_name ) ) ); … … 87 87 ', 'buddypress' ), $sender_name, $subject, $content, $message_link ); 88 88 89 // Only show the disable notifications line if the settings component is enabled 89 // Only show the disable notifications line if the settings component is enabled. 90 90 if ( bp_is_active( 'settings' ) ) { 91 91 $email_content .= sprintf( __( 'To disable these notifications, please log in and go to: %s', 'buddypress' ), $settings_link ); … … 160 160 * @param string $format Return value format. 'string' for BuddyBar-compatible 161 161 * notifications; 'array' for WP Toolbar. Default: 'string'. 162 *163 162 * @return string|array Formatted notifications. 164 163 */ … … 176 175 $amount = 'single'; 177 176 178 // get message thread ID177 // Get message thread ID. 179 178 $message = new BP_Messages_Message( $item_id ); 180 179 $thread_id = $message->thread_id; … … 268 267 global $thread_template; 269 268 270 // get unread PM notifications for the user269 // Get unread PM notifications for the user. 271 270 $new_pm_notifications = BP_Notifications_Notification::get( array( 272 271 'user_id' => bp_loggedin_user_id(), … … 277 276 $unread_message_ids = wp_list_pluck( $new_pm_notifications, 'item_id' ); 278 277 279 // no unread PMs, so stop!278 // No unread PMs, so stop! 280 279 if ( empty( $unread_message_ids ) ) { 281 280 return; 282 281 } 283 282 284 // get the unread message ids for this thread only283 // Get the unread message ids for this thread only. 285 284 $message_ids = array_intersect( $unread_message_ids, wp_list_pluck( $thread_template->thread->messages, 'id' ) ); 286 285 287 // mark each notification for each PM message as read286 // Mark each notification for each PM message as read. 288 287 foreach ( $message_ids as $message_id ) { 289 288 bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), (int) $message_id, buddypress()->messages->id, 'new_message' );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)