Skip to:
Content

BuddyPress.org

Ticket #5942: bp-friends-notifications-5942.diff

File bp-friends-notifications-5942.diff, 6.9 KB (added by tw2113, 11 years ago)
  • src/bp-friends/bp-friends-notifications.php

     
    5656                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    5757        }
    5858
    59         // Send the message
     59        /**
     60         * Filters the email address for who is getting the friend request.
     61         *
     62         * @since BuddyPress (1.2.0)
     63         *
     64         * @param string $to Email address for who is getting the friend request.
     65         */
    6066        $to      = apply_filters( 'friends_notification_new_request_to', $to );
     67
     68        /**
     69         * Filters the subject for the friend request email.
     70         *
     71         * @since BuddyPress (1.2.0)
     72         *
     73         * @param string $subject Subject line to be used in friend request email.
     74         * @param string $initiator_name Name of the person requesting friendship.
     75         */
    6176        $subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name );
     77
     78        /**
     79         * Filters the message for the friend request email.
     80         *
     81         * @since BuddyPress (1.2.0)
     82         *
     83         * @param string $message Message to be used in friend request email.
     84         * @param string $initiator_name Name of the person requesting friendship.
     85         * @param string $initiator_link Profile link of person requesting friendship.
     86         * @param string $all_requests_link User's friends request management link.
     87         * @param string $settings_link Email recipient's settings management link.
     88         */
    6289        $message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link, $settings_link );
    6390
    6491        wp_mail( $to, $subject, $message );
    6592
     93        /**
     94         * Fires after the new friend request email is sent.
     95         *
     96         * @since BuddyPress (1.5.0)
     97         *
     98         * @param int    $friend_id ID of the request recipient.
     99         * @param string $subject Text for the friend request subject field.
     100         * @param string $message Text for the friend request message field.
     101         * @param int    $friendship_id ID of the friendship object.
     102         * @param int    $initiator_id ID of the friendship requester.
     103         */
    66104        do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id );
    67105}
    68106add_action( 'friends_friendship_requested', 'friends_notification_new_request', 10, 3 );
     
    105143                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    106144        }
    107145
    108         // Send the message
     146        /**
     147         * Filters the email address for whose friend request got accepted.
     148         *
     149         * @since BuddyPress (1.2.0)
     150         *
     151         * @param string $to Email address for whose friend request got accepted.
     152         */
    109153        $to      = apply_filters( 'friends_notification_accepted_request_to', $to );
     154
     155        /**
     156         * Filters the subject for the friend request accepted email.
     157         *
     158         * @since BuddyPress (1.2.0)
     159         *
     160         * @param string $subject Subject line to be used in friend
     161         *                 request accepted email.
     162         * @param string $friend_name Name of the person who accepted
     163         *                 the friendship request.
     164         */
    110165        $subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name );
     166
     167        /**
     168         * Filters the message for the friend request accepted email.
     169         *
     170         * @since BuddyPress (1.2.0)
     171         *
     172         * @param string $message Message to be used in friend request email.
     173         * @param string $friend_name Name of the person who accepted
     174         *                 the friendship request.
     175         * @param string $friend_link Profile link of person who accepted
     176         *                 the friendship request.
     177         * @param string $settings_link Email recipient's settings management link.
     178         */
    111179        $message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link );
    112180
    113181        wp_mail( $to, $subject, $message );
    114182
     183        /**
     184         * Fires after the friend request accepted email is sent.
     185         *
     186         * @since BuddyPress (1.5.0)
     187         *
     188         * @param int    $initiator_id ID of the friendship requester.
     189         * @param string $subject Text for the friend request subject field.
     190         * @param string $message Text for the friend request message field.
     191         * @param int    $friendship_id ID of the friendship object.
     192         * @param int    $friend_id ID of the request recipient.
     193         */
    115194        do_action( 'bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id );
    116195}
    117196add_action( 'friends_friendship_accepted', 'friends_notification_accepted_request', 10, 3 );
     
    136215                case 'friendship_accepted':
    137216                        $link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends' );
    138217
    139                         // $action and $amount are used to generate dynamic filter names.
    140218                        $action = 'accepted';
    141219
    142220                        // Set up the string and the filter
     
    169247
    170248        // Return either an HTML link or an array, depending on the requested format
    171249        if ( 'string' == $format ) {
     250
     251                /**
     252                 * Filters the format of friendship notifications based on type and amount
     253                 * of notifications pending.
     254                 *
     255                 * This is a variable filter that has four possible versions.
     256                 * The four possible versions are:
     257                 *              bp_friends_single_friendship_accepted_notification
     258                 *              bp_friends_multiple_friendship_accepted_notification
     259                 *              bp_friends_single_friendship_request_notification
     260                 *              bp_friends_multiple_friendship_request_notification
     261                 *
     262                 * @since BuddyPress (1.0.0)
     263                 *
     264                 * @param string|array $value Depending on format, an HTML link to new
     265                 *                       requests profile tab or array with link and text.
     266                 * @param int          $total_items The total number of messaging-related
     267                 *                       notifications waiting for the user.
     268                 * @param int          $item_id The primary item ID.
     269                 */
    172270                $return = apply_filters( 'bp_friends_' . $amount . '_friendship_' . $action . '_notification', '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $item_id );
    173271        } else {
     272                /** This filter is documented in bp-friends/bp-friends-notifications.php */
    174273                $return = apply_filters( 'bp_friends_' . $amount . '_friendship_' . $action . '_notification', array(
    175274                        'link' => $link,
    176275                        'text' => $text
     
    177276                ), (int) $total_items, $item_id );
    178277        }
    179278
     279        /**
     280         * Fires at the end of the bp-friends notification format callback.
     281         *
     282         * @since BuddyPress (1.0.0)
     283         *
     284         * @param string       $action The kind of notification being rendered.
     285         * @param int          $item_id The primary item ID.
     286         * @param int          $secondary_item_id The secondary item ID.
     287         * @param int          $total_items The total number of messaging-related notifications
     288         *                       waiting for the user.
     289         * @param array|string $return Notification text string or array of link and text.
     290         */
    180291        do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return );
    181292
    182293        return $return;