Пример #1
0
/**
 * Print select anser HTML button.
 *
 * @param int $post_id
 *
 * @return null|string
 */
function ap_select_answer_btn_html($post_id)
{
    if (!ap_user_can_select_answer($post_id)) {
        return;
    }
    $ans = get_post($post_id);
    $action = 'answer-' . $post_id;
    $nonce = wp_create_nonce($action);
    if (!ap_question_best_answer_selected($ans->post_parent)) {
        return '<a href="#" class="ap-btn-select ap-sicon ' . ap_icon('check') . ' ap-tip" data-action="select_answer" data-query="answer_id=' . $post_id . '&__nonce=' . $nonce . '&ap_ajax_action=select_best_answer" title="' . __('Select this answer as best', 'ap') . '">' . __('Select', 'ap') . '</a>';
    } elseif (ap_question_best_answer_selected($ans->post_parent) && ap_answer_is_best($ans->ID)) {
        return '<a href="#" class="ap-btn-select ap-sicon ' . ap_icon('cross') . ' active ap-tip" data-action="select_answer" data-query="answer_id=' . $post_id . '&__nonce=' . $nonce . '&ap_ajax_action=select_best_answer" title="' . __('Unselect this answer', 'ap') . '">' . __('Unselect', 'ap') . '</a>';
    }
}
Пример #2
0
function ap_select_answer_btn_html($post_id)
{
    if (!ap_user_can_select_answer($post_id)) {
        return;
    }
    $ans = get_post($post_id);
    $action = 'answer-' . $post_id;
    $nonce = wp_create_nonce($action);
    if (!ap_is_answer_selected($ans->post_parent)) {
        return '<a href="#" class="ap-btn-select ap-sicon ap-icon-checkmark ap-tip" data-button="ap-select-answer" data-args="' . $post_id . '-' . $nonce . '" title="' . __('Select this answer as best', 'ap') . '"></a>';
    } elseif (ap_is_answer_selected($ans->post_parent) && ap_is_best_answer($ans->ID)) {
        return '<a href="#" class="ap-btn-select ap-sicon ap-icon-checkmark selected ap-tip" data-button="ap-select-answer" data-args="' . $post_id . '-' . $nonce . '" title="' . __('Unselect this answer', 'ap') . '"></a>';
    }
}