bbp_get_reply_revision_log

Return the formatted revision log of the reply.

Description

(string) bbp_get_reply_revision_log( (int) $reply_id = 0 ); 

Returns (string)

Revision log of the reply

Parameters (1)

0. $reply_id — Optional. (int)
Reply id

Usage

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

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_reply_revision_log( $reply_id = 0 ) { 
  2.  
  3. // Create necessary variables 
  4. $reply_id = bbp_get_reply_id( $reply_id ); 
  5.  
  6. // Show the topic reply log if this is a topic in a reply loop 
  7. if ( bbp_is_topic( $reply_id ) ) { 
  8. return bbp_get_topic_revision_log( $reply_id ); 
  9.  
  10. // Get the reply revision log (out of post meta 
  11. $revision_log = bbp_get_reply_raw_revision_log( $reply_id ); 
  12.  
  13. // Check reply and revision log exist 
  14. if ( empty( $reply_id ) || empty( $revision_log ) || !is_array( $revision_log ) ) 
  15. return false; 
  16.  
  17. // Get the actual revisions 
  18. $revisions = bbp_get_reply_revisions( $reply_id ); 
  19. if ( empty( $revisions ) ) 
  20. return false; 
  21.  
  22. $r = "\n\n" . '<ul id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '" class="bbp-reply-revision-log">' . "\n\n"; 
  23.  
  24. // Loop through revisions 
  25. foreach ( (array) $revisions as $revision ) { 
  26.  
  27. if ( empty( $revision_log[$revision->ID] ) ) { 
  28. $author_id = $revision->post_author; 
  29. $reason = ''; 
  30. } else { 
  31. $author_id = $revision_log[$revision->ID]['author']; 
  32. $reason = $revision_log[$revision->ID]['reason']; 
  33.  
  34. $author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_reply_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) ); 
  35. $since = bbp_get_time_since( bbp_convert_date( $revision->post_modified ) ); 
  36.  
  37. $r .= "\t" . '<li id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-reply-revision-log-item">' . "\n"; 
  38. if ( !empty( $reason ) ) { 
  39. $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"; 
  40. } else { 
  41. $r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s.', bbpress ), esc_html( $since ), $author ) . "\n"; 
  42. $r .= "\t" . '</li>' . "\n"; 
  43.  
  44.  
  45. $r .= "\n" . '</ul>' . "\n\n"; 
  46.  
  47. return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id );