Index: includes/replies/template.php
===================================================================
--- includes/replies/template.php	(revision 5064)
+++ includes/replies/template.php	(working copy)
@@ -661,114 +661,141 @@
 function bbp_reply_revision_log( $reply_id = 0 ) {
 	echo bbp_get_reply_revision_log( $reply_id );
 }
-	/**
-	 * Return the formatted revision log of the reply
-	 *
-	 * @since bbPress (r2782)
-	 *
-	 * @param int $reply_id Optional. Reply id
-	 * @uses bbp_get_reply_id() To get the reply id
-	 * @uses bbp_get_reply_revisions() To get the reply revisions
-	 * @uses bbp_get_reply_raw_revision_log() To get the raw revision log
-	 * @uses bbp_get_reply_author_display_name() To get the reply author
-	 * @uses bbp_get_reply_author_link() To get the reply author link
-	 * @uses bbp_convert_date() To convert the date
-	 * @uses bbp_get_time_since() To get the time in since format
-	 * @uses apply_filters() Calls 'bbp_get_reply_revision_log' with the
-	 *                        log and reply id
-	 * @return string Revision log of the reply
-	 */
-	function bbp_get_reply_revision_log( $reply_id = 0 ) {
 
-		// Create necessary variables
-		$reply_id = bbp_get_reply_id( $reply_id );
+/**
+ * Return the formatted revision log of the reply
+ *
+ * @since bbPress (r2782)
+ *
+ * @param int $reply_id Optional. Reply id
+ * @uses bbp_get_reply_id() To get the reply id
+ * @uses bbp_get_reply_revisions() To get the reply revisions
+ * @uses bbp_get_reply_raw_revision_log() To get the raw revision log
+ * @uses bbp_get_reply_author_display_name() To get the reply author
+ * @uses bbp_get_reply_author_link() To get the reply author link
+ * @uses bbp_convert_date() To convert the date
+ * @uses bbp_get_time_since() To get the time in since format
+ * @uses apply_filters() Calls 'bbp_get_reply_revision_log' with the
+ *                        log and reply id
+ * @return string Revision log of the reply
+ */
+function bbp_get_reply_revision_log( $reply_id = 0 ) {
 
-		// Show the topic reply log if this is a topic in a reply loop
-		if ( bbp_is_topic( $reply_id ) ) {
-			return bbp_get_topic_revision_log( $reply_id );
-		}
+	// Create necessary variables
+	$reply_id = bbp_get_reply_id( $reply_id );
 
-		// Get the reply revision log (out of post meta
-		$revision_log = bbp_get_reply_raw_revision_log( $reply_id );
+	// Show the topic reply log if this is a topic in a reply loop
+	if ( bbp_is_topic( $reply_id ) ) {
+		return bbp_get_topic_revision_log( $reply_id );
+	}
 
-		// Check reply and revision log exist
-		if ( empty( $reply_id ) || empty( $revision_log ) || !is_array( $revision_log ) )
-			return false;
+	// Get the reply revision log (out of post meta
+	$revision_log = bbp_get_reply_raw_revision_log( $reply_id );
 
-		// Get the actual revisions
-		$revisions = bbp_get_reply_revisions( $reply_id );
-		if ( empty( $revisions ) )
-			return false;
+	// Check reply and revision log exist
+	if ( empty( $reply_id ) || empty( $revision_log ) || !is_array( $revision_log ) )
+		return false;
 
-		$r = "\n\n" . '<ul id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '" class="bbp-reply-revision-log">' . "\n\n";
+	// Get the actual revisions
 
-		// Loop through revisions
-		foreach ( (array) $revisions as $revision ) {
+	$total = $limit = - 1;
+	$order = 'ASC';
 
-			if ( empty( $revision_log[$revision->ID] ) ) {
-				$author_id = $revision->post_author;
-				$reason    = '';
-			} else {
-				$author_id = $revision_log[$revision->ID]['author'];
-				$reason    = $revision_log[$revision->ID]['reason'];
-			}
+	if ( empty( $_GET['bbp_reply_revisions_all'] ) || intval( $_GET['bbp_reply_revisions_all'] ) != $reply_id ) {
+		$total = bbp_get_reply_revision_count( $reply_id );
+		$limit = (int) apply_filters( 'bbp_reply_revision_log_limit', 1 );
+		$order = 'DESC';
+	}
 
-			$author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_reply_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) );
-			$since  = bbp_get_time_since( bbp_convert_date( $revision->post_modified ) );
+	$revisions = bbp_get_reply_revisions( $reply_id, $limit, $order );
 
-			$r .= "\t" . '<li id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-reply-revision-log-item">' . "\n";
-			if ( !empty( $reason ) ) {
-				$r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n";
-			} else {
-				$r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n";
-			}
-			$r .= "\t" . '</li>' . "\n";
+	if ( empty( $revisions ) )
+		return false;
 
+	$r = "\n\n" . '<ul id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '" class="bbp-reply-revision-log">' . "\n\n";
+
+	// Loop through revisions
+	foreach ( (array) $revisions as $revision ) {
+
+		if ( empty( $revision_log[$revision->ID] ) ) {
+			$author_id = $revision->post_author;
+			$reason    = '';
+		} else {
+			$author_id = $revision_log[$revision->ID]['author'];
+			$reason    = $revision_log[$revision->ID]['reason'];
 		}
 
-		$r .= "\n" . '</ul>' . "\n\n";
+		$author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_reply_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) );
+		$since  = bbp_get_time_since( bbp_convert_date( $revision->post_modified ) );
 
