/**
 * Get nominations attached to a specific achievement by a specific user
 *
 * @since  1.0.0
 * @param  integer $achievement_id The achievement's post ID
 * @param  integer $user_id        The user's ID
 * @return string                  Conatenated output for submission, attachments and comments
 */
function badgeos_get_user_nominations($user_id = 0, $achievement_id = 0)
{
    global $post;
    // Setup our empty args array
    $args = array('post_type' => 'nomination', 'show_attachments' => 'false', 'show_comments' => 'false');
    // Setup our author limit
    if (!empty($user_id)) {
        // Use the provided user ID
        $args['meta_query'][] = array('key' => '_badgeos_nominating_user_id', 'value' => absint($user_id));
    } else {
        // If user doesn't have access to settings,
        // restrict posts to ones they've authored
        if (!badgeos_user_can_manage_submissions()) {
            $args['meta_query'][] = array('key' => '_badgeos_nominating_user_id', 'value' => get_current_user_id());
        }
    }
    // If we were not given an achievement ID,
    // use the current post's ID
    $args['achievement_id'] = absint($achievement_id) ? absint($achievement_id) : $post->ID;
    // Grab our submissions for the current user
    $submissions = badgeos_get_feedback($args);
    // Return filterable output
    return apply_filters('badgeos_get_user_submissions', $submissions, $achievement_id, $user_id);
}
/**
 * Render a filterable list of feedback
 *
 * @since  1.1.0
 * @param  array  $atts Shortcode attributes
 * @return string       Contatenated markup
 */
function badgeos_render_feedback($atts = array())
{
    $atts = wp_parse_args($atts, array('type' => 'submission', 'limit' => '10', 'status' => 'all', 'show_filter' => true, 'show_search' => true, 'show_attachments' => true, 'show_comments' => true));
    $feedback = badgeos_get_feedback(array('post_type' => $atts['type'], 'posts_per_page' => $atts['limit'], 'show_attachments' => $atts['show_attachments'], 'show_comments' => $atts['show_comments'], 'status' => $atts['status']));
    $output = '';
    $output .= badgeos_render_feedback_search($atts);
    $output .= badgeos_render_feedback_filters($atts);
    $output .= '<div class="badgeos-spinner" style="display:none;"></div>';
    $output .= '<div class="badgeos-feedback-container">';
    $output .= $feedback;
    $output .= '</div>';
    return apply_filters('badgeos_render_feedback', $output, $atts);
}
Esempio n. 3
0
/**
 * AJAX Helper for returning feedback posts
 *
 * @since 1.1.0
 * @return void
 */
function badgeos_ajax_get_feedback()
{
    $feedback = badgeos_get_feedback(array('post_type' => isset($_REQUEST['type']) ? esc_html($_REQUEST['type']) : '', 'posts_per_page' => isset($_REQUEST['limit']) ? esc_html($_REQUEST['limit']) : '', 'status' => isset($_REQUEST['status']) ? esc_html($_REQUEST['status']) : '', 'show_attachments' => isset($_REQUEST['show_attachments']) ? esc_html($_REQUEST['show_attachments']) : '', 'show_comments' => isset($_REQUEST['show_comments']) ? esc_html($_REQUEST['show_comments']) : '', 's' => isset($_REQUEST['search']) ? esc_html($_REQUEST['search']) : ''));
    wp_send_json_success(array('feedback' => $feedback));
}