Ticket #1989: 1989.2.patch
File 1989.2.patch, 5.7 KB (added by , 12 years ago) |
---|
-
includes/replies/template.php
661 661 function bbp_reply_revision_log( $reply_id = 0 ) { 662 662 echo bbp_get_reply_revision_log( $reply_id ); 663 663 } 664 664 665 /** 665 666 * Return the formatted revision log of the reply 666 667 * … … 696 697 return false; 697 698 698 699 // Get the actual revisions 699 $revisions = bbp_get_reply_revisions( $reply_id ); 700 701 $total = $limit = - 1; 702 $order = 'ASC'; 703 704 if ( empty( $_GET['bbp_reply_revisions_all'] ) || intval( $_GET['bbp_reply_revisions_all'] ) != $reply_id ) { 705 $total = bbp_get_reply_revision_count( $reply_id ); 706 $limit = (int) apply_filters( 'bbp_reply_revision_log_limit', 1 ); 707 $order = 'DESC'; 708 } 709 710 $revisions = bbp_get_reply_revisions( $reply_id, $limit, $order ); 711 700 712 if ( empty( $revisions ) ) 701 713 return false; 702 714 … … 723 735 $r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n"; 724 736 } 725 737 $r .= "\t" . '</li>' . "\n"; 738 } 726 739 740 // If there are more revisions to show 741 if ( $total > $limit ) { 742 $topic_id = bbp_get_reply_topic_id( $reply_id ); 743 $link_url = add_query_arg( 'bbp_reply_revisions_all', $reply_id, bbp_get_topic_permalink( $topic_id ) . '/#post-' . $reply_id ); 744 $link_text = esc_html__( sprintf( 'Show %d more', $total - $limit ) ); 745 746 $r .= sprintf( "<li class='bbp-reply-revision-log-more' data-id='%d'><a href='%s'>%s</a></li>", $reply_id, $link_url, $link_text ); 727 747 } 728 748 729 749 $r .= "\n" . '</ul>' . "\n\n"; 730 750 731 751 return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id ); 732 752 } 753 733 754 /** 734 755 * Return the raw revision log of the reply 735 756 * … … 755 776 * 756 777 * @since bbPress (r2782) 757 778 * 758 * @param int $reply_id Optional. Reply id 779 * @param int $reply_id Optional. Topic id 780 * @param int $count Optional. Amout of revisions to grab. 781 * @param string $order Optional. ASC/DESC Order of the results. 782 * 759 783 * @uses bbp_get_reply_id() To get the reply id 760 * @uses wp_get_post_revisions() To get the replyrevisions784 * @uses wp_get_post_revisions() To get the topic revisions 761 785 * @uses apply_filters() Calls 'bbp_get_reply_revisions' 762 786 * with the revisions and reply id 763 * @return string reply revisions 787 * 788 * @return string Reply revisions 764 789 */ 765 function bbp_get_reply_revisions( $reply_id = 0 ) {790 function bbp_get_reply_revisions( $reply_id = 0, $count = -1, $order = 'ASC' ) { 766 791 $reply_id = bbp_get_reply_id( $reply_id ); 767 $revisions = wp_get_post_revisions( $reply_id, array( 'order' => 'ASC') );792 $revisions = wp_get_post_revisions( $reply_id, array( 'order' => $order, 'posts_per_page' => $count ) ); 768 793 769 794 return apply_filters( 'bbp_get_reply_revisions', $revisions, $reply_id ); 770 795 } -
includes/topics/template.php
885 885 function bbp_topic_revision_log( $topic_id = 0 ) { 886 886 echo bbp_get_topic_revision_log( $topic_id ); 887 887 } 888 888 889 /** 889 890 * Return the formatted revision log of the topic 890 891 * … … 910 911 if ( empty( $topic_id ) || empty( $revision_log ) || !is_array( $revision_log ) ) 911 912 return false; 912 913 913 $revisions = bbp_get_topic_revisions( $topic_id ); 914 $total = $limit = - 1; 915 $order = 'ASC'; 916 917 if ( empty( $_GET['bbp_topic_revisions_all'] ) || intval( $_GET['bbp_topic_revisions_all'] ) != $topic_id ) { 918 $total = bbp_get_topic_revision_count( $topic_id ); 919 $limit = (int) apply_filters( 'bbp_topic_revision_log_limit', 1 ); 920 $order = 'DESC'; 921 } 922 923 $revisions = bbp_get_topic_revisions( $topic_id, $limit, $order ); 924 914 925 if ( empty( $revisions ) ) 915 926 return false; 916 927 … … 937 948 $r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n"; 938 949 } 939 950 $r .= "\t" . '</li>' . "\n"; 951 } 940 952 953 // If there are more revisions to show 954 if ( $total > $limit ) { 955 $link_url = add_query_arg( 'bbp_topic_revisions_all', $topic_id, bbp_get_topic_permalink( $topic_id ) . '/#post-' . $topic_id ); 956 $link_text = esc_html__( sprintf( 'Show %d more', $total - $limit ) ); 957 958 $r .= sprintf( "<li class='bbp-topic-revision-log-more' data-id='%d'><a href='%s'>%s</a></li>", $topic_id, $link_url, $link_text ); 941 959 } 942 960 943 961 $r .= "\n" . '</ul>' . "\n\n"; 944 962 945 963 return apply_filters( 'bbp_get_topic_revision_log', $r, $topic_id ); 946 964 } 965 947 966 /** 948 967 * Return the raw revision log of the topic 949 968 * … … 957 976 * @return string Raw revision log of the topic 958 977 */ 959 978 function bbp_get_topic_raw_revision_log( $topic_id = 0 ) { 960 $topic_id = bbp_get_topic_id( $topic_id ); 961 979 $topic_id = bbp_get_topic_id( $topic_id ); 962 980 $revision_log = get_post_meta( $topic_id, '_bbp_revision_log', true ); 963 981 $revision_log = empty( $revision_log ) ? array() : $revision_log; 964 982 … … 971 989 * @since bbPress (r2782) 972 990 * 973 991 * @param int $topic_id Optional. Topic id 992 * @param int $count Optional. Amout of revisions to grab. 993 * @param string $order Optional. ASC/DESC Order of the results. 994 * 974 995 * @uses bbp_get_topic_id() To get the topic id 975 996 * @uses wp_get_post_revisions() To get the topic revisions 976 997 * @uses apply_filters() Calls 'bbp_get_topic_revisions' 977 998 * with the revisions and topic id 999 * 978 1000 * @return string Topic revisions 979 1001 */ 980 function bbp_get_topic_revisions( $topic_id = 0 ) {1002 function bbp_get_topic_revisions( $topic_id = 0, $count = -1, $order = 'ASC' ) { 981 1003 $topic_id = bbp_get_topic_id( $topic_id ); 982 $revisions = wp_get_post_revisions( $topic_id, array( 'order' => 'ASC') );1004 $revisions = wp_get_post_revisions( $topic_id, array( 'order' => $order, 'posts_per_page' => $count ) ); 983 1005 984 1006 return apply_filters( 'bbp_get_topic_revisions', $revisions, $topic_id ); 985 1007 }