PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
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 2.2 2.2.1 All 72 releases
← All changes | includes/users/functions.php +71 -71 trunk2.6.17 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 (r2688)
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
@@ -120,9 +120,9 @@
120 120
121 121 // Setup cookie expiration
122 122 $lifetime = (int) apply_filters( 'comment_cookie_lifetime', 30000000 );
123 123 $expiry = time() + $lifetime;
124 - $secure = ( 'https' === wp_parse_url( home_url(), PHP_URL_SCHEME ) );
124 + $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
125 125
126 126 // Set the cookies
127 127 setcookie( 'comment_author_' . COOKIEHASH, $anonymous_data['bbp_anonymous_name'], $expiry, COOKIEPATH, COOKIE_DOMAIN, $secure );
128 128 setcookie( 'comment_author_email_' . COOKIEHASH, $anonymous_data['bbp_anonymous_email'], $expiry, COOKIEPATH, COOKIE_DOMAIN, $secure );
@@ -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 (r3446)
158 158 *
159 159 * @return string
@@ -242,13 +242,13 @@
242 242 return (bool) apply_filters( 'bbp_user_email_change_requires_confirmation', $retval, $user_id, bbp_get_current_user_id() );
243 243 }
244 244
245 245 /**
246 - * Handles the front end user editing from POST requests.
246 + * Handles the front end user editing from POST requests
247 247 *
248 248 * @since 2.0.0 bbPress (r2790)
249 249 *
250 - * @param string $action The requested action to compare this function to.
250 + * @param string $action The requested action to compare this function to
251 251 */
252 252 function bbp_edit_user_handler( $action = '' ) {
253 253
254 254 // Bail if action is not `bbp-update-user`
@@ -340,9 +340,9 @@
340 340
341 341 // Handle user edit
342 342 $edit_user = edit_user( $user_id );
343 343
344 - // Error(s) editing the user, so copy them into the global.
344 + // Error(s) editng the user, so copy them into the global
345 345 if ( is_wp_error( $edit_user ) ) {
346 346 bbpress()->errors = $edit_user;
347 347
348 348 // Successful edit to redirect
@@ -364,9 +364,9 @@
364 364 }
365 365 }
366 366
367 367 /**
368 - * Handles user email address updating from GET requests.
368 + * Handles user email address updating from GET requests
369 369 *
370 370 * @since 2.6.0 bbPress (r5660)
371 371 *
372 372 * @param string $action
@@ -464,9 +464,9 @@
464 464 }
465 465 }
466 466
467 467 /**
468 - * Sends an email when an email address change occurs on POST requests.
468 + * Sends an email when an email address change occurs on POST requests
469 469 *
470 470 * @since 2.6.0 bbPress (r5660)
471 471 *
472 472 * @see send_confirmation_on_profile_email()
@@ -546,9 +546,9 @@
546 546 }
547 547
548 548 /**
549 549 * Conditionally hook the core WordPress output actions to the end of the
550 - * default user's edit profile template.
550 + * default user's edit profile template
551 551 *
552 552 * This allows clever plugin authors to conditionally unhook the WordPress core
553 553 * output actions if they don't want any unexpected junk to appear there, and
554 554 * also avoids needing to pollute the templates with additional logic and actions.
@@ -563,16 +563,16 @@
563 563
564 564 /** User Queries **************************************************************/
565 565
566 566 /**
567 - * Get the topics that a user created.
567 + * Get the topics that a user created
568 568 *
569 569 * @since 2.0.0 bbPress (r2660)
570 570 * @since 2.6.0 bbPress (r6618) Signature changed to accept an array of arguments
571 571 *
572 - * @param array $args Optional. Arguments to pass into bbp_has_topics().
572 + * @param array $args Optional. Arguments to pass into bbp_has_topics()
573 573 *
574 - * @return bool True if user has started topics, otherwise false.
574 + * @return bool True if user has started topics, otherwise false
575 575 */
576 576 function bbp_get_user_topics_started( $args = array() ) {
577 577
578 578 // Backwards compat for pre-2.6.0
@@ -598,16 +598,16 @@
598 598 return apply_filters( 'bbp_get_user_topics_started', $query, $user_id, $r, $args );
599 599 }
600 600
601 601 /**
602 - * Get the replies that a user created.
602 + * Get the replies that a user created
603 603 *
604 604 * @since 2.2.0 bbPress (r4225)
605 605 * @since 2.6.0 bbPress (r6618) Signature changed to accept an array of arguments
606 606 *
607 - * @param array $args Optional. Arguments to pass into bbp_has_replies().
607 + * @param array $args Optional. Arguments to pass into bbp_has_replies()
608 608 *
609 - * @return bool True if user has created replies, otherwise false.
609 + * @return bool True if user has created replies, otherwise false
610 610 */
611 611 function bbp_get_user_replies_created( $args = array() ) {
612 612
613 613 // Backwards compat for pre-2.6.0
@@ -637,11 +637,11 @@
637 637 return apply_filters( 'bbp_get_user_replies_created', $query, $user_id, $r, $args );
638 638 }
639 639
640 640 /**
641 - * Get user IDs from nicenames.
641 + * Get user IDs from nicenames
642 642 *
643 - * This function is primarily used when saving object moderators.
643 + * This function is primarily used when saving object moderators
644 644 *
645 645 * @since 2.6.0 bbPress
646 646 *
647 647 * @param mixed $user_nicenames
@@ -680,15 +680,15 @@
680 680 return (array) apply_filters( 'bbp_get_user_ids_from_nicenames', $retval, $user_nicenames );
681 681 }
682 682
683 683 /**
684 - * Get user nicenames from IDs.
684 + * Get user nicenames from IDs
685 685 *
686 - * This function is primarily used when saving object moderators.
686 + * This function is primarily used when saving object moderators
687 687 *
688 688 * @since 2.6.0 bbPress
689 689 *
690 - * @param mixed $user_ids User ids.
690 + * @param mixed $user_ids
691 691 * @return array
692 692 */
693 693 function bbp_get_user_nicenames_from_ids( $user_ids = array() ) {
694 694
@@ -717,15 +717,15 @@
717 717
718 718 /** Post Counts ***************************************************************/
719 719
720 720 /**
721 - * Return the raw database count of topics by a user.
721 + * Return the raw database count of topics by a user
722 722 *
723 723 * @since 2.1.0 bbPress (r3633)
724 724 *
725 - * @param int $user_id User ID to get count for.
725 + * @param int $user_id User ID to get count for
726 726 *
727 - * @return int Raw DB count of topics.
727 + * @return int Raw DB count of topics
728 728 */
729 729 function bbp_get_user_topic_count_raw( $user_id = 0 ) {
730 730 $user_id = bbp_get_user_id( $user_id );
731 731 $bbp_db = bbp_db();
@@ -743,15 +743,15 @@
743 743 return (int) apply_filters( 'bbp_get_user_topic_count_raw', $count, $user_id );
744 744 }
745 745
746 746 /**
747 - * Return the raw database count of replies by a user.
747 + * Return the raw database count of replies by a user
748 748 *
749 749 * @since 2.1.0 bbPress (r3633)
750 750 *
751 - * @param int $user_id User ID to get count for.
751 + * @param int $user_id User ID to get count for
752 752 *
753 - * @return int Raw DB count of replies.
753 + * @return int Raw DB count of replies
754 754 */
755 755 function bbp_get_user_reply_count_raw( $user_id = 0 ) {
756 756 $user_id = bbp_get_user_id( $user_id );
757 757 $bbp_db = bbp_db();
@@ -774,10 +774,10 @@
774 774 *
775 775 * @since 2.6.0 bbPress (r5309)
776 776 * @since 2.6.17 Rebuild the count when the user option is missing.
777 777 *
778 - * @param int $user_id User id.
779 - * @param int $difference Optional. Default 1. Number to bump.
778 + * @param int $user_id
779 + * @param int $difference
780 780 */
781 781 function bbp_bump_user_topic_count( $user_id = 0, $difference = 1 ) {
782 782
783 783 // Bail if no bump
@@ -815,10 +815,10 @@
815 815 *
816 816 * @since 2.6.0 bbPress (r5309)
817 817 * @since 2.6.17 Rebuild the count when the user option is missing.
818 818 *
819 - * @param int $user_id User id.
820 - * @param int $difference Optional. Default 1. Number to bump.
819 + * @param int $user_id
820 + * @param int $difference
821 821 */
822 822 function bbp_bump_user_reply_count( $user_id = 0, $difference = 1 ) {
823 823
824 824 // Bail if no bump
@@ -1087,9 +1087,9 @@
1087 1087
1088 1088 /** Permissions ***************************************************************/
1089 1089
1090 1090 /**
1091 - * Redirect if unauthorized user is attempting to edit another user.
1091 + * Redirect if unauthorized user is attempting to edit another user
1092 1092 *
1093 1093 * This is hooked to 'bbp_template_redirect' and controls the conditions under
1094 1094 * which a user can edit another user (or themselves.) If these conditions are
1095 1095 * met, we assume a user cannot perform this task, and look for ways they can