Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/22/2015 06:12:16 AM (11 years ago)
Author:
tw2113
Message:

Second pass at Messages Component docs cleanup.

See #6403.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-notifications.php

    r10139 r10304  
    2727function messages_notification_new_message( $raw_args = array() ) {
    2828
    29         // Cast possible $message object as an array
     29        // Cast possible $message object as an array.
    3030        if ( is_object( $raw_args ) ) {
    3131                $args = (array) $raw_args;
     
    3434        }
    3535
    36         // These should be extracted below
     36        // These should be extracted below.
    3737        $recipients    = array();
    3838        $email_subject = $email_content = '';
    3939        $sender_id     = 0;
    4040
    41         // Barf
     41        // Barf.
    4242        extract( $args );
    4343
    44         // Get the sender display name
     44        // Get the sender display name.
    4545        $sender_name = bp_core_get_user_displayname( $sender_id );
    4646
    47         // Bail if no recipients
     47        // Bail if no recipients.
    4848        if ( ! empty( $recipients ) ) {
    4949
     
    5454                        }
    5555
    56                         // User data and links
     56                        // User data and links.
    5757                        $ud = get_userdata( $recipient->user_id );
    5858
    59                         // Bail if user cannot be found
     59                        // Bail if user cannot be found.
    6060                        if ( empty( $ud ) ) {
    6161                                continue;
     
    6666                        $settings_link = bp_core_get_user_domain( $recipient->user_id ) . $settings_slug . '/notifications/';
    6767
    68                         // Sender info
     68                        // Sender info.
    6969                        $sender_name   = stripslashes( $sender_name );
    7070                        $subject       = stripslashes( wp_filter_kses( $subject ) );
    7171                        $content       = stripslashes( wp_filter_kses( $message ) );
    7272
    73                         // Set up and send the message
     73                        // Set up and send the message.
    7474                        $email_to      = $ud->user_email;
    7575                        $email_subject = bp_get_email_subject( array( 'text' => sprintf( __( 'New message from %s', 'buddypress' ), $sender_name ) ) );
     
    8787', 'buddypress' ), $sender_name, $subject, $content, $message_link );
    8888
    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.
    9090                        if ( bp_is_active( 'settings' ) ) {
    9191                                $email_content .= sprintf( __( 'To disable these notifications, please log in and go to: %s', 'buddypress' ), $settings_link );
     
    160160 * @param string $format            Return value format. 'string' for BuddyBar-compatible
    161161 *                                  notifications; 'array' for WP Toolbar. Default: 'string'.
    162  *
    163162 * @return string|array Formatted notifications.
    164163 */
     
    176175                        $amount = 'single';
    177176
    178                         // get message thread ID
     177                        // Get message thread ID.
    179178                        $message   = new BP_Messages_Message( $item_id );
    180179                        $thread_id = $message->thread_id;
     
    268267                global $thread_template;
    269268
    270                 // get unread PM notifications for the user
     269                // Get unread PM notifications for the user.
    271270                $new_pm_notifications = BP_Notifications_Notification::get( array(
    272271                        'user_id'           => bp_loggedin_user_id(),
     
    277276                $unread_message_ids = wp_list_pluck( $new_pm_notifications, 'item_id' );
    278277
    279                 // no unread PMs, so stop!
     278                // No unread PMs, so stop!
    280279                if ( empty( $unread_message_ids ) ) {
    281280                        return;
    282281                }
    283282
    284                 // get the unread message ids for this thread only
     283                // Get the unread message ids for this thread only.
    285284                $message_ids = array_intersect( $unread_message_ids, wp_list_pluck( $thread_template->thread->messages, 'id' ) );
    286285
    287                 // mark each notification for each PM message as read
     286                // Mark each notification for each PM message as read.
    288287                foreach ( $message_ids as $message_id ) {
    289288                        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.