/**
 * Display all Submission attachments in a meta box
 *
 * @since  1.1.0
 * @param  object $post The post content
 * @return object 		The modified post content
 */
function badgeos_submission_attachments($post = null)
{
    //return all submission attachments
    if ($submission_attachments = badgeos_get_submission_attachments(absint($post->ID))) {
        echo $submission_attachments;
    } else {
        _e('No attachments on this submission', 'badgeos');
    }
}
/**
 * Render a given submission
 *
 * @since  1.1.0
 * @param  object $submission A submission post object
 * @param  array  $args       Additional args for content options
 * @return string             Concatenated output
 */
function badgeos_render_submission($submission = null, $args = array())
{
    global $post;
    // If we weren't given a submission, use the current post
    if (empty($submission)) {
        $submission = $post;
    }
    // Get the connected achievement ID
    $achievement_id = get_post_meta($submission->ID, '_badgeos_submission_achievement_id', true);
    $status = get_post_meta($submission->ID, '_badgeos_submission_status', true);
    $submission_author = get_userdata($submission->post_author);
    $display_name = is_object($submission_author) ? $submission_author->display_name : '';
    // Concatenate our output
    $output = '<div class="badgeos-submission badgeos-feedback badgeos-feedback-' . $submission->ID . '">';
    // Submission Title
    $output .= '<h2>' . sprintf(__('Submission: "%1$s" (#%2$d)', 'badgeos'), get_the_title($achievement_id), $submission->ID) . '</h2>';
    // Submission Meta
    $output .= '<p class="badgeos-submission-meta">';
    $output .= sprintf('<strong class="label">%1$s</strong> <span class="badgeos-feedback-author">%2$s</span><br/>', __('Author:', 'badgeos'), $display_name);
    $output .= sprintf('<strong class="label">%1$s</strong> <span class="badgeos-feedback-date">%2$s</span><br/>', __('Date:', 'badgeos'), get_the_time('F j, Y h:i a', $submission));
    if ($achievement_id != $submission->ID) {
        $output .= sprintf('<strong class="label">%1$s</strong> <span class="badgeos-feedback-link">%2$s</span><br/>', __('Achievement:', 'badgeos'), '<a href="' . get_permalink($achievement_id) . '">' . get_the_title($achievement_id) . '</a>');
    }
    $output .= sprintf('<strong class="label">%1$s</strong> <span class="badgeos-feedback-status">%2$s</span><br/>', __('Status:', 'badgeos'), ucfirst($status));
    $output .= '</p>';
    // Submission Content
    $output .= '<div class="badgeos-submission-content">';
    $output .= wpautop($submission->post_content);
    $output .= '</div>';
    // Include any attachments
    if (isset($args['show_attachments']) && 'false' !== $args['show_attachments']) {
        $output .= badgeos_get_submission_attachments($submission->ID);
    }
    // Approve/Deny Buttons for admins only
    if (badgeos_user_can_manage_submissions()) {
        $output .= badgeos_render_feedback_buttons($submission->ID);
    }
    // Include comments and comment form
    if (isset($args['show_comments']) && 'false' !== $args['show_comments']) {
        $output .= badgeos_get_comments_for_submission($submission->ID);
        $output .= badgeos_get_comment_form($submission->ID);
    }
    $output .= '</div><!-- .badgeos-submission -->';
    // Return our filterable output
    return apply_filters('badgeos_render_submission', $output, $submission);
}