| | 614 | |
| | 615 | /** User Topic and Reply Display Counts ***************************************/ |
| | 616 | |
| | 617 | /** |
| | 618 | * Output the user topic counts |
| | 619 | * |
| | 620 | * @since bbPress (rXXXX) |
| | 621 | * |
| | 622 | * @param mixed $args Optional. If an integer, it is used as user id. |
| | 623 | * @uses bbp_get_author_display_topic_count() To get the user topic counts |
| | 624 | */ |
| | 625 | function bbp_author_display_topic_count( $args = '' ) { |
| | 626 | echo bbp_get_author_display_topic_count( $args ); |
| | 627 | } |
| | 628 | /** |
| | 629 | * Return the user topic counts |
| | 630 | * |
| | 631 | * @since bbPress (rXXXX) |
| | 632 | * |
| | 633 | * @param mixed $args Optional. If an integer, it is used as user id. |
| | 634 | * @uses apply_filters Calls 'bbp_no_author_display_topic_count' to |
| | 635 | * not display users topics started counts |
| | 636 | * @uses bbp_get_user_id() To get the user id |
| | 637 | * @uses bbp_get_user_topic_count To get the users topics started count |
| | 638 | * @uses apply_filters() Calls 'bbp_get_author_display_topic_count' with the |
| | 639 | * topics started count and args |
| | 640 | * @return string Users topics started count |
| | 641 | */ |
| | 642 | function bbp_get_author_display_topic_count( $args = '' ) { |
| | 643 | |
| | 644 | // Turn off author displayed topic counts |
| | 645 | if ( apply_filters( 'bbp_no_author_display_topic_count', is_front_page() ) ) { |
| | 646 | return; |
| | 647 | } |
| | 648 | |
| | 649 | // Parse arguments against default values |
| | 650 | $r = bbp_parse_args( $args, array( |
| | 651 | 'post_id' => 0, |
| | 652 | 'before' => '<div class="bbp-author-topic-count">', |
| | 653 | 'title' => __('Topics Started: ', 'bbpress'), |
| | 654 | 'after' => '</div>' |
| | 655 | ), 'get_author_display_topic_count' ); |
| | 656 | |
| | 657 | // Used as user id |
| | 658 | if ( is_numeric( $args ) ) { |
| | 659 | $user_id = bbp_get_user_id( $args ); |
| | 660 | } |
| | 661 | |
| | 662 | // Validate the user ID |
| | 663 | if ( ! empty( $user_id ) ) { |
| | 664 | |
| | 665 | // Get the users topic count |
| | 666 | $topic_count = bbp_get_user_topic_count( $user_id ); |
| | 667 | $topic_count = $r['before'] . $r['title'] . $topic_count . $r['after']; |
| | 668 | } |
| | 669 | |
| | 670 | return apply_filters( 'bbp_get_author_display_topic_count', $topic_count, $r ); |
| | 671 | } |
| | 672 | |
| | 673 | /** |
| | 674 | * Output the user reply counts |
| | 675 | * |
| | 676 | * @since bbPress (rXXXX) |
| | 677 | * |
| | 678 | * @param mixed $args Optional. If an integer, it is used as user id. |
| | 679 | * @uses bbp_get_author_display_reply_count() To get the user reply counts |
| | 680 | */ |
| | 681 | function bbp_author_display_reply_count( $args = '' ) { |
| | 682 | echo bbp_get_author_display_reply_count( $args ); |
| | 683 | } |
| | 684 | /** |
| | 685 | * Return the user reply counts |
| | 686 | * |
| | 687 | * @since bbPress (rXXXX) |
| | 688 | * |
| | 689 | * @param mixed $args Optional. If an integer, it is used as user id. |
| | 690 | * @uses apply_filters Calls 'bbp_no_author_display_reply_count' to |
| | 691 | * not display user replies created counts |
| | 692 | * @uses bbp_get_user_id() To get the user id |
| | 693 | * @uses bbp_get_user_reply_count To get the users replies created count |
| | 694 | * @uses apply_filters() Calls 'bbp_get_author_display_reply_count' with the |
| | 695 | * topics started count and args |
| | 696 | * @return string Users replies created count |
| | 697 | */ |
| | 698 | function bbp_get_author_display_reply_count( $args = '' ) { |
| | 699 | |
| | 700 | // Turn off author author displayed reply counts |
| | 701 | if ( apply_filters( 'bbp_no_author_display_reply_count', is_front_page() ) ) { |
| | 702 | return; |
| | 703 | } |
| | 704 | |
| | 705 | // Parse arguments against default values |
| | 706 | $r = bbp_parse_args( $args, array( |
| | 707 | 'post_id' => 0, |
| | 708 | 'before' => '<div class="bbp-author-reply-count">', |
| | 709 | 'title' => __('Replies Created: ', 'bbpress'), |
| | 710 | 'after' => '</div>' |
| | 711 | ), 'get_author_display_reply_count' ); |
| | 712 | |
| | 713 | // Used as user id |
| | 714 | if ( is_numeric( $args ) ) { |
| | 715 | $user_id = bbp_get_user_id( $args ); |
| | 716 | } |
| | 717 | |
| | 718 | // Validate the user ID |
| | 719 | if ( ! empty( $user_id ) ) { |
| | 720 | |
| | 721 | // Get the users reply count |
| | 722 | $reply_count = bbp_get_user_reply_count( $user_id ); |
| | 723 | $reply_count = $r['before'] . $r['title'] . $reply_count . $r['after']; |
| | 724 | } |
| | 725 | |
| | 726 | return apply_filters( 'bbp_get_author_display_reply_count', $reply_count, $r ); |
| | 727 | } |
| | 728 | |