bbp_get_topic_revision_log

Return the formatted revision log of the topic.

Description

(string) bbp_get_topic_revision_log( (int) $topic_id = 0 ); 

Returns (string)

Revision log of the topic

Parameters (1)

0. $topic_id — Optional. (int)
Topic id

Usage

  1. if ( !function_exists( 'bbp_get_topic_revision_log' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4. // Optional. Topic id 
  5. $topic_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_topic_revision_log($topic_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/topics/template.php  
  1. function bbp_get_topic_revision_log( $topic_id = 0 ) { 
  2. // Create necessary variables 
  3. $topic_id = bbp_get_topic_id( $topic_id ); 
  4. $revision_log = bbp_get_topic_raw_revision_log( $topic_id ); 
  5.  
  6. if ( empty( $topic_id ) || empty( $revision_log ) || !is_array( $revision_log ) ) 
  7. return false; 
  8.  
  9. $revisions = bbp_get_topic_revisions( $topic_id ); 
  10. if ( empty( $revisions ) ) 
  11. return false; 
  12.  
  13. $r = "\n\n" . '<ul id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '" class="bbp-topic-revision-log">' . "\n\n"; 
  14.  
  15. // Loop through revisions 
  16. foreach ( (array) $revisions as $revision ) { 
  17.  
  18. if ( empty( $revision_log[$revision->ID] ) ) { 
  19. $author_id = $revision->post_author; 
  20. $reason = ''; 
  21. } else { 
  22. $author_id = $revision_log[$revision->ID]['author']; 
  23. $reason = $revision_log[$revision->ID]['reason']; 
  24.  
  25. $author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_topic_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) ); 
  26. $since = bbp_get_time_since( bbp_convert_date( $revision->post_modified ) ); 
  27.  
  28. $r .= "\t" . '<li id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-topic-revision-log-item">' . "\n"; 
  29. if ( !empty( $reason ) ) { 
  30. $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"; 
  31. } else { 
  32. $r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s.', bbpress ), esc_html( $since ), $author ) . "\n"; 
  33. $r .= "\t" . '</li>' . "\n"; 
  34.  
  35.  
  36. $r .= "\n" . '</ul>' . "\n\n"; 
  37.  
  38. return apply_filters( 'bbp_get_topic_revision_log', $r, $topic_id );