| @@ -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 (r6330) |
| 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 (r6330) |
| 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 (r2464) |
| 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 (r2464) |
| 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.0.0 bbPress (r2688) |
| 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 (r4671) |
| 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 (r4671) | |
| 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 (r4671) | |
| 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 (r6561) |
| 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 (r5119) |
| 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 (r5119) | |
| 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 (r5119) | |
| 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 (r5119) |
| 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 (r5119) | |
| 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 (r5119) | |
| 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 (r5119) |
| 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 (r5119) | |
| 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 (r5119) | |
| 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 (r2652) |
| 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 (r2652) | |
| 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 (r2652) | |
| 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 (r6308) 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 (r6308) 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 (r6308) 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() ) { |
| @@ -1226,28 +1210,27 @@ | ||
| 1226 | 1210 | |
| 1227 | 1211 | /** Subscriptions *************************************************************/ |
| 1228 | 1212 | |
| 1229 | 1213 | /** |
| 1230 | - * Output the link to the user's subscriptions page (profile page). | |
| 1214 | + * Output the link to the user's subscriptions page (profile page) | |
| 1231 | 1215 | * |
| 1232 | 1216 | * @since 2.0.0 bbPress (r2688) |
| 1233 | 1217 | * @since 2.6.0 bbPress (r6308) Add pagination if in the loop |
| 1234 | 1218 | * |
| 1235 | - * @param int $user_id Optional. User id. | |
| 1219 | + * @param int $user_id Optional. User id | |
| 1236 | 1220 | */ |
| 1237 | 1221 | function bbp_subscriptions_permalink( $user_id = 0 ) { |
| 1238 | 1222 | echo esc_url( bbp_get_subscriptions_permalink( $user_id ) ); |
| 1239 | 1223 | } |
| 1240 | - | |
| 1241 | -/** | |
| 1242 | - * Return the link to the user's subscriptions page (profile page). | |
| 1243 | - * | |
| 1244 | - * @since 2.0.0 bbPress (r2688) | |
| 1245 | - * @since 2.6.0 bbPress (r6308) Add pagination if in the loop | |
| 1246 | - * | |
| 1247 | - * @param int $user_id Optional. User id. | |
| 1248 | - * @return string Permanent link to user subscriptions page. | |
| 1249 | - */ | |
| 1224 | + /** | |
| 1225 | + * Return the link to the user's subscriptions page (profile page) | |
| 1226 | + * | |
| 1227 | + * @since 2.0.0 bbPress (r2688) | |
| 1228 | + * @since 2.6.0 bbPress (r6308) Add pagination if in the loop | |
| 1229 | + * | |
| 1230 | + * @param int $user_id Optional. User id | |
| 1231 | + * @return string Permanent link to user subscriptions page | |
| 1232 | + */ | |
| 1250 | 1233 | function bbp_get_subscriptions_permalink( $user_id = 0 ) { |
| 1251 | 1234 | |
| 1252 | 1235 | // Use displayed user ID if there is one, and one isn't requested |
| 1253 | 1236 | $user_id = bbp_get_user_id( $user_id ); |
| @@ -1311,39 +1294,38 @@ | ||
| 1311 | 1294 | return apply_filters( 'bbp_get_subscriptions_permalink', $url, $user_id ); |
| 1312 | 1295 | } |
| 1313 | 1296 | |
| 1314 | 1297 | /** |
| 1315 | - * Output the link to subscribe/unsubscribe from a topic. | |
| 1298 | + * Output the link to subscribe/unsubscribe from a topic | |
| 1316 | 1299 | * |
| 1317 | 1300 | * @since 2.0.0 bbPress (r2668) |
| 1318 | 1301 | * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support |
| 1319 | 1302 | * |
| 1320 | - * @param array $args See {@link bbp_get_user_subscribe_link()}. | |
| 1321 | - * @param int $user_id Optional. User id. | |
| 1303 | + * @param array $args See {@link bbp_get_user_subscribe_link()} | |
| 1304 | + * @param int $user_id Optional. User id | |
| 1322 | 1305 | * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">. |
| 1323 | 1306 | */ |
| 1324 | 1307 | function bbp_user_subscribe_link( $args = array(), $user_id = 0, $wrap = true ) { |
| 1325 | 1308 | echo bbp_get_user_subscribe_link( $args, $user_id, $wrap ); |
| 1326 | 1309 | } |
| 1327 | - | |
| 1328 | -/** | |
| 1329 | - * Return the link to subscribe/unsubscribe from a forum or topic. | |
| 1330 | - * | |
| 1331 | - * @since 2.0.0 bbPress (r2668) | |
| 1332 | - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support | |
| 1333 | - * | |
| 1334 | - * @param array $args This function supports these arguments: | |
| 1335 | - * - subscribe: Subscribe text | |
| 1336 | - * - unsubscribe: Unsubscribe text | |
| 1337 | - * - user_id: User id | |
| 1338 | - * - topic_id: Topic id | |
| 1339 | - * - forum_id: Forum id | |
| 1340 | - * - before: Before the link | |
| 1341 | - * - after: After the link | |
| 1342 | - * @param int $user_id Optional. User id. | |
| 1343 | - * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">. | |
| 1344 | - * @return string Permanent link to topic. | |
| 1345 | - */ | |
| 1310 | + /** | |
| 1311 | + * Return the link to subscribe/unsubscribe from a forum or topic | |
| 1312 | + * | |
| 1313 | + * @since 2.0.0 bbPress (r2668) | |
| 1314 | + * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support | |
| 1315 | + * | |
| 1316 | + * @param array $args This function supports these arguments: | |
| 1317 | + * - subscribe: Subscribe text | |
| 1318 | + * - unsubscribe: Unsubscribe text | |
| 1319 | + * - user_id: User id | |
| 1320 | + * - topic_id: Topic id | |
| 1321 | + * - forum_id: Forum id | |
| 1322 | + * - before: Before the link | |
| 1323 | + * - after: After the link | |
| 1324 | + * @param int $user_id Optional. User id | |
| 1325 | + * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">. | |
| 1326 | + * @return string Permanent link to topic | |
| 1327 | + */ | |
| 1346 | 1328 | function bbp_get_user_subscribe_link( $args = array(), $user_id = 0, $wrap = true ) { |
| 1347 | 1329 | |
| 1348 | 1330 | // Bail if subscriptions are inactive |
| 1349 | 1331 | if ( ! bbp_is_subscriptions_active() ) { |
| @@ -1432,9 +1414,9 @@ | ||
| 1432 | 1414 | |
| 1433 | 1415 | /** Edit User *****************************************************************/ |
| 1434 | 1416 | |
| 1435 | 1417 | /** |
| 1436 | - * Display profile edit success notice on user edit page. | |
| 1418 | + * Display profile edit success notice on user edit page | |
| 1437 | 1419 | * |
| 1438 | 1420 | * @since 2.0.0 bbPress (r2688) |
| 1439 | 1421 | */ |
| 1440 | 1422 | function bbp_notice_edit_user_success() { |
| @@ -1458,9 +1440,9 @@ | ||
| 1458 | 1440 | <?php |
| 1459 | 1441 | } |
| 1460 | 1442 | |
| 1461 | 1443 | /** |
| 1462 | - * Display pending email change notice on user edit page. | |
| 1444 | + * Display pending email change notice on user edit page | |
| 1463 | 1445 | * |
| 1464 | 1446 | * @since 2.6.0 bbPress (r5660) |
| 1465 | 1447 | */ |
| 1466 | 1448 | function bbp_notice_edit_user_pending_email() { |
| @@ -1494,16 +1476,14 @@ | ||
| 1494 | 1476 | $coded_email = '<code>' . esc_html( $new_email['newemail'] ) . '</code>'; ?> |
| 1495 | 1477 | |
| 1496 | 1478 | <div class="bbp-template-notice info"> |
| 1497 | 1479 | <ul> |
| 1498 | - <li> | |
| 1499 | - <?php | |
| 1500 | - printf( | |
| 1480 | + <li><?php printf( | |
| 1501 | 1481 | /* translators: 1: New email address, 2: Dismiss change link */ |
| 1502 | - esc_html__( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ), | |
| 1503 | - $coded_email, | |
| 1504 | - $dismiss_link | |
| 1505 | - ); | |
| 1482 | + esc_html__( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ), | |
| 1483 | + $coded_email, | |
| 1484 | + $dismiss_link | |
| 1485 | + ); | |
| 1506 | 1486 | ?></li> |
| 1507 | 1487 | </ul> |
| 1508 | 1488 | </div> |
| 1509 | 1489 | |
| @@ -1510,9 +1490,9 @@ | ||
| 1510 | 1490 | <?php |
| 1511 | 1491 | } |
| 1512 | 1492 | |
| 1513 | 1493 | /** |
| 1514 | - * Super admin privileges notice. | |
| 1494 | + * Super admin privileges notice | |
| 1515 | 1495 | * |
| 1516 | 1496 | * @since 2.0.0 bbPress (r2688) |
| 1517 | 1497 | */ |
| 1518 | 1498 | function bbp_notice_edit_user_is_super_admin() { |
| @@ -1527,9 +1507,9 @@ | ||
| 1527 | 1507 | <?php endif; |
| 1528 | 1508 | } |
| 1529 | 1509 | |
| 1530 | 1510 | /** |
| 1531 | - * Drop down for selecting the user's display name. | |
| 1511 | + * Drop down for selecting the user's display name | |
| 1532 | 1512 | * |
| 1533 | 1513 | * @since 2.0.0 bbPress (r2688) |
| 1534 | 1514 | */ |
| 1535 | 1515 | function bbp_edit_user_display_name() { |
| @@ -1575,9 +1555,9 @@ | ||
| 1575 | 1555 | <?php |
| 1576 | 1556 | } |
| 1577 | 1557 | |
| 1578 | 1558 | /** |
| 1579 | - * Output blog role selector (for user edit). | |
| 1559 | + * Output blog role selector (for user edit) | |
| 1580 | 1560 | * |
| 1581 | 1561 | * @since 2.0.0 bbPress (r2688) |
| 1582 | 1562 | */ |
| 1583 | 1563 | function bbp_edit_user_blog_role() { |
| @@ -1607,9 +1587,9 @@ | ||
| 1607 | 1587 | <?php |
| 1608 | 1588 | } |
| 1609 | 1589 | |
| 1610 | 1590 | /** |
| 1611 | - * Output forum role selector (for user edit). | |
| 1591 | + * Output forum role selector (for user edit) | |
| 1612 | 1592 | * |
| 1613 | 1593 | * @since 2.2.0 bbPress (r4284) |
| 1614 | 1594 | */ |
| 1615 | 1595 | function bbp_edit_user_forums_role() { |
| @@ -1656,13 +1636,12 @@ | ||
| 1656 | 1636 | return $show; |
| 1657 | 1637 | } |
| 1658 | 1638 | |
| 1659 | 1639 | /** |
| 1660 | - * Return user contact methods select box. | |
| 1640 | + * Return user contact methods select box | |
| 1661 | 1641 | * |
| 1662 | 1642 | * @since 2.0.0 bbPress (r2688) |
| 1663 | - * | |
| 1664 | - * @return string User contact methods. | |
| 1643 | + * @return string User contact methods | |
| 1665 | 1644 | */ |
| 1666 | 1645 | function bbp_edit_user_contact_methods() { |
| 1667 | 1646 | |
| 1668 | 1647 | // Get the core WordPress contact methods |
| @@ -1672,13 +1651,13 @@ | ||
| 1672 | 1651 | return (array) apply_filters( 'bbp_edit_user_contact_methods', $contact_methods ); |
| 1673 | 1652 | } |
| 1674 | 1653 | |
| 1675 | 1654 | /** |
| 1676 | - * Output the language chooser (for user edit). | |
| 1655 | + * Output the language chooser (for user edit) | |
| 1677 | 1656 | * |
| 1678 | 1657 | * @since 2.6.0 bbPress (r6488) |
| 1679 | 1658 | * |
| 1680 | - * @param array $args See wp_dropdown_languages(). | |
| 1659 | + * @param array $args See wp_dropdown_languages() | |
| 1681 | 1660 | * @return string |
| 1682 | 1661 | */ |
| 1683 | 1662 | function bbp_edit_user_language( $args = array() ) { |
| 1684 | 1663 | |
| @@ -1698,35 +1677,35 @@ | ||
| 1698 | 1677 | * |
| 1699 | 1678 | * Used to avoid cross-site request forgeries when checking posted user profile |
| 1700 | 1679 | * form content. |
| 1701 | 1680 | * |
| 1702 | - * @since 2.6.15 bbPress | |
| 1681 | + * @since 2.6.15 bbPress (r7397) | |
| 1703 | 1682 | * |
| 1704 | - * @param int $user_id User id. | |
| 1683 | + * @param int $user_id | |
| 1705 | 1684 | * |
| 1706 | - * @return bool True if this is a user profile post request with valid nonce. | |
| 1685 | + * @return bool True if this is a user profile post request with valid nonce | |
| 1707 | 1686 | */ |
| 1708 | 1687 | function bbp_is_user_profile_form_post_request( $user_id = 0 ) { |
| 1709 | 1688 | |
| 1710 | - // Bail if no user ID was passed. | |
| 1689 | + // Bail if no user ID was passed | |
| 1711 | 1690 | if ( empty( $user_id ) ) { |
| 1712 | 1691 | return false; |
| 1713 | 1692 | } |
| 1714 | 1693 | |
| 1715 | - // Bail if not a post request. | |
| 1694 | + // Bail if not a post request | |
| 1716 | 1695 | if ( ! bbp_is_post_request() ) { |
| 1717 | 1696 | return false; |
| 1718 | 1697 | } |
| 1719 | 1698 | |
| 1720 | - // Build the nonce action string. | |
| 1699 | + // Build the nonce action string | |
| 1721 | 1700 | $action = 'update-user_' . $user_id; |
| 1722 | 1701 | |
| 1723 | - // User role updates rely on the user profile nonce. | |
| 1702 | + // Editing an existing user | |
| 1724 | 1703 | if ( bbp_verify_nonce_request( $action ) ) { |
| 1725 | 1704 | return true; |
| 1726 | 1705 | } |
| 1727 | 1706 | |
| 1728 | - // Fallback for admin profile requests where URL validation can vary. | |
| 1707 | + // Nonce fallback for admin profile requests where URL validation can vary | |
| 1729 | 1708 | if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], $action ) ) { |
| 1730 | 1709 | return true; |
| 1731 | 1710 | } |
| 1732 | 1711 | |
| @@ -1735,26 +1714,25 @@ | ||
| 1735 | 1714 | |
| 1736 | 1715 | /** Topics Created ************************************************************/ |
| 1737 | 1716 | |
| 1738 | 1717 | /** |
| 1739 | - * Output the link to the user's topics. | |
| 1718 | + * Output the link to the user's topics | |
| 1740 | 1719 | * |
| 1741 | 1720 | * @since 2.2.0 bbPress (r4225) |
| 1742 | 1721 | * |
| 1743 | - * @param int $user_id Optional. User id. | |
| 1722 | + * @param int $user_id Optional. User id | |
| 1744 | 1723 | */ |
| 1745 | 1724 | function bbp_user_topics_created_url( $user_id = 0 ) { |
| 1746 | 1725 | echo esc_url( bbp_get_user_topics_created_url( $user_id ) ); |
| 1747 | 1726 | } |
| 1748 | - | |
| 1749 | -/** | |
| 1750 | - * Return the link to the user's topics. | |
| 1751 | - * | |
| 1752 | - * @since 2.2.0 bbPress (r4225) | |
| 1753 | - * | |
| 1754 | - * @param int $user_id Optional. User id. | |
| 1755 | - * @return string Permanent link to user profile page. | |
| 1756 | - */ | |
| 1727 | + /** | |
| 1728 | + * Return the link to the user's topics | |
| 1729 | + * | |
| 1730 | + * @since 2.2.0 bbPress (r4225) | |
| 1731 | + * | |
| 1732 | + * @param int $user_id Optional. User id | |
| 1733 | + * @return string Permanent link to user profile page | |
| 1734 | + */ | |
| 1757 | 1735 | function bbp_get_user_topics_created_url( $user_id = 0 ) { |
| 1758 | 1736 | |
| 1759 | 1737 | // Use displayed user ID if there is one, and one isn't requested |
| 1760 | 1738 | $user_id = bbp_get_user_id( $user_id ); |
| @@ -1792,26 +1770,25 @@ | ||
| 1792 | 1770 | |
| 1793 | 1771 | /** Replies Created ************************************************************/ |
| 1794 | 1772 | |
| 1795 | 1773 | /** |
| 1796 | - * Output the link to the user's replies. | |
| 1774 | + * Output the link to the user's replies | |
| 1797 | 1775 | * |
| 1798 | 1776 | * @since 2.2.0 bbPress (r4225) |
| 1799 | 1777 | * |
| 1800 | - * @param int $user_id Optional. User id. | |
| 1778 | + * @param int $user_id Optional. User id | |
| 1801 | 1779 | */ |
| 1802 | 1780 | function bbp_user_replies_created_url( $user_id = 0 ) { |
| 1803 | 1781 | echo esc_url( bbp_get_user_replies_created_url( $user_id ) ); |
| 1804 | 1782 | } |
| 1805 | - | |
| 1806 | -/** | |
| 1807 | - * Return the link to the user's replies. | |
| 1808 | - * | |
| 1809 | - * @since 2.2.0 bbPress (r4225) | |
| 1810 | - * | |
| 1811 | - * @param int $user_id Optional. User id. | |
| 1812 | - * @return string Permanent link to user profile page. | |
| 1813 | - */ | |
| 1783 | + /** | |
| 1784 | + * Return the link to the user's replies | |
| 1785 | + * | |
| 1786 | + * @since 2.2.0 bbPress (r4225) | |
| 1787 | + * | |
| 1788 | + * @param int $user_id Optional. User id | |
| 1789 | + * @return string Permanent link to user profile page | |
| 1790 | + */ | |
| 1814 | 1791 | function bbp_get_user_replies_created_url( $user_id = 0 ) { |
| 1815 | 1792 | |
| 1816 | 1793 | // Use displayed user ID if there is one, and one isn't requested |
| 1817 | 1794 | $user_id = bbp_get_user_id( $user_id ); |
| @@ -1849,26 +1826,25 @@ | ||
| 1849 | 1826 | |
| 1850 | 1827 | /** Engagements ***************************************************************/ |
| 1851 | 1828 | |
| 1852 | 1829 | /** |
| 1853 | - * Output the link to the user's engagements. | |
| 1830 | + * Output the link to the user's engagements | |
| 1854 | 1831 | * |
| 1855 | 1832 | * @since 2.6.0 bbPress (r6320) |
| 1856 | 1833 | * |
| 1857 | - * @param int $user_id Optional. User id. | |
| 1834 | + * @param int $user_id Optional. User id | |
| 1858 | 1835 | */ |
| 1859 | 1836 | function bbp_user_engagements_url( $user_id = 0 ) { |
| 1860 | 1837 | echo esc_url( bbp_get_user_engagements_url( $user_id ) ); |
| 1861 | 1838 | } |
| 1862 | - | |
| 1863 | -/** | |
| 1864 | - * Return the link to the user's engagements. | |
| 1865 | - * | |
| 1866 | - * @since 2.6.0 bbPress (r6320) | |
| 1867 | - * | |
| 1868 | - * @param int $user_id Optional. User id. | |
| 1869 | - * @return string Permanent link to user profile page. | |
| 1870 | - */ | |
| 1839 | + /** | |
| 1840 | + * Return the link to the user's engagements | |
| 1841 | + * | |
| 1842 | + * @since 2.6.0 bbPress (r6320) | |
| 1843 | + * | |
| 1844 | + * @param int $user_id Optional. User id | |
| 1845 | + * @return string Permanent link to user profile page | |
| 1846 | + */ | |
| 1871 | 1847 | function bbp_get_user_engagements_url( $user_id = 0 ) { |
| 1872 | 1848 | |
| 1873 | 1849 | // Use displayed user ID if there is one, and one isn't requested |
| 1874 | 1850 | $user_id = bbp_get_user_id( $user_id ); |
| @@ -1906,26 +1882,26 @@ | ||
| 1906 | 1882 | |
| 1907 | 1883 | /** Language ******************************************************************/ |
| 1908 | 1884 | |
| 1909 | 1885 | /** |
| 1910 | - * Output the select element used to save a user's language. | |
| 1886 | + * Output the select element used to save a user's language | |
| 1911 | 1887 | * |
| 1912 | 1888 | * @since 2.6.0 bbPress (r6488) |
| 1913 | 1889 | * |
| 1914 | - * @param array $args See wp_dropdown_languages(). | |
| 1890 | + * @param array $args See wp_dropdown_languages() | |
| 1915 | 1891 | */ |
| 1916 | 1892 | function bbp_user_languages_dropdown( $args = array() ) { |
| 1917 | 1893 | echo bbp_get_user_languages_dropdown( $args ); |
| 1918 | 1894 | } |
| 1919 | 1895 | |
| 1920 | -/** | |
| 1921 | - * Return the select element used to save a user's language. | |
| 1922 | - * | |
| 1923 | - * @since 2.6.0 bbPress (r6488) | |
| 1924 | - * | |
| 1925 | - * @param array $args See wp_dropdown_languages(). | |
| 1926 | - * @return string | |
| 1927 | - */ | |
| 1896 | + /** | |
| 1897 | + * Return the select element used to save a user's language. | |
| 1898 | + * | |
| 1899 | + * @since 2.6.0 bbPress (r6488) | |
| 1900 | + * | |
| 1901 | + * @param array $args See wp_dropdown_languages() | |
| 1902 | + * @return string | |
| 1903 | + */ | |
| 1928 | 1904 | function bbp_get_user_languages_dropdown( $args = array() ) { |
| 1929 | 1905 | |
| 1930 | 1906 | // Get user language |
| 1931 | 1907 | $user_id = ! empty( $args['user_id'] ) |
| @@ -1976,9 +1952,9 @@ | ||
| 1976 | 1952 | |
| 1977 | 1953 | /** Login *********************************************************************/ |
| 1978 | 1954 | |
| 1979 | 1955 | /** |
| 1980 | - * Handle the login and registration template notices. | |
| 1956 | + * Handle the login and registration template notices | |
| 1981 | 1957 | * |
| 1982 | 1958 | * @since 2.0.0 bbPress (r2970) |
| 1983 | 1959 | */ |
| 1984 | 1960 | function bbp_login_notices() { |
| @@ -2021,9 +1997,9 @@ | ||
| 2021 | 1997 | * where the user should never have access to the contents of that file. |
| 2022 | 1998 | * |
| 2023 | 1999 | * @since 2.0.0 bbPress (r2815) |
| 2024 | 2000 | * |
| 2025 | - * @param string $url The URL to redirect to. | |
| 2001 | + * @param string $url The URL to redirect to | |
| 2026 | 2002 | */ |
| 2027 | 2003 | function bbp_logged_in_redirect( $url = '' ) { |
| 2028 | 2004 | |
| 2029 | 2005 | // Bail if user is not logged in |
| @@ -2038,9 +2014,9 @@ | ||
| 2038 | 2014 | bbp_redirect( $redirect_to ); |
| 2039 | 2015 | } |
| 2040 | 2016 | |
| 2041 | 2017 | /** |
| 2042 | - * Output the required hidden fields when logging in. | |
| 2018 | + * Output the required hidden fields when logging in | |
| 2043 | 2019 | * |
| 2044 | 2020 | * @since 2.0.0 bbPress (r2815) |
| 2045 | 2021 | */ |
| 2046 | 2022 | function bbp_user_login_fields() { |
| @@ -2060,9 +2036,9 @@ | ||
| 2060 | 2036 | |
| 2061 | 2037 | /** Register ******************************************************************/ |
| 2062 | 2038 | |
| 2063 | 2039 | /** |
| 2064 | - * Output the required hidden fields when registering. | |
| 2040 | + * Output the required hidden fields when registering | |
| 2065 | 2041 | * |
| 2066 | 2042 | * @since 2.0.0 bbPress (r2815) |
| 2067 | 2043 | */ |
| 2068 | 2044 | function bbp_user_register_fields() { |
| @@ -2083,9 +2059,9 @@ | ||
| 2083 | 2059 | |
| 2084 | 2060 | /** Lost Password *************************************************************/ |
| 2085 | 2061 | |
| 2086 | 2062 | /** |
| 2087 | - * Output the required hidden fields when user lost password. | |
| 2063 | + * Output the required hidden fields when user lost password | |
| 2088 | 2064 | * |
| 2089 | 2065 | * @since 2.0.0 bbPress (r2815) |
| 2090 | 2066 | */ |
| 2091 | 2067 | function bbp_user_lost_pass_fields() { |
| @@ -2105,9 +2081,9 @@ | ||
| 2105 | 2081 | |
| 2106 | 2082 | /** Author Avatar *************************************************************/ |
| 2107 | 2083 | |
| 2108 | 2084 | /** |
| 2109 | - * Output the author link of a post. | |
| 2085 | + * Output the author link of a post | |
| 2110 | 2086 | * |
| 2111 | 2087 | * @since 2.0.0 bbPress (r2875) |
| 2112 | 2088 | * |
| 2113 | 2089 | * @param array $args Optional. If it is an integer, it is used as post id. |
| @@ -2114,17 +2090,16 @@ | ||
| 2114 | 2090 | */ |
| 2115 | 2091 | function bbp_author_link( $args = array() ) { |
| 2116 | 2092 | echo bbp_get_author_link( $args ); |
| 2117 | 2093 | } |
| 2118 | - | |
| 2119 | -/** | |
| 2120 | - * Return the author link of the post. | |
| 2121 | - * | |
| 2122 | - * @since 2.0.0 bbPress (r2875) | |
| 2123 | - * | |
| 2124 | - * @param array $args Optional. If an integer, it is used as reply id. | |
| 2125 | - * @return string Author link of reply. | |
| 2126 | - */ | |
| 2094 | + /** | |
| 2095 | + * Return the author link of the post | |
| 2096 | + * | |
| 2097 | + * @since 2.0.0 bbPress (r2875) | |
| 2098 | + * | |
| 2099 | + * @param array $args Optional. If an integer, it is used as reply id. | |
| 2100 | + * @return string Author link of reply | |
| 2101 | + */ | |
| 2127 | 2102 | function bbp_get_author_link( $args = array() ) { |
| 2128 | 2103 | |
| 2129 | 2104 | $post_id = is_numeric( $args ) ? (int) $args : 0; |
| 2130 | 2105 | |
| @@ -2190,9 +2165,9 @@ | ||
| 2190 | 2165 | } |
| 2191 | 2166 | |
| 2192 | 2167 | // Empty array |
| 2193 | 2168 | $links = array(); |
| 2194 | - $sprint = '<span%1$s>%2$s</span>'; | |
| 2169 | + $sprint = '<span %1$s>%2$s</span>'; | |
| 2195 | 2170 | |
| 2196 | 2171 | // Wrap each link |
| 2197 | 2172 | foreach ( $author_links as $link => $link_text ) { |
| 2198 | 2173 | $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"'; |
| @@ -2221,9 +2196,9 @@ | ||
| 2221 | 2196 | |
| 2222 | 2197 | /** Capabilities **************************************************************/ |
| 2223 | 2198 | |
| 2224 | 2199 | /** |
| 2225 | - * Check if the user can access a specific forum. | |
| 2200 | + * Check if the user can access a specific forum | |
| 2226 | 2201 | * |
| 2227 | 2202 | * @since 2.0.0 bbPress (r3127) |
| 2228 | 2203 | * |
| 2229 | 2204 | * @return bool |
| @@ -2267,9 +2242,9 @@ | ||
| 2267 | 2242 | return apply_filters( 'bbp_user_can_view_forum', $retval, $forum_id, $user_id ); |
| 2268 | 2243 | } |
| 2269 | 2244 | |
| 2270 | 2245 | /** |
| 2271 | - * Check if the current user can publish topics. | |
| 2246 | + * Check if the current user can publish topics | |
| 2272 | 2247 | * |
| 2273 | 2248 | * @since 2.0.0 bbPress (r3127) |
| 2274 | 2249 | * |
| 2275 | 2250 | * @return bool |
| @@ -2296,9 +2271,9 @@ | ||
| 2296 | 2271 | return (bool) apply_filters( 'bbp_current_user_can_publish_topics', $retval ); |
| 2297 | 2272 | } |
| 2298 | 2273 | |
| 2299 | 2274 | /** |
| 2300 | - * Check if the current user can publish forums. | |
| 2275 | + * Check if the current user can publish forums | |
| 2301 | 2276 | * |
| 2302 | 2277 | * @since 2.1.0 bbPress (r3549) |
| 2303 | 2278 | * |
| 2304 | 2279 | * @return bool |
| @@ -2321,9 +2296,9 @@ | ||
| 2321 | 2296 | return (bool) apply_filters( 'bbp_current_user_can_publish_forums', $retval ); |
| 2322 | 2297 | } |
| 2323 | 2298 | |
| 2324 | 2299 | /** |
| 2325 | - * Check if the current user can publish replies. | |
| 2300 | + * Check if the current user can publish replies | |
| 2326 | 2301 | * |
| 2327 | 2302 | * @since 2.0.0 bbPress (r3127) |
| 2328 | 2303 | * |
| 2329 | 2304 | * @return bool |
| @@ -2358,9 +2333,9 @@ | ||
| 2358 | 2333 | * checks from within template parts. |
| 2359 | 2334 | */ |
| 2360 | 2335 | |
| 2361 | 2336 | /** |
| 2362 | - * Get the forums the current user has the ability to see and post to. | |
| 2337 | + * Get the forums the current user has the ability to see and post to | |
| 2363 | 2338 | * |
| 2364 | 2339 | * @since 2.0.0 bbPress (r3127) |
| 2365 | 2340 | * |
| 2366 | 2341 | * @param array $args |
| @@ -2409,9 +2384,9 @@ | ||
| 2409 | 2384 | if ( bbp_is_user_keymaster() ) { |
| 2410 | 2385 | $retval = true; |
| 2411 | 2386 | |
| 2412 | 2387 | // Looking at a single forum & forum is open |
| 2413 | - } elseif ( is_singular() && bbp_is_forum_open() ) { | |
| 2388 | + } elseif ( ( is_page() || is_single() ) && bbp_is_forum_open() ) { | |
| 2414 | 2389 | $retval = bbp_current_user_can_publish_forums(); |
| 2415 | 2390 | |
| 2416 | 2391 | // User can edit this forum |
| 2417 | 2392 | } else { |
| @@ -2438,9 +2413,9 @@ | ||
| 2438 | 2413 | if ( bbp_is_user_keymaster() ) { |
| 2439 | 2414 | $retval = true; |
| 2440 | 2415 | |
| 2441 | 2416 | // Looking at a single forum & forum is open |
| 2442 | - } elseif ( ( bbp_is_single_forum() || is_singular() ) && bbp_is_forum_open() ) { | |
| 2417 | + } elseif ( ( bbp_is_single_forum() || is_page() || is_single() ) && bbp_is_forum_open() ) { | |
| 2443 | 2418 | $retval = bbp_current_user_can_publish_topics(); |
| 2444 | 2419 | |
| 2445 | 2420 | // User can edit this topic |
| 2446 | 2421 | } else { |
| @@ -2516,32 +2491,32 @@ | ||
| 2516 | 2491 | |
| 2517 | 2492 | /** Moderators ****************************************************************/ |
| 2518 | 2493 | |
| 2519 | 2494 | /** |
| 2520 | - * Output the moderators of a forum. | |
| 2495 | + * Output the moderators of a forum | |
| 2521 | 2496 | * |
| 2522 | 2497 | * @since 2.6.0 bbPress |
| 2523 | 2498 | * |
| 2524 | - * @param int $forum_id Optional. Topic id. | |
| 2525 | - * @param array $args See {@link bbp_get_moderator_list()}. | |
| 2499 | + * @param int $forum_id Optional. Topic id | |
| 2500 | + * @param array $args See {@link bbp_get_moderator_list()} | |
| 2526 | 2501 | */ |
| 2527 | 2502 | function bbp_moderator_list( $forum_id = 0, $args = array() ) { |
| 2528 | 2503 | echo bbp_get_moderator_list( $forum_id, $args ); |
| 2529 | 2504 | } |
| 2530 | 2505 | |
| 2531 | -/** | |
| 2532 | - * Return the moderators for an object. | |
| 2533 | - * | |
| 2534 | - * @since 2.6.0 bbPress | |
| 2535 | - * | |
| 2536 | - * @param int $object_id Optional. Object id. | |
| 2537 | - * @param array $args This function supports these arguments: | |
| 2538 | - * - before: Before the tag list | |
| 2539 | - * - sep: Tag separator | |
| 2540 | - * - after: After the tag list | |
| 2541 | - * | |
| 2542 | - * @return string Moderator list of the object. | |
| 2543 | - */ | |
| 2506 | + /** | |
| 2507 | + * Return the moderators for an object | |
| 2508 | + * | |
| 2509 | + * @since 2.6.0 bbPress | |
| 2510 | + * | |
| 2511 | + * @param int $object_id Optional. Object id | |
| 2512 | + * @param array $args This function supports these arguments: | |
| 2513 | + * - before: Before the tag list | |
| 2514 | + * - sep: Tag separator | |
| 2515 | + * - after: After the tag list | |
| 2516 | + * | |
| 2517 | + * @return string Moderator list of the object | |
| 2518 | + */ | |
| 2544 | 2519 | function bbp_get_moderator_list( $object_id = 0, $args = array() ) { |
| 2545 | 2520 | |
| 2546 | 2521 | // Parse arguments against default values |
| 2547 | 2522 | $r = bbp_parse_args( |