示例#1
0
/**
 * Output the revision log of the topic
 *
 * @since 2.0.0 bbPress (r2782)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_revision_log() To get the topic revision log
 */
function bbp_topic_revision_log($topic_id = 0)
{
    echo bbp_get_topic_revision_log($topic_id);
}
示例#2
0
/**
 * Return the formatted revision log of the reply
 *
 * @since bbPress (r2782)
 *
 * @param int $reply_id Optional. Reply id
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply_revisions() To get the reply revisions
 * @uses bbp_get_reply_raw_revision_log() To get the raw revision log
 * @uses bbp_get_reply_author_display_name() To get the reply author
 * @uses bbp_get_reply_author_link() To get the reply author link
 * @uses bbp_convert_date() To convert the date
 * @uses bbp_get_time_since() To get the time in since format
 * @uses apply_filters() Calls 'bbp_get_reply_revision_log' with the
 *                        log and reply id
 * @return string Revision log of the reply
 */
function bbp_get_reply_revision_log($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 bbp_get_topic_revision_log($reply_id);
    }
    // Get the reply revision log (out of post meta
    $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;
    }
    $r = "\n\n" . '<ul id="bbp-reply-revision-log-' . esc_attr($reply_id) . '" class="bbp-reply-revision-log">' . "\n\n";
    // 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'];
        }
        $author = bbp_get_author_link(array('size' => 14, 'link_text' => bbp_get_reply_author_display_name($revision->ID), 'post_id' => $revision->ID));
        $since = bbp_get_time_since(bbp_convert_date($revision->post_modified));
        $r .= "\t" . '<li id="bbp-reply-revision-log-' . esc_attr($reply_id) . '-item-' . esc_attr($revision->ID) . '" class="bbp-reply-revision-log-item">' . "\n";
        if (!empty($reason)) {
            $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";
        } else {
            $r .= "\t\t" . sprintf(esc_html__('This reply was modified %1$s by %2$s.', 'bbpress'), esc_html($since), $author) . "\n";
        }
        $r .= "\t" . '</li>' . "\n";
    }
    $r .= "\n" . '</ul>' . "\n\n";
    return apply_filters('bbp_get_reply_revision_log', $r, $reply_id);
}