PluginProbe
bbPress / 2.6.19
bbPress v2.6.19
2.6.19 2.6.18 2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 All 74 releases
← All changes | includes/users/functions.php +78 -78 trunk → 2.6.19 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress User Functions.
4 + * bbPress User Functions
5 5 *
6 6 * @package bbPress
7 7 * @subpackage Functions
8 8 */
@@ -10,15 +10,15 @@
10 10 // Exit if accessed directly
11 11 defined( 'ABSPATH' ) || exit;
12 12
13 13 /**
14 - * Redirect back to $url when attempting to use the login page.
14 + * Redirect back to $url when attempting to use the login page
15 15 *
16 16 * @since 2.0.0 bbPress (r2815)
17 17 *
18 - * @param string $url The url.
19 - * @param string $raw_url Raw url.
20 - * @param object $user User object.
18 + * @param string $url The url
19 + * @param string $raw_url Raw url
20 + * @param object $user User object
21 21 */
22 22 function bbp_redirect_login( $url = '', $raw_url = '', $user = '' ) {
23 23
24 24 // Raw redirect_to was passed, so use it
@@ -43,9 +43,9 @@
43 43 *
44 44 * @since 2.0.0 bbPress (r2670)
45 45 *
46 46 * @return bool True if anonymous is allowed and user is not logged in, false if
47 - * anonymous is not allowed or user is logged in.
47 + * anonymous is not allowed or user is logged in
48 48 */
49 49 function bbp_is_anonymous() {
50 50 $is_anonymous = ( ! is_user_logged_in() && bbp_allow_anonymous() );
51 51
@@ -53,9 +53,9 @@
53 53 return (bool) apply_filters( 'bbp_is_anonymous', $is_anonymous );
54 54 }
55 55
56 56 /**
57 - * Echoes the values for current poster (uses WP comment cookies).
57 + * Echoes the values for current poster (uses WP comment cookies)
58 58 *
59 59 * @since 2.0.0 bbPress (r2734)
60 60 *
61 61 * @param string $key Which value to echo?
@@ -63,54 +63,54 @@
63 63 function bbp_current_anonymous_user_data( $key = '' ) {
64 64 echo esc_attr( bbp_get_current_anonymous_user_data( $key ) );
65 65 }
66 66
67 -/**
68 - * Get the cookies for current poster (uses WP comment cookies).
69 - *
70 - * @since 2.0.0 bbPress (r2734)
71 - *
72 - * @param string $key Optional. Which value to get? If not given, then
73 - * an array is returned.
74 - * @return string|array Cookie(s) for current poster.
75 - */
76 -function bbp_get_current_anonymous_user_data( $key = '' ) {
67 + /**
68 + * Get the cookies for current poster (uses WP comment cookies).
69 + *
70 + * @since 2.0.0 bbPress (r2734)
71 + *
72 + * @param string $key Optional. Which value to get? If not given, then
73 + * an array is returned.
74 + * @return string|array Cookie(s) for current poster
75 + */
76 + function bbp_get_current_anonymous_user_data( $key = '' ) {
77 77
78 - // Array of allowed cookie names
79 - $cookie_names = array(
80 - 'name' => 'comment_author',
81 - 'email' => 'comment_author_email',
82 - 'url' => 'comment_author_url',
78 + // Array of allowed cookie names
79 + $cookie_names = array(
80 + 'name' => 'comment_author',
81 + 'email' => 'comment_author_email',
82 + 'url' => 'comment_author_url',
83 83
84 - // Here just for the sake of them, use the above ones
85 - 'comment_author' => 'comment_author',
86 - 'comment_author_email' => 'comment_author_email',
87 - 'comment_author_url' => 'comment_author_url',
88 - );
84 + // Here just for the sake of them, use the above ones
85 + 'comment_author' => 'comment_author',
86 + 'comment_author_email' => 'comment_author_email',
87 + 'comment_author_url' => 'comment_author_url',
88 + );
89 89
90 - // Get the current poster's info from the cookies
91 - $bbp_current_poster = wp_get_current_commenter();
90 + // Get the current poster's info from the cookies
91 + $bbp_current_poster = wp_get_current_commenter();
92 92
93 - // Sanitize the cookie key being retrieved
94 - $key = sanitize_key( $key );
93 + // Sanitize the cookie key being retrieved
94 + $key = sanitize_key( $key );
95 95
96 - // Maybe return a specific key
97 - if ( ! empty( $key ) && in_array( $key, array_keys( $cookie_names ), true ) ) {
98 - return $bbp_current_poster[ $cookie_names[ $key ] ];
96 + // Maybe return a specific key
97 + if ( ! empty( $key ) && in_array( $key, array_keys( $cookie_names ), true ) ) {
98 + return $bbp_current_poster[ $cookie_names[ $key ] ];
99 + }
100 +
101 + // Return all keys
102 + return $bbp_current_poster;
99 103 }
100 104
101 - // Return all keys
102 - return $bbp_current_poster;
103 -}
104 -
105 105 /**
106 - * Set the cookies for current poster (uses WP comment cookies).
106 + * Set the cookies for current poster (uses WP comment cookies)
107 107 *
108 108 * @since 2.0.0 bbPress (r2734)
109 109 *
110 110 * @param array $anonymous_data Optional - if it's an anonymous post. Do not
111 111 * supply if supplying $author_id. Should be
112 - * sanitized (see {@link bbp_filter_anonymous_post_data()}.
112 + * sanitized (see {@link bbp_filter_anonymous_post_data()}
113 113 */
114 114 function bbp_set_current_anonymous_user_data( $anonymous_data = array() ) {
115 115
116 116 // Bail if empty or not an array
@@ -129,9 +129,9 @@
129 129 setcookie( 'comment_author_url_' . COOKIEHASH, $anonymous_data['bbp_anonymous_website'], $expiry, COOKIEPATH, COOKIE_DOMAIN, $secure );
130 130 }
131 131
132 132 /**
133 - * Get the poster IP address.
133 + * Get the poster IP address
134 134 *
135 135 * @since 2.0.0 bbPress (r3120)
136 136 * @since 2.6.0 bbPress (r5609) Added `empty()` check for unit tests
137 137 *
@@ -151,9 +151,9 @@
151 151 return apply_filters( 'bbp_current_author_ip', $retval, $remote_address );
152 152 }
153 153
154 154 /**
155 - * Get the poster user agent.
155 + * Get the poster user agent
156 156 *
157 157 * @since 2.0.0 bbPress (r3447)
158 158 *
159 159 * @return string
@@ -171,9 +171,9 @@
171 171
172 172 /**
173 173 * Filter user profile data according to the current user's field permissions.
174 174 *
175 - * @since 2.6.17 bbPress (r7513)
175 + * @since 2.6.17 bbPress (r7514)
176 176 *
177 177 * @param array $data Submitted user profile data.
178 178 * @param int $user_id User being edited.
179 179 * @return array Filtered user profile data.
@@ -228,9 +228,9 @@
228 228 *
229 229 * Self-service changes require confirmation by default, while privileged edits
230 230 * to another user update the address directly.
231 231 *
232 - * @since 2.6.17 bbPress (r7513)
232 + * @since 2.6.17 bbPress (r7514)
233 233 *
234 234 * @param int $user_id User being edited.
235 235 * @return bool Whether confirmation is required.
236 236 */
@@ -269,13 +269,13 @@
269 269 }
270 270 }
271 271
272 272 /**
273 - * Handles the front end user editing from POST requests.
273 + * Handles the front end user editing from POST requests
274 274 *
275 275 * @since 2.0.0 bbPress (r2688)
276 276 *
277 - * @param string $action The requested action to compare this function to.
277 + * @param string $action The requested action to compare this function to
278 278 */
279 279 function bbp_edit_user_handler( $action = '' ) {
280 280
281 281 // Bail if action is not `bbp-update-user`
@@ -367,9 +367,9 @@
367 367
368 368 // Handle user edit
369 369 $edit_user = edit_user( $user_id );
370 370
371 - // Error(s) editing the user, so copy them into the global.
371 + // Error(s) editng the user, so copy them into the global
372 372 if ( is_wp_error( $edit_user ) ) {
373 373 bbpress()->errors = $edit_user;
374 374
375 375 // Successful edit to redirect
@@ -387,9 +387,9 @@
387 387 }
388 388 }
389 389
390 390 /**
391 - * Handles user email address updating from GET requests.
391 + * Handles user email address updating from GET requests
392 392 *
393 393 * @since 2.6.0 bbPress (r5663)
394 394 *
395 395 * @param string $action
@@ -487,9 +487,9 @@
487 487 }
488 488 }
489 489
490 490 /**
491 - * Sends an email when an email address change occurs on POST requests.
491 + * Sends an email when an email address change occurs on POST requests
492 492 *
493 493 * @since 2.6.0 bbPress (r5663)
494 494 *
495 495 * @see send_confirmation_on_profile_email()
@@ -569,9 +569,9 @@
569 569 }
570 570
571 571 /**
572 572 * Conditionally hook the core WordPress output actions to the end of the
573 - * default user's edit profile template.
573 + * default user's edit profile template
574 574 *
575 575 * This allows clever plugin authors to conditionally unhook the WordPress core
576 576 * output actions if they don't want any unexpected junk to appear there, and
577 577 * also avoids needing to pollute the templates with additional logic and actions.
@@ -586,16 +586,16 @@
586 586
587 587 /** User Queries **************************************************************/
588 588
589 589 /**
590 - * Get the topics that a user created.
590 + * Get the topics that a user created
591 591 *
592 592 * @since 2.0.0 bbPress (r2660)
593 593 * @since 2.6.0 bbPress (r6619) Signature changed to accept an array of arguments
594 594 *
595 - * @param array $args Optional. Arguments to pass into bbp_has_topics().
595 + * @param array $args Optional. Arguments to pass into bbp_has_topics()
596 596 *
597 - * @return bool True if user has started topics, otherwise false.
597 + * @return bool True if user has started topics, otherwise false
598 598 */
599 599 function bbp_get_user_topics_started( $args = array() ) {
600 600
601 601 // Backwards compat for pre-2.6.0
@@ -621,16 +621,16 @@
621 621 return apply_filters( 'bbp_get_user_topics_started', $query, $user_id, $r, $args );
622 622 }
623 623
624 624 /**
625 - * Get the replies that a user created.
625 + * Get the replies that a user created
626 626 *
627 627 * @since 2.2.0 bbPress (r4228)
628 628 * @since 2.6.0 bbPress (r6619) Signature changed to accept an array of arguments
629 629 *
630 - * @param array $args Optional. Arguments to pass into bbp_has_replies().
630 + * @param array $args Optional. Arguments to pass into bbp_has_replies()
631 631 *
632 - * @return bool True if user has created replies, otherwise false.
632 + * @return bool True if user has created replies, otherwise false
633 633 */
634 634 function bbp_get_user_replies_created( $args = array() ) {
635 635
636 636 // Backwards compat for pre-2.6.0
@@ -662,11 +662,11 @@
662 662 return apply_filters( 'bbp_get_user_replies_created', $query, $user_id, $r, $args );
663 663 }
664 664
665 665 /**
666 - * Get user IDs from nicenames.
666 + * Get user IDs from nicenames
667 667 *
668 - * This function is primarily used when saving object moderators.
668 + * This function is primarily used when saving object moderators
669 669 *
670 670 * @since 2.6.0 bbPress (r6056)
671 671 *
672 672 * @param mixed $user_nicenames
@@ -705,15 +705,15 @@
705 705 return (array) apply_filters( 'bbp_get_user_ids_from_nicenames', $retval, $user_nicenames );
706 706 }
707 707
708 708 /**
709 - * Get user nicenames from IDs.
709 + * Get user nicenames from IDs
710 710 *
711 - * This function is primarily used when saving object moderators.
711 + * This function is primarily used when saving object moderators
712 712 *
713 713 * @since 2.6.0 bbPress (r6056)
714 714 *
715 - * @param mixed $user_ids User ids.
715 + * @param mixed $user_ids
716 716 * @return array
717 717 */
718 718 function bbp_get_user_nicenames_from_ids( $user_ids = array() ) {
719 719
@@ -742,15 +742,15 @@
742 742
743 743 /** Post Counts ***************************************************************/
744 744
745 745 /**
746 - * Return the raw database count of topics by a user.
746 + * Return the raw database count of topics by a user
747 747 *
748 748 * @since 2.1.0 bbPress (r3633)
749 749 *
750 - * @param int $user_id User ID to get count for.
750 + * @param int $user_id User ID to get count for
751 751 *
752 - * @return int Raw DB count of topics.
752 + * @return int Raw DB count of topics
753 753 */
754 754 function bbp_get_user_topic_count_raw( $user_id = 0 ) {
755 755 $user_id = bbp_get_user_id( $user_id );
756 756 $bbp_db = bbp_db();
@@ -768,15 +768,15 @@
768 768 return (int) apply_filters( 'bbp_get_user_topic_count_raw', $count, $user_id );
769 769 }
770 770
771 771 /**
772 - * Return the raw database count of replies by a user.
772 + * Return the raw database count of replies by a user
773 773 *
774 774 * @since 2.1.0 bbPress (r3633)
775 775 *
776 - * @param int $user_id User ID to get count for.
776 + * @param int $user_id User ID to get count for
777 777 *
778 - * @return int Raw DB count of replies.
778 + * @return int Raw DB count of replies
779 779 */
780 780 function bbp_get_user_reply_count_raw( $user_id = 0 ) {
781 781 $user_id = bbp_get_user_id( $user_id );
782 782 $bbp_db = bbp_db();
@@ -797,12 +797,12 @@
797 797 /**
798 798 * Bump the topic count for a user by a certain amount.
799 799 *
800 800 * @since 2.6.0 bbPress (r5309)
801 - * @since 2.6.17 bbPress (r7449) Rebuild the count when the user option is missing.
801 + * @since 2.6.17 bbPress (r7451) Rebuild the count when the user option is missing.
802 802 *
803 - * @param int $user_id User id.
804 - * @param int $difference Optional. Default 1. Number to bump.
803 + * @param int $user_id
804 + * @param int $difference
805 805 */
806 806 function bbp_bump_user_topic_count( $user_id = 0, $difference = 1 ) {
807 807
808 808 // Bail if no bump
@@ -838,12 +838,12 @@
838 838 /**
839 839 * Bump the reply count for a user by a certain amount.
840 840 *
841 841 * @since 2.6.0 bbPress (r5309)
842 - * @since 2.6.17 bbPress (r7449) Rebuild the count when the user option is missing.
842 + * @since 2.6.17 bbPress (r7451) Rebuild the count when the user option is missing.
843 843 *
844 - * @param int $user_id User id.
845 - * @param int $difference Optional. Default 1. Number to bump.
844 + * @param int $user_id
845 + * @param int $difference
846 846 */
847 847 function bbp_bump_user_reply_count( $user_id = 0, $difference = 1 ) {
848 848
849 849 // Bail if no bump
@@ -878,9 +878,9 @@
878 878
879 879 /**
880 880 * Update user counts when a topic or reply changes authors.
881 881 *
882 - * @since 2.6.17 bbPress (r7467)
882 + * @since 2.6.17 bbPress (r7468)
883 883 *
884 884 * @param int $post_id Post ID.
885 885 * @param WP_Post $post_after Post object following the update.
886 886 * @param WP_Post $post_before Post object before the update.
@@ -940,9 +940,9 @@
940 940
941 941 /**
942 942 * Update topic engagements when a topic or reply changes authors.
943 943 *
944 - * @since 2.6.17 bbPress (r7467)
944 + * @since 2.6.17 bbPress (r7468)
945 945 *
946 946 * @param int $post_id Post ID.
947 947 * @param WP_Post $post_after Post object following the update.
948 948 * @param WP_Post $post_before Post object before the update.
@@ -974,9 +974,9 @@
974 974 * WordPress reassigns post authors directly in the database, bypassing the
975 975 * normal post update actions. Record affected topics before that write, then
976 976 * repair the replacement user's counts and those topics after it completes.
977 977 *
978 - * @since 2.6.17 bbPress (r7467)
978 + * @since 2.6.17 bbPress (r7468)
979 979 *
980 980 * @param int $user_id ID of the user being deleted.
981 981 * @param int|null $reassign ID of the user receiving the posts.
982 982 */
@@ -1112,9 +1112,9 @@
1112 1112
1113 1113 /** Permissions ***************************************************************/
1114 1114
1115 1115 /**
1116 - * Redirect if unauthorized user is attempting to edit another user.
1116 + * Redirect if unauthorized user is attempting to edit another user
1117 1117 *
1118 1118 * This is hooked to 'bbp_template_redirect' and controls the conditions under
1119 1119 * which a user can edit another user (or themselves.) If these conditions are
1120 1120 * met, we assume a user cannot perform this task, and look for ways they can
@@ -1255,9 +1255,9 @@
1255 1255 * Convert passwords from previous platform encryption to WordPress encryption.
1256 1256 *
1257 1257 * @since 2.1.0 bbPress (r4072)
1258 1258 * @since 2.6.10 bbPress (r7245) Switched from direct query to get_user_by()
1259 - * @since 2.6.18 bbPress (r7547) Improved input handling and email login support.
1259 + * @since 2.6.18 bbPress (r7546) Improved input handling and email login support.
1260 1260 */
1261 1261 function bbp_user_maybe_convert_pass() {
1262 1262
1263 1263 // Sanitize login