Changeset 5696 for trunk/bp-messages/bp-messages-notifications.php
- Timestamp:
- 02/10/2012 09:02:53 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-messages/bp-messages-notifications.php
r5445 r5696 1 1 <?php 2 3 /** 4 * BuddyPress Messages Notifications 5 * 6 * @package BuddyPress 7 * @subpackage MessagesNotifications 8 */ 9 10 2 11 // Exit if accessed directly 3 12 if ( !defined( 'ABSPATH' ) ) exit; 4 13 5 function messages_notification_new_message( $args ) { 6 global $bp; 14 function messages_notification_new_message( $args = array() ) { 7 15 8 extract($args); 16 // These should be extracted below 17 $recipients = array(); 18 $email_subject = $email_content = ''; 9 19 10 $email_subject = $email_content = $args = ''; 11 $sender_name = bp_core_get_user_displayname( $sender_id ); 20 extract( $args ); 12 21 13 foreach( $recipients as $recipient ) { 14 if ( $sender_id == $recipient->user_id || 'no' == bp_get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) 15 continue; 22 $sender_name = bp_core_get_user_displayname( $sender_id ); 16 23 17 // User data and links 18 $ud = get_userdata( $recipient->user_id ); 19 $message_link = bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() .'/'; 20 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 21 $settings_link = bp_core_get_user_domain( $recipient->user_id ) . $settings_slug . '/notifications/'; 24 // Bail if no recipients 25 if ( ! empty( $recipients ) ) { 22 26 23 // Sender info 24 $sender_name = stripslashes( $sender_name ); 25 $subject = stripslashes( wp_filter_kses( $subject ) ); 26 $content = stripslashes( wp_filter_kses( $content ) ); 27 foreach( $recipients as $recipient ) { 27 28 28 // Set up and send the message 29 $email_to = $ud->user_email; 30 $sitename = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES ); 31 $email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name ); 29 if ( $sender_id == $recipient->user_id || 'no' == bp_get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) 30 continue; 32 31 33 $email_content = sprintf( __( 32 // User data and links 33 $ud = get_userdata( $recipient->user_id ); 34 $message_link = bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() .'/'; 35 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 36 $settings_link = bp_core_get_user_domain( $recipient->user_id ) . $settings_slug . '/notifications/'; 37 38 // Sender info 39 $sender_name = stripslashes( $sender_name ); 40 $subject = stripslashes( wp_filter_kses( $subject ) ); 41 $content = stripslashes( wp_filter_kses( $content ) ); 42 43 // Set up and send the message 44 $email_to = $ud->user_email; 45 $sitename = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES ); 46 $email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name ); 47 48 $email_content = sprintf( __( 34 49 '%1$s sent you a new message: 35 50 … … 43 58 ', 'buddypress' ), $sender_name, $subject, $content, $message_link ); 44 59 45 $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );60 $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 46 61 47 // Send the message48 $email_to = apply_filters( 'messages_notification_new_message_to',$email_to );49 $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name );50 $email_content = apply_filters( 'messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link );62 // Send the message 63 $email_to = apply_filters( 'messages_notification_new_message_to', $email_to ); 64 $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name ); 65 $email_content = apply_filters( 'messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link ); 51 66 52 wp_mail( $email_to, $email_subject, $email_content ); 67 wp_mail( $email_to, $email_subject, $email_content ); 68 } 53 69 } 54 70
Note: See TracChangeset
for help on using the changeset viewer.