Skip to:
Content

BuddyPress.org

Changeset 9176


Ignore:
Timestamp:
11/25/2014 03:00:40 PM (10 years ago)
Author:
boonebgorges
Message:

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

Props tw2113.
See #5942.

File:
1 edited

Legend:

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

    r8546 r9176  
    2727     */
    2828    function bp_get_friends_slug() {
     29
     30        /**
     31         * Filters the friends component slug.
     32         *
     33         * @since BuddyPress (1.5.0)
     34         *
     35         * @param string $value Friends component slug.
     36         */
    2937        return apply_filters( 'bp_get_friends_slug', buddypress()->friends->slug );
    3038    }
     
    4654     */
    4755    function bp_get_friends_root_slug() {
     56
     57        /**
     58         * Filters the friends component root slug.
     59         *
     60         * @since BuddyPress (1.5.0)
     61         *
     62         * @param string $value Friends component root slug.
     63         */
    4864        return apply_filters( 'bp_get_friends_root_slug', buddypress()->friends->root_slug );
    4965    }
     
    213229        global $members_template;
    214230
    215         if ( 1 == (int) $members_template->member->total_friend_count )
     231        if ( 1 == (int) $members_template->member->total_friend_count ) {
     232
     233            /**
     234             * Filters text used to denote total friend count.
     235             *
     236             * @since BuddyPress (1.2.0)
     237             *
     238             * @param string $value String of the form "x friends".
     239             * @param int    $value Total friend count for current member in the loop.
     240             */
    216241            return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
    217         else
     242        } else {
     243
     244            /** This filter is documented in bp-friends/bp-friends-template.php */
    218245            return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
     246        }
    219247    }
    220248
     
    246274            $user_id = bp_displayed_user_id();
    247275
     276        /**
     277         * Filters the ID of current user in the friend request loop.
     278         *
     279         * @since BuddyPress (1.2.10)
     280         *
     281         * @param int $user_id ID of current user in the friend request loop.
     282         */
    248283        return apply_filters( 'bp_get_potential_friend_id', (int) $user_id );
    249284    }
     
    269304        return false;
    270305
     306    /**
     307     * Filters the status of friendship between logged in user and given user.
     308     *
     309     * @since BuddyPress (1.2.10)
     310     *
     311     * @param string $value String status of friendship. Possible values are 'is_friend', 'not_friends', 'pending'.
     312     */
    271313    return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id );
    272314}
     
    371413        }
    372414
    373         // Filter and return the HTML button
     415        /**
     416         * Filters the HTML for the add friend button.
     417         *
     418         * @since BuddyPress (1.1.0)
     419         *
     420         * @param string $button HTML markup for add friend button.
     421         */
    374422        return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) );
    375423    }
     
    423471    }
    424472
     473    /**
     474     * Filters the total pending friendship requests for a user.
     475     *
     476     * @since BuddyPress (1.2.0)
     477     *
     478     * @param array|int An array of user IDs if found, or a 0 if none are found.
     479     */
    425480    return apply_filters( 'bp_get_friendship_requests', $requests );
    426481}
     
    445500        }
    446501
     502        /**
     503         * Filters the ID of the friendship between the logged in user and the current user in the loop.
     504         *
     505         * @since BuddyPress (1.2.0)
     506         *
     507         * @param int $friendship_id ID of the friendship.
     508         */
    447509        return apply_filters( 'bp_get_friend_friendship_id', $friendship_id );
    448510    }
     
    467529        }
    468530
     531        /**
     532         * Filters the URL for accepting the current friendship request in the loop.
     533         *
     534         * @since BuddyPress (1.0.0)
     535         *
     536         * @param string $value Accept-friendship URL.
     537         */
    469538        return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) );
    470539    }
     
    489558        }
    490559
     560        /**
     561         * Filters the URL for rejecting the current friendship request in the loop.
     562         *
     563         * @since BuddyPress (1.0.0)
     564         *
     565         * @param string $value Reject-friendship URL.
     566         */
    491567        return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) );
    492568    }
     
    507583     */
    508584    function bp_get_total_friend_count( $user_id = 0 ) {
     585
     586        /**
     587         * Filters the total friend count for a given user.
     588         *
     589         * @since BuddyPress (1.2.0)
     590         *
     591         * @param int $value Total friend count.
     592         */
    509593        return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) );
    510594    }
     
    532616            $user_id = bp_loggedin_user_id();
    533617
     618        /**
     619         * Filters the total friendship request count for a given user.
     620         *
     621         * @since BuddyPress (1.2.0)
     622         *
     623         * @param int $value Friendship request count.
     624         */
    534625        return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ) );
    535626    }
     
    585676    }
    586677
    587     // Filter and return
     678    /**
     679     * Filters the number of friends in user's profile.
     680     *
     681     * @since BuddyPress (2.0.0)
     682     *
     683     * @param string $value Formatted string displaying total friends count.
     684     * @param array  $r Array of arguments for string formatting and output.
     685     */
    588686    return apply_filters( 'bp_friends_get_profile_stats', $r['output'], $r );
    589687}
Note: See TracChangeset for help on using the changeset viewer.