Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/11/2014 07:53:48 PM (10 years ago)
Author:
boonebgorges
Message:

Add hook documentation to bp-activity-notifications.php.

See #5938.
Props tw2113.

File:
1 edited

Legend:

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

    r8095 r9134  
    1616 * Send email and BP notifications when a user is mentioned in an update.
    1717 *
    18  * @since BuddyPress (1.2)
     18 * @since BuddyPress (1.2.0)
    1919 *
    2020 * @uses bp_notifications_add_notification()
     
    100100        }
    101101
    102         // Send the message
     102        /**
     103         * Filters the user email that the @mention notification will be sent to.
     104         *
     105         * @since BuddyPress (1.2.0)
     106         *
     107         * @param string $to User email the notification is being sent to.
     108         */
    103109        $to      = apply_filters( 'bp_activity_at_message_notification_to', $to );
     110
     111        /**
     112         * Filters the @mention notification subject that will be sent to user.
     113         *
     114         * @since BuddyPress (1.2.0)
     115         *
     116         * @param string $subject Email notification subject text.
     117         * @param string $poster_name Name of the person who made the @mention.
     118         */
    104119        $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
     120
     121        /**
     122         * Filters the @mention notification message that will be sent to user.
     123         *
     124         * @since BuddyPress (1.2.0)
     125         *
     126         * @param string $message Email notification message text.
     127         * @param string $poster_name Name of the person who made the @mention.
     128         * @param string $content Content of the @mention.
     129         * @param string $message_link URL permalink for the activity message.
     130         * @param string $settings_link URL permalink for the user's notification settings area.
     131         */
    105132        $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
    106133
     
    108135    }
    109136
     137    /**
     138     * Fires after the sending of an @mention email notification.
     139     *
     140     * @since BuddyPress (1.5.0)
     141     *
     142     * @param BP_Activity_Activity $activity Activity Item object.
     143     * @param string               $subject Email notification subject text.
     144     * @param string               $message Email notification message text.
     145     * @param string               $content Content of the @mention.
     146     * @param int                  $receiver_user_id The ID of the user who is receiving the update.
     147     */
    110148    do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id );
    111149}
     
    114152 * Send email and BP notifications when an activity item receives a comment.
    115153 *
    116  * @since BuddyPress (1.2)
     154 * @since BuddyPress (1.2.0)
    117155 *
    118156 * @uses bp_get_user_meta()
     
    178216        }
    179217
    180         /* Send the message */
     218        /**
     219         * Filters the user email that the new comment notification will be sent to.
     220         *
     221         * @since BuddyPress (1.2.0)
     222         *
     223         * @param string $to User email the notification is being sent to.
     224         */
    181225        $to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
     226
     227        /**
     228         * Filters the new comment notification subject that will be sent to user.
     229         *
     230         * @since BuddyPress (1.2.0)
     231         *
     232         * @param string $subject Email notification subject text.
     233         * @param string $poster_name Name of the person who made the comment.
     234         */
    182235        $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
     236
     237        /**
     238         * Filters the new comment notification message that will be sent to user.
     239         *
     240         * @since BuddyPress (1.2.0)
     241         *
     242         * @param string $message Email notification message text.
     243         * @param string $poster_name Name of the person who made the comment.
     244         * @param string $content Content of the comment.
     245         * @param string $thread_link URL permalink for the activity thread.
     246         * @param string $settings_link URL permalink for the user's notification settings area.
     247         */
    183248        $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link );
    184249
    185250        wp_mail( $to, $subject, $message );
    186251
     252        /**
     253         * Fires after the sending of a reply to an update email notification.
     254         *
     255         * @since BuddyPress (1.5.0)
     256         *
     257         * @param int    $user_id ID of the original activity item author.
     258         * @param string $subject Email notification subject text.
     259         * @param string $message Email notification message text.
     260         * @param int    $comment_id ID for the newly received comment.
     261         * @param int    $commenter_id ID of the user who made the comment.
     262         * @param array  $params Arguments used with the original activity comment.
     263         */
    187264        do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
    188265    }
     
    227304        }
    228305
    229         /* Send the message */
     306        /**
     307         * Filters the user email that the new comment reply notification will be sent to.
     308         *
     309         * @since BuddyPress (1.2.0)
     310         *
     311         * @param string $to User email the notification is being sent to.
     312         */
    230313        $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to );
     314
     315        /**
     316         * Filters the new comment reply notification subject that will be sent to user.
     317         *
     318         * @since BuddyPress (1.2.0)
     319         *
     320         * @param string $subject Email notification subject text.
     321         * @param string $poster_name Name of the person who made the comment reply.
     322         */
    231323        $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
     324
     325        /**
     326         * Filters the new comment reply notification message that will be sent to user.
     327         *
     328         * @since BuddyPress (1.2.0)
     329         *
     330         * @param string $message Email notification message text.
     331         * @param string $poster_name Name of the person who made the comment reply.
     332         * @param string $content Content of the comment reply.
     333         * @param string $settings_link URL permalink for the user's notification settings area.
     334         * @param string $thread_link URL permalink for the activity thread.
     335         */
    232336        $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link );
    233337
    234338        wp_mail( $to, $subject, $message );
    235339
     340        /**
     341         * Fires after the sending of a reply to a reply email notification.
     342         *
     343         * @since BuddyPress (1.5.0)
     344         *
     345         * @param int    $user_id ID of the original activity item author.
     346         * @param string $subject Email notification subject text.
     347         * @param string $message Email notification message text.
     348         * @param int    $comment_id ID for the newly received comment.
     349         * @param int    $commenter_id ID of the user who made the comment.
     350         * @param array  $params Arguments used with the original activity comment.
     351         */
    236352        do_action( 'bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
    237353    }
     
    255371 * Format notifications related to activity.
    256372 *
    257  * @since BuddyPress (1.5)
     373 * @since BuddyPress (1.5.0)
    258374 *
    259375 * @uses bp_loggedin_user_domain()
     
    279395            $at_mention_link  = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
    280396            $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );
     397            $amount = 'single';
    281398
    282399            if ( (int) $total_items > 1 ) {
    283400                $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
    284                 $filter = 'bp_activity_multiple_at_mentions_notification';
     401                $amount = 'multiple';
    285402            } else {
    286403                $user_fullname = bp_core_get_user_displayname( $poster_user_id );
    287404                $text =  sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
    288                 $filter = 'bp_activity_single_at_mentions_notification';
    289405            }
    290406        break;
     
    292408
    293409    if ( 'string' == $format ) {
    294         $return = apply_filters( $filter, '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
     410
     411        /**
     412         * Filters the @mention notification for the string format.
     413         *
     414         * This is a variable filter that is dependent on how many items
     415         * need notified about. The two possible hooks are bp_activity_single_at_mentions_notification
     416         * or bp_activity_multiple_at_mentions_notification.
     417         *
     418         * @since BuddyPress (1.5.0)
     419         *
     420         * @param string $string HTML anchor tag for the mention.
     421         * @param string $at_mention_link The permalink for the mention.
     422         * @param int    $total_items How many items being notified about.
     423         * @param int    $activity_id ID of the activity item being formatted.
     424         * @param int    $poster_user_id ID of the user posting the mention.
     425         */
     426        $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
    295427    } else {
    296         $return = apply_filters( $filter, array(
     428
     429        /**
     430         * Filters the @mention notification for any non-string format.
     431         *
     432         * This is a variable filter that is dependent on how many items need notified about.
     433         * The two possible hooks are bp_activity_single_at_mentions_notification
     434         * or bp_activity_multiple_at_mentions_notification.
     435         *
     436         * @since BuddyPress (1.5.0)
     437         *
     438         * @param array  $array Array holding the content and permalink for the mention notification.
     439         * @param string $at_mention_link The permalink for the mention.
     440         * @param int    $total_items How many items being notified about.
     441         * @param int    $activity_id ID of the activity item being formatted.
     442         * @param int    $poster_user_id ID of the user posting the mention.
     443         */
     444        $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array(
    297445            'text' => $text,
    298446            'link' => $at_mention_link
     
    300448    }
    301449
     450    /**
     451     * Fires right before returning the formatted activity notifications.
     452     *
     453     * @since BuddyPress (1.2.0)
     454     *
     455     * @param string $action The type of activity item.
     456     * @param int    $item_id The activity ID.
     457     * @param int    $secondary_item_id @mention mentioner ID.
     458     * @param int    $total_items Total amount of items to format.
     459     */
    302460    do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    303461
     
    339497 * Mark at-mention notifications as read when users visit their Mentions page.
    340498 *
    341  * @since BuddyPress (1.5)
     499 * @since BuddyPress (1.5.0)
    342500 *
    343501 * @uses bp_notifications_mark_all_notifications_by_type()
Note: See TracChangeset for help on using the changeset viewer.