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