BP_REST_Topics_Endpoint::get_topic_revisions( int $topic_id )
Get revisions for topic.
Description
Parameters
- $topic_id
-
(Required) ID of the topic.
Return
(bool|void)
Source
File: bp-forums/classes/class-bp-rest-topics-endpoint.php
public function get_topic_revisions( $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; } $revisions = bbp_get_topic_revisions( $topic_id ); if ( empty( $revisions ) ) { return false; } $retval = array(); // 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']; } $retval[] = array( 'time' => esc_html( bbp_get_time_since( bbp_convert_date( $revision->post_modified ) ) ), 'author_id' => bbp_get_topic_author_id( $topic_id ), 'author_name' => bbp_get_topic_author_display_name( $revision->ID ), 'avatar' => ( ! empty( bbp_get_topic_author_id( $topic_id ) ) ? get_avatar_url( bbp_get_topic_author_id( $topic_id ), 300 ) : '' ), 'reason' => $reason, ); } return apply_filters( 'bp_rest_bbp_get_topic_revision_log', $retval, $topic_id ); }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.