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
2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 | 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.