Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/11/2021 05:26:17 PM (3 years ago)
Author:
espellcaste
Message:

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

Also, adding several minor PHP changes.

See #8553

File:
1 edited

Legend:

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

    r12935 r13105  
    2323    $bp = buddypress();
    2424
    25     return (bool) !empty( $bp->pages->members->id );
     25    return (bool) ! empty( $bp->pages->members->id );
    2626}
    2727
     
    3838 *
    3939 * @since 1.5.0
     40 *
     41 * @global BuddyPress $bp The one true BuddyPress instance.
    4042 */
    4143function bp_core_define_slugs() {
     
    207209    // Don't use this filter.  Subject to removal in a future release.
    208210    // Use the 'bp_core_get_user_domain' filter instead.
    209     $domain       = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login );
     211    $domain = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login );
    210212
    211213    /**
     
    227229 * @since 1.2.0
    228230 *
    229  * @param  int $user_id The ID of the user.
    230  * @return array|bool Array of data on success, boolean false on failure.
     231 * @param int $user_id The ID of the user.
     232 * @return array|bool Array of data on success, false on failure.
    231233 */
    232234function bp_core_get_core_userdata( $user_id = 0 ) {
     
    235237    }
    236238
    237     // Get core user data
     239    // Get core user data.
    238240    $userdata = BP_Core_User::get_core_userdata( $user_id );
    239241
     
    243245     * @since 1.2.0
    244246     *
    245      * @param array|bool $userdata Array of user data for a passed user on success, boolean false on failure.
     247     * @param array|bool $userdata Array of user data for a passed user on success, false on failure.
    246248     */
    247249    return apply_filters( 'bp_core_get_core_userdata', $userdata );
     
    285287     * @param string   $username User login to check.
    286288     */
    287     return apply_filters( 'bp_core_get_userid', ! empty( $user->ID ) ? $user->ID : NULL, $username );
     289    return apply_filters( 'bp_core_get_userid', ! empty( $user->ID ) ? $user->ID : null, $username );
    288290}
    289291
     
    311313     * @param string   $user_nicename User nicename to check.
    312314     */
    313     return apply_filters( 'bp_core_get_userid_from_nicename', ! empty( $user->ID ) ? $user->ID : NULL, $user_nicename );
     315    return apply_filters( 'bp_core_get_userid_from_nicename', ! empty( $user->ID ) ? $user->ID : null, $user_nicename );
    314316}
    315317
     
    362364 */
    363365function bp_members_get_user_nicename( $user_id ) {
     366
    364367    /**
    365368     * Filters the user_nicename based on originally provided user ID.
     
    377380 * @since 1.0.0
    378381 *
    379  * @param int $uid User ID to check.
     382 * @param int $user_id User ID to check.
    380383 * @return string The email for the matched user. Empty string if no user
    381384 *                matches the $user_id.
    382385 */
    383386function bp_core_get_user_email( $user_id ) {
     387
    384388    /**
    385389     * Filters the user email for user based on user ID.
     
    508512}
    509513add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 );
    510 add_filter( 'bp_core_get_user_displayname', 'trim'          );
    511 add_filter( 'bp_core_get_user_displayname', 'stripslashes'  );
    512 add_filter( 'bp_core_get_user_displayname', 'esc_html'      );
     514add_filter( 'bp_core_get_user_displayname', 'trim' );
     515add_filter( 'bp_core_get_user_displayname', 'stripslashes' );
     516add_filter( 'bp_core_get_user_displayname', 'esc_html' );
    513517
    514518/**
     
    569573 * @since 1.2.0
    570574 *
     575 * @global wpdb $wpdb WordPress database object.
     576 *
    571577 * @return int The total number of members.
    572578 */
     
    596602 *
    597603 * @since 1.6.0
     604 *
     605 * @global wpdb $wpdb WordPress database object.
    598606 *
    599607 * @return int The number of active members.
     
    635643 * @since 5.0.0
    636644 *
    637  * @param int   $user_id The user ID to spam or ham.
    638  * @param int   $value   0 to mark the user as `ham`, 1 to mark as `spam`.
     645 * @param int $user_id The user ID to spam or ham.
     646 * @param int $value   0 to mark the user as `ham`, 1 to mark as `spam`.
    639647 * @return bool          True if the spam status of the member changed.
    640648 *                       False otherwise.
     
    677685 * @since 1.6.0
    678686 *
     687 * @global wpdb $wpdb WordPress database object.
     688 *
    679689 * @param int    $user_id       The ID of the user being spammed/hammed.
    680690 * @param string $status        'spam' if being marked as spam, 'ham' otherwise.
    681  * @param bool   $do_wp_cleanup True to force the cleanup of WordPress content
     691 * @param bool   $do_wp_cleanup Optional. True to force the cleanup of WordPress content
    682692 *                              and status, otherwise false. Generally, this should
    683693 *                              only be false if WordPress is expected to have
     
    708718    // Only you can prevent infinite loops.
    709719    remove_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' );
    710     remove_action( 'make_ham_user',  'bp_core_mark_user_ham_admin'  );
     720    remove_action( 'make_ham_user',  'bp_core_mark_user_ham_admin' );
    711721
    712722    // Force the cleanup of WordPress content and status for multisite configs.
     
    833843    // Put things back how we found them.
    834844    add_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' );
    835     add_action( 'make_ham_user',  'bp_core_mark_user_ham_admin' );
     845    add_action( 'make_ham_user', 'bp_core_mark_user_ham_admin' );
    836846
    837847    return true;
     
    865875 *
    866876 * @since 1.6.0
     877 *
     878 * @global BuddyPress $bp The one true BuddyPress instance.
    867879 *
    868880 * @param int $user_id The ID for the user.
     
    937949 * @since 1.6.0
    938950 *
     951 * @global BuddyPress $bp The one true BuddyPress instance.
     952 *
    939953 * @param int $user_id The ID for the user.
    940954 * @return bool True if deleted, otherwise false.
     
    10031017 * @since 1.6.0
    10041018 *
    1005  * @param int $user_id The user ID to check.
     1019 * @param int $user_id Optional. The user ID to check.
    10061020 * @return bool True if active, otherwise false.
    10071021 */
     
    10371051 * @since 1.6.0
    10381052 *
    1039  * @todo No need for the user fallback checks, since they're done in
    1040  *       bp_is_user_active().
    1041  *
    1042  * @param int $user_id The user ID to check.
     1053 * @param int $user_id Optional. The user ID to check.
    10431054 * @return bool True if inactive, otherwise false.
    10441055 */
    10451056function bp_is_user_inactive( $user_id = 0 ) {
    1046 
    1047     // Default to current user.
    1048     if ( empty( $user_id ) && is_user_logged_in() ) {
    1049         $user_id = bp_loggedin_user_id();
    1050     }
    1051 
    1052     // No user to check.
    1053     if ( empty( $user_id ) ) {
    1054         return false;
    1055     }
    1056 
    10571057    // Return the inverse of active.
    1058     return !bp_is_user_active( $user_id );
     1058    return ! bp_is_user_active( $user_id );
    10591059}
    10601060
     
    10661066 *              legacy user query is enabled.
    10671067 *
    1068  * @param int    $user_id ID of the user being updated.
    1069  * @param string $time    Time of last activity, in 'Y-m-d H:i:s' format.
     1068 * @param int    $user_id Optional. ID of the user being updated.
     1069 * @param string $time    Optional. Time of last activity, in 'Y-m-d H:i:s' format.
    10701070 * @return bool True on success, false on failure.
    10711071 */
     
    12111211 * @since 2.0.0
    12121212 *
     1213 * @global BuddyPress $bp The one true BuddyPress instance.
     1214 * @global wpdb $wpdb WordPress database object.
     1215 *
    12131216 * @return bool
    12141217 */
     
    15141517 * @since 1.2.7
    15151518 *
    1516  * @param array|string $value    Illegal names as being saved defined in
    1517  *                               Multisite settings.
    1518  * @param array|string $oldvalue The old value of the option.
     1519 * @param array|string $value Illegal names as being saved defined in
     1520 *                            Multisite settings.
    15191521 * @return array Merged and unique array of illegal names.
    15201522 */
    1521 function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) {
     1523function bp_core_get_illegal_names( $value = '' ) {
    15221524
    15231525    // Make sure $value is array.
     
    15451547        'notifications',
    15461548        'register',
    1547         'activate'
     1549        'activate',
    15481550    );
    15491551
     
    15631565        'BP_ACTIVATION_SLUG',
    15641566    );
    1565     foreach( $slug_constants as $constant ) {
     1567    foreach ( $slug_constants as $constant ) {
    15661568        if ( defined( $constant ) ) {
    15671569            $bp_component_slugs[] = constant( $constant );
     
    15881590
    15891591    // First merge BuddyPress illegal names.
    1590     $bp_merged_names           = array_merge( (array) $filtered_illegal_names, (array) $db_illegal_names );
     1592    $bp_merged_names = array_merge( (array) $filtered_illegal_names, (array) $db_illegal_names );
    15911593
    15921594    // Then merge WordPress and BuddyPress illegal names.
    1593     $merged_names              = array_merge( (array) $wp_filtered_illegal_names, (array) $bp_merged_names );
     1595    $merged_names = array_merge( (array) $wp_filtered_illegal_names, (array) $bp_merged_names );
    15941596
    15951597    // Remove duplicates.
    1596     $illegal_names             = array_unique( (array) $merged_names );
     1598    $illegal_names = array_unique( (array) $merged_names );
    15971599
    15981600    /**
     
    16051607    return apply_filters( 'bp_core_illegal_names', $illegal_names );
    16061608}
    1607 add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names', 10, 2 );
     1609add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names' );
    16081610
    16091611/**
     
    18601862 *
    18611863 * @since 1.2.0
     1864 *
     1865 * @global BuddyPress $bp The one true BuddyPress instance.
    18621866 *
    18631867 * @todo There appears to be a bug in the return value on success.
     
    19951999 * @since 1.2.2
    19962000 *
     2001 * @global wpdb $wpdb WordPress database object.
     2002 *
    19972003 * @param string $key Activation key.
    19982004 * @return int|bool User ID on success, false on failure.
     
    21182124                $current_field = isset( $user['meta']["field_{$field_id}"] ) ? $user['meta']["field_{$field_id}"] : false;
    21192125
    2120                 if ( !empty( $current_field ) ) {
     2126                if ( ! empty( $current_field ) ) {
    21212127                    xprofile_set_field_data( $field_id, $user_id, $current_field );
    21222128                }
     
    22002206 *
    22012207 * @since 2.0.1
     2208 *
     2209 * @global wpdb $wpdb WordPress database object.
    22022210 */
    22032211function bp_members_migrate_signups() {
     
    23152323 * @since 1.1.0
    23162324 *
     2325 * @global BuddyPress $bp The one true BuddyPress instance.
     2326 *
    23172327 * @return string|bool Directory path on success, false on failure.
    23182328 */
     
    23442354        'basedir' => $newbdir,
    23452355        'baseurl' => $newburl,
    2346         'error'   => false
     2356        'error'   => false,
    23472357    ) );
    23482358}
     
    26222632 * @since 2.6.0
    26232633 *
     2634 * @global BuddyPress $bp The one true BuddyPress instance.
     2635 *
    26242636 * @return object The displayed user object, null otherwise.
    26252637 */
     
    26522664    echo bp_get_member_type_tax_name();
    26532665}
    2654 
    26552666    /**
    26562667     * Return the slug of the member type taxonomy.
     
    26612672     */
    26622673    function bp_get_member_type_tax_name() {
     2674
    26632675        /**
    26642676         * Filters the slug of the member type taxonomy.
     
    26902702        'bp_get_member_type_tax_labels',
    26912703        array(
    2692 
    2693             // General labels
     2704            // General labels.
    26942705            'name'                       => _x( 'Member Types', 'Member type taxonomy name', 'buddypress' ),
    26952706            'singular_name'              => _x( 'Member Type', 'Member type taxonomy singular name', 'buddypress' ),
     
    28062817 * @since 2.2.0
    28072818 *
     2819 * @global BuddyPress $bp The one true BuddyPress instance.
     2820 *
    28082821 * @param string $member_type Unique string identifier for the member type.
    28092822 * @param array  $args {
     
    29112924 *
    29122925 * @param string $member_type The name of the member type.
    2913  * @return object A member type object.
     2926 * @return object|null A member type object or null if it doesn't exist.
    29142927 */
    29152928function bp_get_member_type_object( $member_type ) {
     
    29272940 *
    29282941 * @since 2.2.0
     2942 *
     2943 * @global BuddyPress $bp The one true BuddyPress instance.
    29292944 *
    29302945 * @see bp_register_member_type() for accepted arguments.
     
    29402955 */
    29412956function bp_get_member_types( $args = array(), $output = 'names', $operator = 'and' ) {
    2942     $types = buddypress()->members->types;
     2957    $bp    = buddypress();
     2958    $types = $bp->members->types;
    29432959
    29442960    // Merge with types available into the database.
     
    30523068 * @param bool         $append      Optional. True to append this to existing types for user,
    30533069 *                                  false to replace. Default: false.
    3054  * @return false|array $retval See {@see bp_set_object_terms()}.
     3070 * @return bool|array $retval See {@see bp_set_object_terms()}.
    30553071 */
    30563072function bp_set_member_type( $user_id, $member_type, $append = false ) {
     
    31503166
    31513167        if ( ! is_wp_error( $raw_types ) ) {
    3152             $types =  array();
     3168            $types = array();
    31533169
    31543170            // Only include currently registered group types.
     
    31833199     * @since 2.2.0
    31843200     *
    3185      * @param string|array|bool $type    a single member type (if $single is true) or an array of member types
     3201     * @param string|array|bool $type    A single member type (if $single is true) or an array of member types
    31863202     *                                   (if $single is false) or false on failure.
    31873203     * @param int               $user_id ID of the user.
     
    32133229    }
    32143230
    3215     return in_array( $member_type, $types );
     3231    return in_array( $member_type, $types, true );
    32163232}
    32173233
     
    32223238 *
    32233239 * @param int $user_id ID of the user.
    3224  * @return false|array $value See {@see bp_set_member_type()}.
     3240 * @return bool|array $value See {@see bp_set_member_type()}.
    32253241 */
    32263242function bp_remove_member_type_on_user_delete( $user_id ) {
     
    32503266 * @since 2.3.0
    32513267 *
     3268 * @global BuddyPress $bp The one true BuddyPress instance.
     3269 *
    32523270 * @return string
    32533271 */
    32543272function bp_get_current_member_type() {
     3273    $bp = buddypress();
    32553274
    32563275    /**
     
    32613280     * @param string $value "Current" member type.
    32623281     */
    3263     return apply_filters( 'bp_get_current_member_type', buddypress()->current_member_type );
     3282    return apply_filters( 'bp_get_current_member_type', $bp->current_member_type );
    32643283}
    32653284
     
    32853304    }
    32863305
    3287     $path      = bp_core_avatar_upload_path() . '/' . $directory. '/' . $user_id;
     3306    $path      = bp_core_avatar_upload_path() . '/' . $directory . '/' . $user_id;
    32883307    $newbdir   = $path;
    3289     $newurl    = bp_core_avatar_url() . '/' . $directory. '/' . $user_id;
     3308    $newurl    = bp_core_avatar_url() . '/' . $directory . '/' . $user_id;
    32903309    $newburl   = $newurl;
    3291     $newsubdir = '/' . $directory. '/' . $user_id;
     3310    $newsubdir = '/' . $directory . '/' . $user_id;
    32923311
    32933312    /**
     
    33043323        'basedir' => $newbdir,
    33053324        'baseurl' => $newburl,
    3306         'error'   => false
     3325        'error'   => false,
    33073326    ) );
    33083327}
     
    33133332 * @since 8.0.0
    33143333 *
    3315  * @param int $user_id The new user's ID
     3334 * @param int $user_id The new user's ID.
    33163335 */
    33173336function bp_send_welcome_email( $user_id = 0 ) {
     
    33493368 * @since 8.0.0
    33503369 *
    3351  * @param array $args     Invitation arguments.
    3352  *                        See BP_Invitation::get() for list.
    3353  *
    3354  * @return array $invites     Matching BP_Invitation objects.
     3370 * @param array $args Invitation arguments. See BP_Invitation::get() for list.
     3371 * @return array $invites Matching BP_Invitation objects.
    33553372 */
    33563373function bp_members_invitations_get_invites( $args = array() ) {
     
    34113428            'date_modified' => bp_core_current_time(),
    34123429            'content'       => '',
    3413             'send_invite'   => 0
     3430            'send_invite'   => 0,
    34143431        ),
    34153432        'members_invitations_invite_user'
     
    34223439        'date_modified' => $r['date_modified'],
    34233440        'content'       => $r['content'],
    3424         'send_invite'   => $r['send_invite']
     3441        'send_invite'   => $r['send_invite'],
    34253442    );
    34263443
     
    35503567            'inviter_id'    => null,
    35513568            'accepted'      => null,
    3552             'invite_sent'   => null
     3569            'invite_sent'   => null,
    35533570        ),
    35543571        'members_invitations_delete_invites'
     
    35613578        'inviter_id'    => $r['inviter_id'],
    35623579        'accepted'      => $r['accepted'],
    3563         'invite_sent'   => $r['invite_sent']
     3580        'invite_sent'   => $r['invite_sent'],
    35643581    );
    35653582
     
    35853602 * @since 8.0.0
    35863603 *
    3587  * @param BP_Invitation object $invitation Invitation to create hash from.
     3604 * @param BP_Invitation $invitation Invitation to create hash from.
    35883605 *
    35893606 * @return string $hash Calculated sha1 hash.
    35903607 */
    3591 function bp_members_invitations_get_hash( BP_Invitation $invitation ) {
     3608function bp_members_invitations_get_hash( $invitation ) {
    35923609    $hash = false;
    35933610
     
    36133630     * @since 8.0.0
    36143631     *
    3615      * @param string $hash Calculated sha1 hash.
    3616      * @param BP_Invitation object $invitation Invitation hash was created from.
     3632     * @param string        $hash      Calculated sha1 hash.
     3633     * @param BP_Invitation $invitation Invitation hash was created from.
    36173634     */
    36183635    return apply_filters( 'bp_members_invitations_get_hash', $hash, $invitation );
Note: See TracChangeset for help on using the changeset viewer.