PluginProbe
bbPress / 2.6.6
bbPress v2.6.6
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 2.2.2 All 71 releases
← All changes | includes/users/options.php +115 -121 trunk2.6.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress User Options.
4 + * bbPress User Options
5 5 *
6 6 * @package bbPress
7 7 * @subpackage UserOptions
8 8 */
@@ -10,29 +10,26 @@
10 10 // Exit if accessed directly
11 11 defined( 'ABSPATH' ) || exit;
12 12
13 13 /**
14 - * Get the default user options and their values.
14 + * Get the default user options and their values
15 15 *
16 16 * @since 2.1.0 bbPress (r3910)
17 17 *
18 - * @return array Filtered user option names and values.
18 + * @return array Filtered user option names and values
19 19 */
20 20 function bbp_get_default_user_options() {
21 21
22 22 // Filter & return
23 - return (array) apply_filters(
24 - 'bbp_get_default_user_options',
25 - array(
26 - '_bbp_last_posted' => '0', // For checking flooding
27 - '_bbp_topic_count' => '0', // Total topics per site
28 - '_bbp_reply_count' => '0' // Total replies per site
29 - )
30 - );
23 + return (array) apply_filters( 'bbp_get_default_user_options', array(
24 + '_bbp_last_posted' => '0', // For checking flooding
25 + '_bbp_topic_count' => '0', // Total topics per site
26 + '_bbp_reply_count' => '0' // Total replies per site
27 + ) );
31 28 }
32 29
33 30 /**
34 - * Add default user options.
31 + * Add default user options
35 32 *
36 33 * This is destructive, so existing bbPress user options will be overridden.
37 34 *
38 35 * @since 2.1.0 bbPress (r3910)
@@ -54,9 +51,9 @@
54 51 do_action( 'bbp_add_user_options', $user_id );
55 52 }
56 53
57 54 /**
58 - * Delete default user options.
55 + * Delete default user options
59 56 *
60 57 * Hooked to bbp_uninstall, it is only called once when bbPress is uninstalled.
61 58 * This is destructive, so existing bbPress user options will be destroyed.
62 59 *
@@ -101,10 +98,10 @@
101 98 * $bbp->user_options array.
102 99 *
103 100 * @since 2.1.0 bbPress (r3910)
104 101 *
105 - * @param bool $value Optional. Default value false.
106 - * @return mixed false if not overloaded, mixed if set.
102 + * @param bool $value Optional. Default value false
103 + * @return mixed false if not overloaded, mixed if set
107 104 */
108 105 function bbp_filter_get_user_option( $value = false, $option = '', $user = 0 ) {
109 106 $bbp = bbpress();
110 107
@@ -119,9 +116,9 @@
119 116
120 117 /** Post Counts ***************************************************************/
121 118
122 119 /**
123 - * Update the topic count for a user.
120 + * Update the topic count for a user
124 121 *
125 122 * @since 2.6.0 bbPress (r5309)
126 123 *
127 124 * @param int $user_id
@@ -148,13 +145,13 @@
148 145 return update_user_option( $user_id, '_bbp_topic_count', $count );
149 146 }
150 147
151 148 /**
152 - * Update the reply count for a user.
149 + * Update the reply count for a user
153 150 *
154 151 * @since 2.6.0 bbPress (r5309)
155 152 *
156 - * @param int $user_id User id.
153 + * @param int $user_id
157 154 * @param mixed $count
158 155 * @return boolean
159 156 */
160 157 function bbp_update_user_reply_count( $user_id = 0, $count = false ) {
@@ -177,14 +174,14 @@
177 174 return update_user_option( $user_id, '_bbp_reply_count', $count );
178 175 }
179 176
180 177 /**
181 - * Output a users topic count.
178 + * Output a users topic count
182 179 *
183 180 * @since 2.1.0 bbPress (r3632)
184 181 *
185 - * @param int $user_id User id.
186 - * @param boolean $integer Optional. Whether or not to format the result.
182 + * @param int $user_id
183 + * @param boolean $integer Optional. Whether or not to format the result
187 184 *
188 185 * @return string
189 186 */
190 187 function bbp_user_topic_count( $user_id = 0, $integer = false ) {
@@ -189,43 +186,42 @@
189 186 */
190 187 function bbp_user_topic_count( $user_id = 0, $integer = false ) {
191 188 echo esc_html( bbp_get_user_topic_count( $user_id, $integer ) );
192 189 }
190 + /**
191 + * Return a users reply count
192 + *
193 + * @since 2.1.0 bbPress (r3632)
194 + *
195 + * @param int $user_id
196 + * @param boolean $integer Optional. Whether or not to format the result
197 + *
198 + * @return string
199 + */
200 + function bbp_get_user_topic_count( $user_id = 0, $integer = false ) {
193 201
194 -/**
195 - * Return a users reply count.
196 - *
197 - * @since 2.1.0 bbPress (r3632)
198 - *
199 - * @param int $user_id User id.
200 - * @param boolean $integer Optional. Whether or not to format the result.
201 - *
202 - * @return string
203 - */
204 -function bbp_get_user_topic_count( $user_id = 0, $integer = false ) {
202 + // Validate user id
203 + $user_id = bbp_get_user_id( $user_id );
204 + if ( empty( $user_id ) ) {
205 + return false;
206 + }
205 207
206 - // Validate user id
207 - $user_id = bbp_get_user_id( $user_id );
208 - if ( empty( $user_id ) ) {
209 - return false;
208 + $count = get_user_option( '_bbp_topic_count', $user_id );
209 + $filter = ( true === $integer )
210 + ? 'bbp_get_user_topic_count_int'
211 + : 'bbp_get_user_topic_count';
212 +
213 + // Filter & return
214 + return apply_filters( $filter, $count, $user_id );
210 215 }
211 216
212 - $count = get_user_option( '_bbp_topic_count', $user_id );
213 - $filter = ( true === $integer )
214 - ? 'bbp_get_user_topic_count_int'
215 - : 'bbp_get_user_topic_count';
216 -
217 - // Filter & return
218 - return apply_filters( $filter, $count, $user_id );
219 -}
220 -
221 217 /**
222 - * Output a users reply count.
218 + * Output a users reply count
223 219 *
224 220 * @since 2.1.0 bbPress (r3632)
225 221 *
226 - * @param int $user_id User id.
227 - * @param boolean $integer Optional. Whether or not to format the result.
222 + * @param int $user_id
223 + * @param boolean $integer Optional. Whether or not to format the result
228 224 *
229 225 * @return string
230 226 */
231 227 function bbp_user_reply_count( $user_id = 0, $integer = false ) {
@@ -230,41 +226,40 @@
230 226 */
231 227 function bbp_user_reply_count( $user_id = 0, $integer = false ) {
232 228 echo esc_html( bbp_get_user_reply_count( $user_id, $integer ) );
233 229 }
230 + /**
231 + * Return a users reply count
232 + *
233 + * @since 2.1.0 bbPress (r3632)
234 + *
235 + * @param int $user_id
236 + * @param boolean $integer Optional. Whether or not to format the result
237 + *
238 + * @return string
239 + */
240 + function bbp_get_user_reply_count( $user_id = 0, $integer = false ) {
234 241
235 -/**
236 - * Return a users reply count.
237 - *
238 - * @since 2.1.0 bbPress (r3632)
239 - *
240 - * @param int $user_id User id.
241 - * @param boolean $integer Optional. Whether or not to format the result.
242 - *
243 - * @return string
244 - */
245 -function bbp_get_user_reply_count( $user_id = 0, $integer = false ) {
242 + // Validate user id
243 + $user_id = bbp_get_user_id( $user_id );
244 + if ( empty( $user_id ) ) {
245 + return false;
246 + }
246 247
247 - // Validate user id
248 - $user_id = bbp_get_user_id( $user_id );
249 - if ( empty( $user_id ) ) {
250 - return false;
248 + $count = get_user_option( '_bbp_reply_count', $user_id );
249 + $filter = ( true === $integer )
250 + ? 'bbp_get_user_reply_count_int'
251 + : 'bbp_get_user_reply_count';
252 +
253 + return apply_filters( $filter, $count, $user_id );
251 254 }
252 255
253 - $count = get_user_option( '_bbp_reply_count', $user_id );
254 - $filter = ( true === $integer )
255 - ? 'bbp_get_user_reply_count_int'
256 - : 'bbp_get_user_reply_count';
257 -
258 - return apply_filters( $filter, $count, $user_id );
259 -}
260 -
261 256 /**
262 - * Output a users total post count.
257 + * Output a users total post count
263 258 *
264 259 * @since 2.1.0 bbPress (r3632)
265 260 *
266 - * @param int $user_id User id.
261 + * @param int $user_id
267 262 * @param boolean $integer Optional. Whether or not to format the result
268 263 *
269 264 * @return string
270 265 */
@@ -270,47 +265,46 @@
270 265 */
271 266 function bbp_user_post_count( $user_id = 0, $integer = false ) {
272 267 echo esc_html( bbp_get_user_post_count( $user_id, $integer ) );
273 268 }
269 + /**
270 + * Return a users total post count
271 + *
272 + * @since 2.1.0 bbPress (r3632)
273 + *
274 + * @param int $user_id
275 + * @param boolean $integer Optional. Whether or not to format the result
276 + *
277 + * @return string
278 + */
279 + function bbp_get_user_post_count( $user_id = 0, $integer = false ) {
274 280
275 -/**
276 - * Return a users total post count.
277 - *
278 - * @since 2.1.0 bbPress (r3632)
279 - *
280 - * @param int $user_id User id.
281 - * @param boolean $integer Optional. Whether or not to format the result.
282 - *
283 - * @return string
284 - */
285 -function bbp_get_user_post_count( $user_id = 0, $integer = false ) {
281 + // Validate user id
282 + $user_id = bbp_get_user_id( $user_id );
283 + if ( empty( $user_id ) ) {
284 + return false;
285 + }
286 286
287 - // Validate user id
288 - $user_id = bbp_get_user_id( $user_id );
289 - if ( empty( $user_id ) ) {
290 - return false;
287 + $topics = bbp_get_user_topic_count( $user_id, true );
288 + $replies = bbp_get_user_reply_count( $user_id, true );
289 + $count = $topics + $replies;
290 + $filter = ( true === $integer )
291 + ? 'bbp_get_user_post_count_int'
292 + : 'bbp_get_user_post_count';
293 +
294 + return apply_filters( $filter, $count, $user_id );
291 295 }
292 296
293 - $topics = bbp_get_user_topic_count( $user_id, true );
294 - $replies = bbp_get_user_reply_count( $user_id, true );
295 - $count = $topics + $replies;
296 - $filter = ( true === $integer )
297 - ? 'bbp_get_user_post_count_int'
298 - : 'bbp_get_user_post_count';
299 -
300 - return apply_filters( $filter, $count, $user_id );
301 -}
302 -
303 297 /** Last Posted ***************************************************************/
304 298
305 299 /**
306 - * Update a users last posted time, for use with post throttling.
300 + * Update a users last posted time, for use with post throttling
307 301 *
308 302 * @since 2.1.0 bbPress (r3910)
309 303 *
310 - * @param int $user_id User ID to update.
311 - * @param int $time Time in time() format.
312 - * @return bool False if no user or failure, true if successful.
304 + * @param int $user_id User ID to update
305 + * @param int $time Time in time() format
306 + * @return bool False if no user or failure, true if successful
313 307 */
314 308 function bbp_update_user_last_posted( $user_id = 0, $time = 0 ) {
315 309
316 310 // Validate user id
@@ -331,31 +325,31 @@
331 325 * Output the raw value of the last posted time.
332 326 *
333 327 * @since 2.1.0 bbPress (r3910)
334 328 *
335 - * @param int $user_id User ID to retrieve value for.
329 + * @param int $user_id User ID to retrieve value for
336 330 */
337 331 function bbp_user_last_posted( $user_id = 0 ) {
338 332 echo esc_html( bbp_get_user_last_posted( $user_id ) );
339 333 }
340 334
341 -/**
342 - * Return the raw value of the last posted time.
343 - *
344 - * @since 2.1.0 bbPress (r3910)
345 - *
346 - * @param int $user_id User ID to retrieve value for.
347 - * @return mixed False if no user, time() format if exists.
348 - */
349 -function bbp_get_user_last_posted( $user_id = 0 ) {
335 + /**
336 + * Return the raw value of the last posted time.
337 + *
338 + * @since 2.1.0 bbPress (r3910)
339 + *
340 + * @param int $user_id User ID to retrieve value for
341 + * @return mixed False if no user, time() format if exists
342 + */
343 + function bbp_get_user_last_posted( $user_id = 0 ) {
350 344
351 - // Validate user id
352 - $user_id = bbp_get_user_id( $user_id );
353 - if ( empty( $user_id ) ) {
354 - return false;
355 - }
345 + // Validate user id
346 + $user_id = bbp_get_user_id( $user_id );
347 + if ( empty( $user_id ) ) {
348 + return false;
349 + }
356 350
357 - $time = get_user_option( '_bbp_last_posted', $user_id );
351 + $time = get_user_option( '_bbp_last_posted', $user_id );
358 352
359 - // Filter & return
360 - return apply_filters( 'bbp_get_user_last_posted', $time, $user_id );
361 -}
353 + // Filter & return
354 + return apply_filters( 'bbp_get_user_last_posted', $time, $user_id );
355 + }