BP_REST_Reply_Endpoint::get_reply_revisions( int $reply_id )

Get revisions for reply.

Description

from: bbp_get_reply_revision_log()

Parameters

$reply_id

(Required) ID of the reply.

Return

(bool|void)

Source

File: bp-forums/classes/class-bp-rest-reply-endpoint.php

2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
protected function get_reply_revisions( $reply_id = 0 ) {
 
    // Create necessary variables.
    $reply_id = bbp_get_reply_id( $reply_id );
 
    // Show the topic reply log if this is a topic in a reply loop.
    if ( bbp_is_topic( $reply_id ) ) {
        return $this->topic_endpoint->get_topic_revisions( $reply_id );
    }
 
    // Get the reply revision log.
    $revision_log = bbp_get_reply_raw_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 actual revisions.
    $revisions = bbp_get_reply_revisions( $reply_id );
    if ( empty( $revisions ) ) {
        return false;
    }
 
    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'   => $author_id,
            'author_name' => bbp_get_reply_author_display_name( $revision->ID ),
            'avatar'      => ( ! empty( $author_id ) ? get_avatar_url( $author_id, 300 ) : '' ),
            'reason'      => $reason,
        );
    }
 
    return apply_filters( 'bp_rest_bbp_get_reply_revision_log', $retval, $reply_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.