Ejemplo n.º 1
1
function dwqa_get_question_link($post_id)
{
    if ('dwqa-answer' == get_post_type($post_id)) {
        $post_id = dwqa_get_question_from_answer_id($post_id);
    }
    return get_permalink($post_id);
}
Ejemplo n.º 2
0
function dwqa_is_closed($question_id = false)
{
    if (!$question_id) {
        $question_id = get_the_ID();
    }
    if ('dwqa-answer' == get_post_type($question_id)) {
        $question_id = dwqa_get_question_from_answer_id($question_id);
    }
    $status = get_post_meta($question_id, '_dwqa_status', true);
    if ($status == 'close') {
        return true;
    }
    return false;
}
Ejemplo n.º 3
0
function dwqa_answer_button_action()
{
    $html = '';
    if (is_user_logged_in()) {
        if (dwqa_current_user_can('edit_answer')) {
            $parent_id = dwqa_get_question_from_answer_id();
            $html .= '<a class="dwqa_edit_question" href="' . add_query_arg(array('edit' => get_the_ID()), get_permalink($parent_id)) . '">' . __('Edit', 'dwqa') . '</a> ';
        }
        if (dwqa_current_user_can('delete_answer')) {
            $action_url = add_query_arg(array('action' => 'dwqa_delete_answer', 'answer_id' => get_the_ID()), admin_url('admin-ajax.php'));
            $html .= '<a class="dwqa_delete_answer" href="' . wp_nonce_url($action_url, '_dwqa_action_remove_answer_nonce') . '">' . __('Delete', 'dwqa') . '</a> ';
        }
    }
    echo apply_filters('dwqa_answer_button_action', $html);
}