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/template.php +553 -578 trunk → 2.6.19 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress User Template Tags.
4 + * bbPress User Template Tags
5 5 *
6 6 * @package bbPress
7 7 * @subpackage TemplateTags
8 8 */
@@ -12,9 +12,9 @@
12 12
13 13 /** User Loop *****************************************************************/
14 14
15 15 /**
16 - * Extension of WP_User_Query to allow easy looping.
16 + * Extension of WP_User_Query to allow easy looping
17 17 *
18 18 * @since 2.6.0 bbPress (r6332)
19 19 */
20 20 class BBP_User_Query extends WP_User_Query {
@@ -78,9 +78,9 @@
78 78 *
79 79 * @return WP_User Next user.
80 80 */
81 81 public function next_user() {
82 - ++$this->current_user;
82 + $this->current_user++;
83 83 $this->user = $this->results[ $this->current_user ];
84 84
85 85 return $this->user;
86 86 }
@@ -167,10 +167,10 @@
167 167 * The main user loop.
168 168 *
169 169 * @since 2.6.0 bbPress (r6332)
170 170 *
171 - * @param array $args All the arguments supported by {@link WP_User_Query}.
172 - * @return object Multidimensional array of user information.
171 + * @param array $args All the arguments supported by {@link WP_User_Query}
172 + * @return object Multidimensional array of user information
173 173 */
174 174 function bbp_has_users( $args = array() ) {
175 175
176 176 // Parse arguments with default user query for most circumstances
@@ -194,13 +194,13 @@
194 194 return apply_filters( 'bbp_has_users', $bbp->user_query->have_users(), $bbp->user_query );
195 195 }
196 196
197 197 /**
198 - * Whether there are more users available in the loop.
198 + * Whether there are more users available in the loop
199 199 *
200 200 * @since 2.6.0 bbPress (r6332)
201 201 *
202 - * @return object User information.
202 + * @return object User information
203 203 */
204 204 function bbp_users() {
205 205 return bbpress()->user_query->have_users();
206 206 }
@@ -205,13 +205,13 @@
205 205 return bbpress()->user_query->have_users();
206 206 }
207 207
208 208 /**
209 - * Loads up the current user in the loop.
209 + * Loads up the current user in the loop
210 210 *
211 211 * @since 2.6.0 bbPress (r6332)
212 212 *
213 - * @return object User information.
213 + * @return object User information
214 214 */
215 215 function bbp_the_user() {
216 216 return bbpress()->user_query->the_user();
217 217 }
@@ -218,13 +218,13 @@
218 218
219 219 /** Users *********************************************************************/
220 220
221 221 /**
222 - * Output a validated user id.
222 + * Output a validated user id
223 223 *
224 224 * @since 2.0.0 bbPress (r2729)
225 225 *
226 - * @param int $user_id Optional. User id.
226 + * @param int $user_id Optional. User id
227 227 * @param bool $displayed_user_fallback Fallback on displayed user?
228 228 * @param bool $current_user_fallback Fallback on current user?
229 229 */
230 230 function bbp_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
@@ -229,49 +229,48 @@
229 229 */
230 230 function bbp_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
231 231 echo bbp_get_user_id( $user_id, $displayed_user_fallback, $current_user_fallback );
232 232 }
233 + /**
234 + * Return a validated user id
235 + *
236 + * @since 2.0.0 bbPress (r2729)
237 + *
238 + * @param int $user_id Optional. User id
239 + * @param bool $displayed_user_fallback Fallback on displayed user?
240 + * @param bool $current_user_fallback Fallback on current user?
241 + * @return int Validated user id
242 + */
243 + function bbp_get_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
244 + $bbp = bbpress();
233 245
234 -/**
235 - * Return a validated user id.
236 - *
237 - * @since 2.0.0 bbPress (r2729)
238 - *
239 - * @param int $user_id Optional. User id.
240 - * @param bool $displayed_user_fallback Fallback on displayed user?
241 - * @param bool $current_user_fallback Fallback on current user?
242 - * @return int Validated user id.
243 - */
244 -function bbp_get_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
245 - $bbp = bbpress();
246 + // Easy empty checking
247 + if ( ! empty( $user_id ) && is_numeric( $user_id ) ) {
248 + $bbp_user_id = $user_id;
246 249
247 - // Easy empty checking
248 - if ( ! empty( $user_id ) && is_numeric( $user_id ) ) {
249 - $bbp_user_id = $user_id;
250 + // Currently inside a user loop
251 + } elseif ( ! empty( $bbp->user_query->in_the_loop ) && isset( $bbp->user_query->user->ID ) ) {
252 + $bbp_user_id = $bbp->user_query->user->ID;
250 253
251 - // Currently inside a user loop
252 - } elseif ( ! empty( $bbp->user_query->in_the_loop ) && isset( $bbp->user_query->user->ID ) ) {
253 - $bbp_user_id = $bbp->user_query->user->ID;
254 + // Currently viewing or editing a user
255 + } elseif ( ( true === $displayed_user_fallback ) && ! empty( $bbp->displayed_user->ID ) ) {
256 + $bbp_user_id = $bbp->displayed_user->ID;
254 257
255 - // Currently viewing or editing a user
256 - } elseif ( ( true === $displayed_user_fallback ) && ! empty( $bbp->displayed_user->ID ) ) {
257 - $bbp_user_id = $bbp->displayed_user->ID;
258 + // Maybe fallback on the current_user ID
259 + } elseif ( ( true === $current_user_fallback ) && ! empty( $bbp->current_user->ID ) ) {
260 + $bbp_user_id = $bbp->current_user->ID;
258 261
259 - // Maybe fallback on the current_user ID
260 - } elseif ( ( true === $current_user_fallback ) && ! empty( $bbp->current_user->ID ) ) {
261 - $bbp_user_id = $bbp->current_user->ID;
262 + // Failsafe
263 + } else {
264 + $bbp_user_id = 0;
265 + }
262 266
263 - // Failsafe
264 - } else {
265 - $bbp_user_id = 0;
267 + // Filter & return
268 + return (int) apply_filters( 'bbp_get_user_id', (int) $bbp_user_id, $displayed_user_fallback, $current_user_fallback );
266 269 }
267 270
268 - // Filter & return
269 - return (int) apply_filters( 'bbp_get_user_id', (int) $bbp_user_id, $displayed_user_fallback, $current_user_fallback );
270 -}
271 -
272 271 /**
273 - * Output ID of current user.
272 + * Output ID of current user
274 273 *
275 274 * @since 2.0.0 bbPress (r2574)
276 275 */
277 276 function bbp_current_user_id() {
@@ -276,24 +275,23 @@
276 275 */
277 276 function bbp_current_user_id() {
278 277 echo bbp_get_current_user_id();
279 278 }
279 + /**
280 + * Return ID of current user
281 + *
282 + * @since 2.0.0 bbPress (r2574)
283 + *
284 + * @return int Current user id
285 + */
286 + function bbp_get_current_user_id() {
280 287
281 -/**
282 - * Return ID of current user.
283 - *
284 - * @since 2.0.0 bbPress (r2574)
285 - *
286 - * @return int Current user id.
287 - */
288 -function bbp_get_current_user_id() {
288 + // Filter & return
289 + return (int) apply_filters( 'bbp_get_current_user_id', bbp_get_user_id( 0, false, true ) );
290 + }
289 291
290 - // Filter & return
291 - return (int) apply_filters( 'bbp_get_current_user_id', bbp_get_user_id( 0, false, true ) );
292 -}
293 -
294 292 /**
295 - * Output ID of displayed user.
293 + * Output ID of displayed user
296 294 *
297 295 * @since 2.0.0 bbPress (r2688)
298 296 */
299 297 function bbp_displayed_user_id() {
@@ -298,24 +296,23 @@
298 296 */
299 297 function bbp_displayed_user_id() {
300 298 echo bbp_get_displayed_user_id();
301 299 }
300 + /**
301 + * Return ID of displayed user
302 + *
303 + * @since 2.0.0 bbPress (r2688)
304 + *
305 + * @return int Displayed user id
306 + */
307 + function bbp_get_displayed_user_id() {
302 308
303 -/**
304 - * Return ID of displayed user.
305 - *
306 - * @since 2.0.0 bbPress (r2688)
307 - *
308 - * @return int Displayed user id.
309 - */
310 -function bbp_get_displayed_user_id() {
309 + // Filter & return
310 + return apply_filters( 'bbp_get_displayed_user_id', bbp_get_user_id( 0, true, false ) );
311 + }
311 312
312 - // Filter & return
313 - return apply_filters( 'bbp_get_displayed_user_id', bbp_get_user_id( 0, true, false ) );
314 -}
315 -
316 313 /**
317 - * Output a sanitized user field value.
314 + * Output a sanitized user field value
318 315 *
319 316 * This function relies on the $filter parameter to decide how to sanitize
320 317 * the field value that it finds. Since it uses the WP_User object's magic
321 318 * __get() method, it can also be used to get user_meta values.
@@ -321,54 +318,52 @@
321 318 * __get() method, it can also be used to get user_meta values.
322 319 *
323 320 * @since 2.1.0 bbPress (r3634)
324 321 *
325 - * @param string $field Field to get.
326 - * @param string $filter How to filter the field value (null|raw|db|display|edit).
322 + * @param string $field Field to get
323 + * @param string $filter How to filter the field value (null|raw|db|display|edit)
327 324 */
328 325 function bbp_displayed_user_field( $field = '', $filter = 'display' ) {
329 326 echo bbp_get_displayed_user_field( $field, $filter );
330 327 }
328 + /**
329 + * Return a sanitized user field value
330 + *
331 + * This function relies on the $filter parameter to decide how to sanitize
332 + * the field value that it finds. Since it uses the WP_User object's magic
333 + * __get() method, it can also be used to get user_meta values.
334 + *
335 + * @since 2.0.0 bbPress (r2688)
336 + *
337 + * @param string $field Field to get
338 + * @param string $filter How to filter the field value (null|raw|db|display|edit)
339 + * @see WP_User::__get() for more on how the value is retrieved
340 + * @see sanitize_user_field() for more on how the value is sanitized
341 + * @return string|bool Value of the field if it exists, else false
342 + */
343 + function bbp_get_displayed_user_field( $field = '', $filter = 'display' ) {
331 344
332 -/**
333 - * Return a sanitized user field value.
334 - *
335 - * This function relies on the $filter parameter to decide how to sanitize
336 - * the field value that it finds. Since it uses the WP_User object's magic
337 - * __get() method, it can also be used to get user_meta values.
338 - *
339 - * @since 2.0.0 bbPress (r2688)
340 - *
341 - * @see WP_User::__get() for more on how the value is retrieved.
342 - * @see sanitize_user_field() for more on how the value is sanitized.
343 - *
344 - * @param string $field Field to get.
345 - * @param string $filter How to filter the field value (null|raw|db|display|edit).
346 - * @return string|bool Value of the field if it exists, else false.
347 - */
348 -function bbp_get_displayed_user_field( $field = '', $filter = 'display' ) {
345 + // Get the displayed user
346 + $user = bbpress()->displayed_user;
349 347
350 - // Get the displayed user
351 - $user = bbpress()->displayed_user;
348 + // Juggle the user filter property because we don't want to muck up how
349 + // other code might interact with this object.
350 + $old_filter = $user->filter;
351 + $user->filter = $filter;
352 352
353 - // Juggle the user filter property because we don't want to muck up how
354 - // other code might interact with this object.
355 - $old_filter = $user->filter;
356 - $user->filter = $filter;
353 + // Get the field value from the WP_User object. We don't need to perform
354 + // an isset() because the WP_User::__get() does it for us.
355 + $value = $user->$field;
357 356
358 - // Get the field value from the WP_User object. We don't need to perform
359 - // an isset() because the WP_User::__get() does it for us.
360 - $value = $user->$field;
357 + // Put back the user filter property that was previously juggled above.
358 + $user->filter = $old_filter;
361 359
362 - // Put back the user filter property that was previously juggled above.
363 - $user->filter = $old_filter;
360 + // Filter & return
361 + return apply_filters( 'bbp_get_displayed_user_field', $value, $field, $filter );
362 + }
364 363
365 - // Filter & return
366 - return apply_filters( 'bbp_get_displayed_user_field', $value, $field, $filter );
367 -}
368 -
369 364 /**
370 - * Output name of current user.
365 + * Output name of current user
371 366 *
372 367 * @since 2.0.0 bbPress (r2574)
373 368 */
374 369 function bbp_current_user_name() {
@@ -373,133 +368,130 @@
373 368 */
374 369 function bbp_current_user_name() {
375 370 echo esc_attr( bbp_get_current_user_name() );
376 371 }
372 + /**
373 + * Return name of current user
374 + *
375 + * @since 2.0.0 bbPress (r2574)
376 + *
377 + * @return string
378 + */
379 + function bbp_get_current_user_name() {
377 380
378 -/**
379 - * Return name of current user.
380 - *
381 - * @since 2.0.0 bbPress (r2574)
382 - *
383 - * @return string
384 - */
385 -function bbp_get_current_user_name() {
381 + // Default current user name
382 + $default = bbp_get_fallback_display_name();
386 383
387 - // Default current user name
388 - $default = bbp_get_fallback_display_name();
384 + // Check the $user_identity global
385 + $current_user_name = is_user_logged_in()
386 + ? bbp_get_global_object( 'user_identity', false, $default )
387 + : $default;
389 388
390 - // Check the $user_identity global
391 - $current_user_name = is_user_logged_in()
392 - ? bbp_get_global_object( 'user_identity', false, $default )
393 - : $default;
389 + // Filter & return
390 + return apply_filters( 'bbp_get_current_user_name', $current_user_name );
391 + }
394 392
395 - // Filter & return
396 - return apply_filters( 'bbp_get_current_user_name', $current_user_name );
397 -}
398 -
399 393 /**
400 - * Output avatar of current user.
394 + * Output avatar of current user
401 395 *
402 396 * @since 2.0.0 bbPress (r2574)
403 397 *
404 - * @param int $size Size of the avatar. Defaults to 40.
398 + * @param int $size Size of the avatar. Defaults to 40
405 399 */
406 400 function bbp_current_user_avatar( $size = 40 ) {
407 401 echo bbp_get_current_user_avatar( $size );
408 402 }
409 403
410 -/**
411 - * Return avatar of current user.
412 - *
413 - * @since 2.0.0 bbPress (r2574)
414 - *
415 - * @param int $size Size of the avatar. Defaults to 40.
416 - * @return string Current user avatar.
417 - */
418 -function bbp_get_current_user_avatar( $size = 40 ) {
404 + /**
405 + * Return avatar of current user
406 + *
407 + * @since 2.0.0 bbPress (r2574)
408 + *
409 + * @param int $size Size of the avatar. Defaults to 40
410 + * @return string Current user avatar
411 + */
412 + function bbp_get_current_user_avatar( $size = 40 ) {
419 413
420 - $user = bbp_get_current_user_id();
421 - if ( empty( $user ) ) {
422 - $user = bbp_get_current_anonymous_user_data( 'email' );
423 - }
414 + $user = bbp_get_current_user_id();
415 + if ( empty( $user ) ) {
416 + $user = bbp_get_current_anonymous_user_data( 'email' );
417 + }
424 418
425 - $avatar = get_avatar( $user, $size );
419 + $avatar = get_avatar( $user, $size );
426 420
427 - // Filter & return
428 - return apply_filters( 'bbp_get_current_user_avatar', $avatar, $size );
429 -}
421 + // Filter & return
422 + return apply_filters( 'bbp_get_current_user_avatar', $avatar, $size );
423 + }
430 424
431 425 /**
432 - * Output link to the profile page of a user.
426 + * Output link to the profile page of a user
433 427 *
434 428 * @since 2.0.0 bbPress (r2688)
435 429 *
436 - * @param int $user_id Optional. User id.
430 + * @param int $user_id Optional. User id
437 431 */
438 432 function bbp_user_profile_link( $user_id = 0 ) {
439 433 echo bbp_get_user_profile_link( $user_id );
440 434 }
435 + /**
436 + * Return link to the profile page of a user
437 + *
438 + * @since 2.0.0 bbPress (r2688)
439 + *
440 + * @param int $user_id Optional. User id
441 + * @return string User profile link
442 + */
443 + function bbp_get_user_profile_link( $user_id = 0 ) {
441 444
442 -/**
443 - * Return link to the profile page of a user.
444 - *
445 - * @since 2.0.0 bbPress (r2688)
446 - *
447 - * @param int $user_id Optional. User id.
448 - * @return string User profile link.
449 - */
450 -function bbp_get_user_profile_link( $user_id = 0 ) {
445 + // Validate user id
446 + $user_id = bbp_get_user_id( $user_id );
447 + if ( empty( $user_id ) ) {
448 + return false;
449 + }
451 450
452 - // Validate user id
453 - $user_id = bbp_get_user_id( $user_id );
454 - if ( empty( $user_id ) ) {
455 - return false;
456 - }
451 + // Get the user
452 + $user = get_userdata( $user_id );
453 + if ( empty( $user ) ) {
454 + return false;
455 + }
457 456
458 - // Get the user
459 - $user = get_userdata( $user_id );
460 - if ( empty( $user ) ) {
461 - return false;
462 - }
457 + // Display Name
458 + $name = ! empty( $user->display_name )
459 + ? $user->display_name
460 + : bbp_get_fallback_display_name();
463 461
464 - // Display Name
465 - $name = ! empty( $user->display_name )
466 - ? $user->display_name
467 - : bbp_get_fallback_display_name();
462 + // URL
463 + $url = bbp_get_user_profile_url( $user_id );
468 464
469 - // URL
470 - $url = bbp_get_user_profile_url( $user_id );
465 + // Link
466 + $link = ! empty( $url )
467 + ? '<a href="' . esc_url( $url ) . '">' . esc_html( $name ) . '</a>'
468 + : esc_html( $name );
471 469
472 - // Link
473 - $link = ! empty( $url )
474 - ? '<a href="' . esc_url( $url ) . '">' . esc_html( $name ) . '</a>'
475 - : esc_html( $name );
470 + // Filter & return
471 + return (string) apply_filters( 'bbp_get_user_profile_link', $link, $user_id );
472 + }
476 473
477 - // Filter & return
478 - return (string) apply_filters( 'bbp_get_user_profile_link', $link, $user_id );
479 -}
480 -
481 474 /**
482 - * Output a users nicename to the screen.
475 + * Output a users nicename to the screen
483 476 *
484 477 * @since 2.3.0 bbPress (r4672)
485 478 *
486 - * @param int $user_id User ID whose nicename to get.
487 - * @param array $args before|after|user_id|force.
479 + * @param int $user_id User ID whose nicename to get
480 + * @param array $args before|after|user_id|force
488 481 */
489 482 function bbp_user_nicename( $user_id = 0, $args = array() ) {
490 483 echo bbp_get_user_nicename( $user_id, $args );
491 484 }
492 -
493 -/**
494 - * Return a users nicename to the screen.
495 - *
496 - * @since 2.3.0 bbPress (r4672)
497 - *
498 - * @param int $user_id User ID whose nicename to get.
499 - * @param array $args before|after|user_id|force.
500 - * @return string User nicename, maybe wrapped in before/after strings.
501 - */
485 + /**
486 + * Return a users nicename to the screen
487 + *
488 + * @since 2.3.0 bbPress (r4672)
489 + *
490 + * @param int $user_id User ID whose nicename to get
491 + * @param array $args before|after|user_id|force
492 + * @return string User nicename, maybe wrapped in before/after strings
493 + */
502 494 function bbp_get_user_nicename( $user_id = 0, $args = array() ) {
503 495
504 496 // Bail if no user ID passed
505 497 $user_id = bbp_get_user_id( $user_id );
@@ -544,28 +536,27 @@
544 536 return (string) apply_filters( 'bbp_get_user_nicename', $retval, $user_id, $r, $args );
545 537 }
546 538
547 539 /**
548 - * Output URL to the profile page of a user.
540 + * Output URL to the profile page of a user
549 541 *
550 542 * @since 2.0.0 bbPress (r2688)
551 543 *
552 - * @param int $user_id Optional. User id.
553 - * @param string $user_nicename Optional. User nicename.
544 + * @param int $user_id Optional. User id
545 + * @param string $user_nicename Optional. User nicename
554 546 */
555 547 function bbp_user_profile_url( $user_id = 0, $user_nicename = '' ) {
556 548 echo esc_url( bbp_get_user_profile_url( $user_id, $user_nicename ) );
557 549 }
558 -
559 -/**
560 - * Return URL to the profile page of a user.
561 - *
562 - * @since 2.0.0 bbPress (r2688)
563 - *
564 - * @param int $user_id Optional. User id.
565 - * @param string $user_nicename Optional. User nicename.
566 - * @return string User profile url.
567 - */
550 + /**
551 + * Return URL to the profile page of a user
552 + *
553 + * @since 2.0.0 bbPress (r2688)
554 + *
555 + * @param int $user_id Optional. User id
556 + * @param string $user_nicename Optional. User nicename
557 + * @return string User profile url
558 + */
568 559 function bbp_get_user_profile_url( $user_id = 0, $user_nicename = '' ) {
569 560
570 561 // Use displayed user ID if there is one, and one isn't requested
571 562 $user_id = bbp_get_user_id( $user_id );
@@ -606,78 +597,76 @@
606 597 return apply_filters( 'bbp_get_user_profile_url', $url, $user_id, $user_nicename );
607 598 }
608 599
609 600 /**
610 - * Output link to the profile edit page of a user.
601 + * Output link to the profile edit page of a user
611 602 *
612 603 * @since 2.0.0 bbPress (r2688)
613 604 *
614 - * @param int $user_id Optional. User id.
605 + * @param int $user_id Optional. User id
615 606 */
616 607 function bbp_user_profile_edit_link( $user_id = 0 ) {
617 608 echo bbp_get_user_profile_edit_link( $user_id );
618 609 }
610 + /**
611 + * Return link to the profile edit page of a user
612 + *
613 + * @since 2.0.0 bbPress (r2688)
614 + *
615 + * @param int $user_id Optional. User id
616 + * @return string User profile edit link
617 + */
618 + function bbp_get_user_profile_edit_link( $user_id = 0 ) {
619 619
620 -/**
621 - * Return link to the profile edit page of a user.
622 - *
623 - * @since 2.0.0 bbPress (r2688)
624 - *
625 - * @param int $user_id Optional. User id.
626 - * @return string User profile edit link.
627 - */
628 -function bbp_get_user_profile_edit_link( $user_id = 0 ) {
620 + // Validate user id
621 + $user_id = bbp_get_user_id( $user_id );
622 + if ( empty( $user_id ) ) {
623 + return false;
624 + }
629 625
630 - // Validate user id
631 - $user_id = bbp_get_user_id( $user_id );
632 - if ( empty( $user_id ) ) {
633 - return false;
634 - }
626 + // Get the user
627 + $user = get_userdata( $user_id );
628 + if ( empty( $user ) ) {
629 + return false;
630 + }
635 631
636 - // Get the user
637 - $user = get_userdata( $user_id );
638 - if ( empty( $user ) ) {
639 - return false;
640 - }
632 + // Display Name
633 + $name = ! empty( $user->display_name )
634 + ? $user->display_name
635 + : bbp_get_fallback_display_name();
641 636
642 - // Display Name
643 - $name = ! empty( $user->display_name )
644 - ? $user->display_name
645 - : bbp_get_fallback_display_name();
637 + // URL
638 + $url = bbp_get_user_profile_edit_url( $user_id );
646 639
647 - // URL
648 - $url = bbp_get_user_profile_edit_url( $user_id );
640 + // Link
641 + $link = ! empty( $url )
642 + ? '<a href="' . esc_url( $url ) . '">' . esc_html( $name ) . '</a>'
643 + : esc_html( $name );
649 644
650 - // Link
651 - $link = ! empty( $url )
652 - ? '<a href="' . esc_url( $url ) . '">' . esc_html( $name ) . '</a>'
653 - : esc_html( $name );
645 + // Filter & return
646 + return (string) apply_filters( 'bbp_get_user_profile_edit_link', $link, $user_id );
647 + }
654 648
655 - // Filter & return
656 - return (string) apply_filters( 'bbp_get_user_profile_edit_link', $link, $user_id );
657 -}
658 -
659 649 /**
660 - * Output URL to the profile edit page of a user.
650 + * Output URL to the profile edit page of a user
661 651 *
662 652 * @since 2.0.0 bbPress (r2688)
663 653 *
664 - * @param int $user_id Optional. User id.
665 - * @param string $user_nicename Optional. User nicename.
654 + * @param int $user_id Optional. User id
655 + * @param string $user_nicename Optional. User nicename
666 656 */
667 657 function bbp_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
668 658 echo esc_url( bbp_get_user_profile_edit_url( $user_id, $user_nicename ) );
669 659 }
670 -
671 -/**
672 - * Return URL to the profile edit page of a user.
673 - *
674 - * @since 2.0.0 bbPress (r2688)
675 - *
676 - * @param int $user_id Optional. User id.
677 - * @param string $user_nicename Optional. User nicename.
678 - * @return string
679 - */
660 + /**
661 + * Return URL to the profile edit page of a user
662 + *
663 + * @since 2.0.0 bbPress (r2688)
664 + *
665 + * @param int $user_id Optional. User id
666 + * @param string $user_nicename Optional. User nicename
667 + * @return string
668 + */
680 669 function bbp_get_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
681 670
682 671 $user_id = bbp_get_user_id( $user_id );
683 672 if ( empty( $user_id ) ) {
@@ -712,76 +701,74 @@
712 701 return apply_filters( 'bbp_get_user_edit_profile_url', $url, $user_id, $user_nicename );
713 702 }
714 703
715 704 /**
716 - * Output a user's main role for display.
705 + * Output a user's main role for display
717 706 *
718 707 * @since 2.1.0 bbPress (r3860)
719 708 *
720 - * @param int $user_id User id.
709 + * @param int $user_id
721 710 */
722 711 function bbp_user_display_role( $user_id = 0 ) {
723 712 echo esc_attr( bbp_get_user_display_role( $user_id ) );
724 713 }
714 + /**
715 + * Return a user's main role for display
716 + *
717 + * @since 2.1.0 bbPress (r3860)
718 + *
719 + * @param int $user_id
720 + * @return string
721 + */
722 + function bbp_get_user_display_role( $user_id = 0 ) {
725 723
726 -/**
727 - * Return a user's main role for display.
728 - *
729 - * @since 2.1.0 bbPress (r3860)
730 - *
731 - * @param int $user_id User id.
732 - * @return string
733 - */
734 -function bbp_get_user_display_role( $user_id = 0 ) {
724 + // Validate user id
725 + $user_id = bbp_get_user_id( $user_id );
735 726
736 - // Validate user id
737 - $user_id = bbp_get_user_id( $user_id );
727 + // User is not registered
728 + if ( empty( $user_id ) ) {
729 + $role = esc_html__( 'Guest', 'bbpress' );
738 730
739 - // User is not registered
740 - if ( empty( $user_id ) ) {
741 - $role = esc_html__( 'Guest', 'bbpress' );
731 + // User is not active
732 + } elseif ( bbp_is_user_inactive( $user_id ) ) {
733 + $role = esc_html__( 'Inactive', 'bbpress' );
742 734
743 - // User is not active
744 - } elseif ( bbp_is_user_inactive( $user_id ) ) {
745 - $role = esc_html__( 'Inactive', 'bbpress' );
735 + // User have a role
736 + } else {
737 + $role_id = bbp_get_user_role( $user_id );
738 + $role = bbp_get_dynamic_role_name( $role_id );
739 + }
746 740
747 - // User have a role
748 - } else {
749 - $role_id = bbp_get_user_role( $user_id );
750 - $role = bbp_get_dynamic_role_name( $role_id );
751 - }
741 + // No role found so default to generic "Member"
742 + if ( empty( $role ) ) {
743 + $role = esc_html__( 'Member', 'bbpress' );
744 + }
752 745
753 - // No role found so default to generic "Member"
754 - if ( empty( $role ) ) {
755 - $role = esc_html__( 'Member', 'bbpress' );
746 + // Filter & return
747 + return apply_filters( 'bbp_get_user_display_role', $role, $user_id );
756 748 }
757 749
758 - // Filter & return
759 - return apply_filters( 'bbp_get_user_display_role', $role, $user_id );
760 -}
761 -
762 750 /**
763 - * Output the link to the admin section.
751 + * Output the link to the admin section
764 752 *
765 753 * @since 2.0.0 bbPress (r2827)
766 754 *
767 - * @param array $args Optional. See {@link bbp_get_admin_link()}.
755 + * @param array $args Optional. See {@link bbp_get_admin_link()}
768 756 */
769 757 function bbp_admin_link( $args = array() ) {
770 758 echo bbp_get_admin_link( $args );
771 759 }
772 -
773 -/**
774 - * Return the link to the admin section.
775 - *
776 - * @since 2.0.0 bbPress (r2827)
777 - *
778 - * @param array $args Optional. This function supports these arguments:
779 - * - text: The text
780 - * - before: Before the lnk
781 - * - after: After the link
782 - * @return The link.
783 - */
760 + /**
761 + * Return the link to the admin section
762 + *
763 + * @since 2.0.0 bbPress (r2827)
764 + *
765 + * @param array $args Optional. This function supports these arguments:
766 + * - text: The text
767 + * - before: Before the lnk
768 + * - after: After the link
769 + * @return The link
770 + */
784 771 function bbp_get_admin_link( $args = array() ) {
785 772
786 773 // Bail if user cannot globally moderate
787 774 if ( ! current_user_can( 'moderate' ) ) {
@@ -811,9 +798,9 @@
811 798
812 799 /** User IP *******************************************************************/
813 800
814 801 /**
815 - * Output the author IP address of a post.
802 + * Output the author IP address of a post
816 803 *
817 804 * @since 2.0.0 bbPress (r3120)
818 805 *
819 806 * @param array $args Optional. If it is an integer, it is used as post id.
@@ -820,17 +807,16 @@
820 807 */
821 808 function bbp_author_ip( $args = array() ) {
822 809 echo bbp_get_author_ip( $args );
823 810 }
824 -
825 -/**
826 - * Return the author IP address of a post.
827 - *
828 - * @since 2.0.0 bbPress (r3120)
829 - *
830 - * @param array $args Optional. If an integer, it is used as reply id.
831 - * @return string Author link of reply.
832 - */
811 + /**
812 + * Return the author IP address of a post
813 + *
814 + * @since 2.0.0 bbPress (r3120)
815 + *
816 + * @param array $args Optional. If an integer, it is used as reply id.
817 + * @return string Author link of reply
818 + */
833 819 function bbp_get_author_ip( $args = array() ) {
834 820
835 821 // Used as post id
836 822 $post_id = is_numeric( $args ) ? (int) $args : 0;
@@ -865,9 +851,9 @@
865 851 * if something went wrong during saving anonymous user data to the database.
866 852 *
867 853 * @since 2.6.0 bbPress (r6562)
868 854 *
869 - * @param int $object_id For additional context only, usually a post ID.
855 + * @param int $object_id For additional context only, usually a post ID
870 856 *
871 857 * @return string
872 858 */
873 859 function bbp_get_fallback_display_name( $object_id = 0 ) {
@@ -885,49 +871,49 @@
885 871 * and reply author information in the anonymous form template-part.
886 872 *
887 873 * @since 2.5.0 bbPress (r5120)
888 874 *
889 - * @param int $post_id Post id.
875 + * @param int $post_id
890 876 */
891 877 function bbp_author_display_name( $post_id = 0 ) {
892 878 echo esc_attr( bbp_get_author_display_name( $post_id ) );
893 879 }
894 880
895 -/**
896 - * Return the author display-name of a topic or reply.
897 - *
898 - * Convenience function to ensure proper template functions are called
899 - * and correct filters are executed. Used primarily to display topic
900 - * and reply author information in the anonymous form template-part.
901 - *
902 - * @since 2.5.0 bbPress (r5120)
903 - *
904 - * @param int $post_id Post id.
905 - *
906 - * @return string The name of the author.
907 - */
908 -function bbp_get_author_display_name( $post_id = 0 ) {
881 + /**
882 + * Return the author display-name of a topic or reply.
883 + *
884 + * Convenience function to ensure proper template functions are called
885 + * and correct filters are executed. Used primarily to display topic
886 + * and reply author information in the anonymous form template-part.
887 + *
888 + * @since 2.5.0 bbPress (r5120)
889 + *
890 + * @param int $post_id
891 + *
892 + * @return string The name of the author
893 + */
894 + function bbp_get_author_display_name( $post_id = 0 ) {
909 895
910 - // Define local variable(s)
911 - $retval = '';
896 + // Define local variable(s)
897 + $retval = '';
912 898
913 - // Topic edit
914 - if ( bbp_is_topic_edit() ) {
915 - $retval = bbp_get_topic_author_display_name( $post_id );
899 + // Topic edit
900 + if ( bbp_is_topic_edit() ) {
901 + $retval = bbp_get_topic_author_display_name( $post_id );
916 902
917 - // Reply edit
918 - } elseif ( bbp_is_reply_edit() ) {
919 - $retval = bbp_get_reply_author_display_name( $post_id );
903 + // Reply edit
904 + } elseif ( bbp_is_reply_edit() ) {
905 + $retval = bbp_get_reply_author_display_name( $post_id );
920 906
921 - // Not an edit, so rely on current user cookie data
922 - } else {
923 - $retval = bbp_get_current_anonymous_user_data( 'name' );
907 + // Not an edit, so rely on current user cookie data
908 + } else {
909 + $retval = bbp_get_current_anonymous_user_data( 'name' );
910 + }
911 +
912 + // Filter & return
913 + return apply_filters( 'bbp_get_author_display_name', $retval, $post_id );
924 914 }
925 915
926 - // Filter & return
927 - return apply_filters( 'bbp_get_author_display_name', $retval, $post_id );
928 -}
929 -
930 916 /**
931 917 * Output the author email of a topic or reply.
932 918 *
933 919 * Convenience function to ensure proper template functions are called
@@ -935,49 +921,49 @@
935 921 * and reply author information in the anonymous user form template-part.
936 922 *
937 923 * @since 2.5.0 bbPress (r5120)
938 924 *
939 - * @param int $post_id Post id.
925 + * @param int $post_id
940 926 */
941 927 function bbp_author_email( $post_id = 0 ) {
942 928 echo esc_attr( bbp_get_author_email( $post_id ) );
943 929 }
944 930
945 -/**
946 - * Return the author email of a topic or reply.
947 - *
948 - * Convenience function to ensure proper template functions are called
949 - * and correct filters are executed. Used primarily to display topic
950 - * and reply author information in the anonymous user form template-part.
951 - *
952 - * @since 2.5.0 bbPress (r5120)
953 - *
954 - * @param int $post_id Post id.
955 -*
956 - * @return string The email of the author.
957 - */
958 -function bbp_get_author_email( $post_id = 0 ) {
931 + /**
932 + * Return the author email of a topic or reply.
933 + *
934 + * Convenience function to ensure proper template functions are called
935 + * and correct filters are executed. Used primarily to display topic
936 + * and reply author information in the anonymous user form template-part.
937 + *
938 + * @since 2.5.0 bbPress (r5120)
939 + *
940 + * @param int $post_id
941 + *
942 + * @return string The email of the author
943 + */
944 + function bbp_get_author_email( $post_id = 0 ) {
959 945
960 - // Define local variable(s)
961 - $retval = '';
946 + // Define local variable(s)
947 + $retval = '';
962 948
963 - // Topic edit
964 - if ( bbp_is_topic_edit() ) {
965 - $retval = bbp_get_topic_author_email( $post_id );
949 + // Topic edit
950 + if ( bbp_is_topic_edit() ) {
951 + $retval = bbp_get_topic_author_email( $post_id );
966 952
967 - // Reply edit
968 - } elseif ( bbp_is_reply_edit() ) {
969 - $retval = bbp_get_reply_author_email( $post_id );
953 + // Reply edit
954 + } elseif ( bbp_is_reply_edit() ) {
955 + $retval = bbp_get_reply_author_email( $post_id );
970 956
971 - // Not an edit, so rely on current user cookie data
972 - } else {
973 - $retval = bbp_get_current_anonymous_user_data( 'email' );
957 + // Not an edit, so rely on current user cookie data
958 + } else {
959 + $retval = bbp_get_current_anonymous_user_data( 'email' );
960 + }
961 +
962 + // Filter & return
963 + return apply_filters( 'bbp_get_author_email', $retval, $post_id );
974 964 }
975 965
976 - // Filter & return
977 - return apply_filters( 'bbp_get_author_email', $retval, $post_id );
978 -}
979 -
980 966 /**
981 967 * Output the author url of a topic or reply.
982 968 *
983 969 * Convenience function to ensure proper template functions are called
@@ -985,72 +971,71 @@
985 971 * and reply author information in the anonymous user form template-part.
986 972 *
987 973 * @since 2.5.0 bbPress (r5120)
988 974 *
989 - * @param int $post_id Post id.
975 + * @param int $post_id
990 976 */
991 977 function bbp_author_url( $post_id = 0 ) {
992 978 echo esc_attr( bbp_get_author_url( $post_id ) );
993 979 }
994 980
995 -/**
996 - * Return the author url of a topic or reply.
997 - *
998 - * Convenience function to ensure proper template functions are called
999 - * and correct filters are executed. Used primarily to display topic
1000 - * and reply author information in the anonymous user form template-part.
1001 - *
1002 - * @since 2.5.0 bbPress (r5120)
1003 - *
1004 - * @param int $post_id Post id.
1005 - *
1006 - * @return string The url of the author.
1007 - */
1008 -function bbp_get_author_url( $post_id = 0 ) {
981 + /**
982 + * Return the author url of a topic or reply.
983 + *
984 + * Convenience function to ensure proper template functions are called
985 + * and correct filters are executed. Used primarily to display topic
986 + * and reply author information in the anonymous user form template-part.
987 + *
988 + * @since 2.5.0 bbPress (r5120)
989 + *
990 + * @param int $post_id
991 + *
992 + * @return string The url of the author
993 + */
994 + function bbp_get_author_url( $post_id = 0 ) {
1009 995
1010 - // Define local variable(s)
1011 - $retval = '';
996 + // Define local variable(s)
997 + $retval = '';
1012 998
1013 - // Topic edit
1014 - if ( bbp_is_topic_edit() ) {
1015 - $retval = bbp_get_topic_author_url( $post_id );
999 + // Topic edit
1000 + if ( bbp_is_topic_edit() ) {
1001 + $retval = bbp_get_topic_author_url( $post_id );
1016 1002
1017 - // Reply edit
1018 - } elseif ( bbp_is_reply_edit() ) {
1019 - $retval = bbp_get_reply_author_url( $post_id );
1003 + // Reply edit
1004 + } elseif ( bbp_is_reply_edit() ) {
1005 + $retval = bbp_get_reply_author_url( $post_id );
1020 1006
1021 - // Not an edit, so rely on current user cookie data
1022 - } else {
1023 - $retval = bbp_get_current_anonymous_user_data( 'url' );
1007 + // Not an edit, so rely on current user cookie data
1008 + } else {
1009 + $retval = bbp_get_current_anonymous_user_data( 'url' );
1010 + }
1011 +
1012 + // Filter & return
1013 + return apply_filters( 'bbp_get_author_url', $retval, $post_id );
1024 1014 }
1025 1015
1026 - // Filter & return
1027 - return apply_filters( 'bbp_get_author_url', $retval, $post_id );
1028 -}
1029 -
1030 1016 /** Favorites *****************************************************************/
1031 1017
1032 1018 /**
1033 - * Output the link to the user's favorites page (profile page).
1019 + * Output the link to the user's favorites page (profile page)
1034 1020 *
1035 1021 * @since 2.0.0 bbPress (r2660)
1036 1022 * @since 2.6.0 bbPress (r6308) Add pagination if in the loop
1037 1023 *
1038 - * @param int $user_id Optional. User id.
1024 + * @param int $user_id Optional. User id
1039 1025 */
1040 1026 function bbp_favorites_permalink( $user_id = 0 ) {
1041 1027 echo esc_url( bbp_get_favorites_permalink( $user_id ) );
1042 1028 }
1043 -
1044 -/**
1045 - * Return the link to the user's favorites page (profile page).
1046 - *
1047 - * @since 2.0.0 bbPress (r2660)
1048 - * @since 2.6.0 bbPress (r6308) Add pagination if in the loop
1049 - *
1050 - * @param int $user_id Optional. User id.
1051 - * @return string Permanent link to user profile page.
1052 - */
1029 + /**
1030 + * Return the link to the user's favorites page (profile page)
1031 + *
1032 + * @since 2.0.0 bbPress (r2660)
1033 + * @since 2.6.0 bbPress (r6308) Add pagination if in the loop
1034 + *
1035 + * @param int $user_id Optional. User id
1036 + * @return string Permanent link to user profile page
1037 + */
1053 1038 function bbp_get_favorites_permalink( $user_id = 0 ) {
1054 1039
1055 1040 // Use displayed user ID if there is one, and one isn't requested
1056 1041 $user_id = bbp_get_user_id( $user_id );
@@ -1104,42 +1089,41 @@
1104 1089 return apply_filters( 'bbp_get_favorites_permalink', $url, $user_id );
1105 1090 }
1106 1091
1107 1092 /**
1108 - * Output the link to make a topic favorite/remove a topic from favorites.
1093 + * Output the link to make a topic favorite/remove a topic from favorites
1109 1094 *
1110 1095 * @since 2.0.0 bbPress (r2652)
1111 1096 * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1112 1097 *
1113 - * @param array $args See {@link bbp_get_user_favorites_link()}.
1114 - * @param int $user_id Optional. User id.
1098 + * @param array $args See {@link bbp_get_user_favorites_link()}
1099 + * @param int $user_id Optional. User id
1115 1100 * @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">.
1116 1101 */
1117 1102 function bbp_user_favorites_link( $args = array(), $user_id = 0, $wrap = true ) {
1118 1103 echo bbp_get_user_favorites_link( $args, $user_id, $wrap );
1119 1104 }
1120 -
1121 -/**
1122 - * User favorites link.
1123 - *
1124 - * Return the link to make a topic favorite/remove a topic from
1125 - * favorites.
1126 - *
1127 - * @since 2.0.0 bbPress (r2652)
1128 - * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1129 - *
1130 - * @param array $args This function supports these arguments:
1131 - * - subscribe: Favorite text
1132 - * - unsubscribe: Unfavorite text
1133 - * - user_id: User id
1134 - * - topic_id: Topic id
1135 - * - before: Before the link
1136 - * - after: After the link
1137 - * @param int $user_id Optional. User id.
1138 - * @param int $topic_id Optional. Topic id.
1139 - * @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">. See ajax_favorite().
1140 - * @return string User favorites link.
1141 - */
1105 + /**
1106 + * User favorites link
1107 + *
1108 + * Return the link to make a topic favorite/remove a topic from
1109 + * favorites
1110 + *
1111 + * @since 2.0.0 bbPress (r2652)
1112 + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1113 + *
1114 + * @param array $args This function supports these arguments:
1115 + * - subscribe: Favorite text
1116 + * - unsubscribe: Unfavorite text
1117 + * - user_id: User id
1118 + * - topic_id: Topic id
1119 + * - before: Before the link
1120 + * - after: After the link
1121 + * @param int $user_id Optional. User id
1122 + * @param int $topic_id Optional. Topic id
1123 + * @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">. See ajax_favorite()
1124 + * @return string User favorites link
1125 + */
1142 1126 function bbp_get_user_favorites_link( $args = array(), $user_id = 0, $wrap = true ) {
1143 1127
1144 1128 // Bail if favorites are inactive
1145 1129 if ( ! bbp_is_favorites_active() ) {
@@ -1231,28 +1215,27 @@
1231 1215
1232 1216 /** Subscriptions *************************************************************/
1233 1217
1234 1218 /**
1235 - * Output the link to the user's subscriptions page (profile page).
1219 + * Output the link to the user's subscriptions page (profile page)
1236 1220 *
1237 1221 * @since 2.0.0 bbPress (r2688)
1238 1222 * @since 2.6.0 bbPress (r6308) Add pagination if in the loop
1239 1223 *
1240 - * @param int $user_id Optional. User id.
1224 + * @param int $user_id Optional. User id
1241 1225 */
1242 1226 function bbp_subscriptions_permalink( $user_id = 0 ) {
1243 1227 echo esc_url( bbp_get_subscriptions_permalink( $user_id ) );
1244 1228 }
1245 -
1246 -/**
1247 - * Return the link to the user's subscriptions page (profile page).
1248 - *
1249 - * @since 2.0.0 bbPress (r2688)
1250 - * @since 2.6.0 bbPress (r6308) Add pagination if in the loop
1251 - *
1252 - * @param int $user_id Optional. User id.
1253 - * @return string Permanent link to user subscriptions page.
1254 - */
1229 + /**
1230 + * Return the link to the user's subscriptions page (profile page)
1231 + *
1232 + * @since 2.0.0 bbPress (r2688)
1233 + * @since 2.6.0 bbPress (r6308) Add pagination if in the loop
1234 + *
1235 + * @param int $user_id Optional. User id
1236 + * @return string Permanent link to user subscriptions page
1237 + */
1255 1238 function bbp_get_subscriptions_permalink( $user_id = 0 ) {
1256 1239
1257 1240 // Use displayed user ID if there is one, and one isn't requested
1258 1241 $user_id = bbp_get_user_id( $user_id );
@@ -1316,39 +1299,38 @@
1316 1299 return apply_filters( 'bbp_get_subscriptions_permalink', $url, $user_id );
1317 1300 }
1318 1301
1319 1302 /**
1320 - * Output the link to subscribe/unsubscribe from a topic.
1303 + * Output the link to subscribe/unsubscribe from a topic
1321 1304 *
1322 1305 * @since 2.0.0 bbPress (r2668)
1323 1306 * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1324 1307 *
1325 - * @param array $args See {@link bbp_get_user_subscribe_link()}.
1326 - * @param int $user_id Optional. User id.
1308 + * @param array $args See {@link bbp_get_user_subscribe_link()}
1309 + * @param int $user_id Optional. User id
1327 1310 * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">.
1328 1311 */
1329 1312 function bbp_user_subscribe_link( $args = array(), $user_id = 0, $wrap = true ) {
1330 1313 echo bbp_get_user_subscribe_link( $args, $user_id, $wrap );
1331 1314 }
1332 -
1333 -/**
1334 - * Return the link to subscribe/unsubscribe from a forum or topic.
1335 - *
1336 - * @since 2.0.0 bbPress (r2668)
1337 - * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1338 - *
1339 - * @param array $args This function supports these arguments:
1340 - * - subscribe: Subscribe text
1341 - * - unsubscribe: Unsubscribe text
1342 - * - user_id: User id
1343 - * - topic_id: Topic id
1344 - * - forum_id: Forum id
1345 - * - before: Before the link
1346 - * - after: After the link
1347 - * @param int $user_id Optional. User id.
1348 - * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">.
1349 - * @return string Permanent link to topic.
1350 - */
1315 + /**
1316 + * Return the link to subscribe/unsubscribe from a forum or topic
1317 + *
1318 + * @since 2.0.0 bbPress (r2668)
1319 + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1320 + *
1321 + * @param array $args This function supports these arguments:
1322 + * - subscribe: Subscribe text
1323 + * - unsubscribe: Unsubscribe text
1324 + * - user_id: User id
1325 + * - topic_id: Topic id
1326 + * - forum_id: Forum id
1327 + * - before: Before the link
1328 + * - after: After the link
1329 + * @param int $user_id Optional. User id
1330 + * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">.
1331 + * @return string Permanent link to topic
1332 + */
1351 1333 function bbp_get_user_subscribe_link( $args = array(), $user_id = 0, $wrap = true ) {
1352 1334
1353 1335 // Bail if subscriptions are inactive
1354 1336 if ( ! bbp_is_subscriptions_active() ) {
@@ -1442,9 +1424,9 @@
1442 1424
1443 1425 /** Edit User *****************************************************************/
1444 1426
1445 1427 /**
1446 - * Display profile edit success notice on user edit page.
1428 + * Display profile edit success notice on user edit page
1447 1429 *
1448 1430 * @since 2.0.0 bbPress (r2688)
1449 1431 */
1450 1432 function bbp_notice_edit_user_success() {
@@ -1468,9 +1450,9 @@
1468 1450 <?php
1469 1451 }
1470 1452
1471 1453 /**
1472 - * Display pending email change notice on user edit page.
1454 + * Display pending email change notice on user edit page
1473 1455 *
1474 1456 * @since 2.6.0 bbPress (r5661)
1475 1457 */
1476 1458 function bbp_notice_edit_user_pending_email() {
@@ -1504,16 +1486,14 @@
1504 1486 $coded_email = '<code>' . esc_html( $new_email['newemail'] ) . '</code>'; ?>
1505 1487
1506 1488 <div class="bbp-template-notice info">
1507 1489 <ul>
1508 - <li>
1509 - <?php
1510 - printf(
1490 + <li><?php printf(
1511 1491 /* translators: 1: New email address, 2: Dismiss change link */
1512 - esc_html__( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ),
1513 - $coded_email,
1514 - $dismiss_link
1515 - );
1492 + esc_html__( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ),
1493 + $coded_email,
1494 + $dismiss_link
1495 + );
1516 1496 ?></li>
1517 1497 </ul>
1518 1498 </div>
1519 1499
@@ -1520,9 +1500,9 @@
1520 1500 <?php
1521 1501 }
1522 1502
1523 1503 /**
1524 - * Super admin privileges notice.
1504 + * Super admin privileges notice
1525 1505 *
1526 1506 * @since 2.0.0 bbPress (r2688)
1527 1507 */
1528 1508 function bbp_notice_edit_user_is_super_admin() {
@@ -1537,9 +1517,9 @@
1537 1517 <?php endif;
1538 1518 }
1539 1519
1540 1520 /**
1541 - * Drop down for selecting the user's display name.
1521 + * Drop down for selecting the user's display name
1542 1522 *
1543 1523 * @since 2.0.0 bbPress (r2688)
1544 1524 */
1545 1525 function bbp_edit_user_display_name() {
@@ -1585,9 +1565,9 @@
1585 1565 <?php
1586 1566 }
1587 1567
1588 1568 /**
1589 - * Output blog role selector (for user edit).
1569 + * Output blog role selector (for user edit)
1590 1570 *
1591 1571 * @since 2.2.0 bbPress (r4288)
1592 1572 */
1593 1573 function bbp_edit_user_blog_role() {
@@ -1617,9 +1597,9 @@
1617 1597 <?php
1618 1598 }
1619 1599
1620 1600 /**
1621 - * Output forum role selector (for user edit).
1601 + * Output forum role selector (for user edit)
1622 1602 *
1623 1603 * @since 2.2.0 bbPress (r4288)
1624 1604 */
1625 1605 function bbp_edit_user_forums_role() {
@@ -1651,9 +1631,9 @@
1651 1631
1652 1632 /**
1653 1633 * Filter whether password fields are displayed on a bbPress user profile.
1654 1634 *
1655 - * @since 2.6.17 bbPress (r7513)
1635 + * @since 2.6.17 bbPress (r7514)
1656 1636 *
1657 1637 * @param bool $show Whether to show the password fields.
1658 1638 * @param WP_User $profile_user User being edited.
1659 1639 * @return bool Whether to show the password fields.
@@ -1666,13 +1646,12 @@
1666 1646 return $show;
1667 1647 }
1668 1648
1669 1649 /**
1670 - * Return user contact methods select box.
1650 + * Return user contact methods select box
1671 1651 *
1672 1652 * @since 2.0.0 bbPress (r2688)
1673 - *
1674 - * @return string User contact methods.
1653 + * @return string User contact methods
1675 1654 */
1676 1655 function bbp_edit_user_contact_methods() {
1677 1656
1678 1657 // Get the core WordPress contact methods
@@ -1682,13 +1661,13 @@
1682 1661 return (array) apply_filters( 'bbp_edit_user_contact_methods', $contact_methods );
1683 1662 }
1684 1663
1685 1664 /**
1686 - * Output the language chooser (for user edit).
1665 + * Output the language chooser (for user edit)
1687 1666 *
1688 1667 * @since 2.6.0 bbPress (r6489)
1689 1668 *
1690 - * @param array $args See wp_dropdown_languages().
1669 + * @param array $args See wp_dropdown_languages()
1691 1670 * @return string
1692 1671 */
1693 1672 function bbp_edit_user_language( $args = array() ) {
1694 1673
@@ -1708,35 +1687,35 @@
1708 1687 *
1709 1688 * Used to avoid cross-site request forgeries when checking posted user profile
1710 1689 * form content.
1711 1690 *
1712 - * @since 2.6.15 bbPress (r7399)
1691 + * @since 2.6.15 bbPress (r7398)
1713 1692 *
1714 - * @param int $user_id User id.
1693 + * @param int $user_id
1715 1694 *
1716 - * @return bool True if this is a user profile post request with valid nonce.
1695 + * @return bool True if this is a user profile post request with valid nonce
1717 1696 */
1718 1697 function bbp_is_user_profile_form_post_request( $user_id = 0 ) {
1719 1698
1720 - // Bail if no user ID was passed.
1699 + // Bail if no user ID was passed
1721 1700 if ( empty( $user_id ) ) {
1722 1701 return false;
1723 1702 }
1724 1703
1725 - // Bail if not a post request.
1704 + // Bail if not a post request
1726 1705 if ( ! bbp_is_post_request() ) {
1727 1706 return false;
1728 1707 }
1729 1708
1730 - // Build the nonce action string.
1709 + // Build the nonce action string
1731 1710 $action = 'update-user_' . $user_id;
1732 1711
1733 - // User role updates rely on the user profile nonce.
1712 + // Editing an existing user
1734 1713 if ( bbp_verify_nonce_request( $action ) ) {
1735 1714 return true;
1736 1715 }
1737 1716
1738 - // Fallback for admin profile requests where URL validation can vary.
1717 + // Nonce fallback for admin profile requests where URL validation can vary
1739 1718 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], $action ) ) {
1740 1719 return true;
1741 1720 }
1742 1721
@@ -1745,26 +1724,25 @@
1745 1724
1746 1725 /** Topics Created ************************************************************/
1747 1726
1748 1727 /**
1749 - * Output the link to the user's topics.
1728 + * Output the link to the user's topics
1750 1729 *
1751 1730 * @since 2.2.0 bbPress (r4228)
1752 1731 *
1753 - * @param int $user_id Optional. User id.
1732 + * @param int $user_id Optional. User id
1754 1733 */
1755 1734 function bbp_user_topics_created_url( $user_id = 0 ) {
1756 1735 echo esc_url( bbp_get_user_topics_created_url( $user_id ) );
1757 1736 }
1758 -
1759 -/**
1760 - * Return the link to the user's topics.
1761 - *
1762 - * @since 2.2.0 bbPress (r4228)
1763 - *
1764 - * @param int $user_id Optional. User id.
1765 - * @return string Permanent link to user profile page.
1766 - */
1737 + /**
1738 + * Return the link to the user's topics
1739 + *
1740 + * @since 2.2.0 bbPress (r4228)
1741 + *
1742 + * @param int $user_id Optional. User id
1743 + * @return string Permanent link to user profile page
1744 + */
1767 1745 function bbp_get_user_topics_created_url( $user_id = 0 ) {
1768 1746
1769 1747 // Use displayed user ID if there is one, and one isn't requested
1770 1748 $user_id = bbp_get_user_id( $user_id );
@@ -1802,26 +1780,25 @@
1802 1780
1803 1781 /** Replies Created ************************************************************/
1804 1782
1805 1783 /**
1806 - * Output the link to the user's replies.
1784 + * Output the link to the user's replies
1807 1785 *
1808 1786 * @since 2.2.0 bbPress (r4228)
1809 1787 *
1810 - * @param int $user_id Optional. User id.
1788 + * @param int $user_id Optional. User id
1811 1789 */
1812 1790 function bbp_user_replies_created_url( $user_id = 0 ) {
1813 1791 echo esc_url( bbp_get_user_replies_created_url( $user_id ) );
1814 1792 }
1815 -
1816 -/**
1817 - * Return the link to the user's replies.
1818 - *
1819 - * @since 2.2.0 bbPress (r4228)
1820 - *
1821 - * @param int $user_id Optional. User id.
1822 - * @return string Permanent link to user profile page.
1823 - */
1793 + /**
1794 + * Return the link to the user's replies
1795 + *
1796 + * @since 2.2.0 bbPress (r4228)
1797 + *
1798 + * @param int $user_id Optional. User id
1799 + * @return string Permanent link to user profile page
1800 + */
1824 1801 function bbp_get_user_replies_created_url( $user_id = 0 ) {
1825 1802
1826 1803 // Use displayed user ID if there is one, and one isn't requested
1827 1804 $user_id = bbp_get_user_id( $user_id );
@@ -1859,26 +1836,25 @@
1859 1836
1860 1837 /** Engagements ***************************************************************/
1861 1838
1862 1839 /**
1863 - * Output the link to the user's engagements.
1840 + * Output the link to the user's engagements
1864 1841 *
1865 1842 * @since 2.6.0 bbPress (r6320)
1866 1843 *
1867 - * @param int $user_id Optional. User id.
1844 + * @param int $user_id Optional. User id
1868 1845 */
1869 1846 function bbp_user_engagements_url( $user_id = 0 ) {
1870 1847 echo esc_url( bbp_get_user_engagements_url( $user_id ) );
1871 1848 }
1872 -
1873 -/**
1874 - * Return the link to the user's engagements.
1875 - *
1876 - * @since 2.6.0 bbPress (r6320)
1877 - *
1878 - * @param int $user_id Optional. User id.
1879 - * @return string Permanent link to user profile page.
1880 - */
1849 + /**
1850 + * Return the link to the user's engagements
1851 + *
1852 + * @since 2.6.0 bbPress (r6320)
1853 + *
1854 + * @param int $user_id Optional. User id
1855 + * @return string Permanent link to user profile page
1856 + */
1881 1857 function bbp_get_user_engagements_url( $user_id = 0 ) {
1882 1858
1883 1859 // Use displayed user ID if there is one, and one isn't requested
1884 1860 $user_id = bbp_get_user_id( $user_id );
@@ -1916,26 +1892,26 @@
1916 1892
1917 1893 /** Language ******************************************************************/
1918 1894
1919 1895 /**
1920 - * Output the select element used to save a user's language.
1896 + * Output the select element used to save a user's language
1921 1897 *
1922 1898 * @since 2.6.0 bbPress (r6489)
1923 1899 *
1924 - * @param array $args See wp_dropdown_languages().
1900 + * @param array $args See wp_dropdown_languages()
1925 1901 */
1926 1902 function bbp_user_languages_dropdown( $args = array() ) {
1927 1903 echo bbp_get_user_languages_dropdown( $args );
1928 1904 }
1929 1905
1930 -/**
1931 - * Return the select element used to save a user's language.
1932 - *
1933 - * @since 2.6.0 bbPress (r6489)
1934 - *
1935 - * @param array $args See wp_dropdown_languages().
1936 - * @return string
1937 - */
1906 + /**
1907 + * Return the select element used to save a user's language.
1908 + *
1909 + * @since 2.6.0 bbPress (r6489)
1910 + *
1911 + * @param array $args See wp_dropdown_languages()
1912 + * @return string
1913 + */
1938 1914 function bbp_get_user_languages_dropdown( $args = array() ) {
1939 1915
1940 1916 // Get user language
1941 1917 $user_id = ! empty( $args['user_id'] )
@@ -1986,9 +1962,9 @@
1986 1962
1987 1963 /** Login *********************************************************************/
1988 1964
1989 1965 /**
1990 - * Handle the login and registration template notices.
1966 + * Handle the login and registration template notices
1991 1967 *
1992 1968 * @since 2.0.0 bbPress (r2970)
1993 1969 */
1994 1970 function bbp_login_notices() {
@@ -2031,9 +2007,9 @@
2031 2007 * where the user should never have access to the contents of that file.
2032 2008 *
2033 2009 * @since 2.0.0 bbPress (r2815)
2034 2010 *
2035 - * @param string $url The URL to redirect to.
2011 + * @param string $url The URL to redirect to
2036 2012 */
2037 2013 function bbp_logged_in_redirect( $url = '' ) {
2038 2014
2039 2015 // Bail if user is not logged in
@@ -2048,9 +2024,9 @@
2048 2024 bbp_redirect( $redirect_to );
2049 2025 }
2050 2026
2051 2027 /**
2052 - * Output the required hidden fields when logging in.
2028 + * Output the required hidden fields when logging in
2053 2029 *
2054 2030 * @since 2.0.0 bbPress (r2815)
2055 2031 */
2056 2032 function bbp_user_login_fields() {
@@ -2070,9 +2046,9 @@
2070 2046
2071 2047 /** Register ******************************************************************/
2072 2048
2073 2049 /**
2074 - * Output the required hidden fields when registering.
2050 + * Output the required hidden fields when registering
2075 2051 *
2076 2052 * @since 2.0.0 bbPress (r2815)
2077 2053 */
2078 2054 function bbp_user_register_fields() {
@@ -2093,9 +2069,9 @@
2093 2069
2094 2070 /** Lost Password *************************************************************/
2095 2071
2096 2072 /**
2097 - * Output the required hidden fields when user lost password.
2073 + * Output the required hidden fields when user lost password
2098 2074 *
2099 2075 * @since 2.0.0 bbPress (r2815)
2100 2076 */
2101 2077 function bbp_user_lost_pass_fields() {
@@ -2115,9 +2091,9 @@
2115 2091
2116 2092 /** Author Avatar *************************************************************/
2117 2093
2118 2094 /**
2119 - * Output the author link of a post.
2095 + * Output the author link of a post
2120 2096 *
2121 2097 * @since 2.0.0 bbPress (r2874)
2122 2098 *
2123 2099 * @param array $args Optional. If it is an integer, it is used as post id.
@@ -2124,17 +2100,16 @@
2124 2100 */
2125 2101 function bbp_author_link( $args = array() ) {
2126 2102 echo bbp_get_author_link( $args );
2127 2103 }
2128 -
2129 -/**
2130 - * Return the author link of the post.
2131 - *
2132 - * @since 2.0.0 bbPress (r2874)
2133 - *
2134 - * @param array $args Optional. If an integer, it is used as reply id.
2135 - * @return string Author link of reply.
2136 - */
2104 + /**
2105 + * Return the author link of the post
2106 + *
2107 + * @since 2.0.0 bbPress (r2874)
2108 + *
2109 + * @param array $args Optional. If an integer, it is used as reply id.
2110 + * @return string Author link of reply
2111 + */
2137 2112 function bbp_get_author_link( $args = array() ) {
2138 2113
2139 2114 $post_id = is_numeric( $args ) ? (int) $args : 0;
2140 2115
@@ -2205,9 +2180,9 @@
2205 2180 }
2206 2181
2207 2182 // Empty array
2208 2183 $links = array();
2209 - $sprint = '<span%1$s>%2$s</span>';
2184 + $sprint = '<span %1$s>%2$s</span>';
2210 2185
2211 2186 // Wrap each link
2212 2187 foreach ( $author_links as $link => $link_text ) {
2213 2188 $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"';
@@ -2236,12 +2211,12 @@
2236 2211
2237 2212 /** Capabilities **************************************************************/
2238 2213
2239 2214 /**
2240 - * Check if the user can access a specific forum.
2215 + * Check if the user can access a specific forum
2241 2216 *
2242 2217 * @since 2.0.0 bbPress (r3057)
2243 - * @since 2.6.19 bbPress (r7675) Check forum ancestors by default.
2218 + * @since 2.6.19 bbPress (r7676) Check forum ancestors by default.
2244 2219 *
2245 2220 * @return bool
2246 2221 */
2247 2222 function bbp_user_can_view_forum( $args = array() ) {
@@ -2283,9 +2258,9 @@
2283 2258 return apply_filters( 'bbp_user_can_view_forum', $retval, $forum_id, $user_id );
2284 2259 }
2285 2260
2286 2261 /**
2287 - * Check if the current user can publish topics.
2262 + * Check if the current user can publish topics
2288 2263 *
2289 2264 * @since 2.0.0 bbPress (r3366)
2290 2265 *
2291 2266 * @return bool
@@ -2312,9 +2287,9 @@
2312 2287 return (bool) apply_filters( 'bbp_current_user_can_publish_topics', $retval );
2313 2288 }
2314 2289
2315 2290 /**
2316 - * Check if the current user can publish forums.
2291 + * Check if the current user can publish forums
2317 2292 *
2318 2293 * @since 2.1.0 bbPress (r3549)
2319 2294 *
2320 2295 * @return bool
@@ -2337,9 +2312,9 @@
2337 2312 return (bool) apply_filters( 'bbp_current_user_can_publish_forums', $retval );
2338 2313 }
2339 2314
2340 2315 /**
2341 - * Check if the current user can publish replies.
2316 + * Check if the current user can publish replies
2342 2317 *
2343 2318 * @since 2.0.0 bbPress (r3366)
2344 2319 *
2345 2320 * @return bool
@@ -2374,9 +2349,9 @@
2374 2349 * checks from within template parts.
2375 2350 */
2376 2351
2377 2352 /**
2378 - * Get the forums the current user has the ability to see and post to.
2353 + * Get the forums the current user has the ability to see and post to
2379 2354 *
2380 2355 * @since 2.0.0 bbPress (r3127)
2381 2356 *
2382 2357 * @param array $args
@@ -2425,9 +2400,9 @@
2425 2400 if ( bbp_is_user_keymaster() ) {
2426 2401 $retval = true;
2427 2402
2428 2403 // Looking at a single forum & forum is open
2429 - } elseif ( is_singular() && bbp_is_forum_open() ) {
2404 + } elseif ( ( is_page() || is_single() ) && bbp_is_forum_open() ) {
2430 2405 $retval = bbp_current_user_can_publish_forums();
2431 2406
2432 2407 // User can edit this forum
2433 2408 } else {
@@ -2454,9 +2429,9 @@
2454 2429 if ( bbp_is_user_keymaster() ) {
2455 2430 $retval = true;
2456 2431
2457 2432 // Looking at a single forum & forum is open
2458 - } elseif ( ( bbp_is_single_forum() || is_singular() ) && bbp_is_forum_open() ) {
2433 + } elseif ( ( bbp_is_single_forum() || is_page() || is_single() ) && bbp_is_forum_open() ) {
2459 2434 $retval = bbp_current_user_can_publish_topics();
2460 2435
2461 2436 // User can edit this topic
2462 2437 } else {
@@ -2505,9 +2480,9 @@
2505 2480 *
2506 2481 * This covers topic merges, topic splits, and reply moves. Their handlers
2507 2482 * perform the same capability checks independently when processing a request.
2508 2483 *
2509 - * @since 2.6.19 bbPress (r7617)
2484 + * @since 2.6.19 bbPress (r7618)
2510 2485 *
2511 2486 * @param int $topic_id Optional. Topic ID.
2512 2487 * @return bool True if the current user can moderate and edit the topic.
2513 2488 */
@@ -2553,32 +2528,32 @@
2553 2528
2554 2529 /** Moderators ****************************************************************/
2555 2530
2556 2531 /**
2557 - * Output the moderators of a forum.
2532 + * Output the moderators of a forum
2558 2533 *
2559 2534 * @since 2.6.0 bbPress (r6056)
2560 2535 *
2561 - * @param int $forum_id Optional. Topic id.
2562 - * @param array $args See {@link bbp_get_moderator_list()}.
2536 + * @param int $forum_id Optional. Topic id
2537 + * @param array $args See {@link bbp_get_moderator_list()}
2563 2538 */
2564 2539 function bbp_moderator_list( $forum_id = 0, $args = array() ) {
2565 2540 echo bbp_get_moderator_list( $forum_id, $args );
2566 2541 }
2567 2542
2568 -/**
2569 - * Return the moderators for an object.
2570 - *
2571 - * @since 2.6.0 bbPress (r6056)
2572 - *
2573 - * @param int $object_id Optional. Object id.
2574 - * @param array $args This function supports these arguments:
2575 - * - before: Before the tag list
2576 - * - sep: Tag separator
2577 - * - after: After the tag list
2578 - *
2579 - * @return string Moderator list of the object.
2580 - */
2543 + /**
2544 + * Return the moderators for an object
2545 + *
2546 + * @since 2.6.0 bbPress (r6056)
2547 + *
2548 + * @param int $object_id Optional. Object id
2549 + * @param array $args This function supports these arguments:
2550 + * - before: Before the tag list
2551 + * - sep: Tag separator
2552 + * - after: After the tag list
2553 + *
2554 + * @return string Moderator list of the object
2555 + */
2581 2556 function bbp_get_moderator_list( $object_id = 0, $args = array() ) {
2582 2557
2583 2558 // Parse arguments against default values
2584 2559 $r = bbp_parse_args(