Skip to:
Content

BuddyPress.org

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

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

     
    2626         * @since BuddyPress (1.5.0)
    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        }
    3139
     
    4553         * @since BuddyPress (1.5.0)
    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        }
    5066
     
    212228        function bp_get_member_total_friend_count() {
    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
    221249/**
     
    245273                else if ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) )
    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        }
    250285
     
    268303        if ( bp_loggedin_user_id() == $user_id )
    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
     312         *                 'is_friend', 'not_friends', 'pending'.
     313         */
    271314        return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id );
    272315}
    273316
     
    370413                                break;
    371414                }
    372415
    373                 // Filter and return the HTML button
     416                /**
     417                 * Filters the HTML for the add friend button.
     418                 *
     419                 * @since BuddyPress (1.1.0)
     420                 *
     421                 * @param string $button HTML markup for add friend button.
     422                 */
    374423                return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) );
    375424        }
    376425
     
    422471                $requests = 0;
    423472        }
    424473
     474        /**
     475         * Filters the total pending friendship requests for a user.
     476         *
     477         * @since BuddyPress (1.2.0)
     478         *
     479         * @param array|int An array of user IDs if found, or a 0 if none are found.
     480         */
    425481        return apply_filters( 'bp_get_friendship_requests', $requests );
    426482}
    427483
     
    444500                        wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
    445501                }
    446502
     503                /**
     504                 * Filters the ID of the friendship between the logged in user and the current user in the loop.
     505                 *
     506                 * @since BuddyPress (1.2.0)
     507                 *
     508                 * @param int $friendship_id ID of the friendship.
     509                 */
    447510                return apply_filters( 'bp_get_friend_friendship_id', $friendship_id );
    448511        }
    449512
     
    466529                        wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
    467530                }
    468531
     532                /**
     533                 * Filters the URL for accepting the current friendship request in the loop.
     534                 *
     535                 * @since BuddyPress (1.0.0)
     536                 *
     537                 * @param string $value Accept-friendship URL.
     538                 */
    469539                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' ) );
    470540        }
    471541
     
    488558                        wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
    489559                }
    490560
     561                /**
     562                 * Filters the URL for rejecting the current friendship request in the loop.
     563                 *
     564                 * @since BuddyPress (1.0.0)
     565                 *
     566                 * @param string $value Reject-friendship URL.
     567                 */
    491568                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' ) );
    492569        }
    493570
     
    506583         * @return int Total friend count.
    507584         */
    508585        function bp_get_total_friend_count( $user_id = 0 ) {
     586
     587                /**
     588                 * Filters the total friend count for a given user.
     589                 *
     590                 * @since BuddyPress (1.2.0)
     591                 *
     592                 * @param int $value Total friend count.
     593                 */
    509594                return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) );
    510595        }
    511596        add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' );
     
    531616                if ( empty( $user_id ) )
    532617                        $user_id = bp_loggedin_user_id();
    533618
     619                /**
     620                 * Filters the total friendship request count for a given user.
     621                 *
     622                 * @since BuddyPress (1.2.0)
     623                 *
     624                 * @param int $value Friendship request count.
     625                 */
    534626                return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ) );
    535627        }
    536628
     
    584676                }
    585677        }
    586678
    587         // Filter and return
     679        /**
     680         * Filters the number of friends in user's profile.
     681         *
     682         * @since BuddyPress (2.0.0)
     683         *
     684         * @param string $value Formatted string displaying total friends count.
     685         * @param array  $r Array of arguments for string formatting and output.
     686         */
    588687        return apply_filters( 'bp_friends_get_profile_stats', $r['output'], $r );
    589688}