-		return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id );
+		$r .= "\t" . '<li id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-reply-revision-log-item">' . "\n";
+		if ( !empty( $reason ) ) {
+			$r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n";
+		} else {
+			$r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n";
+		}
+		$r .= "\t" . '</li>' . "\n";
+
 	}
-		/**
-		 * Return the raw revision log of the reply
-		 *
-		 * @since bbPress (r2782)
-		 *
-		 * @param int $reply_id Optional. Reply id
-		 * @uses bbp_get_reply_id() To get the reply id
-		 * @uses get_post_meta() To get the revision log meta
-		 * @uses apply_filters() Calls 'bbp_get_reply_raw_revision_log'
-		 *                        with the log and reply id
-		 * @return string Raw revision log of the reply
-		 */
-		function bbp_get_reply_raw_revision_log( $reply_id = 0 ) {
-			$reply_id     = bbp_get_reply_id( $reply_id );
-			$revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true );
-			$revision_log = empty( $revision_log ) ? array() : $revision_log;
 
-			return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id );
-		}
+	// If there are more revisions to show
+	if ( $total > $limit ) {
+		$topic_id  = bbp_get_reply_topic_id( $reply_id );
+		$link_url  = add_query_arg( 'bbp_reply_revisions_all', $reply_id, bbp_get_topic_permalink( $topic_id ) . '/#post-' . $reply_id );
+		$link_text = esc_html__( sprintf( 'Show %d more', $total - $limit ) );
 
+		$r .= sprintf( "<li class='bbp-reply-revision-log-more' data-id='%d'><a href='%s'>%s</a></li>", $reply_id, $link_url, $link_text );
+	}
+
+	$r .= "\n" . '</ul>' . "\n\n";
+
+	return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id );
+}
+
 /**
- * Return the revisions of the reply
+ * Return the raw revision log of the reply
  *
  * @since bbPress (r2782)
  *
  * @param int $reply_id Optional. Reply id
  * @uses bbp_get_reply_id() To get the reply id
- * @uses wp_get_post_revisions() To get the reply revisions
- * @uses apply_filters() Calls 'bbp_get_reply_revisions'
- *                        with the revisions and reply id
- * @return string reply revisions
+ * @uses get_post_meta() To get the revision log meta
+ * @uses apply_filters() Calls 'bbp_get_reply_raw_revision_log'
+ *                        with the log and reply id
+ * @return string Raw revision log of the reply
  */
-function bbp_get_reply_revisions( $reply_id = 0 ) {
+function bbp_get_reply_raw_revision_log( $reply_id = 0 ) {
+	$reply_id     = bbp_get_reply_id( $reply_id );
+	$revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true );
+	$revision_log = empty( $revision_log ) ? array() : $revision_log;
+
+	return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id );
+}
+
+/**
+ * Return the revisions of the reply
+ *
+ * @since bbPress (r2782)
+ *
+ * @param int    $reply_id Optional. Topic id
+ * @param int    $count    Optional. Amout of revisions to grab.
+ * @param string $order    Optional. ASC/DESC Order of the results.
+ *
+ * @uses  bbp_get_reply_id() To get the reply id
+ * @uses  wp_get_post_revisions() To get the topic revisions
+ * @uses  apply_filters() Calls 'bbp_get_reply_revisions'
+ *        with the revisions and reply id
+ *
+ * @return string Reply revisions
+ */
+function bbp_get_reply_revisions( $reply_id = 0, $count = -1, $order = 'ASC' ) {
 	$reply_id  = bbp_get_reply_id( $reply_id );
-	$revisions = wp_get_post_revisions( $reply_id, array( 'order' => 'ASC' ) );
+	$revisions = wp_get_post_revisions( $reply_id, array( 'order' => $order, 'posts_per_page' => $count ) );
 
 	return apply_filters( 'bbp_get_reply_revisions', $revisions, $reply_id );
 }
 
