Skip to:
Content

BuddyPress.org

Changeset 9174


Ignore:
Timestamp:
11/25/2014 02:51:59 PM (12 years ago)
Author:
boonebgorges
Message:

Add hook documentation in bp-friends-functions.php.

Props tw2113.
See #5942.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/bp-friends-functions.php

    r9173 r9174  
    100100        $friendship    = new BP_Friends_Friendship( $friendship_id );
    101101
     102        /**
     103         * Fires before the deletion of a friendship activity item
     104         * for the user who canceled the friendship.
     105         *
     106         * @since BuddyPress (1.5.0)
     107         *
     108         * @param int $friendship_id ID of the friendship object, if any, between a pair of users.
     109         * @param int $initiator_userid ID of the friendship initiator.
     110         * @param int $friend_userid ID of the friend user.
     111         */
    102112        do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid );
    103113
    … …  
    105115        friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => bp_displayed_user_id() ) );
    106116
    107         // This hook is misleadingly named - the friendship is not yet deleted.
    108         // This is your last chance to do something while the friendship exists
     117        /**
     118         * Fires before the friendship connection is removed.
     119         *
     120         * This hook is misleadingly named - the friendship is not yet deleted.
     121         * This is your last chance to do something while the friendship exists.
     122         *
     123         * @since BuddyPress (1.0.0)
     124         *
     125         * @param int $friendship_id ID of the friendship object, if any, between a pair of users.
     126         * @param int $initiator_userid ID of the friendship initiator.
     127         * @param int $friend_userid ID of the friend user.
     128         */
    109129        do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
    110130
    … …  
    112132                friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
    113133
     134                /**
     135                 * Fires after the friendship connection is removed.
     136                 *
     137                 * @since BuddyPress (1.8.0)
     138                 *
     139                 * @param int $initiator_userid ID of the friendship initiator.
     140                 * @param int $friend_userid ID of the friend user.
     141                 */
    114142                do_action( 'friends_friendship_post_delete', $initiator_userid, $friend_userid );
    115143
    … …  
    139167                friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    140168
     169                /**
     170                 * Fires after a friendship is accepted.
     171                 *
     172                 * @since BuddyPress (1.0.0)
     173                 *
     174                 * @param int    $id ID of the pending friendship object.
     175                 * @param int    $initiator_user_id ID of the friendship initiator.
     176                 * @param int    $friend_user_id ID of the user requested friendship with.
     177                 * @param object $friendship BuddyPress Friendship Object.
     178                 */
    141179                do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship );
    142180
    … …  
    157195
    158196        if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::reject( $friendship_id ) ) {
     197
     198                /**
     199                 * Fires after a friendship request is rejected.
     200                 *
     201                 * @since BuddyPress (1.0.0)
     202                 *
     203                 * @param int                   $friendship_id ID of the pending friendship.
     204                 * @param BP_Friends_Friendship $friendships Friendship object. Passed by reference.
     205                 */
    159206                do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
    160207                return true;
    … …  
    181228                do_action_ref_array( 'friends_friendship_whithdrawn', array( $friendship_id, &$friendship ) );
    182229
    183                 // @since 1.9
     230                /**
     231                 * Fires after a friendship request has been withdrawn.
     232                 *
     233                 * @since BuddyPress (1.9.0)
     234                 *
     235                 * @param int                   $friendship_id ID of the friendship.
     236                 * @param BP_Friends_Friendship $friendship Friendship object. Passed by reference.
     237                 */
    184238                do_action_ref_array( 'friends_friendship_withdrawn',  array( $friendship_id, &$friendship ) );
    185239
    … …  
    247301                $count = 0;
    248302
     303        /**
     304         * Filters the total friend count for a given user.
     305         *
     306         * @since BuddyPress (1.2.0)
     307         *
     308         * @param int $count Total friend count for a given user.
     309         */
    249310        return apply_filters( 'friends_get_total_friend_count', $count );
    250311}
    … …  
    338399 */
    339400function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
     401
     402        /**
     403         * Filters a user's most recently active friends.
     404         *
     405         * @since BuddyPress (1.2.0)
     406         *
     407         * @param array {
     408         *     @type int   $total_users Total number of users matched by query params.
     409         *     @type array $paged_users The current page of users matched by query params.
     410         * }
     411         */
    340412        return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
    341413}
    … …  
    356428 */
    357429function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
     430
     431        /**
     432         * Filters a user's friends listed in alphabetical order.
     433         *
     434         * @since BuddyPress (1.2.0)
     435         *
     436         * @return array {
     437         *     @type int   $total_users Total number of users matched by query params.
     438         *     @type array $paged_users The current page of users matched by query params.
     439         * }
     440         */
    358441        return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
    359442}
    … …  
    374457 */
    375458function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
     459
     460        /**
     461         * Filters a user's friends listed from newest to oldest.
     462         *
     463         * @since BuddyPress (1.2.0)
     464         *
     465         * @param array {
     466         *     @type int   $total_users Total number of users matched by query params.
     467         *     @type array $paged_users The current page of users matched by query params.
     468         * }
     469         */
    376470        return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
    377471}
    … …  
    415509        $friends = array();
    416510
    417         // Default args
     511        /**
     512         * Filters default arguments for list of friends a user can invite into this group.
     513         *
     514         * @since BuddyPress (1.5.4)
     515         *
     516         * @param array $value Array of default paremters for invite list.
     517         */
    418518        $args = apply_filters( 'bp_friends_pre_get_invite_list', array(
    419519                'user_id'  => $user_id,
    … …  
    462562                $friends = false;
    463563
    464         // Allow friends to be filtered
     564        /**
     565         * Filters the list of potential friends that can be invited to this group.
     566         *
     567         * @since BuddyPress (1.5.4)
     568         *
     569         * @param array|bool $friends Array friends available to invite or false for no friends.
     570         * @param int        $user_id ID of the user checked for who they can invite.
     571         * @param int        $group_id ID of the group being checked on.
     572         */
    465573        return apply_filters( 'bp_friends_get_invite_list', $friends, $user_id, $group_id );
    466574}
    … …  
    567675function friends_remove_data( $user_id ) {
    568676
     677        /**
     678         * Fires before deletion of friend-related data for a given user.
     679         *
     680         * @since BuddyPress (1.5.0)
     681         *
     682         * @param int $user_id ID for the user whose friend data is being removed.
     683         */
    569684        do_action( 'friends_before_remove_data', $user_id );
    570685
    … …  
    574689        bp_delete_user_meta( $user_id, 'total_friend_count' );
    575690
     691        /**
     692         * Fires after deletion of friend-related data for a given user.
     693         *
     694         * @since BuddyPress (1.0.0)
     695         *
     696         * @param int $user_id ID for the user whose friend data is being removed.
     697         */
    576698        do_action( 'friends_remove_data', $user_id );
    577699}
Note: See TracChangeset for help on using the changeset viewer.