Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/24/2021 04:16:17 AM (5 years ago)
Author:
espellcaste
Message:

Making PHPDoc Improvements to the BP Friends (component) files.

Also, adding several minor PHP changes.

See #8553

File:
1 edited

Legend:

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

    r12670 r13092  
    1515 *
    1616 * @since 1.5.0
    17  *
    1817 */
    1918function bp_friends_slug() {
     
    4342 *
    4443 * @since 1.5.0
    45  *
    4644 */
    4745function bp_friends_root_slug() {
     
    246244         * Return value is a string of the form "x friends".
    247245         *
     246         * @global object $members_template
     247         *
    248248         * @since 1.2.0
    249249         *
     
    296296                global $friends_template;
    297297
    298                 if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) )
     298                if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) ) {
    299299                        $user_id = $friends_template->friendship->friend->id;
    300                 elseif ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) )
     300                } elseif ( empty( $user_id ) && ! isset( $friends_template->friendship->friend ) ) {
    301301                        $user_id = bp_displayed_user_id();
     302                }
    302303
    303304                /**
     
    320321 * @param int $user_id ID of the potential friend. Default: the value of
    321322 *                     {@link bp_get_potential_friend_id()}.
    322  * @return string 'is_friend', 'not_friends', or 'pending'.
     323 * @return bool|string 'is_friend', 'not_friends', or 'pending'.
    323324 */
    324325function bp_is_friend( $user_id = 0 ) {
    325326
    326         if ( !is_user_logged_in() )
     327        if ( ! is_user_logged_in() ) {
    327328                return false;
    328 
    329         if ( empty( $user_id ) )
     329        }
     330
     331        if ( empty( $user_id ) ) {
    330332                $user_id = bp_get_potential_friend_id( $user_id );
    331 
    332         if ( bp_loggedin_user_id() == $user_id )
     333        }
     334
     335        if ( bp_loggedin_user_id() === $user_id ) {
    333336                return false;
     337        }
    334338
    335339        /**
     
    338342         * @since 1.2.10
    339343         *
    340          * @param string $value String status of friendship. Possible values are 'is_friend', 'not_friends', 'pending'.
     344         * @param string $value   String status of friendship. Possible values are 'is_friend', 'not_friends', 'pending'.
     345         * @param int    $user_id ID of the potential friend.
    341346         */
    342347        return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id );
     
    364369         *                                  applies. Default: value of {@link bp_get_potential_friend_id()}.
    365370         * @param bool $friend_status       Not currently used.
    366          * @return false|string HTML for the Add Friend button.
     371         * @return bool|string HTML for the Add Friend button. False if already friends.
    367372         */
    368373        function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
    369374
    370                 if ( empty( $potential_friend_id ) )
     375                if ( empty( $potential_friend_id ) ) {
    371376                        $potential_friend_id = bp_get_potential_friend_id( $potential_friend_id );
     377                }
    372378
    373379                $is_friend = bp_is_friend( $potential_friend_id );
    374380
    375                 if ( empty( $is_friend ) )
     381                if ( empty( $is_friend ) ) {
    376382                        return false;
     383                }
    377384
    378385                switch ( $is_friend ) {
    379                         case 'pending' :
     386                        case 'pending':
    380387                                $button = array(
    381388                                        'id'                => 'pending',
     
    389396                                        'link_id'           => 'friend-' . $potential_friend_id,
    390397                                        'link_rel'          => 'remove',
    391                                         'link_class'        => 'friendship-button pending_friend requested'
     398                                        'link_class'        => 'friendship-button pending_friend requested',
    392399                                );
    393400                                break;
    394401
    395                         case 'awaiting_response' :
     402                        case 'awaiting_response':
    396403                                $button = array(
    397404                                        'id'                => 'awaiting_response',
     
    405412                                        'link_id'           => 'friend-' . $potential_friend_id,
    406413                                        'link_rel'          => 'remove',
    407                                         'link_class'        => 'friendship-button awaiting_response_friend requested'
     414                                        'link_class'        => 'friendship-button awaiting_response_friend requested',
    408415                                );
    409416                                break;
    410417
    411                         case 'is_friend' :
     418                        case 'is_friend':
    412419                                $button = array(
    413420                                        'id'                => 'is_friend',
     
    421428                                        'link_id'           => 'friend-' . $potential_friend_id,
    422429                                        'link_rel'          => 'remove',
    423                                         'link_class'        => 'friendship-button is_friend remove'
     430                                        'link_class'        => 'friendship-button is_friend remove',
    424431                                );
    425432                                break;
     
    437444                                        'link_id'           => 'friend-' . $potential_friend_id,
    438445                                        'link_rel'          => 'add',
    439                                         'link_class'        => 'friendship-button not_friends add'
     446                                        'link_class'        => 'friendship-button not_friends add',
    440447                                );
    441448                                break;
     
    459466 * @param int $user_id Optional. Default: the displayed user's ID, or the
    460467 *                     logged-in user's ID.
    461  * @return false|string A comma-separated list of friend IDs if any are found,
     468 * @return bool|string A comma-separated list of friend IDs if any are found,
    462469 *                      otherwise false.
    463470 */
    464471function bp_get_friend_ids( $user_id = 0 ) {
    465472
    466         if ( empty( $user_id ) )
     473        if ( empty( $user_id ) ) {
    467474                $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
     475        }
    468476
    469477        $friend_ids = friends_get_friend_user_ids( $user_id );
    470478
    471         if ( empty( $friend_ids ) )
     479        if ( empty( $friend_ids ) ) {
    472480                return false;
     481        }
    473482
    474483        return implode( ',', friends_get_friend_user_ids( $user_id ) );
     
    488497 */
    489498function bp_get_friendship_requests( $user_id = 0 ) {
    490         if ( !$user_id ) {
     499        if ( ! $user_id ) {
    491500                $user_id = bp_displayed_user_id();
    492501        }
    493502
    494         if ( !$user_id ) {
     503        if ( ! $user_id ) {
    495504                return 0;
    496505        }
     
    498507        $requests = friends_get_friendship_request_user_ids( $user_id );
    499508
    500         if ( !empty( $requests ) ) {
     509        if ( ! empty( $requests ) ) {
    501510                $requests = implode( ',', (array) $requests );
    502511        } else {
     
    529538         * @since 1.2.0
    530539         *
     540         * @global object $members_template
     541         *
    531542         * @return int ID of the friendship.
    532543         */
     
    562573         * @since 1.0.0
    563574         *
     575         * @global object $members_template
     576         *
    564577         * @return string accept-friendship URL.
    565578         */
     
    597610         * @since 1.0.0
    598611         *
     612         * @global object $members_template
     613         *
    599614         * @return string reject-friendship URL.
    600615         */
     
    656671 * @since 1.2.0
    657672 *
    658  * @see bp_friend_get_total_requests_count() for description of arguments.
    659  *
    660  * @param int $user_id See {@link bp_friend_get_total_requests_count().
     673 * @param int $user_id ID of the user whose requests are being counted.
     674 *                     Default: ID of the logged-in user.
    661675 */
    662676function bp_friend_total_requests_count( $user_id = 0 ) {
     
    673687         */
    674688        function bp_friend_get_total_requests_count( $user_id = 0 ) {
    675                 if ( empty( $user_id ) )
     689                if ( empty( $user_id ) ) {
    676690                        $user_id = bp_loggedin_user_id();
     691                }
    677692
    678693                /**
Note: See TracChangeset for help on using the changeset viewer.