+
 /**
  * Return the revision count of the reply
  *
Index: includes/topics/template.php
===================================================================
--- includes/topics/template.php	(revision 5064)
+++ includes/topics/template.php	(working copy)
@@ -885,101 +885,125 @@
 function bbp_topic_revision_log( $topic_id = 0 ) {
 	echo bbp_get_topic_revision_log( $topic_id );
 }
-	/**
-	 * Return the formatted revision log of the topic
-	 *
-	 * @since bbPress (r2782)
-	 *
-	 * @param int $topic_id Optional. Topic id
-	 * @uses bbp_get_topic_id() To get the topic id
-	 * @uses bbp_get_topic_revisions() To get the topic revisions
-	 * @uses bbp_get_topic_raw_revision_log() To get the raw revision log
-	 * @uses bbp_get_topic_author_display_name() To get the topic author
-	 * @uses bbp_get_author_link() To get the topic author link
-	 * @uses bbp_convert_date() To convert the date
-	 * @uses bbp_get_time_since() To get the time in since format
-	 * @uses apply_filters() Calls 'bbp_get_topic_revision_log' with the
-	 *                        log and topic id
-	 * @return string Revision log of the topic
-	 */
-	function bbp_get_topic_revision_log( $topic_id = 0 ) {
-		// Create necessary variables
-		$topic_id     = bbp_get_topic_id( $topic_id );
-		$revision_log = bbp_get_topic_raw_revision_log( $topic_id );
 
-		if ( empty( $topic_id ) || empty( $revision_log ) || !is_array( $revision_log ) )
-			return false;
+/**
+ * Return the formatted revision log of the topic
+ *
+ * @since bbPress (r2782)
+ *
+ * @param int $topic_id Optional. Topic id
+ * @uses bbp_get_topic_id() To get the topic id
+ * @uses bbp_get_topic_revisions() To get the topic revisions
+ * @uses bbp_get_topic_raw_revision_log() To get the raw revision log
+ * @uses bbp_get_topic_author_display_name() To get the topic author
+ * @uses bbp_get_author_link() To get the topic author link
+ * @uses bbp_convert_date() To convert the date
+ * @uses bbp_get_time_since() To get the time in since format
+ * @uses apply_filters() Calls 'bbp_get_topic_revision_log' with the
+ *                        log and topic id
+ * @return string Revision log of the topic
+ */
+function bbp_get_topic_revision_log( $topic_id = 0 ) {
+	// Create necessary variables
+	$topic_id     = bbp_get_topic_id( $topic_id );
+	$revision_log = bbp_get_topic_raw_revision_log( $topic_id );
 
-		$revisions = bbp_get_topic_revisions( $topic_id );
-		if ( empty( $revisions ) )
-			return false;
+	if ( empty( $topic_id ) || empty( $revision_log ) || !is_array( $revision_log ) )
+		return false;
 
-		$r = "\n\n" . '<ul id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '" class="bbp-topic-revision-log">' . "\n\n";
+	$total = $limit = - 1;
+	$order = 'ASC';
 
-		// Loop through revisions
-		foreach ( (array) $revisions as $revision ) {
+	if ( empty( $_GET['bbp_topic_revisions_all'] ) || intval( $_GET['bbp_topic_revisions_all'] ) != $topic_id ) {
+		$total = bbp_get_topic_revision_count( $topic_id );
+		$limit = (int) apply_filters( 'bbp_topic_revision_log_limit', 1 );
+		$order = 'DESC';
+	}
 
-			if ( empty( $revision_log[$revision->ID] ) ) {
-				$author_id = $revision->post_author;
-				$reason    = '';
-			} else {
-				$author_id = $revision_log[$revision->ID]['author'];
-				$reason    = $revision_log[$revision->ID]['reason'];
-			}
+	$revisions = bbp_get_topic_revisions( $topic_id, $limit, $order );
 
-			$author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_topic_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) );
-			$since  = bbp_get_time_since( bbp_convert_date( $revision->post_modified ) );
+	if ( empty( $revisions ) )
+		return false;
 
-			$r .= "\t" . '<li id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-topic-revision-log-item">' . "\n";
-			if ( !empty( $reason ) ) {
-				$r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n";
-			} else {
-				$r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n";
-			}
-			$r .= "\t" . '</li>' . "\n";
+	$r = "\n\n" . '<ul id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '" class="bbp-topic-revision-log">' . "\n\n";
 
+	// Loop through revisions
+	foreach ( (array) $revisions as $revision ) {
+
+		if ( empty( $revision_log[$revision->ID] ) ) {
+			$author_id = $revision->post_author;
+			$reason    = '';
+		} else {
+			$author_id = $revision_log[$revision->ID]['author'];
+			$reason    = $revision_log[$revision->ID]['reason'];
 		}
 
-		$r .= "\n" . '</ul>' . "\n\n";
+		$author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_topic_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) );
+		$since  = bbp_get_time_since( bbp_convert_date( $revision->post_modified ) );
 
