PluginProbe
bbPress / 2.6.19
bbPress v2.6.19
2.6.19 2.6.18 2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 All 74 releases
← All changes | includes/replies/template.php +898 -946 trunk → 2.6.19 View file →
@@ -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 (r2858)
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 (r2858)
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 (r2858)
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 (r5130)
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 (r5130)
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 (r5130)
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 **************************************************************/
@@ -278,13 +278,13 @@
278 278 return apply_filters( 'bbp_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query );
279 279 }
280 280
281 281 /**
282 - * Whether there are more replies available in the loop.
282 + * Whether there are more replies available in the loop
283 283 *
284 284 * @since 2.0.0 bbPress (r2553)
285 285 *
286 - * @return object Replies information.
286 + * @return object Replies information
287 287 */
288 288 function bbp_replies() {
289 289
290 290 // Put into variable to check against next
@@ -298,13 +298,13 @@
298 298 return $have_posts;
299 299 }
300 300
301 301 /**
302 - * Loads up the current reply in the loop.
302 + * Loads up the current reply in the loop
303 303 *
304 304 * @since 2.0.0 bbPress (r2553)
305 305 *
306 - * @return object Reply information.
306 + * @return object Reply information
307 307 */
308 308 function bbp_the_reply() {
309 309 return bbpress()->reply_query->the_post();
310 310 }
@@ -309,68 +309,67 @@
309 309 return bbpress()->reply_query->the_post();
310 310 }
311 311
312 312 /**
313 - * Output reply id.
313 + * Output reply id
314 314 *
315 315 * @since 2.0.0 bbPress (r2553)
316 316 *
317 - * @param $reply_id Optional. Used to check emptiness.
317 + * @param $reply_id Optional. Used to check emptiness
318 318 */
319 319 function bbp_reply_id( $reply_id = 0 ) {
320 320 echo bbp_get_reply_id( $reply_id );
321 321 }
322 + /**
323 + * Return the id of the reply in a replies loop
324 + *
325 + * @since 2.0.0 bbPress (r2553)
326 + *
327 + * @param $reply_id Optional. Used to check emptiness
328 + * @return int The reply id
329 + */
330 + function bbp_get_reply_id( $reply_id = 0 ) {
331 + $bbp = bbpress();
332 + $wp_query = bbp_get_wp_query();
322 333
323 -/**
324 - * Return the id of the reply in a replies loop.
325 - *
326 - * @since 2.0.0 bbPress (r2553)
327 - *
328 - * @param $reply_id Optional. Used to check emptiness.
329 - * @return int The reply id.
330 - */
331 -function bbp_get_reply_id( $reply_id = 0 ) {
332 - $bbp = bbpress();
333 - $wp_query = bbp_get_wp_query();
334 + // Easy empty checking
335 + if ( ! empty( $reply_id ) && is_numeric( $reply_id ) ) {
336 + $bbp_reply_id = $reply_id;
334 337
335 - // Easy empty checking
336 - if ( ! empty( $reply_id ) && is_numeric( $reply_id ) ) {
337 - $bbp_reply_id = $reply_id;
338 + // Currently inside a replies loop
339 + } elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) {
340 + $bbp_reply_id = $bbp->reply_query->post->ID;
338 341
339 - // Currently inside a replies loop
340 - } elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) {
341 - $bbp_reply_id = $bbp->reply_query->post->ID;
342 + // Currently inside a search loop
343 + } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) {
344 + $bbp_reply_id = $bbp->search_query->post->ID;
342 345
343 - // Currently inside a search loop
344 - } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) {
345 - $bbp_reply_id = $bbp->search_query->post->ID;
346 + // Currently viewing a forum
347 + } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) {
348 + $bbp_reply_id = $bbp->current_reply_id;
346 349
347 - // Currently viewing a forum
348 - } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) {
349 - $bbp_reply_id = $bbp->current_reply_id;
350 + // Currently viewing a reply
351 + } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) {
352 + $bbp_reply_id = $wp_query->post->ID;
350 353
351 - // Currently viewing a reply
352 - } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) {
353 - $bbp_reply_id = $wp_query->post->ID;
354 + // Fallback
355 + } else {
356 + $bbp_reply_id = 0;
357 + }
354 358
355 - // Fallback
356 - } else {
357 - $bbp_reply_id = 0;
359 + // Filter & return
360 + return (int) apply_filters( 'bbp_get_reply_id', $bbp_reply_id, $reply_id );
358 361 }
359 362
360 - // Filter & return
361 - return (int) apply_filters( 'bbp_get_reply_id', $bbp_reply_id, $reply_id );
362 -}
363 -
364 363 /**
365 - * Gets a reply.
364 + * Gets a reply
366 365 *
367 366 * @since 2.0.0 bbPress (r2787)
368 367 *
369 - * @param int|object $reply reply id or reply object.
370 - * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT.
371 - * @param string $filter Optional Sanitation filter. See {@link sanitize_post()}.
372 - * @return mixed Null if error or reply (in specified form) if success.
368 + * @param int|object $reply reply id or reply object
369 + * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT
370 + * @param string $filter Optional Sanitation filter. See {@link sanitize_post()}
371 + * @return mixed Null if error or reply (in specified form) if success
373 372 */
374 373 function bbp_get_reply( $reply, $output = OBJECT, $filter = 'raw' ) {
375 374
376 375 // Maybe get ID from empty or int
@@ -405,55 +404,53 @@
405 404 return apply_filters( 'bbp_get_reply', $retval, $reply, $output, $filter );
406 405 }
407 406
408 407 /**
409 - * Output the link to the reply in the reply loop.
408 + * Output the link to the reply in the reply loop
410 409 *
411 410 * @since 2.0.0 bbPress (r2553)
412 411 *
413 - * @param int $reply_id Optional. Reply id.
412 + * @param int $reply_id Optional. Reply id
414 413 */
415 414 function bbp_reply_permalink( $reply_id = 0 ) {
416 415 echo esc_url( bbp_get_reply_permalink( $reply_id ) );
417 416 }
417 + /**
418 + * Return the link to the reply
419 + *
420 + * @since 2.0.0 bbPress (r2553)
421 + *
422 + * @param int $reply_id Optional. Reply id
423 + *
424 + * @return string Permanent link to reply
425 + */
426 + function bbp_get_reply_permalink( $reply_id = 0 ) {
427 + $reply_id = bbp_get_reply_id( $reply_id );
418 428
419 -/**
420 - * Return the link to the reply.
421 - *
422 - * @since 2.0.0 bbPress (r2553)
423 - *
424 - * @param int $reply_id Optional. Reply id.
425 - *
426 - * @return string Permanent link to reply.
427 - */
428 -function bbp_get_reply_permalink( $reply_id = 0 ) {
429 - $reply_id = bbp_get_reply_id( $reply_id );
429 + // Filter & return
430 + return apply_filters( 'bbp_get_reply_permalink', get_permalink( $reply_id ), $reply_id );
431 + }
430 432
431 - // Filter & return
432 - return apply_filters( 'bbp_get_reply_permalink', get_permalink( $reply_id ), $reply_id );
433 -}
434 -
435 433 /**
436 - * Output the paginated url to the reply in the reply loop.
434 + * Output the paginated url to the reply in the reply loop
437 435 *
438 436 * @since 2.0.0 bbPress (r2680)
439 437 *
440 - * @param int $reply_id Optional. Reply id.
438 + * @param int $reply_id Optional. Reply id
441 439 */
442 440 function bbp_reply_url( $reply_id = 0 ) {
443 441 echo esc_url( bbp_get_reply_url( $reply_id ) );
444 442 }
445 -
446 -/**
447 - * Return the paginated url to the reply in the reply loop.
448 - *
449 - * @since 2.0.0 bbPress (r2680)
450 - *
451 - * @param int $reply_id Optional. Reply id.
452 - * @param string $redirect_to Optional. Pass a redirect value for use with
453 - * shortcodes and other fun things.
454 - * @return string Link to reply relative to paginated topic.
455 - */
443 + /**
444 + * Return the paginated url to the reply in the reply loop
445 + *
446 + * @since 2.0.0 bbPress (r2680)
447 + *
448 + * @param int $reply_id Optional. Reply id
449 + * @param string $redirect_to Optional. Pass a redirect value for use with
450 + * shortcodes and other fun things.
451 + * @return string Link to reply relative to paginated topic
452 + */
456 453 function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) {
457 454
458 455 // Set needed variables
459 456 $reply_id = bbp_get_reply_id( $reply_id );
@@ -524,44 +521,43 @@
524 521 return apply_filters( 'bbp_get_reply_url', $url, $reply_id, $redirect_to );
525 522 }
526 523
527 524 /**
528 - * Output the title of the reply.
525 + * Output the title of the reply
529 526 *
530 527 * @since 2.0.0 bbPress (r2553)
531 528 *
532 - * @param int $reply_id Optional. Reply id.
529 + * @param int $reply_id Optional. Reply id
533 530 */
534 531 function bbp_reply_title( $reply_id = 0 ) {
535 532 echo bbp_get_reply_title( $reply_id );
536 533 }
537 534
538 -/**
539 - * Return the title of the reply.
540 - *
541 - * @since 2.0.0 bbPress (r2553)
542 - *
543 - * @param int $reply_id Optional. Reply id.
544 - * @return string Title of reply.
545 - */
546 -function bbp_get_reply_title( $reply_id = 0 ) {
547 - $reply_id = bbp_get_reply_id( $reply_id );
548 - $title = get_post_field( 'post_title', $reply_id );
549 - $title = apply_filters( 'the_title', $title, $reply_id );
535 + /**
536 + * Return the title of the reply
537 + *
538 + * @since 2.0.0 bbPress (r2553)
539 + *
540 + * @param int $reply_id Optional. Reply id
541 + * @return string Title of reply
542 + */
543 + function bbp_get_reply_title( $reply_id = 0 ) {
544 + $reply_id = bbp_get_reply_id( $reply_id );
545 + $title = get_the_title( $reply_id );
550 546
551 - // Filter & return
552 - return apply_filters( 'bbp_get_reply_title', $title, $reply_id );
553 -}
547 + // Filter & return
548 + return apply_filters( 'bbp_get_reply_title', $title, $reply_id );
549 + }
554 550
555 -/**
556 - * Get empty reply title fallback.
557 - *
558 - * @since 2.5.0 bbPress (r5177)
559 - *
560 - * @param string $post_title Required. Reply Title.
561 - * @param int $post_id Required. Reply ID.
562 - * @return string Title of reply.
563 - */
551 + /**
552 + * Get empty reply title fallback.
553 + *
554 + * @since 2.5.0 bbPress (r5177)
555 + *
556 + * @param string $post_title Required. Reply Title
557 + * @param int $post_id Required. Reply ID
558 + * @return string Title of reply
559 + */
564 560 function bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ) {
565 561
566 562 // Bail if title not empty, or post is not a reply
567 563 if ( ! empty( $post_title ) || ! bbp_is_reply( $post_id ) ) {
@@ -587,116 +583,113 @@
587 583 return apply_filters( 'bbp_get_reply_title_fallback', $reply_title, $post_id, $topic_title );
588 584 }
589 585
590 586 /**
591 - * Output the content of the reply.
587 + * Output the content of the reply
592 588 *
593 589 * @since 2.0.0 bbPress (r2553)
594 590 *
595 - * @param int $reply_id Optional. reply id.
591 + * @param int $reply_id Optional. reply id
596 592 */
597 593 function bbp_reply_content( $reply_id = 0 ) {
598 594 echo bbp_get_reply_content( $reply_id );
599 595 }
596 + /**
597 + * Return the content of the reply
598 + *
599 + * @since 2.0.0 bbPress (r2553)
600 + *
601 + * @param int $reply_id Optional. reply id
602 + * @return string Content of the reply
603 + */
604 + function bbp_get_reply_content( $reply_id = 0 ) {
605 + $reply_id = bbp_get_reply_id( $reply_id );
600 606
601 -/**
602 - * Return the content of the reply.
603 - *
604 - * @since 2.0.0 bbPress (r2553)
605 - *
606 - * @param int $reply_id Optional. reply id.
607 - * @return string Content of the reply.
608 - */
609 -function bbp_get_reply_content( $reply_id = 0 ) {
610 - $reply_id = bbp_get_reply_id( $reply_id );
607 + // Check the reply and its topic and forum ancestors.
608 + $password_id = bbp_get_password_required_id( $reply_id );
609 + if ( ! empty( $password_id ) ) {
610 + return get_the_password_form( $password_id );
611 + }
611 612
612 - // Check the reply and its topic and forum ancestors.
613 - $password_id = bbp_get_password_required_id( $reply_id );
614 - if ( ! empty( $password_id ) ) {
615 - return get_the_password_form( $password_id );
613 + $content = get_post_field( 'post_content', $reply_id );
614 +
615 + // Filter & return
616 + return apply_filters( 'bbp_get_reply_content', $content, $reply_id );
616 617 }
617 618
618 - $content = get_post_field( 'post_content', $reply_id );
619 -
620 - // Filter & return
621 - return apply_filters( 'bbp_get_reply_content', $content, $reply_id );
622 -}
623 -
624 619 /**
625 - * Output the excerpt of the reply.
620 + * Output the excerpt of the reply
626 621 *
627 622 * @since 2.0.0 bbPress (r2751)
628 623 *
629 - * @param int $reply_id Optional. Reply id.
630 - * @param int $length Optional. Length of the excerpt. Defaults to 100 letters.
624 + * @param int $reply_id Optional. Reply id
625 + * @param int $length Optional. Length of the excerpt. Defaults to 100 letters
631 626 */
632 627 function bbp_reply_excerpt( $reply_id = 0, $length = 100 ) {
633 628 echo bbp_get_reply_excerpt( $reply_id, $length );
634 629 }
630 + /**
631 + * Return the excerpt of the reply
632 + *
633 + * @since 2.0.0 bbPress (r2751)
634 + *
635 + * @param int $reply_id Optional. Reply id
636 + * @param int $length Optional. Length of the excerpt. Defaults to 100
637 + * letters
638 + * @return string Reply Excerpt
639 + */
640 + function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) {
641 + $reply_id = bbp_get_reply_id( $reply_id );
642 + $length = (int) $length;
643 + $password_id = bbp_get_password_required_id( $reply_id );
644 + $excerpt = ! empty( $password_id )
645 + ? get_the_password_form( $password_id )
646 + : get_post_field( 'post_excerpt', $reply_id );
635 647
636 -/**
637 - * Return the excerpt of the reply.
638 - *
639 - * @since 2.0.0 bbPress (r2751)
640 - *
641 - * @param int $reply_id Optional. Reply id.
642 - * @param int $length Optional. Length of the excerpt. Defaults to 100
643 - * letters.
644 - * @return string Reply Excerpt.
645 - */
646 -function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) {
647 - $reply_id = bbp_get_reply_id( $reply_id );
648 - $length = (int) $length;
649 - $password_id = bbp_get_password_required_id( $reply_id );
650 - $excerpt = ! empty( $password_id )
651 - ? get_the_password_form( $password_id )
652 - : get_post_field( 'post_excerpt', $reply_id );
648 + if ( empty( $excerpt ) ) {
649 + $excerpt = bbp_get_reply_content( $reply_id );
650 + }
653 651
654 - if ( empty( $excerpt ) ) {
655 - $excerpt = bbp_get_reply_content( $reply_id );
656 - }
652 + $excerpt = trim ( strip_tags( $excerpt ) );
657 653
658 - $excerpt = wp_strip_all_tags( $excerpt );
654 + // Multibyte support
655 + if ( function_exists( 'mb_strlen' ) ) {
656 + $excerpt_length = mb_strlen( $excerpt );
657 + } else {
658 + $excerpt_length = strlen( $excerpt );
659 + }
659 660
660 - // Multibyte support
661 - if ( function_exists( 'mb_strlen' ) ) {
662 - $excerpt_length = mb_strlen( $excerpt );
663 - } else {
664 - $excerpt_length = strlen( $excerpt );
665 - }
661 + if ( ! empty( $length ) && ( $excerpt_length > $length ) ) {
662 + $excerpt = mb_substr( $excerpt, 0, $length - 1 );
663 + $excerpt .= '&hellip;';
664 + }
666 665
667 - if ( ! empty( $length ) && ( $excerpt_length > $length ) ) {
668 - $excerpt = mb_substr( $excerpt, 0, $length - 1 );
669 - $excerpt .= '&hellip;';
666 + // Filter & return
667 + return apply_filters( 'bbp_get_reply_excerpt', $excerpt, $reply_id, $length );
670 668 }
671 669
672 - // Filter & return
673 - return apply_filters( 'bbp_get_reply_excerpt', $excerpt, $reply_id, $length );
674 -}
675 -
676 670 /**
677 - * Output the post date and time of a reply.
671 + * Output the post date and time of a reply
678 672 *
679 673 * @since 2.2.0 bbPress (r4156)
680 674 *
681 675 * @param int $reply_id Optional. Reply id.
682 - * @param bool $humanize Optional. Humanize output using time_since.
683 - * @param bool $gmt Optional. Use GMT.
676 + * @param bool $humanize Optional. Humanize output using time_since
677 + * @param bool $gmt Optional. Use GMT
684 678 */
685 679 function bbp_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) {
686 680 echo bbp_get_reply_post_date( $reply_id, $humanize, $gmt );
687 681 }
688 -
689 -/**
690 - * Return the post date and time of a reply.
691 - *
692 - * @since 2.2.0 bbPress (r4156)
693 - *
694 - * @param int $reply_id Optional. Reply id.
695 - * @param bool $humanize Optional. Humanize output using time_since.
696 - * @param bool $gmt Optional. Use GMT.
697 - * @return string
698 - */
682 + /**
683 + * Return the post date and time of a reply
684 + *
685 + * @since 2.2.0 bbPress (r4156)
686 + *
687 + * @param int $reply_id Optional. Reply id.
688 + * @param bool $humanize Optional. Humanize output using time_since
689 + * @param bool $gmt Optional. Use GMT
690 + * @return string
691 + */
699 692 function bbp_get_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) {
700 693 $reply_id = bbp_get_reply_id( $reply_id );
701 694
702 695 // 4 days, 4 hours ago
@@ -718,15 +711,15 @@
718 711 return apply_filters( 'bbp_get_reply_post_date', $result, $reply_id, $humanize, $gmt, $date, $time );
719 712 }
720 713
721 714 /**
722 - * Append revisions to the reply content.
715 + * Append revisions to the reply content
723 716 *
724 717 * @since 2.0.0 bbPress (r2782)
725 718 *
726 - * @param string $content Optional. Content to which we need to append the revisions to.
727 - * @param int $reply_id Optional. Reply id.
728 - * @return string Content with the revisions appended.
719 + * @param string $content Optional. Content to which we need to append the revisions to
720 + * @param int $reply_id Optional. Reply id
721 + * @return string Content with the revisions appended
729 722 */
730 723 function bbp_reply_content_append_revisions( $content = '', $reply_id = 0 ) {
731 724
732 725 // Bail if in admin or feed
@@ -741,26 +734,25 @@
741 734 return apply_filters( 'bbp_reply_append_revisions', $content . bbp_get_reply_revision_log( $reply_id ), $content, $reply_id );
742 735 }
743 736
744 737 /**
745 - * Output the revision log of the reply.
738 + * Output the revision log of the reply
746 739 *
747 740 * @since 2.0.0 bbPress (r2782)
748 741 *
749 - * @param int $reply_id Optional. Reply id.
742 + * @param int $reply_id Optional. Reply id
750 743 */
751 744 function bbp_reply_revision_log( $reply_id = 0 ) {
752 745 echo bbp_get_reply_revision_log( $reply_id );
753 746 }
754 -
755 -/**
756 - * Return the formatted revision log of the reply.
757 - *
758 - * @since 2.0.0 bbPress (r2782)
759 - *
760 - * @param int $reply_id Optional. Reply id.
761 - * @return string Revision log of the reply.
762 - */
747 + /**
748 + * Return the formatted revision log of the reply
749 + *
750 + * @since 2.0.0 bbPress (r2782)
751 + *
752 + * @param int $reply_id Optional. Reply id
753 + * @return string Revision log of the reply
754 + */
763 755 function bbp_get_reply_revision_log( $reply_id = 0 ) {
764 756
765 757 // Create necessary variables
766 758 $reply_id = bbp_get_reply_id( $reply_id );
@@ -822,35 +814,34 @@
822 814
823 815 // Filter & return
824 816 return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id );
825 817 }
818 + /**
819 + * Return the raw revision log of the reply
820 + *
821 + * @since 2.0.0 bbPress (r2782)
822 + *
823 + * @param int $reply_id Optional. Reply id
824 + * @return string Raw revision log of the reply
825 + */
826 + function bbp_get_reply_raw_revision_log( $reply_id = 0 ) {
827 + $reply_id = bbp_get_reply_id( $reply_id );
828 + $revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true );
829 + $revision_log = ! empty( $revision_log )
830 + ? $revision_log
831 + : array();
826 832
827 -/**
828 - * Return the raw revision log of the reply.
829 - *
830 - * @since 2.0.0 bbPress (r2782)
831 - *
832 - * @param int $reply_id Optional. Reply id.
833 - * @return string Raw revision log of the reply.
834 - */
835 -function bbp_get_reply_raw_revision_log( $reply_id = 0 ) {
836 - $reply_id = bbp_get_reply_id( $reply_id );
837 - $revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true );
838 - $revision_log = ! empty( $revision_log )
839 - ? $revision_log
840 - : array();
833 + // Filter & return
834 + return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id );
835 + }
841 836
842 - // Filter & return
843 - return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id );
844 -}
845 -
846 837 /**
847 - * Return the revisions of the reply.
838 + * Return the revisions of the reply
848 839 *
849 840 * @since 2.0.0 bbPress (r2782)
850 841 *
851 - * @param int $reply_id Optional. Reply id.
852 - * @return WP_Post[]|int[] reply revisions.
842 + * @param int $reply_id Optional. Reply id
843 + * @return WP_Post[]|int[] reply revisions
853 844 */
854 845 function bbp_get_reply_revisions( $reply_id = 0 ) {
855 846 $reply_id = bbp_get_reply_id( $reply_id );
856 847 $revisions = wp_get_post_revisions( $reply_id, array( 'order' => 'ASC' ) );
@@ -859,15 +850,15 @@
859 850 return apply_filters( 'bbp_get_reply_revisions', $revisions, $reply_id );
860 851 }
861 852
862 853 /**
863 - * Return the revision count of the reply.
854 + * Return the revision count of the reply
864 855 *
865 856 * @since 2.0.0 bbPress (r2782)
866 857 *
867 - * @param int $reply_id Optional. Reply id.
868 - * @param boolean $integer Optional. Whether or not to format the result.
869 - * @return string reply revision count.
858 + * @param int $reply_id Optional. Reply id
859 + * @param boolean $integer Optional. Whether or not to format the result
860 + * @return string reply revision count
870 861 */
871 862 function bbp_get_reply_revision_count( $reply_id = 0, $integer = false ) {
872 863 $reply_id = bbp_get_reply_id( $reply_id );
873 864 $count = count( bbp_get_reply_revisions( $reply_id ) );
@@ -878,33 +869,32 @@
878 869 return apply_filters( $filter, $count, $reply_id );
879 870 }
880 871
881 872 /**
882 - * Output the status of the reply.
873 + * Output the status of the reply
883 874 *
884 875 * @since 2.0.0 bbPress (r2667)
885 876 *
886 - * @param int $reply_id Optional. Reply id.
877 + * @param int $reply_id Optional. Reply id
887 878 */
888 879 function bbp_reply_status( $reply_id = 0 ) {
889 880 echo bbp_get_reply_status( $reply_id );
890 881 }
882 + /**
883 + * Return the status of the reply
884 + *
885 + * @since 2.0.0 bbPress (r2667)
886 + *
887 + * @param int $reply_id Optional. Reply id
888 + * @return string Status of reply
889 + */
890 + function bbp_get_reply_status( $reply_id = 0 ) {
891 + $reply_id = bbp_get_reply_id( $reply_id );
891 892
892 -/**
893 - * Return the status of the reply.
894 - *
895 - * @since 2.0.0 bbPress (r2667)
896 - *
897 - * @param int $reply_id Optional. Reply id.
898 - * @return string Status of reply.
899 - */
900 -function bbp_get_reply_status( $reply_id = 0 ) {
901 - $reply_id = bbp_get_reply_id( $reply_id );
893 + // Filter & return
894 + return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id );
895 + }
902 896
903 - // Filter & return
904 - return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id );
905 -}
906 -
907 897 /**
908 898 * Is the reply publicly viewable?
909 899 *
910 900 * See bbp_get_public_reply_statuses() for public statuses.
@@ -910,9 +900,9 @@
910 900 * See bbp_get_public_reply_statuses() for public statuses.
911 901 *
912 902 * @since 2.6.0 bbPress (r6791)
913 903 *
914 - * @param int $reply_id Optional. Reply id.
904 + * @param int $reply_id Optional. Reply id
915 905 * @return bool True if public, false if not.
916 906 */
917 907 function bbp_is_reply_public( $reply_id = 0 ) {
918 908 $reply_id = bbp_get_reply_id( $reply_id );
@@ -929,9 +919,9 @@
929 919 *
930 920 * @since 2.0.0 bbPress (r3501)
931 921 * @since 2.6.0 bbPress (r6922) Returns false if topic is also not published
932 922 *
933 - * @param int $reply_id Optional. Topic id.
923 + * @param int $reply_id Optional. Topic id
934 924 * @return bool True if published, false if not.
935 925 */
936 926 function bbp_is_reply_published( $reply_id = 0 ) {
937 927 $reply_id = bbp_get_reply_id( $reply_id );
@@ -949,9 +939,9 @@
949 939 * Is the reply marked as spam?
950 940 *
951 941 * @since 2.0.0 bbPress (r2740)
952 942 *
953 - * @param int $reply_id Optional. Reply id.
943 + * @param int $reply_id Optional. Reply id
954 944 * @return bool True if spam, false if not.
955 945 */
956 946 function bbp_is_reply_spam( $reply_id = 0 ) {
957 947 $reply_id = bbp_get_reply_id( $reply_id );
@@ -966,9 +956,9 @@
966 956 * Is the reply trashed?
967 957 *
968 958 * @since 2.0.0 bbPress (r2892)
969 959 *
970 - * @param int $reply_id Optional. Topic id.
960 + * @param int $reply_id Optional. Topic id
971 961 * @return bool True if spam, false if not.
972 962 */
973 963 function bbp_is_reply_trash( $reply_id = 0 ) {
974 964 $reply_id = bbp_get_reply_id( $reply_id );
@@ -983,9 +973,9 @@
983 973 * Is the reply pending?
984 974 *
985 975 * @since 2.6.0 bbPress (r5507)
986 976 *
987 - * @param int $reply_id Optional. Topic id.
977 + * @param int $reply_id Optional. Topic id
988 978 * @return bool True if pending, false if not.
989 979 */
990 980 function bbp_is_reply_pending( $reply_id = 0 ) {
991 981 $reply_id = bbp_get_reply_id( $reply_id );
@@ -1000,9 +990,9 @@
1000 990 * Is the reply private?
1001 991 *
1002 992 * @since 2.6.0 bbPress (r5507)
1003 993 *
1004 - * @param int $reply_id Optional. Topic id.
994 + * @param int $reply_id Optional. Topic id
1005 995 * @return bool True if private, false if not.
1006 996 */
1007 997 function bbp_is_reply_private( $reply_id = 0 ) {
1008 998 $reply_id = bbp_get_reply_id( $reply_id );
@@ -1017,9 +1007,9 @@
1017 1007 * Is the reply by an anonymous user?
1018 1008 *
1019 1009 * @since 2.0.0 bbPress (r2753)
1020 1010 *
1021 - * @param int $reply_id Optional. Reply id.
1011 + * @param int $reply_id Optional. Reply id
1022 1012 * @return bool True if the post is by an anonymous user, false if not.
1023 1013 */
1024 1014 function bbp_is_reply_anonymous( $reply_id = 0 ) {
1025 1015 $reply_id = bbp_get_reply_id( $reply_id );
@@ -1041,164 +1031,158 @@
1041 1031
1042 1032 /**
1043 1033 * Deprecated. Use bbp_reply_author_display_name() instead.
1044 1034 *
1045 - * Output the author of the reply.
1035 + * Output the author of the reply
1046 1036 *
1047 1037 * @since 2.0.0 bbPress (r2667)
1048 1038 *
1049 1039 * @deprecated 2.5.0 bbPress (r5119)
1050 1040 *
1051 - * @param int $reply_id Optional. Reply id.
1041 + * @param int $reply_id Optional. Reply id
1052 1042 */
1053 1043 function bbp_reply_author( $reply_id = 0 ) {
1054 - echo bbp_get_reply_author_display_name( $reply_id );
1044 + echo bbp_get_reply_author( $reply_id );
1055 1045 }
1046 + /**
1047 + * Deprecated. Use bbp_get_reply_author_display_name() instead.
1048 + *
1049 + * Return the author of the reply
1050 + *
1051 + * @since 2.0.0 bbPress (r2667)
1052 + *
1053 + * @deprecated 2.5.0 bbPress (r5119)
1054 + *
1055 + * @param int $reply_id Optional. Reply id
1056 + * @return string Author of reply
1057 + */
1058 + function bbp_get_reply_author( $reply_id = 0 ) {
1059 + $reply_id = bbp_get_reply_id( $reply_id );
1056 1060
1057 -/**
1058 - * Deprecated. Use bbp_get_reply_author_display_name() instead.
1059 - *
1060 - * Return the author of the reply.
1061 - *
1062 - * @since 2.0.0 bbPress (r2667)
1063 - *
1064 - * @deprecated 2.5.0 bbPress (r5119)
1065 - *
1066 - * @param int $reply_id Optional. Reply id.
1067 - * @return string Author of reply.
1068 - */
1069 -function bbp_get_reply_author( $reply_id = 0 ) {
1070 - $reply_id = bbp_get_reply_id( $reply_id );
1061 + if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
1062 + $author = get_the_author_meta( 'display_name', bbp_get_reply_author_id( $reply_id ) );
1063 + } else {
1064 + $author = get_post_meta( $reply_id, '_bbp_anonymous_name', true );
1065 + }
1071 1066
1072 - if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
1073 - $author = get_the_author_meta( 'display_name', bbp_get_reply_author_id( $reply_id ) );
1074 - } else {
1075 - $author = get_post_meta( $reply_id, '_bbp_anonymous_name', true );
1067 + // Filter & return
1068 + return apply_filters( 'bbp_get_reply_author', $author, $reply_id );
1076 1069 }
1077 1070
1078 - // Filter & return
1079 - return apply_filters( 'bbp_get_reply_author', $author, $reply_id );
1080 -}
1081 -
1082 1071 /**
1083 - * Output the author ID of the reply.
1072 + * Output the author ID of the reply
1084 1073 *
1085 1074 * @since 2.0.0 bbPress (r2667)
1086 1075 *
1087 - * @param int $reply_id Optional. Reply id.
1076 + * @param int $reply_id Optional. Reply id
1088 1077 */
1089 1078 function bbp_reply_author_id( $reply_id = 0 ) {
1090 1079 echo bbp_get_reply_author_id( $reply_id );
1091 1080 }
1081 + /**
1082 + * Return the author ID of the reply
1083 + *
1084 + * @since 2.0.0 bbPress (r2667)
1085 + *
1086 + * @param int $reply_id Optional. Reply id
1087 + * @return string Author id of reply
1088 + */
1089 + function bbp_get_reply_author_id( $reply_id = 0 ) {
1090 + $reply_id = bbp_get_reply_id( $reply_id );
1091 + $author_id = get_post_field( 'post_author', $reply_id );
1092 1092
1093 -/**
1094 - * Return the author ID of the reply.
1095 - *
1096 - * @since 2.0.0 bbPress (r2667)
1097 - *
1098 - * @param int $reply_id Optional. Reply id.
1099 - * @return string Author id of reply.
1100 - */
1101 -function bbp_get_reply_author_id( $reply_id = 0 ) {
1102 - $reply_id = bbp_get_reply_id( $reply_id );
1103 - $author_id = get_post_field( 'post_author', $reply_id );
1093 + // Filter & return
1094 + return (int) apply_filters( 'bbp_get_reply_author_id', $author_id, $reply_id );
1095 + }
1104 1096
1105 - // Filter & return
1106 - return (int) apply_filters( 'bbp_get_reply_author_id', $author_id, $reply_id );
1107 -}
1108 -
1109 1097 /**
1110 - * Output the author display_name of the reply.
1098 + * Output the author display_name of the reply
1111 1099 *
1112 1100 * @since 2.0.0 bbPress (r2667)
1113 1101 *
1114 - * @param int $reply_id Optional. Reply id.
1102 + * @param int $reply_id Optional. Reply id
1115 1103 */
1116 1104 function bbp_reply_author_display_name( $reply_id = 0 ) {
1117 1105 echo bbp_get_reply_author_display_name( $reply_id );
1118 1106 }
1107 + /**
1108 + * Return the author display_name of the reply
1109 + *
1110 + * @since 2.0.0 bbPress (r2667)
1111 + *
1112 + * @param int $reply_id Optional. Reply id
1113 + * @return string The display name of the author of the reply
1114 + */
1115 + function bbp_get_reply_author_display_name( $reply_id = 0 ) {
1116 + $reply_id = bbp_get_reply_id( $reply_id );
1119 1117
1120 -/**
1121 - * Return the author display_name of the reply.
1122 - *
1123 - * @since 2.0.0 bbPress (r2667)
1124 - *
1125 - * @param int $reply_id Optional. Reply id.
1126 - * @return string The display name of the author of the reply.
1127 - */
1128 -function bbp_get_reply_author_display_name( $reply_id = 0 ) {
1129 - $reply_id = bbp_get_reply_id( $reply_id );
1118 + // User is not a guest
1119 + if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
1130 1120
1131 - // User is not a guest
1132 - if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
1121 + // Get the author ID
1122 + $author_id = bbp_get_reply_author_id( $reply_id );
1133 1123
1134 - // Get the author ID
1135 - $author_id = bbp_get_reply_author_id( $reply_id );
1124 + // Try to get a display name
1125 + $author_name = get_the_author_meta( 'display_name', $author_id );
1136 1126
1137 - // Try to get a display name
1138 - $author_name = get_the_author_meta( 'display_name', $author_id );
1127 + // Fall back to user login
1128 + if ( empty( $author_name ) ) {
1129 + $author_name = get_the_author_meta( 'user_login', $author_id );
1130 + }
1139 1131
1140 - // Fall back to user login
1132 + // User does not have an account
1133 + } else {
1134 + $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true );
1135 + }
1136 +
1137 + // Fallback if nothing could be found
1141 1138 if ( empty( $author_name ) ) {
1142 - $author_name = get_the_author_meta( 'user_login', $author_id );
1139 + $author_name = bbp_get_fallback_display_name( $reply_id );
1143 1140 }
1144 1141
1145 - // User does not have an account
1146 - } else {
1147 - $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true );
1142 + // Filter & return
1143 + return apply_filters( 'bbp_get_reply_author_display_name', $author_name, $reply_id );
1148 1144 }
1149 1145
1150 - // Fallback if nothing could be found
1151 - if ( empty( $author_name ) ) {
1152 - $author_name = bbp_get_fallback_display_name( $reply_id );
1153 - }
1154 -
1155 - // Filter & return
1156 - return apply_filters( 'bbp_get_reply_author_display_name', $author_name, $reply_id );
1157 -}
1158 -
1159 1146 /**
1160 - * Output the author avatar of the reply.
1147 + * Output the author avatar of the reply
1161 1148 *
1162 1149 * @since 2.0.0 bbPress (r2667)
1163 1150 *
1164 - * @param int $reply_id Optional. Reply id.
1165 - * @param int $size Optional. Size of the avatar. Defaults to 40.
1151 + * @param int $reply_id Optional. Reply id
1152 + * @param int $size Optional. Size of the avatar. Defaults to 40
1166 1153 */
1167 1154 function bbp_reply_author_avatar( $reply_id = 0, $size = 40 ) {
1168 1155 echo bbp_get_reply_author_avatar( $reply_id, $size );
1169 1156 }
1170 -
1171 -/**
1172 - * Return the author avatar of the reply.
1173 - *
1174 - * @since 2.0.0 bbPress (r2667)
1175 - *
1176 - * @param int $reply_id Optional. Reply id
1177 - * @param int $size Optional. Size of the avatar. Defaults to 40.
1178 - * @return string Avatar of author of the reply.
1179 - */
1180 -function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) {
1181 - $reply_id = bbp_get_reply_id( $reply_id );
1182 -
1183 - if ( ! empty( $reply_id ) ) {
1184 -
1185 - // Check for anonymous user
1186 - if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
1187 - $author_avatar = get_avatar( bbp_get_reply_author_id( $reply_id ), $size );
1157 + /**
1158 + * Return the author avatar of the reply
1159 + *
1160 + * @since 2.0.0 bbPress (r2667)
1161 + *
1162 + * @param int $reply_id Optional. Reply id
1163 + * @param int $size Optional. Size of the avatar. Defaults to 40
1164 + * @return string Avatar of author of the reply
1165 + */
1166 + function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) {
1167 + $reply_id = bbp_get_reply_id( $reply_id );
1168 + if ( ! empty( $reply_id ) ) {
1169 + // Check for anonymous user
1170 + if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
1171 + $author_avatar = get_avatar( bbp_get_reply_author_id( $reply_id ), $size );
1172 + } else {
1173 + $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ), $size );
1174 + }
1188 1175 } else {
1189 - $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ), $size );
1176 + $author_avatar = '';
1190 1177 }
1191 - } else {
1192 - $author_avatar = '';
1178 +
1179 + // Filter & return
1180 + return apply_filters( 'bbp_get_reply_author_avatar', $author_avatar, $reply_id, $size );
1193 1181 }
1194 1182
1195 - // Filter & return
1196 - return apply_filters( 'bbp_get_reply_author_avatar', $author_avatar, $reply_id, $size );
1197 -}
1198 -
1199 1183 /**
1200 - * Output the author link of the reply.
1184 + * Output the author link of the reply
1201 1185 *
1202 1186 * @since 2.0.0 bbPress (r2720)
1203 1187 *
1204 1188 * @param array $args Optional. If it is an integer, it is used as reply id.
@@ -1205,17 +1189,16 @@
1205 1189 */
1206 1190 function bbp_reply_author_link( $args = array() ) {
1207 1191 echo bbp_get_reply_author_link( $args );
1208 1192 }
1209 -
1210 -/**
1211 - * Return the author link of the reply.
1212 - *
1213 - * @since 2.0.0 bbPress (r2720)
1214 - *
1215 - * @param array $args Optional. If an integer, it is used as reply id.
1216 - * @return string Author link of reply.
1217 - */
1193 + /**
1194 + * Return the author link of the reply
1195 + *
1196 + * @since 2.0.0 bbPress (r2720)
1197 + *
1198 + * @param array $args Optional. If an integer, it is used as reply id.
1199 + * @return string Author link of reply
1200 + */
1218 1201 function bbp_get_reply_author_link( $args = array() ) {
1219 1202
1220 1203 // Parse arguments against default values
1221 1204 $r = bbp_parse_args(
@@ -1279,9 +1262,9 @@
1279 1262 }
1280 1263
1281 1264 // Empty array
1282 1265 $links = array();
1283 - $sprint = '<span%1$s>%2$s</span>';
1266 + $sprint = '<span %1$s>%2$s</span>';
1284 1267
1285 1268 // Wrap each link
1286 1269 foreach ( $author_links as $link => $link_text ) {
1287 1270 $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"';
@@ -1313,92 +1296,89 @@
1313 1296 return apply_filters( 'bbp_get_reply_author_link', $author_link, $r, $args );
1314 1297 }
1315 1298
1316 1299 /**
1317 - * Output the author url of the reply.
1300 + * Output the author url of the reply
1318 1301 *
1319 1302 * @since 2.0.0 bbPress (r2667)
1320 1303 *
1321 - * @param int $reply_id Optional. Reply id.
1304 + * @param int $reply_id Optional. Reply id
1322 1305 */
1323 1306 function bbp_reply_author_url( $reply_id = 0 ) {
1324 1307 echo esc_url( bbp_get_reply_author_url( $reply_id ) );
1325 1308 }
1309 + /**
1310 + * Return the author url of the reply
1311 + *
1312 + * @since 2.0.0 bbPress (r2667)
1313 + *
1314 + * @param int $reply_id Optional. Reply id
1315 + * @return string Author URL of the reply
1316 + */
1317 + function bbp_get_reply_author_url( $reply_id = 0 ) {
1318 + $reply_id = bbp_get_reply_id( $reply_id );
1326 1319
1327 -/**
1328 - * Return the author url of the reply.
1329 - *
1330 - * @since 2.0.0 bbPress (r2667)
1331 - *
1332 - * @param int $reply_id Optional. Reply id.
1333 - * @return string Author URL of the reply.
1334 - */
1335 -function bbp_get_reply_author_url( $reply_id = 0 ) {
1336 - $reply_id = bbp_get_reply_id( $reply_id );
1320 + // Check for anonymous user or non-existant user
1321 + if ( ! bbp_is_reply_anonymous( $reply_id ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
1322 + $author_url = bbp_get_user_profile_url( bbp_get_reply_author_id( $reply_id ) );
1323 + } else {
1324 + $author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true );
1325 + if ( empty( $author_url ) ) {
1326 + $author_url = '';
1327 + }
1328 + }
1337 1329
1338 - // Check for anonymous user or non-existant user
1339 - if ( ! bbp_is_reply_anonymous( $reply_id ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
1340 - $author_url = bbp_get_user_profile_url( bbp_get_reply_author_id( $reply_id ) );
1341 - } else {
1342 - $author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true );
1343 -
1344 - if ( empty( $author_url ) ) {
1345 - $author_url = '';
1346 - }
1330 + // Filter & return
1331 + return apply_filters( 'bbp_get_reply_author_url', $author_url, $reply_id );
1347 1332 }
1348 1333
1349 - // Filter & return
1350 - return apply_filters( 'bbp_get_reply_author_url', $author_url, $reply_id );
1351 -}
1352 -
1353 1334 /**
1354 - * Output the reply author email address.
1335 + * Output the reply author email address
1355 1336 *
1356 1337 * @since 2.0.0 bbPress (r3446)
1357 1338 *
1358 - * @param int $reply_id Optional. Reply id.
1339 + * @param int $reply_id Optional. Reply id
1359 1340 */
1360 1341 function bbp_reply_author_email( $reply_id = 0 ) {
1361 1342 echo bbp_get_reply_author_email( $reply_id );
1362 1343 }
1344 + /**
1345 + * Return the reply author email address
1346 + *
1347 + * @since 2.0.0 bbPress (r3446)
1348 + *
1349 + * @param int $reply_id Optional. Reply id
1350 + * @return string Reply author email address
1351 + */
1352 + function bbp_get_reply_author_email( $reply_id = 0 ) {
1353 + $reply_id = bbp_get_reply_id( $reply_id );
1363 1354
1364 -/**
1365 - * Return the reply author email address.
1366 - *
1367 - * @since 2.0.0 bbPress (r3446)
1368 - *
1369 - * @param int $reply_id Optional. Reply id.
1370 - * @return string Reply author email address.
1371 - */
1372 -function bbp_get_reply_author_email( $reply_id = 0 ) {
1373 - $reply_id = bbp_get_reply_id( $reply_id );
1355 + // Not anonymous
1356 + if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
1374 1357
1375 - // Not anonymous
1376 - if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
1358 + // Use reply author email address
1359 + $user_id = bbp_get_reply_author_id( $reply_id );
1360 + $user = get_userdata( $user_id );
1361 + $author_email = ! empty( $user->user_email ) ? $user->user_email : '';
1377 1362
1378 - // Use reply author email address
1379 - $user_id = bbp_get_reply_author_id( $reply_id );
1380 - $user = get_userdata( $user_id );
1381 - $author_email = ! empty( $user->user_email ) ? $user->user_email : '';
1363 + // Anonymous
1364 + } else {
1382 1365
1383 - // Anonymous
1384 - } else {
1366 + // Get email from post meta
1367 + $author_email = get_post_meta( $reply_id, '_bbp_anonymous_email', true );
1385 1368
1386 - // Get email from post meta
1387 - $author_email = get_post_meta( $reply_id, '_bbp_anonymous_email', true );
1369 + // Sanity check for missing email address
1370 + if ( empty( $author_email ) ) {
1371 + $author_email = '';
1372 + }
1373 + }
1388 1374
1389 - // Sanity check for missing email address
1390 - if ( empty( $author_email ) ) {
1391 - $author_email = '';
1392 - }
1375 + // Filter & return
1376 + return apply_filters( 'bbp_get_reply_author_email', $author_email, $reply_id );
1393 1377 }
1394 1378
1395 - // Filter & return
1396 - return apply_filters( 'bbp_get_reply_author_email', $author_email, $reply_id );
1397 -}
1398 -
1399 1379 /**
1400 - * Output the reply author role.
1380 + * Output the reply author role
1401 1381 *
1402 1382 * @since 2.1.0 bbPress (r3860)
1403 1383 *
1404 1384 * @param array $args Optional.
@@ -1405,17 +1385,16 @@
1405 1385 */
1406 1386 function bbp_reply_author_role( $args = array() ) {
1407 1387 echo bbp_get_reply_author_role( $args );
1408 1388 }
1409 -
1410 -/**
1411 - * Return the reply author role.
1412 - *
1413 - * @since 2.1.0 bbPress (r3860)
1414 - *
1415 - * @param array $args Optional.
1416 - * @return string Reply author role.
1417 - */
1389 + /**
1390 + * Return the reply author role
1391 + *
1392 + * @since 2.1.0 bbPress (r3860)
1393 + *
1394 + * @param array $args Optional.
1395 + * @return string Reply author role
1396 + */
1418 1397 function bbp_get_reply_author_role( $args = array() ) {
1419 1398
1420 1399 // Parse arguments against default values
1421 1400 $r = bbp_parse_args(
@@ -1430,15 +1409,9 @@
1430 1409 );
1431 1410
1432 1411 $reply_id = bbp_get_reply_id( $r['reply_id'] );
1433 1412 $role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) );
1434 - $css_role = sanitize_key( $role );
1435 1413
1436 - // Add role as CSS class to default 'before' value.
1437 - if ( empty( $args['before'] ) ) {
1438 - $r['before'] = '<div class="bbp-author-role bbp-role-' . esc_attr( $css_role ) . '">';
1439 - }
1440 -
1441 1414 // Backwards compatibilty with old 'class' argument
1442 1415 if ( ! empty( $r['class'] ) ) {
1443 1416 $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'] );
1444 1417
@@ -1452,171 +1425,162 @@
1452 1425 return apply_filters( 'bbp_get_reply_author_role', $author_role, $r, $args );
1453 1426 }
1454 1427
1455 1428 /**
1456 - * Output the topic title a reply belongs to.
1429 + * Output the topic title a reply belongs to
1457 1430 *
1458 1431 * @since 2.0.0 bbPress (r2680)
1459 1432 *
1460 - * @param int $reply_id Optional. Reply id.
1433 + * @param int $reply_id Optional. Reply id
1461 1434 */
1462 1435 function bbp_reply_topic_title( $reply_id = 0 ) {
1463 1436 echo bbp_get_reply_topic_title( $reply_id );
1464 1437 }
1438 + /**
1439 + * Return the topic title a reply belongs to
1440 + *
1441 + * @since 2.0.0 bbPress (r2680)
1442 + *
1443 + * @param int $reply_id Optional. Reply id
1444 + * @return string The topic title of the reply
1445 + */
1446 + function bbp_get_reply_topic_title( $reply_id = 0 ) {
1447 + $reply_id = bbp_get_reply_id( $reply_id );
1448 + $topic_id = bbp_get_reply_topic_id( $reply_id );
1465 1449
1466 -/**
1467 - * Return the topic title a reply belongs to.
1468 - *
1469 - * @since 2.0.0 bbPress (r2680)
1470 - *
1471 - * @param int $reply_id Optional. Reply id.
1472 - * @return string The topic title of the reply.
1473 - */
1474 -function bbp_get_reply_topic_title( $reply_id = 0 ) {
1475 - $reply_id = bbp_get_reply_id( $reply_id );
1476 - $topic_id = bbp_get_reply_topic_id( $reply_id );
1477 - $title = bbp_get_topic_title( $topic_id );
1450 + // Filter & return
1451 + return apply_filters( 'bbp_get_reply_topic_title', bbp_get_topic_title( $topic_id ), $reply_id );
1452 + }
1478 1453
1479 - // Filter & return
1480 - return apply_filters( 'bbp_get_reply_topic_title', $title, $reply_id );
1481 -}
1482 -
1483 1454 /**
1484 - * Output the topic id a reply belongs to.
1455 + * Output the topic id a reply belongs to
1485 1456 *
1486 1457 * @since 2.0.0 bbPress (r2553)
1487 1458 *
1488 - * @param int $reply_id Optional. Reply id.
1459 + * @param int $reply_id Optional. Reply id
1489 1460 */
1490 1461 function bbp_reply_topic_id( $reply_id = 0 ) {
1491 1462 echo bbp_get_reply_topic_id( $reply_id );
1492 1463 }
1464 + /**
1465 + * Return the topic id a reply belongs to
1466 + *
1467 + * @since 2.0.0 bbPress (r2553)
1468 + *
1469 + * @param int $reply_id Optional. Reply id
1470 + * @return int The topic id of the reply
1471 + */
1472 + function bbp_get_reply_topic_id( $reply_id = 0 ) {
1473 + $reply_id = bbp_get_reply_id( $reply_id );
1474 + $topic_id = (int) get_post_field( 'post_parent', $reply_id );
1493 1475
1494 -/**
1495 - * Return the topic id a reply belongs to.
1496 - *
1497 - * @since 2.0.0 bbPress (r2553)
1498 - *
1499 - * @param int $reply_id Optional. Reply id.
1500 - * @return int The topic id of the reply.
1501 - */
1502 -function bbp_get_reply_topic_id( $reply_id = 0 ) {
1503 - $reply_id = bbp_get_reply_id( $reply_id );
1504 - $topic_id = (int) get_post_field( 'post_parent', $reply_id );
1476 + // Meta-data fallback
1477 + if ( empty( $topic_id ) ) {
1478 + $topic_id = (int) get_post_meta( $reply_id, '_bbp_topic_id', true );
1479 + }
1505 1480
1506 - // Meta-data fallback
1507 - if ( empty( $topic_id ) ) {
1508 - $topic_id = (int) get_post_meta( $reply_id, '_bbp_topic_id', true );
1509 - }
1481 + // Filter
1482 + if ( ! empty( $topic_id ) ) {
1483 + $topic_id = (int) bbp_get_topic_id( $topic_id );
1484 + }
1510 1485
1511 - // Filter
1512 - if ( ! empty( $topic_id ) ) {
1513 - $topic_id = (int) bbp_get_topic_id( $topic_id );
1486 + // Filter & return
1487 + return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id );
1514 1488 }
1515 1489
1516 - // Filter & return
1517 - return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id );
1518 -}
1519 -
1520 1490 /**
1521 - * Output the forum id a reply belongs to.
1491 + * Output the forum id a reply belongs to
1522 1492 *
1523 1493 * @since 2.0.0 bbPress (r2680)
1524 1494 *
1525 - * @param int $reply_id Optional. Reply id.
1495 + * @param int $reply_id Optional. Reply id
1526 1496 */
1527 1497 function bbp_reply_forum_id( $reply_id = 0 ) {
1528 1498 echo bbp_get_reply_forum_id( $reply_id );
1529 1499 }
1500 + /**
1501 + * Return the forum id a reply belongs to
1502 + *
1503 + * @since 2.0.0 bbPress (r2680)
1504 + *
1505 + * @param int $reply_id Optional. Reply id
1506 + *
1507 + * @return int The forum id of the reply
1508 + */
1509 + function bbp_get_reply_forum_id( $reply_id = 0 ) {
1510 + $reply_id = bbp_get_reply_id( $reply_id );
1511 + $topic_id = bbp_get_reply_topic_id( $reply_id );
1512 + $forum_id = (int) get_post_field( 'post_parent', $topic_id );
1530 1513
1531 -/**
1532 - * Return the forum id a reply belongs to.
1533 - *
1534 - * @since 2.0.0 bbPress (r2680)
1535 - *
1536 - * @param int $reply_id Optional. Reply id.
1537 - *
1538 - * @return int The forum id of the reply.
1539 - */
1540 -function bbp_get_reply_forum_id( $reply_id = 0 ) {
1541 - $reply_id = bbp_get_reply_id( $reply_id );
1542 - $topic_id = bbp_get_reply_topic_id( $reply_id );
1543 - $forum_id = (int) get_post_field( 'post_parent', $topic_id );
1514 + // Meta-data fallback
1515 + if ( empty( $forum_id ) ) {
1516 + $forum_id = (int) get_post_meta( $reply_id, '_bbp_forum_id', true );
1517 + }
1544 1518
1545 - // Meta-data fallback
1546 - if ( empty( $forum_id ) ) {
1547 - $forum_id = (int) get_post_meta( $reply_id, '_bbp_forum_id', true );
1548 - }
1519 + // Filter
1520 + if ( ! empty( $forum_id ) ) {
1521 + $forum_id = (int) bbp_get_forum_id( $forum_id );
1522 + }
1549 1523
1550 - // Filter
1551 - if ( ! empty( $forum_id ) ) {
1552 - $forum_id = (int) bbp_get_forum_id( $forum_id );
1524 + // Filter & return
1525 + return (int) apply_filters( 'bbp_get_reply_forum_id', $forum_id, $reply_id );
1553 1526 }
1554 1527
1555 - // Filter & return
1556 - return (int) apply_filters( 'bbp_get_reply_forum_id', $forum_id, $reply_id );
1557 -}
1558 -
1559 1528 /**
1560 - * Output the ancestor reply id of a reply.
1529 + * Output the ancestor reply id of a reply
1561 1530 *
1562 1531 * @since 2.4.0 bbPress (r4944)
1563 1532 *
1564 - * @param int $reply_id Optional. Reply id.
1533 + * @param int $reply_id Optional. Reply id
1565 1534 */
1566 1535 function bbp_reply_ancestor_id( $reply_id = 0 ) {
1567 1536 echo bbp_get_reply_ancestor_id( $reply_id );
1568 1537 }
1538 + /**
1539 + * Return the ancestor reply id of a reply
1540 + *
1541 + * @since 2.4.0 bbPress (r4944)
1542 + *
1543 + * @param in $reply_id Reply id
1544 + */
1545 + function bbp_get_reply_ancestor_id( $reply_id = 0 ) {
1569 1546
1570 -/**
1571 - * Return the ancestor reply id of a reply.
1572 - *
1573 - * @since 2.4.0 bbPress (r4944)
1574 - *
1575 - * @param in $reply_id Reply id.
1576 - */
1577 -function bbp_get_reply_ancestor_id( $reply_id = 0 ) {
1547 + // Validation
1548 + $reply_id = bbp_get_reply_id( $reply_id );
1549 + if ( empty( $reply_id ) ) {
1550 + return false;
1551 + }
1578 1552
1579 - // Validation
1580 - $reply_id = bbp_get_reply_id( $reply_id );
1581 - if ( empty( $reply_id ) ) {
1582 - return false;
1583 - }
1584 -
1585 - // Find highest reply ancestor
1586 - $ancestor_id = $reply_id;
1587 -
1588 - // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
1589 - while ( $parent_id = bbp_get_reply_to( $ancestor_id ) ) {
1590 - if ( empty( $parent_id ) || ( $parent_id === $ancestor_id ) || ( bbp_get_reply_topic_id( $reply_id ) === $parent_id ) || ( $parent_id === $reply_id ) ) {
1591 - break;
1553 + // Find highest reply ancestor
1554 + $ancestor_id = $reply_id;
1555 + while ( $parent_id = bbp_get_reply_to( $ancestor_id ) ) {
1556 + if ( empty( $parent_id ) || ( $parent_id === $ancestor_id ) || ( bbp_get_reply_topic_id( $reply_id ) === $parent_id ) || ( $parent_id === $reply_id ) ) {
1557 + break;
1558 + }
1559 + $ancestor_id = $parent_id;
1592 1560 }
1593 1561
1594 - $ancestor_id = $parent_id;
1562 + return (int) $ancestor_id;
1595 1563 }
1596 1564
1597 - return (int) $ancestor_id;
1598 -}
1599 -
1600 1565 /**
1601 - * Output the reply to id of a reply.
1566 + * Output the reply to id of a reply
1602 1567 *
1603 1568 * @since 2.4.0 bbPress (r4944)
1604 1569 *
1605 - * @param int $reply_id Optional. Reply id.
1570 + * @param int $reply_id Optional. Reply id
1606 1571 */
1607 1572 function bbp_reply_to( $reply_id = 0 ) {
1608 1573 echo bbp_get_reply_to( $reply_id );
1609 1574 }
1610 -
1611 -/**
1612 - * Return the reply to id of a reply.
1613 - *
1614 - * @since 2.4.0 bbPress (r4944)
1615 - *
1616 - * @param int $reply_id Optional. Reply id.
1617 - * @return int The parent reply id of the reply.
1618 - */
1575 + /**
1576 + * Return the reply to id of a reply
1577 + *
1578 + * @since 2.4.0 bbPress (r4944)
1579 + *
1580 + * @param int $reply_id Optional. Reply id
1581 + * @return int The parent reply id of the reply
1582 + */
1619 1583 function bbp_get_reply_to( $reply_id = 0 ) {
1620 1584
1621 1585 // Assume there is no reply_to set
1622 1586 $reply_to = 0;
@@ -1633,9 +1597,9 @@
1633 1597 return (int) apply_filters( 'bbp_get_reply_to', $reply_to, $reply_id );
1634 1598 }
1635 1599
1636 1600 /**
1637 - * Output the link for the reply to.
1601 + * Output the link for the reply to
1638 1602 *
1639 1603 * @since 2.4.0 bbPress (r4944)
1640 1604 *
1641 1605 * @param array $args
@@ -1643,16 +1607,16 @@
1643 1607 function bbp_reply_to_link( $args = array() ) {
1644 1608 echo bbp_get_reply_to_link( $args );
1645 1609 }
1646 1610
1647 -/**
1648 - * Return the link for a reply to a reply.
1649 - *
1650 - * @since 2.4.0 bbPress (r4944)
1651 - *
1652 - * @param array $args Arguments.
1653 - * @return string Link for a reply to a reply.
1654 - */
1611 + /**
1612 + * Return the link for a reply to a reply
1613 + *
1614 + * @since 2.4.0 bbPress (r4944)
1615 + *
1616 + * @param array $args Arguments
1617 + * @return string Link for a reply to a reply
1618 + */
1655 1619 function bbp_get_reply_to_link( $args = array() ) {
1656 1620
1657 1621 // Parse arguments against default values
1658 1622 $r = bbp_parse_args(
@@ -1712,9 +1676,9 @@
1712 1676 return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args );
1713 1677 }
1714 1678
1715 1679 /**
1716 - * Output the reply to a reply cancellation link.
1680 + * Output the reply to a reply cancellation link
1717 1681 *
1718 1682 * @since 2.4.0 bbPress (r4944)
1719 1683 */
1720 1684 function bbp_cancel_reply_to_link( $text = '' ) {
@@ -1719,88 +1683,86 @@
1719 1683 */
1720 1684 function bbp_cancel_reply_to_link( $text = '' ) {
1721 1685 echo bbp_get_cancel_reply_to_link( $text );
1722 1686 }
1687 + /**
1688 + * Return the cancellation link for a reply to a reply
1689 + *
1690 + * @since 2.4.0 bbPress (r4944)
1691 + *
1692 + * @param string $text The cancel text
1693 + * @return string The cancellation link
1694 + */
1695 + function bbp_get_cancel_reply_to_link( $text = '' ) {
1723 1696
1724 -/**
1725 - * Return the cancellation link for a reply to a reply.
1726 - *
1727 - * @since 2.4.0 bbPress (r4944)
1728 - *
1729 - * @param string $text The cancel text.
1730 - * @return string The cancellation link.
1731 - */
1732 -function bbp_get_cancel_reply_to_link( $text = '' ) {
1697 + // Bail if not hierarchical or editing a reply
1698 + if ( ! bbp_thread_replies() || bbp_is_reply_edit() ) {
1699 + return;
1700 + }
1733 1701
1734 - // Bail if not hierarchical or editing a reply
1735 - if ( ! bbp_thread_replies() || bbp_is_reply_edit() ) {
1736 - return;
1737 - }
1702 + // Set default text
1703 + if ( empty( $text ) ) {
1704 + $text = esc_html__( 'Cancel', 'bbpress' );
1705 + }
1738 1706
1739 - // Set default text
1740 - if ( empty( $text ) ) {
1741 - $text = esc_html__( 'Cancel', 'bbpress' );
1742 - }
1707 + // Replying to...
1708 + $reply_to = isset( $_GET['bbp_reply_to'] )
1709 + ? (int) $_GET['bbp_reply_to']
1710 + : 0;
1743 1711
1744 - // Replying to...
1745 - $reply_to = isset( $_GET['bbp_reply_to'] )
1746 - ? (int) $_GET['bbp_reply_to']
1747 - : 0;
1712 + // Set visibility
1713 + $style = ! empty( $reply_to ) ? '' : ' style="display:none;"';
1714 + $link = remove_query_arg( array( 'bbp_reply_to', '_wpnonce' ) ) . "#post-{$reply_to}";
1715 + $retval = sprintf( '<a href="%1$s" id="bbp-cancel-reply-to-link"%2$s>%3$s</a>', esc_url( $link ), $style, esc_html( $text ) );
1748 1716
1749 - // Set visibility
1750 - $style = ! empty( $reply_to ) ? '' : ' style="display:none;"';
1751 - $link = remove_query_arg( array( 'bbp_reply_to', '_wpnonce' ) ) . "#post-{$reply_to}";
1752 - $retval = sprintf( '<a href="%1$s" id="bbp-cancel-reply-to-link"%2$s>%3$s</a>', esc_url( $link ), $style, esc_html( $text ) );
1717 + // Filter & return
1718 + return apply_filters( 'bbp_get_cancel_reply_to_link', $retval, $link, $text );
1719 + }
1753 1720
1754 - // Filter & return
1755 - return apply_filters( 'bbp_get_cancel_reply_to_link', $retval, $link, $text );
1756 -}
1757 -
1758 1721 /**
1759 - * Output the numeric position of a reply within a topic.
1722 + * Output the numeric position of a reply within a topic
1760 1723 *
1761 1724 * @since 2.0.0 bbPress (r2984)
1762 1725 *
1763 - * @param int $reply_id Optional. Reply id.
1764 - * @param int $topic_id Optional. Topic id.
1726 + * @param int $reply_id Optional. Reply id
1727 + * @param int $topic_id Optional. Topic id
1765 1728 */
1766 1729 function bbp_reply_position( $reply_id = 0, $topic_id = 0 ) {
1767 1730 echo bbp_get_reply_position( $reply_id, $topic_id );
1768 1731 }
1732 + /**
1733 + * Return the numeric position of a reply within a topic
1734 + *
1735 + * @since 2.0.0 bbPress (r2984)
1736 + *
1737 + * @param int $reply_id Optional. Reply id
1738 + * @param int $topic_id Optional. Topic id
1739 + * @return int Reply position
1740 + */
1741 + function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) {
1769 1742
1770 -/**
1771 - * Return the numeric position of a reply within a topic.
1772 - *
1773 - * @since 2.0.0 bbPress (r2984)
1774 - *
1775 - * @param int $reply_id Optional. Reply id.
1776 - * @param int $topic_id Optional. Topic id.
1777 - * @return int Reply position.
1778 - */
1779 -function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) {
1743 + // Get required data
1744 + $reply_id = bbp_get_reply_id( $reply_id );
1745 + $reply_position = get_post_field( 'menu_order', $reply_id );
1780 1746
1781 - // Get required data
1782 - $reply_id = bbp_get_reply_id( $reply_id );
1783 - $reply_position = get_post_field( 'menu_order', $reply_id );
1747 + // Reply doesn't have a position so get the raw value
1748 + if ( empty( $reply_position ) ) {
1784 1749
1785 - // Reply doesn't have a position so get the raw value
1786 - if ( empty( $reply_position ) ) {
1750 + // Get topic ID
1751 + $topic_id = ! empty( $topic_id )
1752 + ? bbp_get_topic_id( $topic_id )
1753 + : bbp_get_reply_topic_id( $reply_id );
1787 1754
1788 - // Get topic ID
1789 - $topic_id = ! empty( $topic_id )
1790 - ? bbp_get_topic_id( $topic_id )
1791 - : bbp_get_reply_topic_id( $reply_id );
1755 + // Post is not the topic
1756 + if ( $reply_id !== $topic_id ) {
1757 + $reply_position = bbp_get_reply_position_raw( $reply_id, $topic_id );
1792 1758
1793 - // Post is not the topic
1794 - if ( $reply_id !== $topic_id ) {
1795 - $reply_position = bbp_get_reply_position_raw( $reply_id, $topic_id );
1759 + // Update the reply position in the posts table so we'll never have
1760 + // to hit the DB again.
1761 + if ( ! empty( $reply_position ) ) {
1762 + bbp_update_reply_position( $reply_id, $reply_position );
1763 + }
1796 1764
1797 - // Update the reply position in the posts table so we'll never have
1798 - // to hit the DB again.
1799 - if ( ! empty( $reply_position ) ) {
1800 - bbp_update_reply_position( $reply_id, $reply_position );
1801 - }
1802 -
1803 1765 // Topic's position is always 0
1804 1766 } else {
1805 1767 $reply_position = 0;
1806 1768 }
@@ -1805,21 +1767,21 @@
1805 1767 $reply_position = 0;
1806 1768 }
1807 1769 }
1808 1770
1809 - // Bump the position by one if the topic is included in the reply loop
1810 - if ( ! bbp_show_lead_topic() ) {
1811 - ++$reply_position;
1771 + // Bump the position by one if the topic is included in the reply loop
1772 + if ( ! bbp_show_lead_topic() ) {
1773 + $reply_position++;
1774 + }
1775 +
1776 + // Filter & return
1777 + return (int) apply_filters( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id );
1812 1778 }
1813 1779
1814 - // Filter & return
1815 - return (int) apply_filters( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id );
1816 -}
1817 -
1818 1780 /** Reply Admin Links *********************************************************/
1819 1781
1820 1782 /**
1821 - * Output admin links for reply.
1783 + * Output admin links for reply
1822 1784 *
1823 1785 * @since 2.0.0 bbPress (r2667)
1824 1786 *
1825 1787 * @param array $args See {@link bbp_get_reply_admin_links()}
@@ -1826,24 +1788,23 @@
1826 1788 */
1827 1789 function bbp_reply_admin_links( $args = array() ) {
1828 1790 echo bbp_get_reply_admin_links( $args );
1829 1791 }
1830 -
1831 -/**
1832 - * Return admin links for reply.
1833 - *
1834 - * @since 2.0.0 bbPress (r2667)
1835 - *
1836 - * @param array $args This function supports these arguments:
1837 - * - id: Optional. Reply id
1838 - * - before: HTML before the links. Defaults to
1839 - * '<span class="bbp-admin-links">'
1840 - * - after: HTML after the links. Defaults to '</span>'
1841 - * - sep: Separator. Defaults to ' | '
1842 - * - links: Array of the links to display. By default, edit, trash,
1843 - * spam, reply move, and topic split links are displayed
1844 - * @return string Reply admin links.
1845 - */
1792 + /**
1793 + * Return admin links for reply
1794 + *
1795 + * @since 2.0.0 bbPress (r2667)
1796 + *
1797 + * @param array $args This function supports these arguments:
1798 + * - id: Optional. Reply id
1799 + * - before: HTML before the links. Defaults to
1800 + * '<span class="bbp-admin-links">'
1801 + * - after: HTML after the links. Defaults to '</span>'
1802 + * - sep: Separator. Defaults to ' | '
1803 + * - links: Array of the links to display. By default, edit, trash,
1804 + * spam, reply move, and topic split links are displayed
1805 + * @return string Reply admin links
1806 + */
1846 1807 function bbp_get_reply_admin_links( $args = array() ) {
1847 1808
1848 1809 // Parse arguments against default values
1849 1810 $r = bbp_parse_args(
@@ -1908,30 +1869,30 @@
1908 1869 return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args );
1909 1870 }
1910 1871
1911 1872 /**
1912 - * Output the edit link of the reply.
1873 + * Output the edit link of the reply
1913 1874 *
1914 1875 * @since 2.0.0 bbPress (r2740)
1915 1876 *
1916 - * @param array $args See {@link bbp_get_reply_edit_link()}.
1877 + * @param array $args See {@link bbp_get_reply_edit_link()}
1917 1878 */
1918 1879 function bbp_reply_edit_link( $args = array() ) {
1919 1880 echo bbp_get_reply_edit_link( $args );
1920 1881 }
1921 1882
1922 -/**
1923 - * Return the edit link of the reply.
1924 - *
1925 - * @since 2.0.0 bbPress (r2740)
1926 - *
1927 - * @param array $args This function supports these arguments:
1928 - * - id: Reply id
1929 - * - link_before: HTML before the link
1930 - * - link_after: HTML after the link
1931 - * - edit_text: Edit text. Defaults to 'Edit'
1932 - * @return string Reply edit link.
1933 - */
1883 + /**
1884 + * Return the edit link of the reply
1885 + *
1886 + * @since 2.0.0 bbPress (r2740)
1887 + *
1888 + * @param array $args This function supports these arguments:
1889 + * - id: Reply id
1890 + * - link_before: HTML before the link
1891 + * - link_after: HTML after the link
1892 + * - edit_text: Edit text. Defaults to 'Edit'
1893 + * @return string Reply edit link
1894 + */
1934 1895 function bbp_get_reply_edit_link( $args = array() ) {
1935 1896
1936 1897 // Parse arguments against default values
1937 1898 $r = bbp_parse_args(
@@ -1971,26 +1932,25 @@
1971 1932 return apply_filters( 'bbp_get_reply_edit_link', $retval, $r, $args );
1972 1933 }
1973 1934
1974 1935 /**
1975 - * Output URL to the reply edit page.
1936 + * Output URL to the reply edit page
1976 1937 *
1977 1938 * @since 2.0.0 bbPress (r2753)
1978 1939 *
1979 - * @param int $reply_id Optional. Reply id.
1940 + * @param int $reply_id Optional. Reply id
1980 1941 */
1981 1942 function bbp_reply_edit_url( $reply_id = 0 ) {
1982 1943 echo esc_url( bbp_get_reply_edit_url( $reply_id ) );
1983 1944 }
1984 -
1985 -/**
1986 - * Return URL to the reply edit page.
1987 - *
1988 - * @since 2.0.0 bbPress (r2753)
1989 - *
1990 - * @param int $reply_id Optional. Reply id.
1991 - * @return string Reply edit url.
1992 - */
1945 + /**
1946 + * Return URL to the reply edit page
1947 + *
1948 + * @since 2.0.0 bbPress (r2753)
1949 + *
1950 + * @param int $reply_id Optional. Reply id
1951 + * @return string Reply edit url
1952 + */
1993 1953 function bbp_get_reply_edit_url( $reply_id = 0 ) {
1994 1954
1995 1955 // Bail if no reply
1996 1956 $reply = bbp_get_reply( $reply_id );
@@ -2024,33 +1984,33 @@
2024 1984 return apply_filters( 'bbp_get_reply_edit_url', $url, $reply_id );
2025 1985 }
2026 1986
2027 1987 /**
2028 - * Output the trash link of the reply.
1988 + * Output the trash link of the reply
2029 1989 *
2030 1990 * @since 2.0.0 bbPress (r2740)
2031 1991 *
2032 - * @param array $args See {@link bbp_get_reply_trash_link()}.
1992 + * @param array $args See {@link bbp_get_reply_trash_link()}
2033 1993 */
2034 1994 function bbp_reply_trash_link( $args = array() ) {
2035 1995 echo bbp_get_reply_trash_link( $args );
2036 1996 }
2037 1997
2038 -/**
2039 - * Return the trash link of the reply.
2040 - *
2041 - * @since 2.0.0 bbPress (r2740)
2042 - *
2043 - * @param array $args This function supports these arguments:
2044 - * - id: Reply id
2045 - * - link_before: HTML before the link
2046 - * - link_after: HTML after the link
2047 - * - sep: Separator
2048 - * - trash_text: Trash text
2049 - * - restore_text: Restore text
2050 - * - delete_text: Delete text
2051 - * @return string Reply trash link.
2052 - */
1998 + /**
1999 + * Return the trash link of the reply
2000 + *
2001 + * @since 2.0.0 bbPress (r2740)
2002 + *
2003 + * @param array $args This function supports these arguments:
2004 + * - id: Reply id
2005 + * - link_before: HTML before the link
2006 + * - link_after: HTML after the link
2007 + * - sep: Separator
2008 + * - trash_text: Trash text
2009 + * - restore_text: Restore text
2010 + * - delete_text: Delete text
2011 + * @return string Reply trash link
2012 + */
2053 2013 function bbp_get_reply_trash_link( $args = array() ) {
2054 2014
2055 2015 // Parse arguments against default values
2056 2016 $r = bbp_parse_args(
@@ -2114,31 +2074,31 @@
2114 2074 return apply_filters( 'bbp_get_reply_trash_link', $retval, $r, $args );
2115 2075 }
2116 2076
2117 2077 /**
2118 - * Output the spam link of the reply.
2078 + * Output the spam link of the reply
2119 2079 *
2120 2080 * @since 2.0.0 bbPress (r2740)
2121 2081 *
2122 - * @param array $args See {@link bbp_get_reply_spam_link()}.
2082 + * @param array $args See {@link bbp_get_reply_spam_link()}
2123 2083 */
2124 2084 function bbp_reply_spam_link( $args = array() ) {
2125 2085 echo bbp_get_reply_spam_link( $args );
2126 2086 }
2127 2087
2128 -/**
2129 - * Return the spam link of the reply.
2130 - *
2131 - * @since 2.0.0 bbPress (r2740)
2132 - *
2133 - * @param array $args This function supports these arguments:
2134 - * - id: Reply id
2135 - * - link_before: HTML before the link
2136 - * - link_after: HTML after the link
2137 - * - spam_text: Spam text
2138 - * - unspam_text: Unspam text
2139 - * @return string Reply spam link.
2140 - */
2088 + /**
2089 + * Return the spam link of the reply
2090 + *
2091 + * @since 2.0.0 bbPress (r2740)
2092 + *
2093 + * @param array $args This function supports these arguments:
2094 + * - id: Reply id
2095 + * - link_before: HTML before the link
2096 + * - link_after: HTML after the link
2097 + * - spam_text: Spam text
2098 + * - unspam_text: Unspam text
2099 + * @return string Reply spam link
2100 + */
2141 2101 function bbp_get_reply_spam_link( $args = array() ) {
2142 2102
2143 2103 // Parse arguments against default values
2144 2104 $r = bbp_parse_args(
@@ -2178,35 +2138,35 @@
2178 2138 return apply_filters( 'bbp_get_reply_spam_link', $retval, $r, $args );
2179 2139 }
2180 2140
2181 2141 /**
2182 - * Move reply link.
2142 + * Move reply link
2183 2143 *
2184 - * Output the move link of the reply.
2144 + * Output the move link of the reply
2185 2145 *
2186 2146 * @since 2.3.0 bbPress (r4522)
2187 2147 *
2188 - * @param array $args See {@link bbp_get_reply_move_link()}.
2148 + * @param array $args See {@link bbp_get_reply_move_link()}
2189 2149 */
2190 2150 function bbp_reply_move_link( $args = array() ) {
2191 2151 echo bbp_get_reply_move_link( $args );
2192 2152 }
2193 2153
2194 -/**
2195 - * Get move reply link.
2196 - *
2197 - * Return the move link of the reply.
2198 - *
2199 - * @since 2.3.0 bbPress (r4522)
2200 - *
2201 - * @param array $args This function supports these arguments:
2202 - * - id: Reply id
2203 - * - link_before: HTML before the link
2204 - * - link_after: HTML after the link
2205 - * - move_text: Move text
2206 - * - move_title: Move title attribute
2207 - * @return string Reply move link.
2208 - */
2154 + /**
2155 + * Get move reply link
2156 + *
2157 + * Return the move link of the reply
2158 + *
2159 + * @since 2.3.0 bbPress (r4522)
2160 + *
2161 + * @param array $args This function supports these arguments:
2162 + * - id: Reply id
2163 + * - link_before: HTML before the link
2164 + * - link_after: HTML after the link
2165 + * - move_text: Move text
2166 + * - move_title: Move title attribute
2167 + * @return string Reply move link
2168 + */
2209 2169 function bbp_get_reply_move_link( $args = array() ) {
2210 2170
2211 2171 // Parse arguments against default values
2212 2172 $r = bbp_parse_args(
@@ -2244,35 +2204,35 @@
2244 2204 return apply_filters( 'bbp_get_reply_move_link', $retval, $r, $args );
2245 2205 }
2246 2206
2247 2207 /**
2248 - * Split topic link.
2208 + * Split topic link
2249 2209 *
2250 - * Output the split link of the topic (but is bundled with each reply).
2210 + * Output the split link of the topic (but is bundled with each reply)
2251 2211 *
2252 2212 * @since 2.0.0 bbPress (r2756)
2253 2213 *
2254 - * @param array $args See {@link bbp_get_topic_split_link()}.
2214 + * @param array $args See {@link bbp_get_topic_split_link()}
2255 2215 */
2256 2216 function bbp_topic_split_link( $args = array() ) {
2257 2217 echo bbp_get_topic_split_link( $args );
2258 2218 }
2259 2219
2260 -/**
2261 - * Get split topic link.
2262 - *
2263 - * Return the split link of the topic (but is bundled with each reply).
2264 - *
2265 - * @since 2.0.0 bbPress (r2756)
2266 - *
2267 - * @param array $args This function supports these arguments:
2268 - * - id: Reply id
2269 - * - link_before: HTML before the link
2270 - * - link_after: HTML after the link
2271 - * - split_text: Split text
2272 - * - split_title: Split title attribute
2273 - * @return string Topic split link.
2274 - */
2220 + /**
2221 + * Get split topic link
2222 + *
2223 + * Return the split link of the topic (but is bundled with each reply)
2224 + *
2225 + * @since 2.0.0 bbPress (r2756)
2226 + *
2227 + * @param array $args This function supports these arguments:
2228 + * - id: Reply id
2229 + * - link_before: HTML before the link
2230 + * - link_after: HTML after the link
2231 + * - split_text: Split text
2232 + * - split_title: Split title attribute
2233 + * @return string Topic split link
2234 + */
2275 2235 function bbp_get_topic_split_link( $args = array() ) {
2276 2236
2277 2237 // Parse arguments against default values
2278 2238 $r = bbp_parse_args(
@@ -2310,32 +2270,32 @@
2310 2270 return apply_filters( 'bbp_get_topic_split_link', $retval, $r, $args );
2311 2271 }
2312 2272
2313 2273 /**
2314 - * Output the approve link of the reply.
2274 + * Output the approve link of the reply
2315 2275 *
2316 2276 * @since 2.6.0 bbPress (r5507)
2317 2277 *
2318 - * @param array $args See {@link bbp_get_reply_approve_link()}.
2278 + * @param array $args See {@link bbp_get_reply_approve_link()}
2319 2279 */
2320 2280 function bbp_reply_approve_link( $args = array() ) {
2321 2281 echo bbp_get_reply_approve_link( $args );
2322 2282 }
2323 2283
2324 -/**
2325 - * Return the approve link of the reply.
2326 - *
2327 - * @since 2.6.0 bbPress (r5507)
2328 - *
2329 - * @param array $args This function supports these args:
2330 - * - id: Optional. Reply id
2331 - * - link_before: Before the link
2332 - * - link_after: After the link
2333 - * - sep: Separator between links
2334 - * - approve_text: Approve text
2335 - * - unapprove_text: Unapprove text
2336 - * @return string Reply approve link.
2337 - */
2284 + /**
2285 + * Return the approve link of the reply
2286 + *
2287 + * @since 2.6.0 bbPress (r5507)
2288 + *
2289 + * @param array $args This function supports these args:
2290 + * - id: Optional. Reply id
2291 + * - link_before: Before the link
2292 + * - link_after: After the link
2293 + * - sep: Separator between links
2294 + * - approve_text: Approve text
2295 + * - unapprove_text: Unapprove text
2296 + * @return string Reply approve link
2297 + */
2338 2298 function bbp_get_reply_approve_link( $args = array() ) {
2339 2299
2340 2300 // Parse arguments against default values
2341 2301 $r = bbp_parse_args(
@@ -2376,86 +2336,85 @@
2376 2336 return apply_filters( 'bbp_get_reply_approve_link', $retval, $r, $args );
2377 2337 }
2378 2338
2379 2339 /**
2380 - * Output the row class of a reply.
2340 + * Output the row class of a reply
2381 2341 *
2382 2342 * @since 2.0.0 bbPress (r2678)
2383 2343 *
2384 - * @param int $reply_id Optional. Reply ID.
2385 - * @param array Extra classes you can pass when calling this function.
2344 + * @param int $reply_id Optional. Reply ID
2345 + * @param array Extra classes you can pass when calling this function
2386 2346 */
2387 2347 function bbp_reply_class( $reply_id = 0, $classes = array() ) {
2388 2348 echo bbp_get_reply_class( $reply_id, $classes );
2389 2349 }
2350 + /**
2351 + * Return the row class of a reply
2352 + *
2353 + * @since 2.0.0 bbPress (r2678)
2354 + *
2355 + * @param int $reply_id Optional. Reply ID
2356 + * @param array Extra classes you can pass when calling this function
2357 + * @return string Row class of the reply
2358 + */
2359 + function bbp_get_reply_class( $reply_id = 0, $classes = array() ) {
2360 + $bbp = bbpress();
2361 + $reply_id = bbp_get_reply_id( $reply_id );
2362 + $topic_id = bbp_get_reply_topic_id( $reply_id );
2363 + $forum_id = bbp_get_reply_forum_id( $reply_id );
2364 + $author_id = bbp_get_reply_author_id( $reply_id );
2365 + $reply_pos = bbp_get_reply_position( $reply_id, true );
2366 + $classes = array_filter( (array) $classes );
2367 + $count = isset( $bbp->reply_query->current_post )
2368 + ? (int) $bbp->reply_query->current_post
2369 + : 1;
2390 2370
2391 -/**
2392 - * Return the row class of a reply.
2393 - *
2394 - * @since 2.0.0 bbPress (r2678)
2395 - *
2396 - * @param int $reply_id Optional. Reply ID.
2397 - * @param array Extra classes you can pass when calling this function.
2398 - * @return string Row class of the reply.
2399 - */
2400 -function bbp_get_reply_class( $reply_id = 0, $classes = array() ) {
2401 - $bbp = bbpress();
2402 - $reply_id = bbp_get_reply_id( $reply_id );
2403 - $topic_id = bbp_get_reply_topic_id( $reply_id );
2404 - $forum_id = bbp_get_reply_forum_id( $reply_id );
2405 - $author_id = bbp_get_reply_author_id( $reply_id );
2406 - $reply_pos = bbp_get_reply_position( $reply_id, true );
2407 - $classes = array_filter( (array) $classes );
2408 - $count = isset( $bbp->reply_query->current_post )
2409 - ? (int) $bbp->reply_query->current_post
2410 - : 1;
2371 + // Stripes
2372 + $even_odd = ( $count % 2 )
2373 + ? 'even'
2374 + : 'odd';
2411 2375
2412 - // Stripes
2413 - $even_odd = ( $count % 2 )
2414 - ? 'even'
2415 - : 'odd';
2376 + // Forum moderator replied to topic
2377 + $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id )
2378 + ? 'forum-mod'
2379 + : '';
2416 2380
2417 - // Forum moderator replied to topic
2418 - $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id )
2419 - ? 'forum-mod'
2420 - : '';
2381 + // Topic author replied to others
2382 + $topic_author = ( bbp_get_topic_author_id( $topic_id ) === $author_id )
2383 + ? 'topic-author'
2384 + : '';
2421 2385
2422 - // Topic author replied to others
2423 - $topic_author = ( bbp_get_topic_author_id( $topic_id ) === $author_id )
2424 - ? 'topic-author'
2425 - : '';
2386 + // Get reply classes
2387 + $reply_classes = array(
2388 + 'loop-item-' . $count,
2389 + 'user-id-' . $author_id,
2390 + 'bbp-parent-forum-' . $forum_id,
2391 + 'bbp-parent-topic-' . $topic_id,
2392 + 'bbp-reply-position-' . $reply_pos,
2393 + $even_odd,
2394 + $topic_author,
2395 + $forum_moderator
2396 + );
2426 2397
2427 - // Get reply classes
2428 - $reply_classes = array(
2429 - 'loop-item-' . $count,
2430 - 'user-id-' . $author_id,
2431 - 'bbp-parent-forum-' . $forum_id,
2432 - 'bbp-parent-topic-' . $topic_id,
2433 - 'bbp-reply-position-' . $reply_pos,
2434 - $even_odd,
2435 - $topic_author,
2436 - $forum_moderator
2437 - );
2398 + // Run the topic classes through the post-class filters, which also
2399 + // handles the escaping of each individual class.
2400 + $post_classes = get_post_class( array_merge( $classes, $reply_classes ), $reply_id );
2438 2401
2439 - // Run the topic classes through the post-class filters, which also
2440 - // handles the escaping of each individual class.
2441 - $post_classes = get_post_class( array_merge( $classes, $reply_classes ), $reply_id );
2402 + // Filter
2403 + $new_classes = apply_filters( 'bbp_get_reply_class', $post_classes, $reply_id, $classes );
2442 2404
2443 - // Filter
2444 - $new_classes = apply_filters( 'bbp_get_reply_class', $post_classes, $reply_id, $classes );
2405 + // Return
2406 + return 'class="' . implode( ' ', $new_classes ) . '"';
2407 + }
2445 2408
2446 - // Return
2447 - return 'class="' . implode( ' ', $new_classes ) . '"';
2448 -}
2449 -
2450 2409 /** Pagination ****************************************************************/
2451 2410
2452 2411 /**
2453 - * Return the base URL used inside of pagination links.
2412 + * Return the base URL used inside of pagination links
2454 2413 *
2455 2414 * @since 2.6.0 bbPress (r6680)
2456 2415 *
2457 - * @param int $topic_id Topic id.
2416 + * @param int $topic_id
2458 2417 * @return string
2459 2418 */
2460 2419 function bbp_get_replies_pagination_base( $topic_id = 0 ) {
2461 2420
@@ -2490,9 +2449,9 @@
2490 2449 return apply_filters( 'bbp_get_replies_pagination_base', $base, $topic_id );
2491 2450 }
2492 2451
2493 2452 /**
2494 - * Output the topic pagination count.
2453 + * Output the topic pagination count
2495 2454 *
2496 2455 * The results are unescaped by design, to allow them to be filtered freely via
2497 2456 * the 'bbp_get_topic_pagination_count' filter.
2498 2457 *
@@ -2501,16 +2460,15 @@
2501 2460 */
2502 2461 function bbp_topic_pagination_count() {
2503 2462 echo bbp_get_topic_pagination_count();
2504 2463 }
2505 -
2506 -/**
2507 - * Return the topic pagination count.
2508 - *
2509 - * @since 2.0.0 bbPress (r2519)
2510 - *
2511 - * @return string Topic pagination count.
2512 - */
2464 + /**
2465 + * Return the topic pagination count
2466 + *
2467 + * @since 2.0.0 bbPress (r2519)
2468 + *
2469 + * @return string Topic pagination count
2470 + */
2513 2471 function bbp_get_topic_pagination_count() {
2514 2472 $bbp = bbpress();
2515 2473
2516 2474 // Define local variable(s)
@@ -2576,9 +2534,9 @@
2576 2534 return apply_filters( 'bbp_get_topic_pagination_count', $retstr );
2577 2535 }
2578 2536
2579 2537 /**
2580 - * Output topic pagination links.
2538 + * Output topic pagination links
2581 2539 *
2582 2540 * @since 2.0.0 bbPress (r2519)
2583 2541 */
2584 2542 function bbp_topic_pagination_links() {
@@ -2583,31 +2541,30 @@
2583 2541 */
2584 2542 function bbp_topic_pagination_links() {
2585 2543 echo bbp_get_topic_pagination_links();
2586 2544 }
2545 + /**
2546 + * Return topic pagination links
2547 + *
2548 + * @since 2.0.0 bbPress (r2519)
2549 + *
2550 + * @return string Topic pagination links
2551 + */
2552 + function bbp_get_topic_pagination_links() {
2553 + $bbp = bbpress();
2587 2554
2588 -/**
2589 - * Return topic pagination links.
2590 - *
2591 - * @since 2.0.0 bbPress (r2519)
2592 - *
2593 - * @return string Topic pagination links.
2594 - */
2595 -function bbp_get_topic_pagination_links() {
2596 - $bbp = bbpress();
2555 + if ( ! isset( $bbp->reply_query->pagination_links ) || empty( $bbp->reply_query->pagination_links ) ) {
2556 + return false;
2557 + }
2597 2558
2598 - if ( ! isset( $bbp->reply_query->pagination_links ) || empty( $bbp->reply_query->pagination_links ) ) {
2599 - return false;
2559 + // Filter & return
2560 + return apply_filters( 'bbp_get_topic_pagination_links', $bbp->reply_query->pagination_links );
2600 2561 }
2601 2562
2602 - // Filter & return
2603 - return apply_filters( 'bbp_get_topic_pagination_links', $bbp->reply_query->pagination_links );
2604 -}
2605 -
2606 2563 /** Forms *********************************************************************/
2607 2564
2608 2565 /**
2609 - * Output the value of reply content field.
2566 + * Output the value of reply content field
2610 2567 *
2611 2568 * @since 2.0.0 bbPress (r3101)
2612 2569 */
2613 2570 function bbp_form_reply_content() {
@@ -2612,37 +2569,36 @@
2612 2569 */
2613 2570 function bbp_form_reply_content() {
2614 2571 echo bbp_get_form_reply_content();
2615 2572 }
2573 + /**
2574 + * Return the value of reply content field
2575 + *
2576 + * @since 2.0.0 bbPress (r3101)
2577 + *
2578 + * @return string Value of reply content field
2579 + */
2580 + function bbp_get_form_reply_content() {
2616 2581
2617 -/**
2618 - * Return the value of reply content field.
2619 - *
2620 - * @since 2.0.0 bbPress (r3101)
2621 - *
2622 - * @return string Value of reply content field.
2623 - */
2624 -function bbp_get_form_reply_content() {
2582 + // Get _POST data
2583 + if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_content'] ) ) {
2584 + $reply_content = wp_unslash( $_POST['bbp_reply_content'] );
2625 2585
2626 - // Get _POST data
2627 - if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_content'] ) ) {
2628 - $reply_content = wp_unslash( $_POST['bbp_reply_content'] );
2586 + // Get edit data
2587 + } elseif ( bbp_is_reply_edit() ) {
2588 + $reply_content = bbp_get_global_post_field( 'post_content', 'raw' );
2629 2589
2630 - // Get edit data
2631 - } elseif ( bbp_is_reply_edit() ) {
2632 - $reply_content = bbp_get_global_post_field( 'post_content', 'raw' );
2590 + // No data
2591 + } else {
2592 + $reply_content = '';
2593 + }
2633 2594
2634 - // No data
2635 - } else {
2636 - $reply_content = '';
2595 + // Filter & return
2596 + return apply_filters( 'bbp_get_form_reply_content', $reply_content );
2637 2597 }
2638 2598
2639 - // Filter & return
2640 - return apply_filters( 'bbp_get_form_reply_content', $reply_content );
2641 -}
2642 -
2643 2599 /**
2644 - * Output the value of the reply to field.
2600 + * Output the value of the reply to field
2645 2601 *
2646 2602 * @since 2.4.0 bbPress (r4944)
2647 2603 */
2648 2604 function bbp_form_reply_to() {
@@ -2648,34 +2604,34 @@
2648 2604 function bbp_form_reply_to() {
2649 2605 echo bbp_get_form_reply_to();
2650 2606 }
2651 2607
2652 -/**
2653 - * Return the value of reply to field.
2654 - *
2655 - * @since 2.4.0 bbPress (r4944)
2656 - *
2657 - * @return string Value of reply to field.
2658 - */
2659 -function bbp_get_form_reply_to() {
2608 + /**
2609 + * Return the value of reply to field
2610 + *
2611 + * @since 2.4.0 bbPress (r4944)
2612 + *
2613 + * @return string Value of reply to field
2614 + */
2615 + function bbp_get_form_reply_to() {
2660 2616
2661 - // Set initial value
2662 - $reply_to = 0;
2617 + // Set initial value
2618 + $reply_to = 0;
2663 2619
2664 - // Get $_REQUEST data
2665 - if ( isset( $_REQUEST['bbp_reply_to'] ) ) {
2666 - $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] );
2667 - }
2620 + // Get $_REQUEST data
2621 + if ( isset( $_REQUEST['bbp_reply_to'] ) ) {
2622 + $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] );
2623 + }
2668 2624
2669 - // If empty, get from meta
2670 - if ( empty( $reply_to ) ) {
2671 - $reply_to = bbp_get_reply_to();
2625 + // If empty, get from meta
2626 + if ( empty( $reply_to ) ) {
2627 + $reply_to = bbp_get_reply_to();
2628 + }
2629 +
2630 + // Filter & return
2631 + return apply_filters( 'bbp_get_form_reply_to', $reply_to );
2672 2632 }
2673 2633
2674 - // Filter & return
2675 - return apply_filters( 'bbp_get_form_reply_to', $reply_to );
2676 -}
2677 -
2678 2634 /**
2679 2635 * Output a select box allowing to pick which reply an existing hierarchical
2680 2636 * reply belongs to.
2681 2637 *
@@ -2680,23 +2636,22 @@
2680 2636 * reply belongs to.
2681 2637 *
2682 2638 * @since 2.6.0 bbPress (r5387)
2683 2639 *
2684 - * @param int $reply_id Reply id.
2640 + * @param int $reply_id
2685 2641 */
2686 2642 function bbp_reply_to_dropdown( $reply_id = 0 ) {
2687 2643 echo bbp_get_reply_to_dropdown( $reply_id );
2688 2644 }
2689 -
2690 -/**
2691 - * Return a select box allowing to pick which topic/reply a reply belongs.
2692 - *
2693 - * @since 2.6.0 bbPress (r5387)
2694 - *
2695 - * @param int $reply_id Reply id.
2696 - *
2697 - * @return string The dropdown.
2698 - */
2645 + /**
2646 + * Return a select box allowing to pick which topic/reply a reply belongs.
2647 + *
2648 + * @since 2.6.0 bbPress (r5387)
2649 + *
2650 + * @param int $reply_id
2651 + *
2652 + * @return string The dropdown
2653 + */
2699 2654 function bbp_get_reply_to_dropdown( $reply_id = 0 ) {
2700 2655
2701 2656 // Validate the reply data
2702 2657 $reply_id = bbp_get_reply_id( $reply_id );
@@ -2758,9 +2713,9 @@
2758 2713 return apply_filters( 'bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id );
2759 2714 }
2760 2715
2761 2716 /**
2762 - * Output checked value of reply log edit field.
2717 + * Output checked value of reply log edit field
2763 2718 *
2764 2719 * @since 2.0.0 bbPress (r3101)
2765 2720 */
2766 2721 function bbp_form_reply_log_edit() {
@@ -2765,36 +2720,35 @@
2765 2720 */
2766 2721 function bbp_form_reply_log_edit() {
2767 2722 echo bbp_get_form_reply_log_edit();
2768 2723 }
2724 + /**
2725 + * Return checked value of reply log edit field
2726 + *
2727 + * @since 2.0.0 bbPress (r3101)
2728 + *
2729 + * @return string Reply log edit checked value
2730 + */
2731 + function bbp_get_form_reply_log_edit() {
2769 2732
2770 -/**
2771 - * Return checked value of reply log edit field.
2772 - *
2773 - * @since 2.0.0 bbPress (r3101)
2774 - *
2775 - * @return string Reply log edit checked value.
2776 - */
2777 -function bbp_get_form_reply_log_edit() {
2733 + // Get _POST data
2734 + if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_log_reply_edit'] ) ) {
2735 + $reply_revision = (bool) $_POST['bbp_log_reply_edit'];
2778 2736
2779 - // Get _POST data
2780 - if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_log_reply_edit'] ) ) {
2781 - $reply_revision = (bool) $_POST['bbp_log_reply_edit'];
2737 + // No data
2738 + } else {
2739 + $reply_revision = true;
2740 + }
2782 2741
2783 - // No data
2784 - } else {
2785 - $reply_revision = true;
2742 + // Get checked output
2743 + $checked = checked( $reply_revision, true, false );
2744 +
2745 + // Filter & return
2746 + return apply_filters( 'bbp_get_form_reply_log_edit', $checked, $reply_revision );
2786 2747 }
2787 2748
2788 - // Get checked output
2789 - $checked = checked( $reply_revision, true, false );
2790 -
2791 - // Filter & return
2792 - return apply_filters( 'bbp_get_form_reply_log_edit', $checked, $reply_revision );
2793 -}
2794 -
2795 2749 /**
2796 - * Output the value of the reply edit reason.
2750 + * Output the value of the reply edit reason
2797 2751 *
2798 2752 * @since 2.0.0 bbPress (r3101)
2799 2753 */
2800 2754 function bbp_form_reply_edit_reason() {
@@ -2799,33 +2753,32 @@
2799 2753 */
2800 2754 function bbp_form_reply_edit_reason() {
2801 2755 echo bbp_get_form_reply_edit_reason();
2802 2756 }
2757 + /**
2758 + * Return the value of the reply edit reason
2759 + *
2760 + * @since 2.0.0 bbPress (r3101)
2761 + *
2762 + * @return string Reply edit reason value
2763 + */
2764 + function bbp_get_form_reply_edit_reason() {
2803 2765
2804 -/**
2805 - * Return the value of the reply edit reason.
2806 - *
2807 - * @since 2.0.0 bbPress (r3101)
2808 - *
2809 - * @return string Reply edit reason value.
2810 - */
2811 -function bbp_get_form_reply_edit_reason() {
2766 + // Get _POST data
2767 + if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_edit_reason'] ) ) {
2768 + $reply_edit_reason = wp_unslash( $_POST['bbp_reply_edit_reason'] );
2812 2769
2813 - // Get _POST data
2814 - if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_edit_reason'] ) ) {
2815 - $reply_edit_reason = wp_unslash( $_POST['bbp_reply_edit_reason'] );
2770 + // No data
2771 + } else {
2772 + $reply_edit_reason = '';
2773 + }
2816 2774
2817 - // No data
2818 - } else {
2819 - $reply_edit_reason = '';
2775 + // Filter & return
2776 + return apply_filters( 'bbp_get_form_reply_edit_reason', $reply_edit_reason );
2820 2777 }
2821 2778
2822 - // Filter & return
2823 - return apply_filters( 'bbp_get_form_reply_edit_reason', $reply_edit_reason );
2824 -}
2825 -
2826 2779 /**
2827 - * Output value reply status dropdown.
2780 + * Output value reply status dropdown
2828 2781 *
2829 2782 * @since 2.6.0 bbPress (r5399)
2830 2783 *
2831 2784 * @param $args This function supports these arguments:
@@ -2836,24 +2789,23 @@
2836 2789 */
2837 2790 function bbp_form_reply_status_dropdown( $args = array() ) {
2838 2791 echo bbp_get_form_reply_status_dropdown( $args );
2839 2792 }
2840 -
2841 -/**
2842 - * Returns reply status dropdown.
2843 - *
2844 - * This dropdown is only intended to be seen by users with the 'moderate'
2845 - * capability. Because of this, no additional capability checks are performed
2846 - * within this function to check available reply statuses.
2847 - *
2848 - * @since 2.6.0 bbPress (r5399)
2849 - *
2850 - * @param $args This function supports these arguments:
2851 - * - select_id: Select id. Defaults to bbp_reply_status
2852 - * - tab: Deprecated. Tabindex
2853 - * - reply_id: Reply id
2854 - * - selected: Override the selected option
2855 - */
2793 + /**
2794 + * Returns reply status dropdown
2795 + *
2796 + * This dropdown is only intended to be seen by users with the 'moderate'
2797 + * capability. Because of this, no additional capability checks are performed
2798 + * within this function to check available reply statuses.
2799 + *
2800 + * @since 2.6.0 bbPress (r5399)
2801 + *
2802 + * @param $args This function supports these arguments:
2803 + * - select_id: Select id. Defaults to bbp_reply_status
2804 + * - tab: Deprecated. Tabindex
2805 + * - reply_id: Reply id
2806 + * - selected: Override the selected option
2807 + */
2856 2808 function bbp_get_form_reply_status_dropdown( $args = array() ) {
2857 2809
2858 2810 // Parse arguments against default values
2859 2811 $r = bbp_parse_args(
@@ -2914,9 +2866,9 @@
2914 2866 * @see bbp_reply_form_fields()
2915 2867 *
2916 2868 * @since 2.6.0 bbPress (r5558)
2917 2869 *
2918 - * @return boolean True if is a post request with valid nonce.
2870 + * @return boolean True if is a post request with valid nonce
2919 2871 */
2920 2872 function bbp_is_reply_form_post_request() {
2921 2873
2922 2874 // Bail if not a post request