Changeset 13105 for trunk/src/bp-members/bp-members-functions.php
- Timestamp:
- 09/11/2021 05:26:17 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-functions.php
r12935 r13105 23 23 $bp = buddypress(); 24 24 25 return (bool) ! empty( $bp->pages->members->id );25 return (bool) ! empty( $bp->pages->members->id ); 26 26 } 27 27 … … 38 38 * 39 39 * @since 1.5.0 40 * 41 * @global BuddyPress $bp The one true BuddyPress instance. 40 42 */ 41 43 function bp_core_define_slugs() { … … 207 209 // Don't use this filter. Subject to removal in a future release. 208 210 // Use the 'bp_core_get_user_domain' filter instead. 209 $domain 211 $domain = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login ); 210 212 211 213 /** … … 227 229 * @since 1.2.0 228 230 * 229 * @param 230 * @return array|bool Array of data on success, booleanfalse on failure.231 * @param int $user_id The ID of the user. 232 * @return array|bool Array of data on success, false on failure. 231 233 */ 232 234 function bp_core_get_core_userdata( $user_id = 0 ) { … … 235 237 } 236 238 237 // Get core user data 239 // Get core user data. 238 240 $userdata = BP_Core_User::get_core_userdata( $user_id ); 239 241 … … 243 245 * @since 1.2.0 244 246 * 245 * @param array|bool $userdata Array of user data for a passed user on success, booleanfalse on failure.247 * @param array|bool $userdata Array of user data for a passed user on success, false on failure. 246 248 */ 247 249 return apply_filters( 'bp_core_get_core_userdata', $userdata ); … … 285 287 * @param string $username User login to check. 286 288 */ 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 ); 288 290 } 289 291 … … 311 313 * @param string $user_nicename User nicename to check. 312 314 */ 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 ); 314 316 } 315 317 … … 362 364 */ 363 365 function bp_members_get_user_nicename( $user_id ) { 366 364 367 /** 365 368 * Filters the user_nicename based on originally provided user ID. … … 377 380 * @since 1.0.0 378 381 * 379 * @param int $u id User ID to check.382 * @param int $user_id User ID to check. 380 383 * @return string The email for the matched user. Empty string if no user 381 384 * matches the $user_id. 382 385 */ 383 386 function bp_core_get_user_email( $user_id ) { 387 384 388 /** 385 389 * Filters the user email for user based on user ID. … … 508 512 } 509 513 add_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' 514 add_filter( 'bp_core_get_user_displayname', 'trim' ); 515 add_filter( 'bp_core_get_user_displayname', 'stripslashes' ); 516 add_filter( 'bp_core_get_user_displayname', 'esc_html' ); 513 517 514 518 /** … … 569 573 * @since 1.2.0 570 574 * 575 * @global wpdb $wpdb WordPress database object. 576 * 571 577 * @return int The total number of members. 572 578 */ … … 596 602 * 597 603 * @since 1.6.0 604 * 605 * @global wpdb $wpdb WordPress database object. 598 606 * 599 607 * @return int The number of active members. … … 635 643 * @since 5.0.0 636 644 * 637 * @param int 638 * @param int 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`. 639 647 * @return bool True if the spam status of the member changed. 640 648 * False otherwise. … … 677 685 * @since 1.6.0 678 686 * 687 * @global wpdb $wpdb WordPress database object. 688 * 679 689 * @param int $user_id The ID of the user being spammed/hammed. 680 690 * @param string $status 'spam' if being marked as spam, 'ham' otherwise. 681 * @param bool $do_wp_cleanup True to force the cleanup of WordPress content691 * @param bool $do_wp_cleanup Optional. True to force the cleanup of WordPress content 682 692 * and status, otherwise false. Generally, this should 683 693 * only be false if WordPress is expected to have … … 708 718 // Only you can prevent infinite loops. 709 719 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' ); 711 721 712 722 // Force the cleanup of WordPress content and status for multisite configs. … … 833 843 // Put things back how we found them. 834 844 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' ); 836 846 837 847 return true; … … 865 875 * 866 876 * @since 1.6.0 877 * 878 * @global BuddyPress $bp The one true BuddyPress instance. 867 879 * 868 880 * @param int $user_id The ID for the user. … … 937 949 * @since 1.6.0 938 950 * 951 * @global BuddyPress $bp The one true BuddyPress instance. 952 * 939 953 * @param int $user_id The ID for the user. 940 954 * @return bool True if deleted, otherwise false. … … 1003 1017 * @since 1.6.0 1004 1018 * 1005 * @param int $user_id The user ID to check.1019 * @param int $user_id Optional. The user ID to check. 1006 1020 * @return bool True if active, otherwise false. 1007 1021 */ … … 1037 1051 * @since 1.6.0 1038 1052 * 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. 1043 1054 * @return bool True if inactive, otherwise false. 1044 1055 */ 1045 1056 function 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 1057 1057 // Return the inverse of active. 1058 return ! bp_is_user_active( $user_id );1058 return ! bp_is_user_active( $user_id ); 1059 1059 } 1060 1060 … … 1066 1066 * legacy user query is enabled. 1067 1067 * 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. 1070 1070 * @return bool True on success, false on failure. 1071 1071 */ … … 1211 1211 * @since 2.0.0 1212 1212 * 1213 * @global BuddyPress $bp The one true BuddyPress instance. 1214 * @global wpdb $wpdb WordPress database object. 1215 * 1213 1216 * @return bool 1214 1217 */ … … 1514 1517 * @since 1.2.7 1515 1518 * 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. 1519 1521 * @return array Merged and unique array of illegal names. 1520 1522 */ 1521 function bp_core_get_illegal_names( $value = '' , $oldvalue = '') {1523 function bp_core_get_illegal_names( $value = '' ) { 1522 1524 1523 1525 // Make sure $value is array. … … 1545 1547 'notifications', 1546 1548 'register', 1547 'activate' 1549 'activate', 1548 1550 ); 1549 1551 … … 1563 1565 'BP_ACTIVATION_SLUG', 1564 1566 ); 1565 foreach ( $slug_constants as $constant ) {1567 foreach ( $slug_constants as $constant ) { 1566 1568 if ( defined( $constant ) ) { 1567 1569 $bp_component_slugs[] = constant( $constant ); … … 1588 1590 1589 1591 // First merge BuddyPress illegal names. 1590 $bp_merged_names 1592 $bp_merged_names = array_merge( (array) $filtered_illegal_names, (array) $db_illegal_names ); 1591 1593 1592 1594 // Then merge WordPress and BuddyPress illegal names. 1593 $merged_names 1595 $merged_names = array_merge( (array) $wp_filtered_illegal_names, (array) $bp_merged_names ); 1594 1596 1595 1597 // Remove duplicates. 1596 $illegal_names 1598 $illegal_names = array_unique( (array) $merged_names ); 1597 1599 1598 1600 /** … … 1605 1607 return apply_filters( 'bp_core_illegal_names', $illegal_names ); 1606 1608 } 1607 add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names' , 10, 2);1609 add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names' ); 1608 1610 1609 1611 /** … … 1860 1862 * 1861 1863 * @since 1.2.0 1864 * 1865 * @global BuddyPress $bp The one true BuddyPress instance. 1862 1866 * 1863 1867 * @todo There appears to be a bug in the return value on success. … … 1995 1999 * @since 1.2.2 1996 2000 * 2001 * @global wpdb $wpdb WordPress database object. 2002 * 1997 2003 * @param string $key Activation key. 1998 2004 * @return int|bool User ID on success, false on failure. … … 2118 2124 $current_field = isset( $user['meta']["field_{$field_id}"] ) ? $user['meta']["field_{$field_id}"] : false; 2119 2125 2120 if ( ! empty( $current_field ) ) {2126 if ( ! empty( $current_field ) ) { 2121 2127 xprofile_set_field_data( $field_id, $user_id, $current_field ); 2122 2128 } … … 2200 2206 * 2201 2207 * @since 2.0.1 2208 * 2209 * @global wpdb $wpdb WordPress database object. 2202 2210 */ 2203 2211 function bp_members_migrate_signups() { … … 2315 2323 * @since 1.1.0 2316 2324 * 2325 * @global BuddyPress $bp The one true BuddyPress instance. 2326 * 2317 2327 * @return string|bool Directory path on success, false on failure. 2318 2328 */ … … 2344 2354 'basedir' => $newbdir, 2345 2355 'baseurl' => $newburl, 2346 'error' => false 2356 'error' => false, 2347 2357 ) ); 2348 2358 } … … 2622 2632 * @since 2.6.0 2623 2633 * 2634 * @global BuddyPress $bp The one true BuddyPress instance. 2635 * 2624 2636 * @return object The displayed user object, null otherwise. 2625 2637 */ … … 2652 2664 echo bp_get_member_type_tax_name(); 2653 2665 } 2654 2655 2666 /** 2656 2667 * Return the slug of the member type taxonomy. … … 2661 2672 */ 2662 2673 function bp_get_member_type_tax_name() { 2674 2663 2675 /** 2664 2676 * Filters the slug of the member type taxonomy. … … 2690 2702 'bp_get_member_type_tax_labels', 2691 2703 array( 2692 2693 // General labels 2704 // General labels. 2694 2705 'name' => _x( 'Member Types', 'Member type taxonomy name', 'buddypress' ), 2695 2706 'singular_name' => _x( 'Member Type', 'Member type taxonomy singular name', 'buddypress' ), … … 2806 2817 * @since 2.2.0 2807 2818 * 2819 * @global BuddyPress $bp The one true BuddyPress instance. 2820 * 2808 2821 * @param string $member_type Unique string identifier for the member type. 2809 2822 * @param array $args { … … 2911 2924 * 2912 2925 * @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. 2914 2927 */ 2915 2928 function bp_get_member_type_object( $member_type ) { … … 2927 2940 * 2928 2941 * @since 2.2.0 2942 * 2943 * @global BuddyPress $bp The one true BuddyPress instance. 2929 2944 * 2930 2945 * @see bp_register_member_type() for accepted arguments. … … 2940 2955 */ 2941 2956 function bp_get_member_types( $args = array(), $output = 'names', $operator = 'and' ) { 2942 $types = buddypress()->members->types; 2957 $bp = buddypress(); 2958 $types = $bp->members->types; 2943 2959 2944 2960 // Merge with types available into the database. … … 3052 3068 * @param bool $append Optional. True to append this to existing types for user, 3053 3069 * 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()}. 3055 3071 */ 3056 3072 function bp_set_member_type( $user_id, $member_type, $append = false ) { … … 3150 3166 3151 3167 if ( ! is_wp_error( $raw_types ) ) { 3152 $types = 3168 $types = array(); 3153 3169 3154 3170 // Only include currently registered group types. … … 3183 3199 * @since 2.2.0 3184 3200 * 3185 * @param string|array|bool $type asingle member type (if $single is true) or an array of member types3201 * @param string|array|bool $type A single member type (if $single is true) or an array of member types 3186 3202 * (if $single is false) or false on failure. 3187 3203 * @param int $user_id ID of the user. … … 3213 3229 } 3214 3230 3215 return in_array( $member_type, $types );3231 return in_array( $member_type, $types, true ); 3216 3232 } 3217 3233 … … 3222 3238 * 3223 3239 * @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()}. 3225 3241 */ 3226 3242 function bp_remove_member_type_on_user_delete( $user_id ) { … … 3250 3266 * @since 2.3.0 3251 3267 * 3268 * @global BuddyPress $bp The one true BuddyPress instance. 3269 * 3252 3270 * @return string 3253 3271 */ 3254 3272 function bp_get_current_member_type() { 3273 $bp = buddypress(); 3255 3274 3256 3275 /** … … 3261 3280 * @param string $value "Current" member type. 3262 3281 */ 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 ); 3264 3283 } 3265 3284 … … 3285 3304 } 3286 3305 3287 $path = bp_core_avatar_upload_path() . '/' . $directory . '/' . $user_id;3306 $path = bp_core_avatar_upload_path() . '/' . $directory . '/' . $user_id; 3288 3307 $newbdir = $path; 3289 $newurl = bp_core_avatar_url() . '/' . $directory . '/' . $user_id;3308 $newurl = bp_core_avatar_url() . '/' . $directory . '/' . $user_id; 3290 3309 $newburl = $newurl; 3291 $newsubdir = '/' . $directory . '/' . $user_id;3310 $newsubdir = '/' . $directory . '/' . $user_id; 3292 3311 3293 3312 /** … … 3304 3323 'basedir' => $newbdir, 3305 3324 'baseurl' => $newburl, 3306 'error' => false 3325 'error' => false, 3307 3326 ) ); 3308 3327 } … … 3313 3332 * @since 8.0.0 3314 3333 * 3315 * @param int $user_id The new user's ID 3334 * @param int $user_id The new user's ID. 3316 3335 */ 3317 3336 function bp_send_welcome_email( $user_id = 0 ) { … … 3349 3368 * @since 8.0.0 3350 3369 * 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. 3355 3372 */ 3356 3373 function bp_members_invitations_get_invites( $args = array() ) { … … 3411 3428 'date_modified' => bp_core_current_time(), 3412 3429 'content' => '', 3413 'send_invite' => 0 3430 'send_invite' => 0, 3414 3431 ), 3415 3432 'members_invitations_invite_user' … … 3422 3439 'date_modified' => $r['date_modified'], 3423 3440 'content' => $r['content'], 3424 'send_invite' => $r['send_invite'] 3441 'send_invite' => $r['send_invite'], 3425 3442 ); 3426 3443 … … 3550 3567 'inviter_id' => null, 3551 3568 'accepted' => null, 3552 'invite_sent' => null 3569 'invite_sent' => null, 3553 3570 ), 3554 3571 'members_invitations_delete_invites' … … 3561 3578 'inviter_id' => $r['inviter_id'], 3562 3579 'accepted' => $r['accepted'], 3563 'invite_sent' => $r['invite_sent'] 3580 'invite_sent' => $r['invite_sent'], 3564 3581 ); 3565 3582 … … 3585 3602 * @since 8.0.0 3586 3603 * 3587 * @param BP_Invitation object$invitation Invitation to create hash from.3604 * @param BP_Invitation $invitation Invitation to create hash from. 3588 3605 * 3589 3606 * @return string $hash Calculated sha1 hash. 3590 3607 */ 3591 function bp_members_invitations_get_hash( BP_Invitation$invitation ) {3608 function bp_members_invitations_get_hash( $invitation ) { 3592 3609 $hash = false; 3593 3610 … … 3613 3630 * @since 8.0.0 3614 3631 * 3615 * @param string $hashCalculated 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. 3617 3634 */ 3618 3635 return apply_filters( 'bp_members_invitations_get_hash', $hash, $invitation );
Note: See TracChangeset
for help on using the changeset viewer.