-		return apply_filters( 'bbp_get_topic_revision_log', $r, $topic_id );
+		$r .= "\t" . '<li id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-topic-revision-log-item">' . "\n";
+		if ( !empty( $reason ) ) {
+			$r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n";
+		} else {
+			$r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n";
+		}
+		$r .= "\t" . '</li>' . "\n";
+
 	}
-		/**
-		 * Return the raw revision log of the topic
-		 *
-		 * @since bbPress (r2782)
-		 *
-		 * @param int $topic_id Optional. Topic id
-		 * @uses bbp_get_topic_id() To get the topic id
-		 * @uses get_post_meta() To get the revision log meta
-		 * @uses apply_filters() Calls 'bbp_get_topic_raw_revision_log'
-		 *                        with the log and topic id
-		 * @return string Raw revision log of the topic
-		 */
-		function bbp_get_topic_raw_revision_log( $topic_id = 0 ) {
-			$topic_id = bbp_get_topic_id( $topic_id );
 
-			$revision_log = get_post_meta( $topic_id, '_bbp_revision_log', true );
-			$revision_log = empty( $revision_log ) ? array() : $revision_log;
+	// If there are more revisions to show
+	if ( $total > $limit ) {
+		$link_url  = add_query_arg( 'bbp_topic_revisions_all', $topic_id, bbp_get_topic_permalink( $topic_id ) . '/#post-' . $topic_id );
+		$link_text = esc_html__( sprintf( 'Show %d more', $total - $limit ) );
 
-			return apply_filters( 'bbp_get_topic_raw_revision_log', $revision_log, $topic_id );
-		}
+		$r .= sprintf( "<li class='bbp-topic-revision-log-more' data-id='%d'><a href='%s'>%s</a></li>", $topic_id, $link_url, $link_text );
+	}
 
+	$r .= "\n" . '</ul>' . "\n\n";
+
+	return apply_filters( 'bbp_get_topic_revision_log', $r, $topic_id );
+}
+
 /**
- * Return the revisions of the topic
+ * Return the raw revision log of the topic
  *
  * @since bbPress (r2782)
  *
  * @param int $topic_id Optional. Topic id
  * @uses bbp_get_topic_id() To get the topic id
- * @uses wp_get_post_revisions() To get the topic revisions
- * @uses apply_filters() Calls 'bbp_get_topic_revisions'
- *                        with the revisions and topic id
+ * @uses get_post_meta() To get the revision log meta
+ * @uses apply_filters() Calls 'bbp_get_topic_raw_revision_log'
+ *                        with the log and topic id
+ * @return string Raw revision log of the topic
+ */
+function bbp_get_topic_raw_revision_log( $topic_id = 0 ) {
+	$topic_id = bbp_get_topic_id( $topic_id );
+
+	$revision_log = get_post_meta( $topic_id, '_bbp_revision_log', true );
+	$revision_log = empty( $revision_log ) ? array() : $revision_log;
+
+	return apply_filters( 'bbp_get_topic_raw_revision_log', $revision_log, $topic_id );
+}
+
+/**
+ * Return the revisions of the topic
+ *
+ * @since bbPress (r2782)
+ *
+ * @param int    $topic_id Optional. Topic id
+ * @param int    $count    Optional. Amout of revisions to grab.
+ * @param string $order    Optional. ASC/DESC Order of the results.
+ *
+ * @uses  bbp_get_topic_id() To get the topic id
+ * @uses  wp_get_post_revisions() To get the topic revisions
+ * @uses  apply_filters() Calls 'bbp_get_topic_revisions'
+ *        with the revisions and topic id
+ *
  * @return string Topic revisions
  */
-function bbp_get_topic_revisions( $topic_id = 0 ) {
+function bbp_get_topic_revisions( $topic_id = 0, $count = -1, $order = 'ASC' ) {
 	$topic_id  = bbp_get_topic_id( $topic_id );
-	$revisions = wp_get_post_revisions( $topic_id, array( 'order' => 'ASC' ) );
+	$revisions = wp_get_post_revisions( $topic_id, array( 'order' => $order, 'posts_per_page' => $count ) );
 
 	return apply_filters( 'bbp_get_topic_revisions', $revisions, $topic_id );
 }
