| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * bbPress Reply Template Tags. | |
| 4 | + * bbPress Reply Template Tags | |
| 5 | 5 | * |
| 6 | 6 | * @package bbPress |
| 7 | 7 | * @subpackage TemplateTags |
| 8 | 8 | */ |
| @@ -12,9 +12,9 @@ | ||
| 12 | 12 | |
| 13 | 13 | /** Post Type *****************************************************************/ |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Return the unique id of the custom post type for replies. | |
| 16 | + * Return the unique id of the custom post type for replies | |
| 17 | 17 | * |
| 18 | 18 | * @since 2.0.0 bbPress (r2857) |
| 19 | 19 | * |
| 20 | 20 | */ |
| @@ -20,24 +20,24 @@ | ||
| 20 | 20 | */ |
| 21 | 21 | function bbp_reply_post_type() { |
| 22 | 22 | echo bbp_get_reply_post_type(); |
| 23 | 23 | } |
| 24 | + /** | |
| 25 | + * Return the unique id of the custom post type for replies | |
| 26 | + * | |
| 27 | + * @since 2.0.0 bbPress (r2857) | |
| 28 | + * | |
| 29 | + * post type id | |
| 30 | + * @return string The unique reply post type id | |
| 31 | + */ | |
| 32 | + function bbp_get_reply_post_type() { | |
| 24 | 33 | |
| 25 | -/** | |
| 26 | - * Return the unique id of the custom post type for replies. | |
| 27 | - * | |
| 28 | - * @since 2.0.0 bbPress (r2857) | |
| 29 | - * | |
| 30 | - * @return string The unique reply post type id. | |
| 31 | - */ | |
| 32 | -function bbp_get_reply_post_type() { | |
| 34 | + // Filter & return | |
| 35 | + return apply_filters( 'bbp_get_reply_post_type', bbpress()->reply_post_type ); | |
| 36 | + } | |
| 33 | 37 | |
| 34 | - // Filter & return | |
| 35 | - return apply_filters( 'bbp_get_reply_post_type', bbpress()->reply_post_type ); | |
| 36 | -} | |
| 37 | - | |
| 38 | 38 | /** |
| 39 | - * Return array of labels used by the reply post type. | |
| 39 | + * Return array of labels used by the reply post type | |
| 40 | 40 | * |
| 41 | 41 | * @since 2.5.0 bbPress (r5129) |
| 42 | 42 | * |
| 43 | 43 | * @return array |
| @@ -52,9 +52,9 @@ | ||
| 52 | 52 | 'menu_name' => esc_attr__( 'Replies', 'bbpress' ), |
| 53 | 53 | 'singular_name' => esc_attr_x( 'Reply', 'noun', 'bbpress' ), |
| 54 | 54 | 'all_items' => esc_attr__( 'All Replies', 'bbpress' ), |
| 55 | 55 | 'add_new' => esc_attr__( 'Add New', 'bbpress' ), |
| 56 | - 'add_new_item' => esc_attr__( 'Add Reply', 'bbpress' ), | |
| 56 | + 'add_new_item' => esc_attr__( 'Create New Reply', 'bbpress' ), | |
| 57 | 57 | 'edit' => esc_attr__( 'Edit', 'bbpress' ), |
| 58 | 58 | 'edit_item' => esc_attr__( 'Edit Reply', 'bbpress' ), |
| 59 | 59 | 'new_item' => esc_attr__( 'New Reply', 'bbpress' ), |
| 60 | 60 | 'view' => esc_attr__( 'View Reply', 'bbpress' ), |
| @@ -84,9 +84,9 @@ | ||
| 84 | 84 | ); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | - * Return array of reply post type rewrite settings. | |
| 88 | + * Return array of reply post type rewrite settings | |
| 89 | 89 | * |
| 90 | 90 | * @since 2.5.0 bbPress (r5129) |
| 91 | 91 | * |
| 92 | 92 | * @return array |
| @@ -103,9 +103,9 @@ | ||
| 103 | 103 | ); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | - * Return array of features the reply post type supports. | |
| 107 | + * Return array of features the reply post type supports | |
| 108 | 108 | * |
| 109 | 109 | * @since 2.5.0 bbPress (r5129) |
| 110 | 110 | * |
| 111 | 111 | * @return array |
| @@ -125,14 +125,14 @@ | ||
| 125 | 125 | |
| 126 | 126 | /** Reply Loop Functions ******************************************************/ |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | - * The main reply loop. WordPress makes this easy for us. | |
| 129 | + * The main reply loop. WordPress makes this easy for us | |
| 130 | 130 | * |
| 131 | 131 | * @since 2.0.0 bbPress (r2553) |
| 132 | 132 | * |
| 133 | - * @param array $args All the arguments supported by {@link WP_Query}. | |
| 134 | - * @return object Multidimensional array of reply information. | |
| 133 | + * @param array $args All the arguments supported by {@link WP_Query} | |
| 134 | + * @return object Multidimensional array of reply information | |
| 135 | 135 | */ |
| 136 | 136 | function bbp_has_replies( $args = array() ) { |
| 137 | 137 | |
| 138 | 138 | /** Defaults **************************************************************/ |
| @@ -272,13 +272,13 @@ | ||
| 272 | 272 | return apply_filters( 'bbp_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query ); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * Whether there are more replies available in the loop. | |
| 276 | + * Whether there are more replies available in the loop | |
| 277 | 277 | * |
| 278 | 278 | * @since 2.0.0 bbPress (r2553) |
| 279 | 279 | * |
| 280 | - * @return object Replies information. | |
| 280 | + * @return object Replies information | |
| 281 | 281 | */ |
| 282 | 282 | function bbp_replies() { |
| 283 | 283 | |
| 284 | 284 | // Put into variable to check against next |
| @@ -292,13 +292,13 @@ | ||
| 292 | 292 | return $have_posts; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | - * Loads up the current reply in the loop. | |
| 296 | + * Loads up the current reply in the loop | |
| 297 | 297 | * |
| 298 | 298 | * @since 2.0.0 bbPress (r2553) |
| 299 | 299 | * |
| 300 | - * @return object Reply information. | |
| 300 | + * @return object Reply information | |
| 301 | 301 | */ |
| 302 | 302 | function bbp_the_reply() { |
| 303 | 303 | return bbpress()->reply_query->the_post(); |
| 304 | 304 | } |
| @@ -303,68 +303,67 @@ | ||
| 303 | 303 | return bbpress()->reply_query->the_post(); |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | - * Output reply id. | |
| 307 | + * Output reply id | |
| 308 | 308 | * |
| 309 | 309 | * @since 2.0.0 bbPress (r2553) |
| 310 | 310 | * |
| 311 | - * @param $reply_id Optional. Used to check emptiness. | |
| 311 | + * @param $reply_id Optional. Used to check emptiness | |
| 312 | 312 | */ |
| 313 | 313 | function bbp_reply_id( $reply_id = 0 ) { |
| 314 | 314 | echo bbp_get_reply_id( $reply_id ); |
| 315 | 315 | } |
| 316 | + /** | |
| 317 | + * Return the id of the reply in a replies loop | |
| 318 | + * | |
| 319 | + * @since 2.0.0 bbPress (r2553) | |
| 320 | + * | |
| 321 | + * @param $reply_id Optional. Used to check emptiness | |
| 322 | + * @return int The reply id | |
| 323 | + */ | |
| 324 | + function bbp_get_reply_id( $reply_id = 0 ) { | |
| 325 | + $bbp = bbpress(); | |
| 326 | + $wp_query = bbp_get_wp_query(); | |
| 316 | 327 | |
| 317 | -/** | |
| 318 | - * Return the id of the reply in a replies loop. | |
| 319 | - * | |
| 320 | - * @since 2.0.0 bbPress (r2553) | |
| 321 | - * | |
| 322 | - * @param $reply_id Optional. Used to check emptiness. | |
| 323 | - * @return int The reply id. | |
| 324 | - */ | |
| 325 | -function bbp_get_reply_id( $reply_id = 0 ) { | |
| 326 | - $bbp = bbpress(); | |
| 327 | - $wp_query = bbp_get_wp_query(); | |
| 328 | + // Easy empty checking | |
| 329 | + if ( ! empty( $reply_id ) && is_numeric( $reply_id ) ) { | |
| 330 | + $bbp_reply_id = $reply_id; | |
| 328 | 331 | |
| 329 | - // Easy empty checking | |
| 330 | - if ( ! empty( $reply_id ) && is_numeric( $reply_id ) ) { | |
| 331 | - $bbp_reply_id = $reply_id; | |
| 332 | + // Currently inside a replies loop | |
| 333 | + } elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) { | |
| 334 | + $bbp_reply_id = $bbp->reply_query->post->ID; | |
| 332 | 335 | |
| 333 | - // Currently inside a replies loop | |
| 334 | - } elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) { | |
| 335 | - $bbp_reply_id = $bbp->reply_query->post->ID; | |
| 336 | + // Currently inside a search loop | |
| 337 | + } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) { | |
| 338 | + $bbp_reply_id = $bbp->search_query->post->ID; | |
| 336 | 339 | |
| 337 | - // Currently inside a search loop | |
| 338 | - } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) { | |
| 339 | - $bbp_reply_id = $bbp->search_query->post->ID; | |
| 340 | + // Currently viewing a forum | |
| 341 | + } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) { | |
| 342 | + $bbp_reply_id = $bbp->current_reply_id; | |
| 340 | 343 | |
| 341 | - // Currently viewing a forum | |
| 342 | - } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) { | |
| 343 | - $bbp_reply_id = $bbp->current_reply_id; | |
| 344 | + // Currently viewing a reply | |
| 345 | + } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) { | |
| 346 | + $bbp_reply_id = $wp_query->post->ID; | |
| 344 | 347 | |
| 345 | - // Currently viewing a reply | |
| 346 | - } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) { | |
| 347 | - $bbp_reply_id = $wp_query->post->ID; | |
| 348 | + // Fallback | |
| 349 | + } else { | |
| 350 | + $bbp_reply_id = 0; | |
| 351 | + } | |
| 348 | 352 | |
| 349 | - // Fallback | |
| 350 | - } else { | |
| 351 | - $bbp_reply_id = 0; | |
| 353 | + // Filter & return | |
| 354 | + return (int) apply_filters( 'bbp_get_reply_id', $bbp_reply_id, $reply_id ); | |
| 352 | 355 | } |
| 353 | 356 | |
| 354 | - // Filter & return | |
| 355 | - return (int) apply_filters( 'bbp_get_reply_id', $bbp_reply_id, $reply_id ); | |
| 356 | -} | |
| 357 | - | |
| 358 | 357 | /** |
| 359 | - * Gets a reply. | |
| 358 | + * Gets a reply | |
| 360 | 359 | * |
| 361 | 360 | * @since 2.0.0 bbPress (r2787) |
| 362 | 361 | * |
| 363 | - * @param int|object $reply reply id or reply object. | |
| 364 | - * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT. | |
| 365 | - * @param string $filter Optional Sanitation filter. See {@link sanitize_post()}. | |
| 366 | - * @return mixed Null if error or reply (in specified form) if success. | |
| 362 | + * @param int|object $reply reply id or reply object | |
| 363 | + * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT | |
| 364 | + * @param string $filter Optional Sanitation filter. See {@link sanitize_post()} | |
| 365 | + * @return mixed Null if error or reply (in specified form) if success | |
| 367 | 366 | */ |
| 368 | 367 | function bbp_get_reply( $reply, $output = OBJECT, $filter = 'raw' ) { |
| 369 | 368 | |
| 370 | 369 | // Maybe get ID from empty or int |
| @@ -399,55 +398,53 @@ | ||
| 399 | 398 | return apply_filters( 'bbp_get_reply', $retval, $reply, $output, $filter ); |
| 400 | 399 | } |
| 401 | 400 | |
| 402 | 401 | /** |
| 403 | - * Output the link to the reply in the reply loop. | |
| 402 | + * Output the link to the reply in the reply loop | |
| 404 | 403 | * |
| 405 | 404 | * @since 2.0.0 bbPress (r2553) |
| 406 | 405 | * |
| 407 | - * @param int $reply_id Optional. Reply id. | |
| 406 | + * @param int $reply_id Optional. Reply id | |
| 408 | 407 | */ |
| 409 | 408 | function bbp_reply_permalink( $reply_id = 0 ) { |
| 410 | 409 | echo esc_url( bbp_get_reply_permalink( $reply_id ) ); |
| 411 | 410 | } |
| 411 | + /** | |
| 412 | + * Return the link to the reply | |
| 413 | + * | |
| 414 | + * @since 2.0.0 bbPress (r2553) | |
| 415 | + * | |
| 416 | + * @param int $reply_id Optional. Reply id | |
| 417 | + * | |
| 418 | + * @return string Permanent link to reply | |
| 419 | + */ | |
| 420 | + function bbp_get_reply_permalink( $reply_id = 0 ) { | |
| 421 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 412 | 422 | |
| 413 | -/** | |
| 414 | - * Return the link to the reply. | |
| 415 | - * | |
| 416 | - * @since 2.0.0 bbPress (r2553) | |
| 417 | - * | |
| 418 | - * @param int $reply_id Optional. Reply id. | |
| 419 | - * | |
| 420 | - * @return string Permanent link to reply. | |
| 421 | - */ | |
| 422 | -function bbp_get_reply_permalink( $reply_id = 0 ) { | |
| 423 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 423 | + // Filter & return | |
| 424 | + return apply_filters( 'bbp_get_reply_permalink', get_permalink( $reply_id ), $reply_id ); | |
| 425 | + } | |
| 424 | 426 | |
| 425 | - // Filter & return | |
| 426 | - return apply_filters( 'bbp_get_reply_permalink', get_permalink( $reply_id ), $reply_id ); | |
| 427 | -} | |
| 428 | - | |
| 429 | 427 | /** |
| 430 | - * Output the paginated url to the reply in the reply loop. | |
| 428 | + * Output the paginated url to the reply in the reply loop | |
| 431 | 429 | * |
| 432 | 430 | * @since 2.0.0 bbPress (r2679) |
| 433 | 431 | * |
| 434 | - * @param int $reply_id Optional. Reply id. | |
| 432 | + * @param int $reply_id Optional. Reply id | |
| 435 | 433 | */ |
| 436 | 434 | function bbp_reply_url( $reply_id = 0 ) { |
| 437 | 435 | echo esc_url( bbp_get_reply_url( $reply_id ) ); |
| 438 | 436 | } |
| 439 | - | |
| 440 | -/** | |
| 441 | - * Return the paginated url to the reply in the reply loop. | |
| 442 | - * | |
| 443 | - * @since 2.0.0 bbPress (r2679) | |
| 444 | - * | |
| 445 | - * @param int $reply_id Optional. Reply id. | |
| 446 | - * @param string $redirect_to Optional. Pass a redirect value for use with | |
| 447 | - * shortcodes and other fun things. | |
| 448 | - * @return string Link to reply relative to paginated topic. | |
| 449 | - */ | |
| 437 | + /** | |
| 438 | + * Return the paginated url to the reply in the reply loop | |
| 439 | + * | |
| 440 | + * @since 2.0.0 bbPress (r2679) | |
| 441 | + * | |
| 442 | + * @param int $reply_id Optional. Reply id | |
| 443 | + * @param string $redirect_to Optional. Pass a redirect value for use with | |
| 444 | + * shortcodes and other fun things. | |
| 445 | + * @return string Link to reply relative to paginated topic | |
| 446 | + */ | |
| 450 | 447 | function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) { |
| 451 | 448 | |
| 452 | 449 | // Set needed variables |
| 453 | 450 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -518,44 +515,43 @@ | ||
| 518 | 515 | return apply_filters( 'bbp_get_reply_url', $url, $reply_id, $redirect_to ); |
| 519 | 516 | } |
| 520 | 517 | |
| 521 | 518 | /** |
| 522 | - * Output the title of the reply. | |
| 519 | + * Output the title of the reply | |
| 523 | 520 | * |
| 524 | 521 | * @since 2.0.0 bbPress (r2553) |
| 525 | 522 | * |
| 526 | - * @param int $reply_id Optional. Reply id. | |
| 523 | + * @param int $reply_id Optional. Reply id | |
| 527 | 524 | */ |
| 528 | 525 | function bbp_reply_title( $reply_id = 0 ) { |
| 529 | 526 | echo bbp_get_reply_title( $reply_id ); |
| 530 | 527 | } |
| 531 | 528 | |
| 532 | -/** | |
| 533 | - * Return the title of the reply. | |
| 534 | - * | |
| 535 | - * @since 2.0.0 bbPress (r2553) | |
| 536 | - * | |
| 537 | - * @param int $reply_id Optional. Reply id. | |
| 538 | - * @return string Title of reply. | |
| 539 | - */ | |
| 540 | -function bbp_get_reply_title( $reply_id = 0 ) { | |
| 541 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 542 | - $title = get_post_field( 'post_title', $reply_id ); | |
| 543 | - $title = apply_filters( 'the_title', $title, $reply_id ); | |
| 529 | + /** | |
| 530 | + * Return the title of the reply | |
| 531 | + * | |
| 532 | + * @since 2.0.0 bbPress (r2553) | |
| 533 | + * | |
| 534 | + * @param int $reply_id Optional. Reply id | |
| 535 | + * @return string Title of reply | |
| 536 | + */ | |
| 537 | + function bbp_get_reply_title( $reply_id = 0 ) { | |
| 538 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 539 | + $title = get_the_title( $reply_id ); | |
| 544 | 540 | |
| 545 | - // Filter & return | |
| 546 | - return apply_filters( 'bbp_get_reply_title', $title, $reply_id ); | |
| 547 | -} | |
| 541 | + // Filter & return | |
| 542 | + return apply_filters( 'bbp_get_reply_title', $title, $reply_id ); | |
| 543 | + } | |
| 548 | 544 | |
| 549 | -/** | |
| 550 | - * Get empty reply title fallback. | |
| 551 | - * | |
| 552 | - * @since 2.5.0 bbPress (r5177) | |
| 553 | - * | |
| 554 | - * @param string $post_title Required. Reply Title. | |
| 555 | - * @param int $post_id Required. Reply ID. | |
| 556 | - * @return string Title of reply. | |
| 557 | - */ | |
| 545 | + /** | |
| 546 | + * Get empty reply title fallback. | |
| 547 | + * | |
| 548 | + * @since 2.5.0 bbPress (r5177) | |
| 549 | + * | |
| 550 | + * @param string $post_title Required. Reply Title | |
| 551 | + * @param int $post_id Required. Reply ID | |
| 552 | + * @return string Title of reply | |
| 553 | + */ | |
| 558 | 554 | function bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ) { |
| 559 | 555 | |
| 560 | 556 | // Bail if title not empty, or post is not a reply |
| 561 | 557 | if ( ! empty( $post_title ) || ! bbp_is_reply( $post_id ) ) { |
| @@ -576,112 +572,109 @@ | ||
| 576 | 572 | return apply_filters( 'bbp_get_reply_title_fallback', $reply_title, $post_id, $topic_title ); |
| 577 | 573 | } |
| 578 | 574 | |
| 579 | 575 | /** |
| 580 | - * Output the content of the reply. | |
| 576 | + * Output the content of the reply | |
| 581 | 577 | * |
| 582 | 578 | * @since 2.0.0 bbPress (r2553) |
| 583 | 579 | * |
| 584 | - * @param int $reply_id Optional. reply id. | |
| 580 | + * @param int $reply_id Optional. reply id | |
| 585 | 581 | */ |
| 586 | 582 | function bbp_reply_content( $reply_id = 0 ) { |
| 587 | 583 | echo bbp_get_reply_content( $reply_id ); |
| 588 | 584 | } |
| 585 | + /** | |
| 586 | + * Return the content of the reply | |
| 587 | + * | |
| 588 | + * @since 2.0.0 bbPress (r2780) | |
| 589 | + * | |
| 590 | + * @param int $reply_id Optional. reply id | |
| 591 | + * @return string Content of the reply | |
| 592 | + */ | |
| 593 | + function bbp_get_reply_content( $reply_id = 0 ) { | |
| 594 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 589 | 595 | |
| 590 | -/** | |
| 591 | - * Return the content of the reply. | |
| 592 | - * | |
| 593 | - * @since 2.0.0 bbPress (r2780) | |
| 594 | - * | |
| 595 | - * @param int $reply_id Optional. reply id. | |
| 596 | - * @return string Content of the reply. | |
| 597 | - */ | |
| 598 | -function bbp_get_reply_content( $reply_id = 0 ) { | |
| 599 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 596 | + // Check if password is required | |
| 597 | + if ( post_password_required( $reply_id ) ) { | |
| 598 | + return get_the_password_form(); | |
| 599 | + } | |
| 600 | 600 | |
| 601 | - // Check if password is required | |
| 602 | - if ( post_password_required( $reply_id ) ) { | |
| 603 | - return get_the_password_form(); | |
| 601 | + $content = get_post_field( 'post_content', $reply_id ); | |
| 602 | + | |
| 603 | + // Filter & return | |
| 604 | + return apply_filters( 'bbp_get_reply_content', $content, $reply_id ); | |
| 604 | 605 | } |
| 605 | 606 | |
| 606 | - $content = get_post_field( 'post_content', $reply_id ); | |
| 607 | - | |
| 608 | - // Filter & return | |
| 609 | - return apply_filters( 'bbp_get_reply_content', $content, $reply_id ); | |
| 610 | -} | |
| 611 | - | |
| 612 | 607 | /** |
| 613 | - * Output the excerpt of the reply. | |
| 608 | + * Output the excerpt of the reply | |
| 614 | 609 | * |
| 615 | 610 | * @since 2.0.0 bbPress (r2751) |
| 616 | 611 | * |
| 617 | - * @param int $reply_id Optional. Reply id. | |
| 618 | - * @param int $length Optional. Length of the excerpt. Defaults to 100 letters. | |
| 612 | + * @param int $reply_id Optional. Reply id | |
| 613 | + * @param int $length Optional. Length of the excerpt. Defaults to 100 letters | |
| 619 | 614 | */ |
| 620 | 615 | function bbp_reply_excerpt( $reply_id = 0, $length = 100 ) { |
| 621 | 616 | echo bbp_get_reply_excerpt( $reply_id, $length ); |
| 622 | 617 | } |
| 618 | + /** | |
| 619 | + * Return the excerpt of the reply | |
| 620 | + * | |
| 621 | + * @since 2.0.0 bbPress (r2751) | |
| 622 | + * | |
| 623 | + * @param int $reply_id Optional. Reply id | |
| 624 | + * @param int $length Optional. Length of the excerpt. Defaults to 100 | |
| 625 | + * letters | |
| 626 | + * @return string Reply Excerpt | |
| 627 | + */ | |
| 628 | + function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) { | |
| 629 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 630 | + $length = (int) $length; | |
| 631 | + $excerpt = get_post_field( 'post_excerpt', $reply_id ); | |
| 623 | 632 | |
| 624 | -/** | |
| 625 | - * Return the excerpt of the reply. | |
| 626 | - * | |
| 627 | - * @since 2.0.0 bbPress (r2751) | |
| 628 | - * | |
| 629 | - * @param int $reply_id Optional. Reply id. | |
| 630 | - * @param int $length Optional. Length of the excerpt. Defaults to 100 | |
| 631 | - * letters. | |
| 632 | - * @return string Reply Excerpt. | |
| 633 | - */ | |
| 634 | -function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) { | |
| 635 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 636 | - $length = (int) $length; | |
| 637 | - $excerpt = get_post_field( 'post_excerpt', $reply_id ); | |
| 633 | + if ( empty( $excerpt ) ) { | |
| 634 | + $excerpt = bbp_get_reply_content( $reply_id ); | |
| 635 | + } | |
| 638 | 636 | |
| 639 | - if ( empty( $excerpt ) ) { | |
| 640 | - $excerpt = bbp_get_reply_content( $reply_id ); | |
| 641 | - } | |
| 637 | + $excerpt = trim ( strip_tags( $excerpt ) ); | |
| 642 | 638 | |
| 643 | - $excerpt = wp_strip_all_tags( $excerpt ); | |
| 639 | + // Multibyte support | |
| 640 | + if ( function_exists( 'mb_strlen' ) ) { | |
| 641 | + $excerpt_length = mb_strlen( $excerpt ); | |
| 642 | + } else { | |
| 643 | + $excerpt_length = strlen( $excerpt ); | |
| 644 | + } | |
| 644 | 645 | |
| 645 | - // Multibyte support | |
| 646 | - if ( function_exists( 'mb_strlen' ) ) { | |
| 647 | - $excerpt_length = mb_strlen( $excerpt ); | |
| 648 | - } else { | |
| 649 | - $excerpt_length = strlen( $excerpt ); | |
| 650 | - } | |
| 646 | + if ( ! empty( $length ) && ( $excerpt_length > $length ) ) { | |
| 647 | + $excerpt = mb_substr( $excerpt, 0, $length - 1 ); | |
| 648 | + $excerpt .= '…'; | |
| 649 | + } | |
| 651 | 650 | |
| 652 | - if ( ! empty( $length ) && ( $excerpt_length > $length ) ) { | |
| 653 | - $excerpt = mb_substr( $excerpt, 0, $length - 1 ); | |
| 654 | - $excerpt .= '…'; | |
| 651 | + // Filter & return | |
| 652 | + return apply_filters( 'bbp_get_reply_excerpt', $excerpt, $reply_id, $length ); | |
| 655 | 653 | } |
| 656 | 654 | |
| 657 | - // Filter & return | |
| 658 | - return apply_filters( 'bbp_get_reply_excerpt', $excerpt, $reply_id, $length ); | |
| 659 | -} | |
| 660 | - | |
| 661 | 655 | /** |
| 662 | - * Output the post date and time of a reply. | |
| 656 | + * Output the post date and time of a reply | |
| 663 | 657 | * |
| 664 | 658 | * @since 2.2.0 bbPress (r4155) |
| 665 | 659 | * |
| 666 | 660 | * @param int $reply_id Optional. Reply id. |
| 667 | - * @param bool $humanize Optional. Humanize output using time_since. | |
| 668 | - * @param bool $gmt Optional. Use GMT. | |
| 661 | + * @param bool $humanize Optional. Humanize output using time_since | |
| 662 | + * @param bool $gmt Optional. Use GMT | |
| 669 | 663 | */ |
| 670 | 664 | function bbp_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) { |
| 671 | 665 | echo bbp_get_reply_post_date( $reply_id, $humanize, $gmt ); |
| 672 | 666 | } |
| 673 | - | |
| 674 | -/** | |
| 675 | - * Return the post date and time of a reply. | |
| 676 | - * | |
| 677 | - * @since 2.2.0 bbPress (r4155) | |
| 678 | - * | |
| 679 | - * @param int $reply_id Optional. Reply id. | |
| 680 | - * @param bool $humanize Optional. Humanize output using time_since. | |
| 681 | - * @param bool $gmt Optional. Use GMT. | |
| 682 | - * @return string | |
| 683 | - */ | |
| 667 | + /** | |
| 668 | + * Return the post date and time of a reply | |
| 669 | + * | |
| 670 | + * @since 2.2.0 bbPress (r4155) | |
| 671 | + * | |
| 672 | + * @param int $reply_id Optional. Reply id. | |
| 673 | + * @param bool $humanize Optional. Humanize output using time_since | |
| 674 | + * @param bool $gmt Optional. Use GMT | |
| 675 | + * @return string | |
| 676 | + */ | |
| 684 | 677 | function bbp_get_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) { |
| 685 | 678 | $reply_id = bbp_get_reply_id( $reply_id ); |
| 686 | 679 | |
| 687 | 680 | // 4 days, 4 hours ago |
| @@ -703,15 +696,15 @@ | ||
| 703 | 696 | return apply_filters( 'bbp_get_reply_post_date', $result, $reply_id, $humanize, $gmt, $date, $time ); |
| 704 | 697 | } |
| 705 | 698 | |
| 706 | 699 | /** |
| 707 | - * Append revisions to the reply content. | |
| 700 | + * Append revisions to the reply content | |
| 708 | 701 | * |
| 709 | 702 | * @since 2.0.0 bbPress (r2782) |
| 710 | 703 | * |
| 711 | - * @param string $content Optional. Content to which we need to append the revisions to. | |
| 712 | - * @param int $reply_id Optional. Reply id. | |
| 713 | - * @return string Content with the revisions appended. | |
| 704 | + * @param string $content Optional. Content to which we need to append the revisions to | |
| 705 | + * @param int $reply_id Optional. Reply id | |
| 706 | + * @return string Content with the revisions appended | |
| 714 | 707 | */ |
| 715 | 708 | function bbp_reply_content_append_revisions( $content = '', $reply_id = 0 ) { |
| 716 | 709 | |
| 717 | 710 | // Bail if in admin or feed |
| @@ -726,26 +719,25 @@ | ||
| 726 | 719 | return apply_filters( 'bbp_reply_append_revisions', $content . bbp_get_reply_revision_log( $reply_id ), $content, $reply_id ); |
| 727 | 720 | } |
| 728 | 721 | |
| 729 | 722 | /** |
| 730 | - * Output the revision log of the reply. | |
| 723 | + * Output the revision log of the reply | |
| 731 | 724 | * |
| 732 | 725 | * @since 2.0.0 bbPress (r2782) |
| 733 | 726 | * |
| 734 | - * @param int $reply_id Optional. Reply id. | |
| 727 | + * @param int $reply_id Optional. Reply id | |
| 735 | 728 | */ |
| 736 | 729 | function bbp_reply_revision_log( $reply_id = 0 ) { |
| 737 | 730 | echo bbp_get_reply_revision_log( $reply_id ); |
| 738 | 731 | } |
| 739 | - | |
| 740 | -/** | |
| 741 | - * Return the formatted revision log of the reply. | |
| 742 | - * | |
| 743 | - * @since 2.0.0 bbPress (r2782) | |
| 744 | - * | |
| 745 | - * @param int $reply_id Optional. Reply id. | |
| 746 | - * @return string Revision log of the reply. | |
| 747 | - */ | |
| 732 | + /** | |
| 733 | + * Return the formatted revision log of the reply | |
| 734 | + * | |
| 735 | + * @since 2.0.0 bbPress (r2782) | |
| 736 | + * | |
| 737 | + * @param int $reply_id Optional. Reply id | |
| 738 | + * @return string Revision log of the reply | |
| 739 | + */ | |
| 748 | 740 | function bbp_get_reply_revision_log( $reply_id = 0 ) { |
| 749 | 741 | |
| 750 | 742 | // Create necessary variables |
| 751 | 743 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -807,35 +799,34 @@ | ||
| 807 | 799 | |
| 808 | 800 | // Filter & return |
| 809 | 801 | return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id ); |
| 810 | 802 | } |
| 803 | + /** | |
| 804 | + * Return the raw revision log of the reply | |
| 805 | + * | |
| 806 | + * @since 2.0.0 bbPress (r2782) | |
| 807 | + * | |
| 808 | + * @param int $reply_id Optional. Reply id | |
| 809 | + * @return string Raw revision log of the reply | |
| 810 | + */ | |
| 811 | + function bbp_get_reply_raw_revision_log( $reply_id = 0 ) { | |
| 812 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 813 | + $revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true ); | |
| 814 | + $revision_log = ! empty( $revision_log ) | |
| 815 | + ? $revision_log | |
| 816 | + : array(); | |
| 811 | 817 | |
| 812 | -/** | |
| 813 | - * Return the raw revision log of the reply. | |
| 814 | - * | |
| 815 | - * @since 2.0.0 bbPress (r2782) | |
| 816 | - * | |
| 817 | - * @param int $reply_id Optional. Reply id. | |
| 818 | - * @return string Raw revision log of the reply. | |
| 819 | - */ | |
| 820 | -function bbp_get_reply_raw_revision_log( $reply_id = 0 ) { | |
| 821 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 822 | - $revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true ); | |
| 823 | - $revision_log = ! empty( $revision_log ) | |
| 824 | - ? $revision_log | |
| 825 | - : array(); | |
| 818 | + // Filter & return | |
| 819 | + return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id ); | |
| 820 | + } | |
| 826 | 821 | |
| 827 | - // Filter & return | |
| 828 | - return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id ); | |
| 829 | -} | |
| 830 | - | |
| 831 | 822 | /** |
| 832 | - * Return the revisions of the reply. | |
| 823 | + * Return the revisions of the reply | |
| 833 | 824 | * |
| 834 | 825 | * @since 2.0.0 bbPress (r2782) |
| 835 | 826 | * |
| 836 | - * @param int $reply_id Optional. Reply id. | |
| 837 | - * @return WP_Post[]|int[] reply revisions. | |
| 827 | + * @param int $reply_id Optional. Reply id | |
| 828 | + * @return WP_Post[]|int[] reply revisions | |
| 838 | 829 | */ |
| 839 | 830 | function bbp_get_reply_revisions( $reply_id = 0 ) { |
| 840 | 831 | $reply_id = bbp_get_reply_id( $reply_id ); |
| 841 | 832 | $revisions = wp_get_post_revisions( $reply_id, array( 'order' => 'ASC' ) ); |
| @@ -844,15 +835,15 @@ | ||
| 844 | 835 | return apply_filters( 'bbp_get_reply_revisions', $revisions, $reply_id ); |
| 845 | 836 | } |
| 846 | 837 | |
| 847 | 838 | /** |
| 848 | - * Return the revision count of the reply. | |
| 839 | + * Return the revision count of the reply | |
| 849 | 840 | * |
| 850 | 841 | * @since 2.0.0 bbPress (r2782) |
| 851 | 842 | * |
| 852 | - * @param int $reply_id Optional. Reply id. | |
| 853 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 854 | - * @return string reply revision count. | |
| 843 | + * @param int $reply_id Optional. Reply id | |
| 844 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 845 | + * @return string reply revision count | |
| 855 | 846 | */ |
| 856 | 847 | function bbp_get_reply_revision_count( $reply_id = 0, $integer = false ) { |
| 857 | 848 | $reply_id = bbp_get_reply_id( $reply_id ); |
| 858 | 849 | $count = count( bbp_get_reply_revisions( $reply_id ) ); |
| @@ -863,33 +854,32 @@ | ||
| 863 | 854 | return apply_filters( $filter, $count, $reply_id ); |
| 864 | 855 | } |
| 865 | 856 | |
| 866 | 857 | /** |
| 867 | - * Output the status of the reply. | |
| 858 | + * Output the status of the reply | |
| 868 | 859 | * |
| 869 | 860 | * @since 2.0.0 bbPress (r2667) |
| 870 | 861 | * |
| 871 | - * @param int $reply_id Optional. Reply id. | |
| 862 | + * @param int $reply_id Optional. Reply id | |
| 872 | 863 | */ |
| 873 | 864 | function bbp_reply_status( $reply_id = 0 ) { |
| 874 | 865 | echo bbp_get_reply_status( $reply_id ); |
| 875 | 866 | } |
| 867 | + /** | |
| 868 | + * Return the status of the reply | |
| 869 | + * | |
| 870 | + * @since 2.0.0 bbPress (r2667) | |
| 871 | + * | |
| 872 | + * @param int $reply_id Optional. Reply id | |
| 873 | + * @return string Status of reply | |
| 874 | + */ | |
| 875 | + function bbp_get_reply_status( $reply_id = 0 ) { | |
| 876 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 876 | 877 | |
| 877 | -/** | |
| 878 | - * Return the status of the reply. | |
| 879 | - * | |
| 880 | - * @since 2.0.0 bbPress (r2667) | |
| 881 | - * | |
| 882 | - * @param int $reply_id Optional. Reply id. | |
| 883 | - * @return string Status of reply. | |
| 884 | - */ | |
| 885 | -function bbp_get_reply_status( $reply_id = 0 ) { | |
| 886 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 878 | + // Filter & return | |
| 879 | + return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id ); | |
| 880 | + } | |
| 887 | 881 | |
| 888 | - // Filter & return | |
| 889 | - return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id ); | |
| 890 | -} | |
| 891 | - | |
| 892 | 882 | /** |
| 893 | 883 | * Is the reply publicly viewable? |
| 894 | 884 | * |
| 895 | 885 | * See bbp_get_public_reply_statuses() for public statuses. |
| @@ -895,9 +885,9 @@ | ||
| 895 | 885 | * See bbp_get_public_reply_statuses() for public statuses. |
| 896 | 886 | * |
| 897 | 887 | * @since 2.6.0 bbPress (r6391) |
| 898 | 888 | * |
| 899 | - * @param int $reply_id Optional. Reply id. | |
| 889 | + * @param int $reply_id Optional. Reply id | |
| 900 | 890 | * @return bool True if public, false if not. |
| 901 | 891 | */ |
| 902 | 892 | function bbp_is_reply_public( $reply_id = 0 ) { |
| 903 | 893 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -914,9 +904,9 @@ | ||
| 914 | 904 | * |
| 915 | 905 | * @since 2.0.0 bbPress (r3496) |
| 916 | 906 | * @since 2.6.0 bbPress (r6922) Returns false if topic is also not published |
| 917 | 907 | * |
| 918 | - * @param int $reply_id Optional. Topic id. | |
| 908 | + * @param int $reply_id Optional. Topic id | |
| 919 | 909 | * @return bool True if published, false if not. |
| 920 | 910 | */ |
| 921 | 911 | function bbp_is_reply_published( $reply_id = 0 ) { |
| 922 | 912 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -934,9 +924,9 @@ | ||
| 934 | 924 | * Is the reply marked as spam? |
| 935 | 925 | * |
| 936 | 926 | * @since 2.0.0 bbPress (r2740) |
| 937 | 927 | * |
| 938 | - * @param int $reply_id Optional. Reply id. | |
| 928 | + * @param int $reply_id Optional. Reply id | |
| 939 | 929 | * @return bool True if spam, false if not. |
| 940 | 930 | */ |
| 941 | 931 | function bbp_is_reply_spam( $reply_id = 0 ) { |
| 942 | 932 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -951,9 +941,9 @@ | ||
| 951 | 941 | * Is the reply trashed? |
| 952 | 942 | * |
| 953 | 943 | * @since 2.0.0 bbPress (r2884) |
| 954 | 944 | * |
| 955 | - * @param int $reply_id Optional. Topic id. | |
| 945 | + * @param int $reply_id Optional. Topic id | |
| 956 | 946 | * @return bool True if spam, false if not. |
| 957 | 947 | */ |
| 958 | 948 | function bbp_is_reply_trash( $reply_id = 0 ) { |
| 959 | 949 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -968,9 +958,9 @@ | ||
| 968 | 958 | * Is the reply pending? |
| 969 | 959 | * |
| 970 | 960 | * @since 2.6.0 bbPress (r5507) |
| 971 | 961 | * |
| 972 | - * @param int $reply_id Optional. Topic id. | |
| 962 | + * @param int $reply_id Optional. Topic id | |
| 973 | 963 | * @return bool True if pending, false if not. |
| 974 | 964 | */ |
| 975 | 965 | function bbp_is_reply_pending( $reply_id = 0 ) { |
| 976 | 966 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -985,9 +975,9 @@ | ||
| 985 | 975 | * Is the reply private? |
| 986 | 976 | * |
| 987 | 977 | * @since 2.6.0 bbPress (r5507) |
| 988 | 978 | * |
| 989 | - * @param int $reply_id Optional. Topic id. | |
| 979 | + * @param int $reply_id Optional. Topic id | |
| 990 | 980 | * @return bool True if private, false if not. |
| 991 | 981 | */ |
| 992 | 982 | function bbp_is_reply_private( $reply_id = 0 ) { |
| 993 | 983 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -1002,9 +992,9 @@ | ||
| 1002 | 992 | * Is the reply by an anonymous user? |
| 1003 | 993 | * |
| 1004 | 994 | * @since 2.0.0 bbPress (r2753) |
| 1005 | 995 | * |
| 1006 | - * @param int $reply_id Optional. Reply id. | |
| 996 | + * @param int $reply_id Optional. Reply id | |
| 1007 | 997 | * @return bool True if the post is by an anonymous user, false if not. |
| 1008 | 998 | */ |
| 1009 | 999 | function bbp_is_reply_anonymous( $reply_id = 0 ) { |
| 1010 | 1000 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -1026,164 +1016,158 @@ | ||
| 1026 | 1016 | |
| 1027 | 1017 | /** |
| 1028 | 1018 | * Deprecated. Use bbp_reply_author_display_name() instead. |
| 1029 | 1019 | * |
| 1030 | - * Output the author of the reply. | |
| 1020 | + * Output the author of the reply | |
| 1031 | 1021 | * |
| 1032 | 1022 | * @since 2.0.0 bbPress (r2667) |
| 1033 | 1023 | * |
| 1034 | 1024 | * @deprecated 2.5.0 bbPress (r5119) |
| 1035 | 1025 | * |
| 1036 | - * @param int $reply_id Optional. Reply id. | |
| 1026 | + * @param int $reply_id Optional. Reply id | |
| 1037 | 1027 | */ |
| 1038 | 1028 | function bbp_reply_author( $reply_id = 0 ) { |
| 1039 | - echo bbp_get_reply_author_display_name( $reply_id ); | |
| 1029 | + echo bbp_get_reply_author( $reply_id ); | |
| 1040 | 1030 | } |
| 1031 | + /** | |
| 1032 | + * Deprecated. Use bbp_get_reply_author_display_name() instead. | |
| 1033 | + * | |
| 1034 | + * Return the author of the reply | |
| 1035 | + * | |
| 1036 | + * @since 2.0.0 bbPress (r2667) | |
| 1037 | + * | |
| 1038 | + * @deprecated 2.5.0 bbPress (r5119) | |
| 1039 | + * | |
| 1040 | + * @param int $reply_id Optional. Reply id | |
| 1041 | + * @return string Author of reply | |
| 1042 | + */ | |
| 1043 | + function bbp_get_reply_author( $reply_id = 0 ) { | |
| 1044 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1041 | 1045 | |
| 1042 | -/** | |
| 1043 | - * Deprecated. Use bbp_get_reply_author_display_name() instead. | |
| 1044 | - * | |
| 1045 | - * Return the author of the reply. | |
| 1046 | - * | |
| 1047 | - * @since 2.0.0 bbPress (r2667) | |
| 1048 | - * | |
| 1049 | - * @deprecated 2.5.0 bbPress (r5119) | |
| 1050 | - * | |
| 1051 | - * @param int $reply_id Optional. Reply id. | |
| 1052 | - * @return string Author of reply. | |
| 1053 | - */ | |
| 1054 | -function bbp_get_reply_author( $reply_id = 0 ) { | |
| 1055 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1046 | + if ( ! bbp_is_reply_anonymous( $reply_id ) ) { | |
| 1047 | + $author = get_the_author_meta( 'display_name', bbp_get_reply_author_id( $reply_id ) ); | |
| 1048 | + } else { | |
| 1049 | + $author = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); | |
| 1050 | + } | |
| 1056 | 1051 | |
| 1057 | - if ( ! bbp_is_reply_anonymous( $reply_id ) ) { | |
| 1058 | - $author = get_the_author_meta( 'display_name', bbp_get_reply_author_id( $reply_id ) ); | |
| 1059 | - } else { | |
| 1060 | - $author = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); | |
| 1052 | + // Filter & return | |
| 1053 | + return apply_filters( 'bbp_get_reply_author', $author, $reply_id ); | |
| 1061 | 1054 | } |
| 1062 | 1055 | |
| 1063 | - // Filter & return | |
| 1064 | - return apply_filters( 'bbp_get_reply_author', $author, $reply_id ); | |
| 1065 | -} | |
| 1066 | - | |
| 1067 | 1056 | /** |
| 1068 | - * Output the author ID of the reply. | |
| 1057 | + * Output the author ID of the reply | |
| 1069 | 1058 | * |
| 1070 | 1059 | * @since 2.0.0 bbPress (r2667) |
| 1071 | 1060 | * |
| 1072 | - * @param int $reply_id Optional. Reply id. | |
| 1061 | + * @param int $reply_id Optional. Reply id | |
| 1073 | 1062 | */ |
| 1074 | 1063 | function bbp_reply_author_id( $reply_id = 0 ) { |
| 1075 | 1064 | echo bbp_get_reply_author_id( $reply_id ); |
| 1076 | 1065 | } |
| 1066 | + /** | |
| 1067 | + * Return the author ID of the reply | |
| 1068 | + * | |
| 1069 | + * @since 2.0.0 bbPress (r2667) | |
| 1070 | + * | |
| 1071 | + * @param int $reply_id Optional. Reply id | |
| 1072 | + * @return string Author id of reply | |
| 1073 | + */ | |
| 1074 | + function bbp_get_reply_author_id( $reply_id = 0 ) { | |
| 1075 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1076 | + $author_id = get_post_field( 'post_author', $reply_id ); | |
| 1077 | 1077 | |
| 1078 | -/** | |
| 1079 | - * Return the author ID of the reply. | |
| 1080 | - * | |
| 1081 | - * @since 2.0.0 bbPress (r2667) | |
| 1082 | - * | |
| 1083 | - * @param int $reply_id Optional. Reply id. | |
| 1084 | - * @return string Author id of reply. | |
| 1085 | - */ | |
| 1086 | -function bbp_get_reply_author_id( $reply_id = 0 ) { | |
| 1087 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1088 | - $author_id = get_post_field( 'post_author', $reply_id ); | |
| 1078 | + // Filter & return | |
| 1079 | + return (int) apply_filters( 'bbp_get_reply_author_id', $author_id, $reply_id ); | |
| 1080 | + } | |
| 1089 | 1081 | |
| 1090 | - // Filter & return | |
| 1091 | - return (int) apply_filters( 'bbp_get_reply_author_id', $author_id, $reply_id ); | |
| 1092 | -} | |
| 1093 | - | |
| 1094 | 1082 | /** |
| 1095 | - * Output the author display_name of the reply. | |
| 1083 | + * Output the author display_name of the reply | |
| 1096 | 1084 | * |
| 1097 | 1085 | * @since 2.0.0 bbPress (r2667) |
| 1098 | 1086 | * |
| 1099 | - * @param int $reply_id Optional. Reply id. | |
| 1087 | + * @param int $reply_id Optional. Reply id | |
| 1100 | 1088 | */ |
| 1101 | 1089 | function bbp_reply_author_display_name( $reply_id = 0 ) { |
| 1102 | 1090 | echo bbp_get_reply_author_display_name( $reply_id ); |
| 1103 | 1091 | } |
| 1092 | + /** | |
| 1093 | + * Return the author display_name of the reply | |
| 1094 | + * | |
| 1095 | + * @since 2.0.0 bbPress (r2667) | |
| 1096 | + * | |
| 1097 | + * @param int $reply_id Optional. Reply id | |
| 1098 | + * @return string The display name of the author of the reply | |
| 1099 | + */ | |
| 1100 | + function bbp_get_reply_author_display_name( $reply_id = 0 ) { | |
| 1101 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1104 | 1102 | |
| 1105 | -/** | |
| 1106 | - * Return the author display_name of the reply. | |
| 1107 | - * | |
| 1108 | - * @since 2.0.0 bbPress (r2667) | |
| 1109 | - * | |
| 1110 | - * @param int $reply_id Optional. Reply id. | |
| 1111 | - * @return string The display name of the author of the reply. | |
| 1112 | - */ | |
| 1113 | -function bbp_get_reply_author_display_name( $reply_id = 0 ) { | |
| 1114 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1103 | + // User is not a guest | |
| 1104 | + if ( ! bbp_is_reply_anonymous( $reply_id ) ) { | |
| 1115 | 1105 | |
| 1116 | - // User is not a guest | |
| 1117 | - if ( ! bbp_is_reply_anonymous( $reply_id ) ) { | |
| 1106 | + // Get the author ID | |
| 1107 | + $author_id = bbp_get_reply_author_id( $reply_id ); | |
| 1118 | 1108 | |
| 1119 | - // Get the author ID | |
| 1120 | - $author_id = bbp_get_reply_author_id( $reply_id ); | |
| 1109 | + // Try to get a display name | |
| 1110 | + $author_name = get_the_author_meta( 'display_name', $author_id ); | |
| 1121 | 1111 | |
| 1122 | - // Try to get a display name | |
| 1123 | - $author_name = get_the_author_meta( 'display_name', $author_id ); | |
| 1112 | + // Fall back to user login | |
| 1113 | + if ( empty( $author_name ) ) { | |
| 1114 | + $author_name = get_the_author_meta( 'user_login', $author_id ); | |
| 1115 | + } | |
| 1124 | 1116 | |
| 1125 | - // Fall back to user login | |
| 1117 | + // User does not have an account | |
| 1118 | + } else { | |
| 1119 | + $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); | |
| 1120 | + } | |
| 1121 | + | |
| 1122 | + // Fallback if nothing could be found | |
| 1126 | 1123 | if ( empty( $author_name ) ) { |
| 1127 | - $author_name = get_the_author_meta( 'user_login', $author_id ); | |
| 1124 | + $author_name = bbp_get_fallback_display_name( $reply_id ); | |
| 1128 | 1125 | } |
| 1129 | 1126 | |
| 1130 | - // User does not have an account | |
| 1131 | - } else { | |
| 1132 | - $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); | |
| 1127 | + // Filter & return | |
| 1128 | + return apply_filters( 'bbp_get_reply_author_display_name', $author_name, $reply_id ); | |
| 1133 | 1129 | } |
| 1134 | 1130 | |
| 1135 | - // Fallback if nothing could be found | |
| 1136 | - if ( empty( $author_name ) ) { | |
| 1137 | - $author_name = bbp_get_fallback_display_name( $reply_id ); | |
| 1138 | - } | |
| 1139 | - | |
| 1140 | - // Filter & return | |
| 1141 | - return apply_filters( 'bbp_get_reply_author_display_name', $author_name, $reply_id ); | |
| 1142 | -} | |
| 1143 | - | |
| 1144 | 1131 | /** |
| 1145 | - * Output the author avatar of the reply. | |
| 1132 | + * Output the author avatar of the reply | |
| 1146 | 1133 | * |
| 1147 | 1134 | * @since 2.0.0 bbPress (r2667) |
| 1148 | 1135 | * |
| 1149 | - * @param int $reply_id Optional. Reply id. | |
| 1150 | - * @param int $size Optional. Size of the avatar. Defaults to 40. | |
| 1136 | + * @param int $reply_id Optional. Reply id | |
| 1137 | + * @param int $size Optional. Size of the avatar. Defaults to 40 | |
| 1151 | 1138 | */ |
| 1152 | 1139 | function bbp_reply_author_avatar( $reply_id = 0, $size = 40 ) { |
| 1153 | 1140 | echo bbp_get_reply_author_avatar( $reply_id, $size ); |
| 1154 | 1141 | } |
| 1155 | - | |
| 1156 | -/** | |
| 1157 | - * Return the author avatar of the reply. | |
| 1158 | - * | |
| 1159 | - * @since 2.0.0 bbPress (r2667) | |
| 1160 | - * | |
| 1161 | - * @param int $reply_id Optional. Reply id | |
| 1162 | - * @param int $size Optional. Size of the avatar. Defaults to 40. | |
| 1163 | - * @return string Avatar of author of the reply. | |
| 1164 | - */ | |
| 1165 | -function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) { | |
| 1166 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1167 | - | |
| 1168 | - if ( ! empty( $reply_id ) ) { | |
| 1169 | - | |
| 1170 | - // Check for anonymous user | |
| 1171 | - if ( ! bbp_is_reply_anonymous( $reply_id ) ) { | |
| 1172 | - $author_avatar = get_avatar( bbp_get_reply_author_id( $reply_id ), $size ); | |
| 1142 | + /** | |
| 1143 | + * Return the author avatar of the reply | |
| 1144 | + * | |
| 1145 | + * @since 2.0.0 bbPress (r2667) | |
| 1146 | + * | |
| 1147 | + * @param int $reply_id Optional. Reply id | |
| 1148 | + * @param int $size Optional. Size of the avatar. Defaults to 40 | |
| 1149 | + * @return string Avatar of author of the reply | |
| 1150 | + */ | |
| 1151 | + function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) { | |
| 1152 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1153 | + if ( ! empty( $reply_id ) ) { | |
| 1154 | + // Check for anonymous user | |
| 1155 | + if ( ! bbp_is_reply_anonymous( $reply_id ) ) { | |
| 1156 | + $author_avatar = get_avatar( bbp_get_reply_author_id( $reply_id ), $size ); | |
| 1157 | + } else { | |
| 1158 | + $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ), $size ); | |
| 1159 | + } | |
| 1173 | 1160 | } else { |
| 1174 | - $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ), $size ); | |
| 1161 | + $author_avatar = ''; | |
| 1175 | 1162 | } |
| 1176 | - } else { | |
| 1177 | - $author_avatar = ''; | |
| 1163 | + | |
| 1164 | + // Filter & return | |
| 1165 | + return apply_filters( 'bbp_get_reply_author_avatar', $author_avatar, $reply_id, $size ); | |
| 1178 | 1166 | } |
| 1179 | 1167 | |
| 1180 | - // Filter & return | |
| 1181 | - return apply_filters( 'bbp_get_reply_author_avatar', $author_avatar, $reply_id, $size ); | |
| 1182 | -} | |
| 1183 | - | |
| 1184 | 1168 | /** |
| 1185 | - * Output the author link of the reply. | |
| 1169 | + * Output the author link of the reply | |
| 1186 | 1170 | * |
| 1187 | 1171 | * @since 2.0.0 bbPress (r2717) |
| 1188 | 1172 | * |
| 1189 | 1173 | * @param array $args Optional. If it is an integer, it is used as reply id. |
| @@ -1190,17 +1174,16 @@ | ||
| 1190 | 1174 | */ |
| 1191 | 1175 | function bbp_reply_author_link( $args = array() ) { |
| 1192 | 1176 | echo bbp_get_reply_author_link( $args ); |
| 1193 | 1177 | } |
| 1194 | - | |
| 1195 | -/** | |
| 1196 | - * Return the author link of the reply. | |
| 1197 | - * | |
| 1198 | - * @since 2.0.0 bbPress (r2717) | |
| 1199 | - * | |
| 1200 | - * @param array $args Optional. If an integer, it is used as reply id. | |
| 1201 | - * @return string Author link of reply. | |
| 1202 | - */ | |
| 1178 | + /** | |
| 1179 | + * Return the author link of the reply | |
| 1180 | + * | |
| 1181 | + * @since 2.0.0 bbPress (r2717) | |
| 1182 | + * | |
| 1183 | + * @param array $args Optional. If an integer, it is used as reply id. | |
| 1184 | + * @return string Author link of reply | |
| 1185 | + */ | |
| 1203 | 1186 | function bbp_get_reply_author_link( $args = array() ) { |
| 1204 | 1187 | |
| 1205 | 1188 | // Parse arguments against default values |
| 1206 | 1189 | $r = bbp_parse_args( |
| @@ -1264,9 +1247,9 @@ | ||
| 1264 | 1247 | } |
| 1265 | 1248 | |
| 1266 | 1249 | // Empty array |
| 1267 | 1250 | $links = array(); |
| 1268 | - $sprint = '<span%1$s>%2$s</span>'; | |
| 1251 | + $sprint = '<span %1$s>%2$s</span>'; | |
| 1269 | 1252 | |
| 1270 | 1253 | // Wrap each link |
| 1271 | 1254 | foreach ( $author_links as $link => $link_text ) { |
| 1272 | 1255 | $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"'; |
| @@ -1298,92 +1281,89 @@ | ||
| 1298 | 1281 | return apply_filters( 'bbp_get_reply_author_link', $author_link, $r, $args ); |
| 1299 | 1282 | } |
| 1300 | 1283 | |
| 1301 | 1284 | /** |
| 1302 | - * Output the author url of the reply. | |
| 1285 | + * Output the author url of the reply | |
| 1303 | 1286 | * |
| 1304 | 1287 | * @since 2.0.0 bbPress (r2667) |
| 1305 | 1288 | * |
| 1306 | - * @param int $reply_id Optional. Reply id. | |
| 1289 | + * @param int $reply_id Optional. Reply id | |
| 1307 | 1290 | */ |
| 1308 | 1291 | function bbp_reply_author_url( $reply_id = 0 ) { |
| 1309 | 1292 | echo esc_url( bbp_get_reply_author_url( $reply_id ) ); |
| 1310 | 1293 | } |
| 1294 | + /** | |
| 1295 | + * Return the author url of the reply | |
| 1296 | + * | |
| 1297 | + * @since 2.0.0 bbPress (r2667) | |
| 1298 | + * | |
| 1299 | + * @param int $reply_id Optional. Reply id | |
| 1300 | + * @return string Author URL of the reply | |
| 1301 | + */ | |
| 1302 | + function bbp_get_reply_author_url( $reply_id = 0 ) { | |
| 1303 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1311 | 1304 | |
| 1312 | -/** | |
| 1313 | - * Return the author url of the reply. | |
| 1314 | - * | |
| 1315 | - * @since 2.0.0 bbPress (r2667) | |
| 1316 | - * | |
| 1317 | - * @param int $reply_id Optional. Reply id. | |
| 1318 | - * @return string Author URL of the reply. | |
| 1319 | - */ | |
| 1320 | -function bbp_get_reply_author_url( $reply_id = 0 ) { | |
| 1321 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1305 | + // Check for anonymous user or non-existant user | |
| 1306 | + if ( ! bbp_is_reply_anonymous( $reply_id ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) { | |
| 1307 | + $author_url = bbp_get_user_profile_url( bbp_get_reply_author_id( $reply_id ) ); | |
| 1308 | + } else { | |
| 1309 | + $author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true ); | |
| 1310 | + if ( empty( $author_url ) ) { | |
| 1311 | + $author_url = ''; | |
| 1312 | + } | |
| 1313 | + } | |
| 1322 | 1314 | |
| 1323 | - // Check for anonymous user or non-existant user | |
| 1324 | - if ( ! bbp_is_reply_anonymous( $reply_id ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) { | |
| 1325 | - $author_url = bbp_get_user_profile_url( bbp_get_reply_author_id( $reply_id ) ); | |
| 1326 | - } else { | |
| 1327 | - $author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true ); | |
| 1328 | - | |
| 1329 | - if ( empty( $author_url ) ) { | |
| 1330 | - $author_url = ''; | |
| 1331 | - } | |
| 1315 | + // Filter & return | |
| 1316 | + return apply_filters( 'bbp_get_reply_author_url', $author_url, $reply_id ); | |
| 1332 | 1317 | } |
| 1333 | 1318 | |
| 1334 | - // Filter & return | |
| 1335 | - return apply_filters( 'bbp_get_reply_author_url', $author_url, $reply_id ); | |
| 1336 | -} | |
| 1337 | - | |
| 1338 | 1319 | /** |
| 1339 | - * Output the reply author email address. | |
| 1320 | + * Output the reply author email address | |
| 1340 | 1321 | * |
| 1341 | 1322 | * @since 2.0.0 bbPress (r3445) |
| 1342 | 1323 | * |
| 1343 | - * @param int $reply_id Optional. Reply id. | |
| 1324 | + * @param int $reply_id Optional. Reply id | |
| 1344 | 1325 | */ |
| 1345 | 1326 | function bbp_reply_author_email( $reply_id = 0 ) { |
| 1346 | 1327 | echo bbp_get_reply_author_email( $reply_id ); |
| 1347 | 1328 | } |
| 1329 | + /** | |
| 1330 | + * Return the reply author email address | |
| 1331 | + * | |
| 1332 | + * @since 2.0.0 bbPress (r3445) | |
| 1333 | + * | |
| 1334 | + * @param int $reply_id Optional. Reply id | |
| 1335 | + * @return string Reply author email address | |
| 1336 | + */ | |
| 1337 | + function bbp_get_reply_author_email( $reply_id = 0 ) { | |
| 1338 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1348 | 1339 | |
| 1349 | -/** | |
| 1350 | - * Return the reply author email address. | |
| 1351 | - * | |
| 1352 | - * @since 2.0.0 bbPress (r3445) | |
| 1353 | - * | |
| 1354 | - * @param int $reply_id Optional. Reply id. | |
| 1355 | - * @return string Reply author email address. | |
| 1356 | - */ | |
| 1357 | -function bbp_get_reply_author_email( $reply_id = 0 ) { | |
| 1358 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1340 | + // Not anonymous | |
| 1341 | + if ( ! bbp_is_reply_anonymous( $reply_id ) ) { | |
| 1359 | 1342 | |
| 1360 | - // Not anonymous | |
| 1361 | - if ( ! bbp_is_reply_anonymous( $reply_id ) ) { | |
| 1343 | + // Use reply author email address | |
| 1344 | + $user_id = bbp_get_reply_author_id( $reply_id ); | |
| 1345 | + $user = get_userdata( $user_id ); | |
| 1346 | + $author_email = ! empty( $user->user_email ) ? $user->user_email : ''; | |
| 1362 | 1347 | |
| 1363 | - // Use reply author email address | |
| 1364 | - $user_id = bbp_get_reply_author_id( $reply_id ); | |
| 1365 | - $user = get_userdata( $user_id ); | |
| 1366 | - $author_email = ! empty( $user->user_email ) ? $user->user_email : ''; | |
| 1348 | + // Anonymous | |
| 1349 | + } else { | |
| 1367 | 1350 | |
| 1368 | - // Anonymous | |
| 1369 | - } else { | |
| 1351 | + // Get email from post meta | |
| 1352 | + $author_email = get_post_meta( $reply_id, '_bbp_anonymous_email', true ); | |
| 1370 | 1353 | |
| 1371 | - // Get email from post meta | |
| 1372 | - $author_email = get_post_meta( $reply_id, '_bbp_anonymous_email', true ); | |
| 1354 | + // Sanity check for missing email address | |
| 1355 | + if ( empty( $author_email ) ) { | |
| 1356 | + $author_email = ''; | |
| 1357 | + } | |
| 1358 | + } | |
| 1373 | 1359 | |
| 1374 | - // Sanity check for missing email address | |
| 1375 | - if ( empty( $author_email ) ) { | |
| 1376 | - $author_email = ''; | |
| 1377 | - } | |
| 1360 | + // Filter & return | |
| 1361 | + return apply_filters( 'bbp_get_reply_author_email', $author_email, $reply_id ); | |
| 1378 | 1362 | } |
| 1379 | 1363 | |
| 1380 | - // Filter & return | |
| 1381 | - return apply_filters( 'bbp_get_reply_author_email', $author_email, $reply_id ); | |
| 1382 | -} | |
| 1383 | - | |
| 1384 | 1364 | /** |
| 1385 | - * Output the reply author role. | |
| 1365 | + * Output the reply author role | |
| 1386 | 1366 | * |
| 1387 | 1367 | * @since 2.1.0 bbPress (r3860) |
| 1388 | 1368 | * |
| 1389 | 1369 | * @param array $args Optional. |
| @@ -1390,17 +1370,16 @@ | ||
| 1390 | 1370 | */ |
| 1391 | 1371 | function bbp_reply_author_role( $args = array() ) { |
| 1392 | 1372 | echo bbp_get_reply_author_role( $args ); |
| 1393 | 1373 | } |
| 1394 | - | |
| 1395 | -/** | |
| 1396 | - * Return the reply author role. | |
| 1397 | - * | |
| 1398 | - * @since 2.1.0 bbPress (r3860) | |
| 1399 | - * | |
| 1400 | - * @param array $args Optional. | |
| 1401 | - * @return string Reply author role. | |
| 1402 | - */ | |
| 1374 | + /** | |
| 1375 | + * Return the reply author role | |
| 1376 | + * | |
| 1377 | + * @since 2.1.0 bbPress (r3860) | |
| 1378 | + * | |
| 1379 | + * @param array $args Optional. | |
| 1380 | + * @return string Reply author role | |
| 1381 | + */ | |
| 1403 | 1382 | function bbp_get_reply_author_role( $args = array() ) { |
| 1404 | 1383 | |
| 1405 | 1384 | // Parse arguments against default values |
| 1406 | 1385 | $r = bbp_parse_args( |
| @@ -1415,15 +1394,9 @@ | ||
| 1415 | 1394 | ); |
| 1416 | 1395 | |
| 1417 | 1396 | $reply_id = bbp_get_reply_id( $r['reply_id'] ); |
| 1418 | 1397 | $role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ); |
| 1419 | - $css_role = sanitize_key( $role ); | |
| 1420 | 1398 | |
| 1421 | - // Add role as CSS class to default 'before' value. | |
| 1422 | - if ( empty( $args['before'] ) ) { | |
| 1423 | - $r['before'] = '<div class="bbp-author-role bbp-role-' . esc_attr( $css_role ) . '">'; | |
| 1424 | - } | |
| 1425 | - | |
| 1426 | 1399 | // Backwards compatibilty with old 'class' argument |
| 1427 | 1400 | if ( ! empty( $r['class'] ) ) { |
| 1428 | 1401 | $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], esc_attr( $r['class'] ), esc_html( $role ), $r['after'] ); |
| 1429 | 1402 | |
| @@ -1437,171 +1410,162 @@ | ||
| 1437 | 1410 | return apply_filters( 'bbp_get_reply_author_role', $author_role, $r, $args ); |
| 1438 | 1411 | } |
| 1439 | 1412 | |
| 1440 | 1413 | /** |
| 1441 | - * Output the topic title a reply belongs to. | |
| 1414 | + * Output the topic title a reply belongs to | |
| 1442 | 1415 | * |
| 1443 | 1416 | * @since 2.0.0 bbPress (r2553) |
| 1444 | 1417 | * |
| 1445 | - * @param int $reply_id Optional. Reply id. | |
| 1418 | + * @param int $reply_id Optional. Reply id | |
| 1446 | 1419 | */ |
| 1447 | 1420 | function bbp_reply_topic_title( $reply_id = 0 ) { |
| 1448 | 1421 | echo bbp_get_reply_topic_title( $reply_id ); |
| 1449 | 1422 | } |
| 1423 | + /** | |
| 1424 | + * Return the topic title a reply belongs to | |
| 1425 | + * | |
| 1426 | + * @since 2.0.0 bbPress (r2553) | |
| 1427 | + * | |
| 1428 | + * @param int $reply_id Optional. Reply id | |
| 1429 | + * @return string The topic title of the reply | |
| 1430 | + */ | |
| 1431 | + function bbp_get_reply_topic_title( $reply_id = 0 ) { | |
| 1432 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1433 | + $topic_id = bbp_get_reply_topic_id( $reply_id ); | |
| 1450 | 1434 | |
| 1451 | -/** | |
| 1452 | - * Return the topic title a reply belongs to. | |
| 1453 | - * | |
| 1454 | - * @since 2.0.0 bbPress (r2553) | |
| 1455 | - * | |
| 1456 | - * @param int $reply_id Optional. Reply id. | |
| 1457 | - * @return string The topic title of the reply. | |
| 1458 | - */ | |
| 1459 | -function bbp_get_reply_topic_title( $reply_id = 0 ) { | |
| 1460 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1461 | - $topic_id = bbp_get_reply_topic_id( $reply_id ); | |
| 1462 | - $title = bbp_get_topic_title( $topic_id ); | |
| 1435 | + // Filter & return | |
| 1436 | + return apply_filters( 'bbp_get_reply_topic_title', bbp_get_topic_title( $topic_id ), $reply_id ); | |
| 1437 | + } | |
| 1463 | 1438 | |
| 1464 | - // Filter & return | |
| 1465 | - return apply_filters( 'bbp_get_reply_topic_title', $title, $reply_id ); | |
| 1466 | -} | |
| 1467 | - | |
| 1468 | 1439 | /** |
| 1469 | - * Output the topic id a reply belongs to. | |
| 1440 | + * Output the topic id a reply belongs to | |
| 1470 | 1441 | * |
| 1471 | 1442 | * @since 2.0.0 bbPress (r2553) |
| 1472 | 1443 | * |
| 1473 | - * @param int $reply_id Optional. Reply id. | |
| 1444 | + * @param int $reply_id Optional. Reply id | |
| 1474 | 1445 | */ |
| 1475 | 1446 | function bbp_reply_topic_id( $reply_id = 0 ) { |
| 1476 | 1447 | echo bbp_get_reply_topic_id( $reply_id ); |
| 1477 | 1448 | } |
| 1449 | + /** | |
| 1450 | + * Return the topic id a reply belongs to | |
| 1451 | + * | |
| 1452 | + * @since 2.0.0 bbPress (r2553) | |
| 1453 | + * | |
| 1454 | + * @param int $reply_id Optional. Reply id | |
| 1455 | + * @return int The topic id of the reply | |
| 1456 | + */ | |
| 1457 | + function bbp_get_reply_topic_id( $reply_id = 0 ) { | |
| 1458 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1459 | + $topic_id = (int) get_post_field( 'post_parent', $reply_id ); | |
| 1478 | 1460 | |
| 1479 | -/** | |
| 1480 | - * Return the topic id a reply belongs to. | |
| 1481 | - * | |
| 1482 | - * @since 2.0.0 bbPress (r2553) | |
| 1483 | - * | |
| 1484 | - * @param int $reply_id Optional. Reply id. | |
| 1485 | - * @return int The topic id of the reply. | |
| 1486 | - */ | |
| 1487 | -function bbp_get_reply_topic_id( $reply_id = 0 ) { | |
| 1488 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1489 | - $topic_id = (int) get_post_field( 'post_parent', $reply_id ); | |
| 1461 | + // Meta-data fallback | |
| 1462 | + if ( empty( $topic_id ) ) { | |
| 1463 | + $topic_id = (int) get_post_meta( $reply_id, '_bbp_topic_id', true ); | |
| 1464 | + } | |
| 1490 | 1465 | |
| 1491 | - // Meta-data fallback | |
| 1492 | - if ( empty( $topic_id ) ) { | |
| 1493 | - $topic_id = (int) get_post_meta( $reply_id, '_bbp_topic_id', true ); | |
| 1494 | - } | |
| 1466 | + // Filter | |
| 1467 | + if ( ! empty( $topic_id ) ) { | |
| 1468 | + $topic_id = (int) bbp_get_topic_id( $topic_id ); | |
| 1469 | + } | |
| 1495 | 1470 | |
| 1496 | - // Filter | |
| 1497 | - if ( ! empty( $topic_id ) ) { | |
| 1498 | - $topic_id = (int) bbp_get_topic_id( $topic_id ); | |
| 1471 | + // Filter & return | |
| 1472 | + return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id ); | |
| 1499 | 1473 | } |
| 1500 | 1474 | |
| 1501 | - // Filter & return | |
| 1502 | - return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id ); | |
| 1503 | -} | |
| 1504 | - | |
| 1505 | 1475 | /** |
| 1506 | - * Output the forum id a reply belongs to. | |
| 1476 | + * Output the forum id a reply belongs to | |
| 1507 | 1477 | * |
| 1508 | 1478 | * @since 2.0.0 bbPress (r2679) |
| 1509 | 1479 | * |
| 1510 | - * @param int $reply_id Optional. Reply id. | |
| 1480 | + * @param int $reply_id Optional. Reply id | |
| 1511 | 1481 | */ |
| 1512 | 1482 | function bbp_reply_forum_id( $reply_id = 0 ) { |
| 1513 | 1483 | echo bbp_get_reply_forum_id( $reply_id ); |
| 1514 | 1484 | } |
| 1485 | + /** | |
| 1486 | + * Return the forum id a reply belongs to | |
| 1487 | + * | |
| 1488 | + * @since 2.0.0 bbPress (r2679) | |
| 1489 | + * | |
| 1490 | + * @param int $reply_id Optional. Reply id | |
| 1491 | + * | |
| 1492 | + * @return int The forum id of the reply | |
| 1493 | + */ | |
| 1494 | + function bbp_get_reply_forum_id( $reply_id = 0 ) { | |
| 1495 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1496 | + $topic_id = bbp_get_reply_topic_id( $reply_id ); | |
| 1497 | + $forum_id = (int) get_post_field( 'post_parent', $topic_id ); | |
| 1515 | 1498 | |
| 1516 | -/** | |
| 1517 | - * Return the forum id a reply belongs to. | |
| 1518 | - * | |
| 1519 | - * @since 2.0.0 bbPress (r2679) | |
| 1520 | - * | |
| 1521 | - * @param int $reply_id Optional. Reply id. | |
| 1522 | - * | |
| 1523 | - * @return int The forum id of the reply. | |
| 1524 | - */ | |
| 1525 | -function bbp_get_reply_forum_id( $reply_id = 0 ) { | |
| 1526 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1527 | - $topic_id = bbp_get_reply_topic_id( $reply_id ); | |
| 1528 | - $forum_id = (int) get_post_field( 'post_parent', $topic_id ); | |
| 1499 | + // Meta-data fallback | |
| 1500 | + if ( empty( $forum_id ) ) { | |
| 1501 | + $forum_id = (int) get_post_meta( $reply_id, '_bbp_forum_id', true ); | |
| 1502 | + } | |
| 1529 | 1503 | |
| 1530 | - // Meta-data fallback | |
| 1531 | - if ( empty( $forum_id ) ) { | |
| 1532 | - $forum_id = (int) get_post_meta( $reply_id, '_bbp_forum_id', true ); | |
| 1533 | - } | |
| 1504 | + // Filter | |
| 1505 | + if ( ! empty( $forum_id ) ) { | |
| 1506 | + $forum_id = (int) bbp_get_forum_id( $forum_id ); | |
| 1507 | + } | |
| 1534 | 1508 | |
| 1535 | - // Filter | |
| 1536 | - if ( ! empty( $forum_id ) ) { | |
| 1537 | - $forum_id = (int) bbp_get_forum_id( $forum_id ); | |
| 1509 | + // Filter & return | |
| 1510 | + return (int) apply_filters( 'bbp_get_reply_forum_id', $forum_id, $reply_id ); | |
| 1538 | 1511 | } |
| 1539 | 1512 | |
| 1540 | - // Filter & return | |
| 1541 | - return (int) apply_filters( 'bbp_get_reply_forum_id', $forum_id, $reply_id ); | |
| 1542 | -} | |
| 1543 | - | |
| 1544 | 1513 | /** |
| 1545 | - * Output the ancestor reply id of a reply. | |
| 1514 | + * Output the ancestor reply id of a reply | |
| 1546 | 1515 | * |
| 1547 | 1516 | * @since 2.4.0 bbPress (r4944) |
| 1548 | 1517 | * |
| 1549 | - * @param int $reply_id Optional. Reply id. | |
| 1518 | + * @param int $reply_id Optional. Reply id | |
| 1550 | 1519 | */ |
| 1551 | 1520 | function bbp_reply_ancestor_id( $reply_id = 0 ) { |
| 1552 | 1521 | echo bbp_get_reply_ancestor_id( $reply_id ); |
| 1553 | 1522 | } |
| 1523 | + /** | |
| 1524 | + * Return the ancestor reply id of a reply | |
| 1525 | + * | |
| 1526 | + * @since 2.4.0 bbPress (r4944) | |
| 1527 | + * | |
| 1528 | + * @param in $reply_id Reply id | |
| 1529 | + */ | |
| 1530 | + function bbp_get_reply_ancestor_id( $reply_id = 0 ) { | |
| 1554 | 1531 | |
| 1555 | -/** | |
| 1556 | - * Return the ancestor reply id of a reply. | |
| 1557 | - * | |
| 1558 | - * @since 2.4.0 bbPress (r4944) | |
| 1559 | - * | |
| 1560 | - * @param in $reply_id Reply id. | |
| 1561 | - */ | |
| 1562 | -function bbp_get_reply_ancestor_id( $reply_id = 0 ) { | |
| 1532 | + // Validation | |
| 1533 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1534 | + if ( empty( $reply_id ) ) { | |
| 1535 | + return false; | |
| 1536 | + } | |
| 1563 | 1537 | |
| 1564 | - // Validation | |
| 1565 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1566 | - if ( empty( $reply_id ) ) { | |
| 1567 | - return false; | |
| 1568 | - } | |
| 1569 | - | |
| 1570 | - // Find highest reply ancestor | |
| 1571 | - $ancestor_id = $reply_id; | |
| 1572 | - | |
| 1573 | - // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition | |
| 1574 | - while ( $parent_id = bbp_get_reply_to( $ancestor_id ) ) { | |
| 1575 | - if ( empty( $parent_id ) || ( $parent_id === $ancestor_id ) || ( bbp_get_reply_topic_id( $reply_id ) === $parent_id ) || ( $parent_id === $reply_id ) ) { | |
| 1576 | - break; | |
| 1538 | + // Find highest reply ancestor | |
| 1539 | + $ancestor_id = $reply_id; | |
| 1540 | + while ( $parent_id = bbp_get_reply_to( $ancestor_id ) ) { | |
| 1541 | + if ( empty( $parent_id ) || ( $parent_id === $ancestor_id ) || ( bbp_get_reply_topic_id( $reply_id ) === $parent_id ) || ( $parent_id === $reply_id ) ) { | |
| 1542 | + break; | |
| 1543 | + } | |
| 1544 | + $ancestor_id = $parent_id; | |
| 1577 | 1545 | } |
| 1578 | 1546 | |
| 1579 | - $ancestor_id = $parent_id; | |
| 1547 | + return (int) $ancestor_id; | |
| 1580 | 1548 | } |
| 1581 | 1549 | |
| 1582 | - return (int) $ancestor_id; | |
| 1583 | -} | |
| 1584 | - | |
| 1585 | 1550 | /** |
| 1586 | - * Output the reply to id of a reply. | |
| 1551 | + * Output the reply to id of a reply | |
| 1587 | 1552 | * |
| 1588 | 1553 | * @since 2.4.0 bbPress (r4944) |
| 1589 | 1554 | * |
| 1590 | - * @param int $reply_id Optional. Reply id. | |
| 1555 | + * @param int $reply_id Optional. Reply id | |
| 1591 | 1556 | */ |
| 1592 | 1557 | function bbp_reply_to( $reply_id = 0 ) { |
| 1593 | 1558 | echo bbp_get_reply_to( $reply_id ); |
| 1594 | 1559 | } |
| 1595 | - | |
| 1596 | -/** | |
| 1597 | - * Return the reply to id of a reply. | |
| 1598 | - * | |
| 1599 | - * @since 2.4.0 bbPress (r4944) | |
| 1600 | - * | |
| 1601 | - * @param int $reply_id Optional. Reply id. | |
| 1602 | - * @return int The parent reply id of the reply. | |
| 1603 | - */ | |
| 1560 | + /** | |
| 1561 | + * Return the reply to id of a reply | |
| 1562 | + * | |
| 1563 | + * @since 2.4.0 bbPress (r4944) | |
| 1564 | + * | |
| 1565 | + * @param int $reply_id Optional. Reply id | |
| 1566 | + * @return int The parent reply id of the reply | |
| 1567 | + */ | |
| 1604 | 1568 | function bbp_get_reply_to( $reply_id = 0 ) { |
| 1605 | 1569 | |
| 1606 | 1570 | // Assume there is no reply_to set |
| 1607 | 1571 | $reply_to = 0; |
| @@ -1618,9 +1582,9 @@ | ||
| 1618 | 1582 | return (int) apply_filters( 'bbp_get_reply_to', $reply_to, $reply_id ); |
| 1619 | 1583 | } |
| 1620 | 1584 | |
| 1621 | 1585 | /** |
| 1622 | - * Output the link for the reply to. | |
| 1586 | + * Output the link for the reply to | |
| 1623 | 1587 | * |
| 1624 | 1588 | * @since 2.4.0 bbPress (r4944) |
| 1625 | 1589 | * |
| 1626 | 1590 | * @param array $args |
| @@ -1628,16 +1592,16 @@ | ||
| 1628 | 1592 | function bbp_reply_to_link( $args = array() ) { |
| 1629 | 1593 | echo bbp_get_reply_to_link( $args ); |
| 1630 | 1594 | } |
| 1631 | 1595 | |
| 1632 | -/** | |
| 1633 | - * Return the link for a reply to a reply. | |
| 1634 | - * | |
| 1635 | - * @since 2.4.0 bbPress (r4944) | |
| 1636 | - * | |
| 1637 | - * @param array $args Arguments. | |
| 1638 | - * @return string Link for a reply to a reply. | |
| 1639 | - */ | |
| 1596 | + /** | |
| 1597 | + * Return the link for a reply to a reply | |
| 1598 | + * | |
| 1599 | + * @since 2.4.0 bbPress (r4944) | |
| 1600 | + * | |
| 1601 | + * @param array $args Arguments | |
| 1602 | + * @return string Link for a reply to a reply | |
| 1603 | + */ | |
| 1640 | 1604 | function bbp_get_reply_to_link( $args = array() ) { |
| 1641 | 1605 | |
| 1642 | 1606 | // Parse arguments against default values |
| 1643 | 1607 | $r = bbp_parse_args( |
| @@ -1697,9 +1661,9 @@ | ||
| 1697 | 1661 | return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args ); |
| 1698 | 1662 | } |
| 1699 | 1663 | |
| 1700 | 1664 | /** |
| 1701 | - * Output the reply to a reply cancellation link. | |
| 1665 | + * Output the reply to a reply cancellation link | |
| 1702 | 1666 | * |
| 1703 | 1667 | * @since 2.4.0 bbPress (r4944) |
| 1704 | 1668 | */ |
| 1705 | 1669 | function bbp_cancel_reply_to_link( $text = '' ) { |
| @@ -1704,88 +1668,86 @@ | ||
| 1704 | 1668 | */ |
| 1705 | 1669 | function bbp_cancel_reply_to_link( $text = '' ) { |
| 1706 | 1670 | echo bbp_get_cancel_reply_to_link( $text ); |
| 1707 | 1671 | } |
| 1672 | + /** | |
| 1673 | + * Return the cancellation link for a reply to a reply | |
| 1674 | + * | |
| 1675 | + * @since 2.4.0 bbPress (r4944) | |
| 1676 | + * | |
| 1677 | + * @param string $text The cancel text | |
| 1678 | + * @return string The cancellation link | |
| 1679 | + */ | |
| 1680 | + function bbp_get_cancel_reply_to_link( $text = '' ) { | |
| 1708 | 1681 | |
| 1709 | -/** | |
| 1710 | - * Return the cancellation link for a reply to a reply. | |
| 1711 | - * | |
| 1712 | - * @since 2.4.0 bbPress (r4944) | |
| 1713 | - * | |
| 1714 | - * @param string $text The cancel text. | |
| 1715 | - * @return string The cancellation link. | |
| 1716 | - */ | |
| 1717 | -function bbp_get_cancel_reply_to_link( $text = '' ) { | |
| 1682 | + // Bail if not hierarchical or editing a reply | |
| 1683 | + if ( ! bbp_thread_replies() || bbp_is_reply_edit() ) { | |
| 1684 | + return; | |
| 1685 | + } | |
| 1718 | 1686 | |
| 1719 | - // Bail if not hierarchical or editing a reply | |
| 1720 | - if ( ! bbp_thread_replies() || bbp_is_reply_edit() ) { | |
| 1721 | - return; | |
| 1722 | - } | |
| 1687 | + // Set default text | |
| 1688 | + if ( empty( $text ) ) { | |
| 1689 | + $text = esc_html__( 'Cancel', 'bbpress' ); | |
| 1690 | + } | |
| 1723 | 1691 | |
| 1724 | - // Set default text | |
| 1725 | - if ( empty( $text ) ) { | |
| 1726 | - $text = esc_html__( 'Cancel', 'bbpress' ); | |
| 1727 | - } | |
| 1692 | + // Replying to... | |
| 1693 | + $reply_to = isset( $_GET['bbp_reply_to'] ) | |
| 1694 | + ? (int) $_GET['bbp_reply_to'] | |
| 1695 | + : 0; | |
| 1728 | 1696 | |
| 1729 | - // Replying to... | |
| 1730 | - $reply_to = isset( $_GET['bbp_reply_to'] ) | |
| 1731 | - ? (int) $_GET['bbp_reply_to'] | |
| 1732 | - : 0; | |
| 1697 | + // Set visibility | |
| 1698 | + $style = ! empty( $reply_to ) ? '' : ' style="display:none;"'; | |
| 1699 | + $link = remove_query_arg( array( 'bbp_reply_to', '_wpnonce' ) ) . "#post-{$reply_to}"; | |
| 1700 | + $retval = sprintf( '<a href="%1$s" id="bbp-cancel-reply-to-link"%2$s>%3$s</a>', esc_url( $link ), $style, esc_html( $text ) ); | |
| 1733 | 1701 | |
| 1734 | - // Set visibility | |
| 1735 | - $style = ! empty( $reply_to ) ? '' : ' style="display:none;"'; | |
| 1736 | - $link = remove_query_arg( array( 'bbp_reply_to', '_wpnonce' ) ) . "#post-{$reply_to}"; | |
| 1737 | - $retval = sprintf( '<a href="%1$s" id="bbp-cancel-reply-to-link"%2$s>%3$s</a>', esc_url( $link ), $style, esc_html( $text ) ); | |
| 1702 | + // Filter & return | |
| 1703 | + return apply_filters( 'bbp_get_cancel_reply_to_link', $retval, $link, $text ); | |
| 1704 | + } | |
| 1738 | 1705 | |
| 1739 | - // Filter & return | |
| 1740 | - return apply_filters( 'bbp_get_cancel_reply_to_link', $retval, $link, $text ); | |
| 1741 | -} | |
| 1742 | - | |
| 1743 | 1706 | /** |
| 1744 | - * Output the numeric position of a reply within a topic. | |
| 1707 | + * Output the numeric position of a reply within a topic | |
| 1745 | 1708 | * |
| 1746 | 1709 | * @since 2.0.0 bbPress (r2984) |
| 1747 | 1710 | * |
| 1748 | - * @param int $reply_id Optional. Reply id. | |
| 1749 | - * @param int $topic_id Optional. Topic id. | |
| 1711 | + * @param int $reply_id Optional. Reply id | |
| 1712 | + * @param int $topic_id Optional. Topic id | |
| 1750 | 1713 | */ |
| 1751 | 1714 | function bbp_reply_position( $reply_id = 0, $topic_id = 0 ) { |
| 1752 | 1715 | echo bbp_get_reply_position( $reply_id, $topic_id ); |
| 1753 | 1716 | } |
| 1717 | + /** | |
| 1718 | + * Return the numeric position of a reply within a topic | |
| 1719 | + * | |
| 1720 | + * @since 2.0.0 bbPress (r2984) | |
| 1721 | + * | |
| 1722 | + * @param int $reply_id Optional. Reply id | |
| 1723 | + * @param int $topic_id Optional. Topic id | |
| 1724 | + * @return int Reply position | |
| 1725 | + */ | |
| 1726 | + function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) { | |
| 1754 | 1727 | |
| 1755 | -/** | |
| 1756 | - * Return the numeric position of a reply within a topic. | |
| 1757 | - * | |
| 1758 | - * @since 2.0.0 bbPress (r2984) | |
| 1759 | - * | |
| 1760 | - * @param int $reply_id Optional. Reply id. | |
| 1761 | - * @param int $topic_id Optional. Topic id. | |
| 1762 | - * @return int Reply position. | |
| 1763 | - */ | |
| 1764 | -function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) { | |
| 1728 | + // Get required data | |
| 1729 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1730 | + $reply_position = get_post_field( 'menu_order', $reply_id ); | |
| 1765 | 1731 | |
| 1766 | - // Get required data | |
| 1767 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 1768 | - $reply_position = get_post_field( 'menu_order', $reply_id ); | |
| 1732 | + // Reply doesn't have a position so get the raw value | |
| 1733 | + if ( empty( $reply_position ) ) { | |
| 1769 | 1734 | |
| 1770 | - // Reply doesn't have a position so get the raw value | |
| 1771 | - if ( empty( $reply_position ) ) { | |
| 1735 | + // Get topic ID | |
| 1736 | + $topic_id = ! empty( $topic_id ) | |
| 1737 | + ? bbp_get_topic_id( $topic_id ) | |
| 1738 | + : bbp_get_reply_topic_id( $reply_id ); | |
| 1772 | 1739 | |
| 1773 | - // Get topic ID | |
| 1774 | - $topic_id = ! empty( $topic_id ) | |
| 1775 | - ? bbp_get_topic_id( $topic_id ) | |
| 1776 | - : bbp_get_reply_topic_id( $reply_id ); | |
| 1740 | + // Post is not the topic | |
| 1741 | + if ( $reply_id !== $topic_id ) { | |
| 1742 | + $reply_position = bbp_get_reply_position_raw( $reply_id, $topic_id ); | |
| 1777 | 1743 | |
| 1778 | - // Post is not the topic | |
| 1779 | - if ( $reply_id !== $topic_id ) { | |
| 1780 | - $reply_position = bbp_get_reply_position_raw( $reply_id, $topic_id ); | |
| 1744 | + // Update the reply position in the posts table so we'll never have | |
| 1745 | + // to hit the DB again. | |
| 1746 | + if ( ! empty( $reply_position ) ) { | |
| 1747 | + bbp_update_reply_position( $reply_id, $reply_position ); | |
| 1748 | + } | |
| 1781 | 1749 | |
| 1782 | - // Update the reply position in the posts table so we'll never have | |
| 1783 | - // to hit the DB again. | |
| 1784 | - if ( ! empty( $reply_position ) ) { | |
| 1785 | - bbp_update_reply_position( $reply_id, $reply_position ); | |
| 1786 | - } | |
| 1787 | - | |
| 1788 | 1750 | // Topic's position is always 0 |
| 1789 | 1751 | } else { |
| 1790 | 1752 | $reply_position = 0; |
| 1791 | 1753 | } |
| @@ -1790,21 +1752,21 @@ | ||
| 1790 | 1752 | $reply_position = 0; |
| 1791 | 1753 | } |
| 1792 | 1754 | } |
| 1793 | 1755 | |
| 1794 | - // Bump the position by one if the topic is included in the reply loop | |
| 1795 | - if ( ! bbp_show_lead_topic() ) { | |
| 1796 | - ++$reply_position; | |
| 1756 | + // Bump the position by one if the topic is included in the reply loop | |
| 1757 | + if ( ! bbp_show_lead_topic() ) { | |
| 1758 | + $reply_position++; | |
| 1759 | + } | |
| 1760 | + | |
| 1761 | + // Filter & return | |
| 1762 | + return (int) apply_filters( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id ); | |
| 1797 | 1763 | } |
| 1798 | 1764 | |
| 1799 | - // Filter & return | |
| 1800 | - return (int) apply_filters( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id ); | |
| 1801 | -} | |
| 1802 | - | |
| 1803 | 1765 | /** Reply Admin Links *********************************************************/ |
| 1804 | 1766 | |
| 1805 | 1767 | /** |
| 1806 | - * Output admin links for reply. | |
| 1768 | + * Output admin links for reply | |
| 1807 | 1769 | * |
| 1808 | 1770 | * @since 2.0.0 bbPress (r2667) |
| 1809 | 1771 | * |
| 1810 | 1772 | * @param array $args See {@link bbp_get_reply_admin_links()} |
| @@ -1811,24 +1773,23 @@ | ||
| 1811 | 1773 | */ |
| 1812 | 1774 | function bbp_reply_admin_links( $args = array() ) { |
| 1813 | 1775 | echo bbp_get_reply_admin_links( $args ); |
| 1814 | 1776 | } |
| 1815 | - | |
| 1816 | -/** | |
| 1817 | - * Return admin links for reply. | |
| 1818 | - * | |
| 1819 | - * @since 2.0.0 bbPress (r2667) | |
| 1820 | - * | |
| 1821 | - * @param array $args This function supports these arguments: | |
| 1822 | - * - id: Optional. Reply id | |
| 1823 | - * - before: HTML before the links. Defaults to | |
| 1824 | - * '<span class="bbp-admin-links">' | |
| 1825 | - * - after: HTML after the links. Defaults to '</span>' | |
| 1826 | - * - sep: Separator. Defaults to ' | ' | |
| 1827 | - * - links: Array of the links to display. By default, edit, trash, | |
| 1828 | - * spam, reply move, and topic split links are displayed | |
| 1829 | - * @return string Reply admin links. | |
| 1830 | - */ | |
| 1777 | + /** | |
| 1778 | + * Return admin links for reply | |
| 1779 | + * | |
| 1780 | + * @since 2.0.0 bbPress (r2667) | |
| 1781 | + * | |
| 1782 | + * @param array $args This function supports these arguments: | |
| 1783 | + * - id: Optional. Reply id | |
| 1784 | + * - before: HTML before the links. Defaults to | |
| 1785 | + * '<span class="bbp-admin-links">' | |
| 1786 | + * - after: HTML after the links. Defaults to '</span>' | |
| 1787 | + * - sep: Separator. Defaults to ' | ' | |
| 1788 | + * - links: Array of the links to display. By default, edit, trash, | |
| 1789 | + * spam, reply move, and topic split links are displayed | |
| 1790 | + * @return string Reply admin links | |
| 1791 | + */ | |
| 1831 | 1792 | function bbp_get_reply_admin_links( $args = array() ) { |
| 1832 | 1793 | |
| 1833 | 1794 | // Parse arguments against default values |
| 1834 | 1795 | $r = bbp_parse_args( |
| @@ -1893,30 +1854,30 @@ | ||
| 1893 | 1854 | return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args ); |
| 1894 | 1855 | } |
| 1895 | 1856 | |
| 1896 | 1857 | /** |
| 1897 | - * Output the edit link of the reply. | |
| 1858 | + * Output the edit link of the reply | |
| 1898 | 1859 | * |
| 1899 | 1860 | * @since 2.0.0 bbPress (r2740) |
| 1900 | 1861 | * |
| 1901 | - * @param array $args See {@link bbp_get_reply_edit_link()}. | |
| 1862 | + * @param array $args See {@link bbp_get_reply_edit_link()} | |
| 1902 | 1863 | */ |
| 1903 | 1864 | function bbp_reply_edit_link( $args = array() ) { |
| 1904 | 1865 | echo bbp_get_reply_edit_link( $args ); |
| 1905 | 1866 | } |
| 1906 | 1867 | |
| 1907 | -/** | |
| 1908 | - * Return the edit link of the reply. | |
| 1909 | - * | |
| 1910 | - * @since 2.0.0 bbPress (r2740) | |
| 1911 | - * | |
| 1912 | - * @param array $args This function supports these arguments: | |
| 1913 | - * - id: Reply id | |
| 1914 | - * - link_before: HTML before the link | |
| 1915 | - * - link_after: HTML after the link | |
| 1916 | - * - edit_text: Edit text. Defaults to 'Edit' | |
| 1917 | - * @return string Reply edit link. | |
| 1918 | - */ | |
| 1868 | + /** | |
| 1869 | + * Return the edit link of the reply | |
| 1870 | + * | |
| 1871 | + * @since 2.0.0 bbPress (r2740) | |
| 1872 | + * | |
| 1873 | + * @param array $args This function supports these arguments: | |
| 1874 | + * - id: Reply id | |
| 1875 | + * - link_before: HTML before the link | |
| 1876 | + * - link_after: HTML after the link | |
| 1877 | + * - edit_text: Edit text. Defaults to 'Edit' | |
| 1878 | + * @return string Reply edit link | |
| 1879 | + */ | |
| 1919 | 1880 | function bbp_get_reply_edit_link( $args = array() ) { |
| 1920 | 1881 | |
| 1921 | 1882 | // Parse arguments against default values |
| 1922 | 1883 | $r = bbp_parse_args( |
| @@ -1956,26 +1917,25 @@ | ||
| 1956 | 1917 | return apply_filters( 'bbp_get_reply_edit_link', $retval, $r, $args ); |
| 1957 | 1918 | } |
| 1958 | 1919 | |
| 1959 | 1920 | /** |
| 1960 | - * Output URL to the reply edit page. | |
| 1921 | + * Output URL to the reply edit page | |
| 1961 | 1922 | * |
| 1962 | 1923 | * @since 2.0.0 bbPress (r2753) |
| 1963 | 1924 | * |
| 1964 | - * @param int $reply_id Optional. Reply id. | |
| 1925 | + * @param int $reply_id Optional. Reply id | |
| 1965 | 1926 | */ |
| 1966 | 1927 | function bbp_reply_edit_url( $reply_id = 0 ) { |
| 1967 | 1928 | echo esc_url( bbp_get_reply_edit_url( $reply_id ) ); |
| 1968 | 1929 | } |
| 1969 | - | |
| 1970 | -/** | |
| 1971 | - * Return URL to the reply edit page. | |
| 1972 | - * | |
| 1973 | - * @since 2.0.0 bbPress (r2753) | |
| 1974 | - * | |
| 1975 | - * @param int $reply_id Optional. Reply id. | |
| 1976 | - * @return string Reply edit url. | |
| 1977 | - */ | |
| 1930 | + /** | |
| 1931 | + * Return URL to the reply edit page | |
| 1932 | + * | |
| 1933 | + * @since 2.0.0 bbPress (r2753) | |
| 1934 | + * | |
| 1935 | + * @param int $reply_id Optional. Reply id | |
| 1936 | + * @return string Reply edit url | |
| 1937 | + */ | |
| 1978 | 1938 | function bbp_get_reply_edit_url( $reply_id = 0 ) { |
| 1979 | 1939 | |
| 1980 | 1940 | // Bail if no reply |
| 1981 | 1941 | $reply = bbp_get_reply( $reply_id ); |
| @@ -2009,33 +1969,33 @@ | ||
| 2009 | 1969 | return apply_filters( 'bbp_get_reply_edit_url', $url, $reply_id ); |
| 2010 | 1970 | } |
| 2011 | 1971 | |
| 2012 | 1972 | /** |
| 2013 | - * Output the trash link of the reply. | |
| 1973 | + * Output the trash link of the reply | |
| 2014 | 1974 | * |
| 2015 | 1975 | * @since 2.0.0 bbPress (r2740) |
| 2016 | 1976 | * |
| 2017 | - * @param array $args See {@link bbp_get_reply_trash_link()}. | |
| 1977 | + * @param array $args See {@link bbp_get_reply_trash_link()} | |
| 2018 | 1978 | */ |
| 2019 | 1979 | function bbp_reply_trash_link( $args = array() ) { |
| 2020 | 1980 | echo bbp_get_reply_trash_link( $args ); |
| 2021 | 1981 | } |
| 2022 | 1982 | |
| 2023 | -/** | |
| 2024 | - * Return the trash link of the reply. | |
| 2025 | - * | |
| 2026 | - * @since 2.0.0 bbPress (r2740) | |
| 2027 | - * | |
| 2028 | - * @param array $args This function supports these arguments: | |
| 2029 | - * - id: Reply id | |
| 2030 | - * - link_before: HTML before the link | |
| 2031 | - * - link_after: HTML after the link | |
| 2032 | - * - sep: Separator | |
| 2033 | - * - trash_text: Trash text | |
| 2034 | - * - restore_text: Restore text | |
| 2035 | - * - delete_text: Delete text | |
| 2036 | - * @return string Reply trash link. | |
| 2037 | - */ | |
| 1983 | + /** | |
| 1984 | + * Return the trash link of the reply | |
| 1985 | + * | |
| 1986 | + * @since 2.0.0 bbPress (r2740) | |
| 1987 | + * | |
| 1988 | + * @param array $args This function supports these arguments: | |
| 1989 | + * - id: Reply id | |
| 1990 | + * - link_before: HTML before the link | |
| 1991 | + * - link_after: HTML after the link | |
| 1992 | + * - sep: Separator | |
| 1993 | + * - trash_text: Trash text | |
| 1994 | + * - restore_text: Restore text | |
| 1995 | + * - delete_text: Delete text | |
| 1996 | + * @return string Reply trash link | |
| 1997 | + */ | |
| 2038 | 1998 | function bbp_get_reply_trash_link( $args = array() ) { |
| 2039 | 1999 | |
| 2040 | 2000 | // Parse arguments against default values |
| 2041 | 2001 | $r = bbp_parse_args( |
| @@ -2099,31 +2059,31 @@ | ||
| 2099 | 2059 | return apply_filters( 'bbp_get_reply_trash_link', $retval, $r, $args ); |
| 2100 | 2060 | } |
| 2101 | 2061 | |
| 2102 | 2062 | /** |
| 2103 | - * Output the spam link of the reply. | |
| 2063 | + * Output the spam link of the reply | |
| 2104 | 2064 | * |
| 2105 | 2065 | * @since 2.0.0 bbPress (r2740) |
| 2106 | 2066 | * |
| 2107 | - * @param array $args See {@link bbp_get_reply_spam_link()}. | |
| 2067 | + * @param array $args See {@link bbp_get_reply_spam_link()} | |
| 2108 | 2068 | */ |
| 2109 | 2069 | function bbp_reply_spam_link( $args = array() ) { |
| 2110 | 2070 | echo bbp_get_reply_spam_link( $args ); |
| 2111 | 2071 | } |
| 2112 | 2072 | |
| 2113 | -/** | |
| 2114 | - * Return the spam link of the reply. | |
| 2115 | - * | |
| 2116 | - * @since 2.0.0 bbPress (r2740) | |
| 2117 | - * | |
| 2118 | - * @param array $args This function supports these arguments: | |
| 2119 | - * - id: Reply id | |
| 2120 | - * - link_before: HTML before the link | |
| 2121 | - * - link_after: HTML after the link | |
| 2122 | - * - spam_text: Spam text | |
| 2123 | - * - unspam_text: Unspam text | |
| 2124 | - * @return string Reply spam link. | |
| 2125 | - */ | |
| 2073 | + /** | |
| 2074 | + * Return the spam link of the reply | |
| 2075 | + * | |
| 2076 | + * @since 2.0.0 bbPress (r2740) | |
| 2077 | + * | |
| 2078 | + * @param array $args This function supports these arguments: | |
| 2079 | + * - id: Reply id | |
| 2080 | + * - link_before: HTML before the link | |
| 2081 | + * - link_after: HTML after the link | |
| 2082 | + * - spam_text: Spam text | |
| 2083 | + * - unspam_text: Unspam text | |
| 2084 | + * @return string Reply spam link | |
| 2085 | + */ | |
| 2126 | 2086 | function bbp_get_reply_spam_link( $args = array() ) { |
| 2127 | 2087 | |
| 2128 | 2088 | // Parse arguments against default values |
| 2129 | 2089 | $r = bbp_parse_args( |
| @@ -2163,35 +2123,35 @@ | ||
| 2163 | 2123 | return apply_filters( 'bbp_get_reply_spam_link', $retval, $r, $args ); |
| 2164 | 2124 | } |
| 2165 | 2125 | |
| 2166 | 2126 | /** |
| 2167 | - * Move reply link. | |
| 2127 | + * Move reply link | |
| 2168 | 2128 | * |
| 2169 | - * Output the move link of the reply. | |
| 2129 | + * Output the move link of the reply | |
| 2170 | 2130 | * |
| 2171 | 2131 | * @since 2.3.0 bbPress (r4521) |
| 2172 | 2132 | * |
| 2173 | - * @param array $args See {@link bbp_get_reply_move_link()}. | |
| 2133 | + * @param array $args See {@link bbp_get_reply_move_link()} | |
| 2174 | 2134 | */ |
| 2175 | 2135 | function bbp_reply_move_link( $args = array() ) { |
| 2176 | 2136 | echo bbp_get_reply_move_link( $args ); |
| 2177 | 2137 | } |
| 2178 | 2138 | |
| 2179 | -/** | |
| 2180 | - * Get move reply link. | |
| 2181 | - * | |
| 2182 | - * Return the move link of the reply. | |
| 2183 | - * | |
| 2184 | - * @since 2.3.0 bbPress (r4521) | |
| 2185 | - * | |
| 2186 | - * @param array $args This function supports these arguments: | |
| 2187 | - * - id: Reply id | |
| 2188 | - * - link_before: HTML before the link | |
| 2189 | - * - link_after: HTML after the link | |
| 2190 | - * - move_text: Move text | |
| 2191 | - * - move_title: Move title attribute | |
| 2192 | - * @return string Reply move link. | |
| 2193 | - */ | |
| 2139 | + /** | |
| 2140 | + * Get move reply link | |
| 2141 | + * | |
| 2142 | + * Return the move link of the reply | |
| 2143 | + * | |
| 2144 | + * @since 2.3.0 bbPress (r4521) | |
| 2145 | + * | |
| 2146 | + * @param array $args This function supports these arguments: | |
| 2147 | + * - id: Reply id | |
| 2148 | + * - link_before: HTML before the link | |
| 2149 | + * - link_after: HTML after the link | |
| 2150 | + * - move_text: Move text | |
| 2151 | + * - move_title: Move title attribute | |
| 2152 | + * @return string Reply move link | |
| 2153 | + */ | |
| 2194 | 2154 | function bbp_get_reply_move_link( $args = array() ) { |
| 2195 | 2155 | |
| 2196 | 2156 | // Parse arguments against default values |
| 2197 | 2157 | $r = bbp_parse_args( |
| @@ -2229,35 +2189,35 @@ | ||
| 2229 | 2189 | return apply_filters( 'bbp_get_reply_move_link', $retval, $r, $args ); |
| 2230 | 2190 | } |
| 2231 | 2191 | |
| 2232 | 2192 | /** |
| 2233 | - * Split topic link. | |
| 2193 | + * Split topic link | |
| 2234 | 2194 | * |
| 2235 | - * Output the split link of the topic (but is bundled with each reply). | |
| 2195 | + * Output the split link of the topic (but is bundled with each reply) | |
| 2236 | 2196 | * |
| 2237 | 2197 | * @since 2.0.0 bbPress (r2756) |
| 2238 | 2198 | * |
| 2239 | - * @param array $args See {@link bbp_get_topic_split_link()}. | |
| 2199 | + * @param array $args See {@link bbp_get_topic_split_link()} | |
| 2240 | 2200 | */ |
| 2241 | 2201 | function bbp_topic_split_link( $args = array() ) { |
| 2242 | 2202 | echo bbp_get_topic_split_link( $args ); |
| 2243 | 2203 | } |
| 2244 | 2204 | |
| 2245 | -/** | |
| 2246 | - * Get split topic link. | |
| 2247 | - * | |
| 2248 | - * Return the split link of the topic (but is bundled with each reply). | |
| 2249 | - * | |
| 2250 | - * @since 2.0.0 bbPress (r2756) | |
| 2251 | - * | |
| 2252 | - * @param array $args This function supports these arguments: | |
| 2253 | - * - id: Reply id | |
| 2254 | - * - link_before: HTML before the link | |
| 2255 | - * - link_after: HTML after the link | |
| 2256 | - * - split_text: Split text | |
| 2257 | - * - split_title: Split title attribute | |
| 2258 | - * @return string Topic split link. | |
| 2259 | - */ | |
| 2205 | + /** | |
| 2206 | + * Get split topic link | |
| 2207 | + * | |
| 2208 | + * Return the split link of the topic (but is bundled with each reply) | |
| 2209 | + * | |
| 2210 | + * @since 2.0.0 bbPress (r2756) | |
| 2211 | + * | |
| 2212 | + * @param array $args This function supports these arguments: | |
| 2213 | + * - id: Reply id | |
| 2214 | + * - link_before: HTML before the link | |
| 2215 | + * - link_after: HTML after the link | |
| 2216 | + * - split_text: Split text | |
| 2217 | + * - split_title: Split title attribute | |
| 2218 | + * @return string Topic split link | |
| 2219 | + */ | |
| 2260 | 2220 | function bbp_get_topic_split_link( $args = array() ) { |
| 2261 | 2221 | |
| 2262 | 2222 | // Parse arguments against default values |
| 2263 | 2223 | $r = bbp_parse_args( |
| @@ -2295,32 +2255,32 @@ | ||
| 2295 | 2255 | return apply_filters( 'bbp_get_topic_split_link', $retval, $r, $args ); |
| 2296 | 2256 | } |
| 2297 | 2257 | |
| 2298 | 2258 | /** |
| 2299 | - * Output the approve link of the reply. | |
| 2259 | + * Output the approve link of the reply | |
| 2300 | 2260 | * |
| 2301 | 2261 | * @since 2.6.0 bbPress (r5507) |
| 2302 | 2262 | * |
| 2303 | - * @param array $args See {@link bbp_get_reply_approve_link()}. | |
| 2263 | + * @param array $args See {@link bbp_get_reply_approve_link()} | |
| 2304 | 2264 | */ |
| 2305 | 2265 | function bbp_reply_approve_link( $args = array() ) { |
| 2306 | 2266 | echo bbp_get_reply_approve_link( $args ); |
| 2307 | 2267 | } |
| 2308 | 2268 | |
| 2309 | -/** | |
| 2310 | - * Return the approve link of the reply. | |
| 2311 | - * | |
| 2312 | - * @since 2.6.0 bbPress (r5507) | |
| 2313 | - * | |
| 2314 | - * @param array $args This function supports these args: | |
| 2315 | - * - id: Optional. Reply id | |
| 2316 | - * - link_before: Before the link | |
| 2317 | - * - link_after: After the link | |
| 2318 | - * - sep: Separator between links | |
| 2319 | - * - approve_text: Approve text | |
| 2320 | - * - unapprove_text: Unapprove text | |
| 2321 | - * @return string Reply approve link. | |
| 2322 | - */ | |
| 2269 | + /** | |
| 2270 | + * Return the approve link of the reply | |
| 2271 | + * | |
| 2272 | + * @since 2.6.0 bbPress (r5507) | |
| 2273 | + * | |
| 2274 | + * @param array $args This function supports these args: | |
| 2275 | + * - id: Optional. Reply id | |
| 2276 | + * - link_before: Before the link | |
| 2277 | + * - link_after: After the link | |
| 2278 | + * - sep: Separator between links | |
| 2279 | + * - approve_text: Approve text | |
| 2280 | + * - unapprove_text: Unapprove text | |
| 2281 | + * @return string Reply approve link | |
| 2282 | + */ | |
| 2323 | 2283 | function bbp_get_reply_approve_link( $args = array() ) { |
| 2324 | 2284 | |
| 2325 | 2285 | // Parse arguments against default values |
| 2326 | 2286 | $r = bbp_parse_args( |
| @@ -2361,86 +2321,85 @@ | ||
| 2361 | 2321 | return apply_filters( 'bbp_get_reply_approve_link', $retval, $r, $args ); |
| 2362 | 2322 | } |
| 2363 | 2323 | |
| 2364 | 2324 | /** |
| 2365 | - * Output the row class of a reply. | |
| 2325 | + * Output the row class of a reply | |
| 2366 | 2326 | * |
| 2367 | 2327 | * @since 2.0.0 bbPress (r2678) |
| 2368 | 2328 | * |
| 2369 | - * @param int $reply_id Optional. Reply ID. | |
| 2370 | - * @param array Extra classes you can pass when calling this function. | |
| 2329 | + * @param int $reply_id Optional. Reply ID | |
| 2330 | + * @param array Extra classes you can pass when calling this function | |
| 2371 | 2331 | */ |
| 2372 | 2332 | function bbp_reply_class( $reply_id = 0, $classes = array() ) { |
| 2373 | 2333 | echo bbp_get_reply_class( $reply_id, $classes ); |
| 2374 | 2334 | } |
| 2335 | + /** | |
| 2336 | + * Return the row class of a reply | |
| 2337 | + * | |
| 2338 | + * @since 2.0.0 bbPress (r2678) | |
| 2339 | + * | |
| 2340 | + * @param int $reply_id Optional. Reply ID | |
| 2341 | + * @param array Extra classes you can pass when calling this function | |
| 2342 | + * @return string Row class of the reply | |
| 2343 | + */ | |
| 2344 | + function bbp_get_reply_class( $reply_id = 0, $classes = array() ) { | |
| 2345 | + $bbp = bbpress(); | |
| 2346 | + $reply_id = bbp_get_reply_id( $reply_id ); | |
| 2347 | + $topic_id = bbp_get_reply_topic_id( $reply_id ); | |
| 2348 | + $forum_id = bbp_get_reply_forum_id( $reply_id ); | |
| 2349 | + $author_id = bbp_get_reply_author_id( $reply_id ); | |
| 2350 | + $reply_pos = bbp_get_reply_position( $reply_id, true ); | |
| 2351 | + $classes = array_filter( (array) $classes ); | |
| 2352 | + $count = isset( $bbp->reply_query->current_post ) | |
| 2353 | + ? (int) $bbp->reply_query->current_post | |
| 2354 | + : 1; | |
| 2375 | 2355 | |
| 2376 | -/** | |
| 2377 | - * Return the row class of a reply. | |
| 2378 | - * | |
| 2379 | - * @since 2.0.0 bbPress (r2678) | |
| 2380 | - * | |
| 2381 | - * @param int $reply_id Optional. Reply ID. | |
| 2382 | - * @param array Extra classes you can pass when calling this function. | |
| 2383 | - * @return string Row class of the reply. | |
| 2384 | - */ | |
| 2385 | -function bbp_get_reply_class( $reply_id = 0, $classes = array() ) { | |
| 2386 | - $bbp = bbpress(); | |
| 2387 | - $reply_id = bbp_get_reply_id( $reply_id ); | |
| 2388 | - $topic_id = bbp_get_reply_topic_id( $reply_id ); | |
| 2389 | - $forum_id = bbp_get_reply_forum_id( $reply_id ); | |
| 2390 | - $author_id = bbp_get_reply_author_id( $reply_id ); | |
| 2391 | - $reply_pos = bbp_get_reply_position( $reply_id, true ); | |
| 2392 | - $classes = array_filter( (array) $classes ); | |
| 2393 | - $count = isset( $bbp->reply_query->current_post ) | |
| 2394 | - ? (int) $bbp->reply_query->current_post | |
| 2395 | - : 1; | |
| 2356 | + // Stripes | |
| 2357 | + $even_odd = ( $count % 2 ) | |
| 2358 | + ? 'even' | |
| 2359 | + : 'odd'; | |
| 2396 | 2360 | |
| 2397 | - // Stripes | |
| 2398 | - $even_odd = ( $count % 2 ) | |
| 2399 | - ? 'even' | |
| 2400 | - : 'odd'; | |
| 2361 | + // Forum moderator replied to topic | |
| 2362 | + $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id ) | |
| 2363 | + ? 'forum-mod' | |
| 2364 | + : ''; | |
| 2401 | 2365 | |
| 2402 | - // Forum moderator replied to topic | |
| 2403 | - $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id ) | |
| 2404 | - ? 'forum-mod' | |
| 2405 | - : ''; | |
| 2366 | + // Topic author replied to others | |
| 2367 | + $topic_author = ( bbp_get_topic_author_id( $topic_id ) === $author_id ) | |
| 2368 | + ? 'topic-author' | |
| 2369 | + : ''; | |
| 2406 | 2370 | |
| 2407 | - // Topic author replied to others | |
| 2408 | - $topic_author = ( bbp_get_topic_author_id( $topic_id ) === $author_id ) | |
| 2409 | - ? 'topic-author' | |
| 2410 | - : ''; | |
| 2371 | + // Get reply classes | |
| 2372 | + $reply_classes = array( | |
| 2373 | + 'loop-item-' . $count, | |
| 2374 | + 'user-id-' . $author_id, | |
| 2375 | + 'bbp-parent-forum-' . $forum_id, | |
| 2376 | + 'bbp-parent-topic-' . $topic_id, | |
| 2377 | + 'bbp-reply-position-' . $reply_pos, | |
| 2378 | + $even_odd, | |
| 2379 | + $topic_author, | |
| 2380 | + $forum_moderator | |
| 2381 | + ); | |
| 2411 | 2382 | |
| 2412 | - // Get reply classes | |
| 2413 | - $reply_classes = array( | |
| 2414 | - 'loop-item-' . $count, | |
| 2415 | - 'user-id-' . $author_id, | |
| 2416 | - 'bbp-parent-forum-' . $forum_id, | |
| 2417 | - 'bbp-parent-topic-' . $topic_id, | |
| 2418 | - 'bbp-reply-position-' . $reply_pos, | |
| 2419 | - $even_odd, | |
| 2420 | - $topic_author, | |
| 2421 | - $forum_moderator | |
| 2422 | - ); | |
| 2383 | + // Run the topic classes through the post-class filters, which also | |
| 2384 | + // handles the escaping of each individual class. | |
| 2385 | + $post_classes = get_post_class( array_merge( $classes, $reply_classes ), $reply_id ); | |
| 2423 | 2386 | |
| 2424 | - // Run the topic classes through the post-class filters, which also | |
| 2425 | - // handles the escaping of each individual class. | |
| 2426 | - $post_classes = get_post_class( array_merge( $classes, $reply_classes ), $reply_id ); | |
| 2387 | + // Filter | |
| 2388 | + $new_classes = apply_filters( 'bbp_get_reply_class', $post_classes, $reply_id, $classes ); | |
| 2427 | 2389 | |
| 2428 | - // Filter | |
| 2429 | - $new_classes = apply_filters( 'bbp_get_reply_class', $post_classes, $reply_id, $classes ); | |
| 2390 | + // Return | |
| 2391 | + return 'class="' . implode( ' ', $new_classes ) . '"'; | |
| 2392 | + } | |
| 2430 | 2393 | |
| 2431 | - // Return | |
| 2432 | - return 'class="' . implode( ' ', $new_classes ) . '"'; | |
| 2433 | -} | |
| 2434 | - | |
| 2435 | 2394 | /** Pagination ****************************************************************/ |
| 2436 | 2395 | |
| 2437 | 2396 | /** |
| 2438 | - * Return the base URL used inside of pagination links. | |
| 2397 | + * Return the base URL used inside of pagination links | |
| 2439 | 2398 | * |
| 2440 | 2399 | * @since 2.6.0 bbPress (r6679) |
| 2441 | 2400 | * |
| 2442 | - * @param int $topic_id Topic id. | |
| 2401 | + * @param int $topic_id | |
| 2443 | 2402 | * @return string |
| 2444 | 2403 | */ |
| 2445 | 2404 | function bbp_get_replies_pagination_base( $topic_id = 0 ) { |
| 2446 | 2405 | |
| @@ -2475,9 +2434,9 @@ | ||
| 2475 | 2434 | return apply_filters( 'bbp_get_replies_pagination_base', $base, $topic_id ); |
| 2476 | 2435 | } |
| 2477 | 2436 | |
| 2478 | 2437 | /** |
| 2479 | - * Output the topic pagination count. | |
| 2438 | + * Output the topic pagination count | |
| 2480 | 2439 | * |
| 2481 | 2440 | * The results are unescaped by design, to allow them to be filtered freely via |
| 2482 | 2441 | * the 'bbp_get_topic_pagination_count' filter. |
| 2483 | 2442 | * |
| @@ -2486,16 +2445,15 @@ | ||
| 2486 | 2445 | */ |
| 2487 | 2446 | function bbp_topic_pagination_count() { |
| 2488 | 2447 | echo bbp_get_topic_pagination_count(); |
| 2489 | 2448 | } |
| 2490 | - | |
| 2491 | -/** | |
| 2492 | - * Return the topic pagination count. | |
| 2493 | - * | |
| 2494 | - * @since 2.0.0 bbPress (r2519) | |
| 2495 | - * | |
| 2496 | - * @return string Topic pagination count. | |
| 2497 | - */ | |
| 2449 | + /** | |
| 2450 | + * Return the topic pagination count | |
| 2451 | + * | |
| 2452 | + * @since 2.0.0 bbPress (r2519) | |
| 2453 | + * | |
| 2454 | + * @return string Topic pagination count | |
| 2455 | + */ | |
| 2498 | 2456 | function bbp_get_topic_pagination_count() { |
| 2499 | 2457 | $bbp = bbpress(); |
| 2500 | 2458 | |
| 2501 | 2459 | // Define local variable(s) |
| @@ -2561,9 +2519,9 @@ | ||
| 2561 | 2519 | return apply_filters( 'bbp_get_topic_pagination_count', $retstr ); |
| 2562 | 2520 | } |
| 2563 | 2521 | |
| 2564 | 2522 | /** |
| 2565 | - * Output topic pagination links. | |
| 2523 | + * Output topic pagination links | |
| 2566 | 2524 | * |
| 2567 | 2525 | * @since 2.0.0 bbPress (r2519) |
| 2568 | 2526 | */ |
| 2569 | 2527 | function bbp_topic_pagination_links() { |
| @@ -2568,31 +2526,30 @@ | ||
| 2568 | 2526 | */ |
| 2569 | 2527 | function bbp_topic_pagination_links() { |
| 2570 | 2528 | echo bbp_get_topic_pagination_links(); |
| 2571 | 2529 | } |
| 2530 | + /** | |
| 2531 | + * Return topic pagination links | |
| 2532 | + * | |
| 2533 | + * @since 2.0.0 bbPress (r2519) | |
| 2534 | + * | |
| 2535 | + * @return string Topic pagination links | |
| 2536 | + */ | |
| 2537 | + function bbp_get_topic_pagination_links() { | |
| 2538 | + $bbp = bbpress(); | |
| 2572 | 2539 | |
| 2573 | -/** | |
| 2574 | - * Return topic pagination links. | |
| 2575 | - * | |
| 2576 | - * @since 2.0.0 bbPress (r2519) | |
| 2577 | - * | |
| 2578 | - * @return string Topic pagination links. | |
| 2579 | - */ | |
| 2580 | -function bbp_get_topic_pagination_links() { | |
| 2581 | - $bbp = bbpress(); | |
| 2540 | + if ( ! isset( $bbp->reply_query->pagination_links ) || empty( $bbp->reply_query->pagination_links ) ) { | |
| 2541 | + return false; | |
| 2542 | + } | |
| 2582 | 2543 | |
| 2583 | - if ( ! isset( $bbp->reply_query->pagination_links ) || empty( $bbp->reply_query->pagination_links ) ) { | |
| 2584 | - return false; | |
| 2544 | + // Filter & return | |
| 2545 | + return apply_filters( 'bbp_get_topic_pagination_links', $bbp->reply_query->pagination_links ); | |
| 2585 | 2546 | } |
| 2586 | 2547 | |
| 2587 | - // Filter & return | |
| 2588 | - return apply_filters( 'bbp_get_topic_pagination_links', $bbp->reply_query->pagination_links ); | |
| 2589 | -} | |
| 2590 | - | |
| 2591 | 2548 | /** Forms *********************************************************************/ |
| 2592 | 2549 | |
| 2593 | 2550 | /** |
| 2594 | - * Output the value of reply content field. | |
| 2551 | + * Output the value of reply content field | |
| 2595 | 2552 | * |
| 2596 | 2553 | * @since 2.0.0 bbPress (r3130) |
| 2597 | 2554 | */ |
| 2598 | 2555 | function bbp_form_reply_content() { |
| @@ -2597,37 +2554,36 @@ | ||
| 2597 | 2554 | */ |
| 2598 | 2555 | function bbp_form_reply_content() { |
| 2599 | 2556 | echo bbp_get_form_reply_content(); |
| 2600 | 2557 | } |
| 2558 | + /** | |
| 2559 | + * Return the value of reply content field | |
| 2560 | + * | |
| 2561 | + * @since 2.0.0 bbPress (r3130) | |
| 2562 | + * | |
| 2563 | + * @return string Value of reply content field | |
| 2564 | + */ | |
| 2565 | + function bbp_get_form_reply_content() { | |
| 2601 | 2566 | |
| 2602 | -/** | |
| 2603 | - * Return the value of reply content field. | |
| 2604 | - * | |
| 2605 | - * @since 2.0.0 bbPress (r3130) | |
| 2606 | - * | |
| 2607 | - * @return string Value of reply content field. | |
| 2608 | - */ | |
| 2609 | -function bbp_get_form_reply_content() { | |
| 2567 | + // Get _POST data | |
| 2568 | + if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_content'] ) ) { | |
| 2569 | + $reply_content = wp_unslash( $_POST['bbp_reply_content'] ); | |
| 2610 | 2570 | |
| 2611 | - // Get _POST data | |
| 2612 | - if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_content'] ) ) { | |
| 2613 | - $reply_content = wp_unslash( $_POST['bbp_reply_content'] ); | |
| 2571 | + // Get edit data | |
| 2572 | + } elseif ( bbp_is_reply_edit() ) { | |
| 2573 | + $reply_content = bbp_get_global_post_field( 'post_content', 'raw' ); | |
| 2614 | 2574 | |
| 2615 | - // Get edit data | |
| 2616 | - } elseif ( bbp_is_reply_edit() ) { | |
| 2617 | - $reply_content = bbp_get_global_post_field( 'post_content', 'raw' ); | |
| 2575 | + // No data | |
| 2576 | + } else { | |
| 2577 | + $reply_content = ''; | |
| 2578 | + } | |
| 2618 | 2579 | |
| 2619 | - // No data | |
| 2620 | - } else { | |
| 2621 | - $reply_content = ''; | |
| 2580 | + // Filter & return | |
| 2581 | + return apply_filters( 'bbp_get_form_reply_content', $reply_content ); | |
| 2622 | 2582 | } |
| 2623 | 2583 | |
| 2624 | - // Filter & return | |
| 2625 | - return apply_filters( 'bbp_get_form_reply_content', $reply_content ); | |
| 2626 | -} | |
| 2627 | - | |
| 2628 | 2584 | /** |
| 2629 | - * Output the value of the reply to field. | |
| 2585 | + * Output the value of the reply to field | |
| 2630 | 2586 | * |
| 2631 | 2587 | * @since 2.4.0 bbPress (r4944) |
| 2632 | 2588 | */ |
| 2633 | 2589 | function bbp_form_reply_to() { |
| @@ -2633,34 +2589,34 @@ | ||
| 2633 | 2589 | function bbp_form_reply_to() { |
| 2634 | 2590 | echo bbp_get_form_reply_to(); |
| 2635 | 2591 | } |
| 2636 | 2592 | |
| 2637 | -/** | |
| 2638 | - * Return the value of reply to field. | |
| 2639 | - * | |
| 2640 | - * @since 2.4.0 bbPress (r4944) | |
| 2641 | - * | |
| 2642 | - * @return string Value of reply to field. | |
| 2643 | - */ | |
| 2644 | -function bbp_get_form_reply_to() { | |
| 2593 | + /** | |
| 2594 | + * Return the value of reply to field | |
| 2595 | + * | |
| 2596 | + * @since 2.4.0 bbPress (r4944) | |
| 2597 | + * | |
| 2598 | + * @return string Value of reply to field | |
| 2599 | + */ | |
| 2600 | + function bbp_get_form_reply_to() { | |
| 2645 | 2601 | |
| 2646 | - // Set initial value | |
| 2647 | - $reply_to = 0; | |
| 2602 | + // Set initial value | |
| 2603 | + $reply_to = 0; | |
| 2648 | 2604 | |
| 2649 | - // Get $_REQUEST data | |
| 2650 | - if ( isset( $_REQUEST['bbp_reply_to'] ) ) { | |
| 2651 | - $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] ); | |
| 2652 | - } | |
| 2605 | + // Get $_REQUEST data | |
| 2606 | + if ( isset( $_REQUEST['bbp_reply_to'] ) ) { | |
| 2607 | + $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] ); | |
| 2608 | + } | |
| 2653 | 2609 | |
| 2654 | - // If empty, get from meta | |
| 2655 | - if ( empty( $reply_to ) ) { | |
| 2656 | - $reply_to = bbp_get_reply_to(); | |
| 2610 | + // If empty, get from meta | |
| 2611 | + if ( empty( $reply_to ) ) { | |
| 2612 | + $reply_to = bbp_get_reply_to(); | |
| 2613 | + } | |
| 2614 | + | |
| 2615 | + // Filter & return | |
| 2616 | + return apply_filters( 'bbp_get_form_reply_to', $reply_to ); | |
| 2657 | 2617 | } |
| 2658 | 2618 | |
| 2659 | - // Filter & return | |
| 2660 | - return apply_filters( 'bbp_get_form_reply_to', $reply_to ); | |
| 2661 | -} | |
| 2662 | - | |
| 2663 | 2619 | /** |
| 2664 | 2620 | * Output a select box allowing to pick which reply an existing hierarchical |
| 2665 | 2621 | * reply belongs to. |
| 2666 | 2622 | * |
| @@ -2665,23 +2621,22 @@ | ||
| 2665 | 2621 | * reply belongs to. |
| 2666 | 2622 | * |
| 2667 | 2623 | * @since 2.6.0 bbPress (r5387) |
| 2668 | 2624 | * |
| 2669 | - * @param int $reply_id Reply id. | |
| 2625 | + * @param int $reply_id | |
| 2670 | 2626 | */ |
| 2671 | 2627 | function bbp_reply_to_dropdown( $reply_id = 0 ) { |
| 2672 | 2628 | echo bbp_get_reply_to_dropdown( $reply_id ); |
| 2673 | 2629 | } |
| 2674 | - | |
| 2675 | -/** | |
| 2676 | - * Return a select box allowing to pick which topic/reply a reply belongs. | |
| 2677 | - * | |
| 2678 | - * @since 2.6.0 bbPress (r5387) | |
| 2679 | - * | |
| 2680 | - * @param int $reply_id Reply id. | |
| 2681 | - * | |
| 2682 | - * @return string The dropdown. | |
| 2683 | - */ | |
| 2630 | + /** | |
| 2631 | + * Return a select box allowing to pick which topic/reply a reply belongs. | |
| 2632 | + * | |
| 2633 | + * @since 2.6.0 bbPress (r5387) | |
| 2634 | + * | |
| 2635 | + * @param int $reply_id | |
| 2636 | + * | |
| 2637 | + * @return string The dropdown | |
| 2638 | + */ | |
| 2684 | 2639 | function bbp_get_reply_to_dropdown( $reply_id = 0 ) { |
| 2685 | 2640 | |
| 2686 | 2641 | // Validate the reply data |
| 2687 | 2642 | $reply_id = bbp_get_reply_id( $reply_id ); |
| @@ -2743,9 +2698,9 @@ | ||
| 2743 | 2698 | return apply_filters( 'bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id ); |
| 2744 | 2699 | } |
| 2745 | 2700 | |
| 2746 | 2701 | /** |
| 2747 | - * Output checked value of reply log edit field. | |
| 2702 | + * Output checked value of reply log edit field | |
| 2748 | 2703 | * |
| 2749 | 2704 | * @since 2.0.0 bbPress (r3130) |
| 2750 | 2705 | */ |
| 2751 | 2706 | function bbp_form_reply_log_edit() { |
| @@ -2750,36 +2705,35 @@ | ||
| 2750 | 2705 | */ |
| 2751 | 2706 | function bbp_form_reply_log_edit() { |
| 2752 | 2707 | echo bbp_get_form_reply_log_edit(); |
| 2753 | 2708 | } |
| 2709 | + /** | |
| 2710 | + * Return checked value of reply log edit field | |
| 2711 | + * | |
| 2712 | + * @since 2.0.0 bbPress (r3130) | |
| 2713 | + * | |
| 2714 | + * @return string Reply log edit checked value | |
| 2715 | + */ | |
| 2716 | + function bbp_get_form_reply_log_edit() { | |
| 2754 | 2717 | |
| 2755 | -/** | |
| 2756 | - * Return checked value of reply log edit field. | |
| 2757 | - * | |
| 2758 | - * @since 2.0.0 bbPress (r3130) | |
| 2759 | - * | |
| 2760 | - * @return string Reply log edit checked value. | |
| 2761 | - */ | |
| 2762 | -function bbp_get_form_reply_log_edit() { | |
| 2718 | + // Get _POST data | |
| 2719 | + if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_log_reply_edit'] ) ) { | |
| 2720 | + $reply_revision = (bool) $_POST['bbp_log_reply_edit']; | |
| 2763 | 2721 | |
| 2764 | - // Get _POST data | |
| 2765 | - if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_log_reply_edit'] ) ) { | |
| 2766 | - $reply_revision = (bool) $_POST['bbp_log_reply_edit']; | |
| 2722 | + // No data | |
| 2723 | + } else { | |
| 2724 | + $reply_revision = true; | |
| 2725 | + } | |
| 2767 | 2726 | |
| 2768 | - // No data | |
| 2769 | - } else { | |
| 2770 | - $reply_revision = true; | |
| 2727 | + // Get checked output | |
| 2728 | + $checked = checked( $reply_revision, true, false ); | |
| 2729 | + | |
| 2730 | + // Filter & return | |
| 2731 | + return apply_filters( 'bbp_get_form_reply_log_edit', $checked, $reply_revision ); | |
| 2771 | 2732 | } |
| 2772 | 2733 | |
| 2773 | - // Get checked output | |
| 2774 | - $checked = checked( $reply_revision, true, false ); | |
| 2775 | - | |
| 2776 | - // Filter & return | |
| 2777 | - return apply_filters( 'bbp_get_form_reply_log_edit', $checked, $reply_revision ); | |
| 2778 | -} | |
| 2779 | - | |
| 2780 | 2734 | /** |
| 2781 | - * Output the value of the reply edit reason. | |
| 2735 | + * Output the value of the reply edit reason | |
| 2782 | 2736 | * |
| 2783 | 2737 | * @since 2.0.0 bbPress (r3130) |
| 2784 | 2738 | */ |
| 2785 | 2739 | function bbp_form_reply_edit_reason() { |
| @@ -2784,33 +2738,32 @@ | ||
| 2784 | 2738 | */ |
| 2785 | 2739 | function bbp_form_reply_edit_reason() { |
| 2786 | 2740 | echo bbp_get_form_reply_edit_reason(); |
| 2787 | 2741 | } |
| 2742 | + /** | |
| 2743 | + * Return the value of the reply edit reason | |
| 2744 | + * | |
| 2745 | + * @since 2.0.0 bbPress (r3130) | |
| 2746 | + * | |
| 2747 | + * @return string Reply edit reason value | |
| 2748 | + */ | |
| 2749 | + function bbp_get_form_reply_edit_reason() { | |
| 2788 | 2750 | |
| 2789 | -/** | |
| 2790 | - * Return the value of the reply edit reason. | |
| 2791 | - * | |
| 2792 | - * @since 2.0.0 bbPress (r3130) | |
| 2793 | - * | |
| 2794 | - * @return string Reply edit reason value. | |
| 2795 | - */ | |
| 2796 | -function bbp_get_form_reply_edit_reason() { | |
| 2751 | + // Get _POST data | |
| 2752 | + if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_edit_reason'] ) ) { | |
| 2753 | + $reply_edit_reason = wp_unslash( $_POST['bbp_reply_edit_reason'] ); | |
| 2797 | 2754 | |
| 2798 | - // Get _POST data | |
| 2799 | - if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_edit_reason'] ) ) { | |
| 2800 | - $reply_edit_reason = wp_unslash( $_POST['bbp_reply_edit_reason'] ); | |
| 2755 | + // No data | |
| 2756 | + } else { | |
| 2757 | + $reply_edit_reason = ''; | |
| 2758 | + } | |
| 2801 | 2759 | |
| 2802 | - // No data | |
| 2803 | - } else { | |
| 2804 | - $reply_edit_reason = ''; | |
| 2760 | + // Filter & return | |
| 2761 | + return apply_filters( 'bbp_get_form_reply_edit_reason', $reply_edit_reason ); | |
| 2805 | 2762 | } |
| 2806 | 2763 | |
| 2807 | - // Filter & return | |
| 2808 | - return apply_filters( 'bbp_get_form_reply_edit_reason', $reply_edit_reason ); | |
| 2809 | -} | |
| 2810 | - | |
| 2811 | 2764 | /** |
| 2812 | - * Output value reply status dropdown. | |
| 2765 | + * Output value reply status dropdown | |
| 2813 | 2766 | * |
| 2814 | 2767 | * @since 2.6.0 bbPress (r5399) |
| 2815 | 2768 | * |
| 2816 | 2769 | * @param $args This function supports these arguments: |
| @@ -2821,24 +2774,23 @@ | ||
| 2821 | 2774 | */ |
| 2822 | 2775 | function bbp_form_reply_status_dropdown( $args = array() ) { |
| 2823 | 2776 | echo bbp_get_form_reply_status_dropdown( $args ); |
| 2824 | 2777 | } |
| 2825 | - | |
| 2826 | -/** | |
| 2827 | - * Returns reply status dropdown. | |
| 2828 | - * | |
| 2829 | - * This dropdown is only intended to be seen by users with the 'moderate' | |
| 2830 | - * capability. Because of this, no additional capability checks are performed | |
| 2831 | - * within this function to check available reply statuses. | |
| 2832 | - * | |
| 2833 | - * @since 2.6.0 bbPress (r5399) | |
| 2834 | - * | |
| 2835 | - * @param $args This function supports these arguments: | |
| 2836 | - * - select_id: Select id. Defaults to bbp_reply_status | |
| 2837 | - * - tab: Deprecated. Tabindex | |
| 2838 | - * - reply_id: Reply id | |
| 2839 | - * - selected: Override the selected option | |
| 2840 | - */ | |
| 2778 | + /** | |
| 2779 | + * Returns reply status dropdown | |
| 2780 | + * | |
| 2781 | + * This dropdown is only intended to be seen by users with the 'moderate' | |
| 2782 | + * capability. Because of this, no additional capability checks are performed | |
| 2783 | + * within this function to check available reply statuses. | |
| 2784 | + * | |
| 2785 | + * @since 2.6.0 bbPress (r5399) | |
| 2786 | + * | |
| 2787 | + * @param $args This function supports these arguments: | |
| 2788 | + * - select_id: Select id. Defaults to bbp_reply_status | |
| 2789 | + * - tab: Deprecated. Tabindex | |
| 2790 | + * - reply_id: Reply id | |
| 2791 | + * - selected: Override the selected option | |
| 2792 | + */ | |
| 2841 | 2793 | function bbp_get_form_reply_status_dropdown( $args = array() ) { |
| 2842 | 2794 | |
| 2843 | 2795 | // Parse arguments against default values |
| 2844 | 2796 | $r = bbp_parse_args( |
| @@ -2899,9 +2851,9 @@ | ||
| 2899 | 2851 | * @see bbp_reply_form_fields() |
| 2900 | 2852 | * |
| 2901 | 2853 | * @since 2.6.0 bbPress (r5558) |
| 2902 | 2854 | * |
| 2903 | - * @return boolean True if is a post request with valid nonce. | |
| 2855 | + * @return boolean True if is a post request with valid nonce | |
| 2904 | 2856 | */ |
| 2905 | 2857 | function bbp_is_reply_form_post_request() { |
| 2906 | 2858 | |
| 2907 | 2859 | // Bail if not a post request |