Example #1
0
 /**
  * Add answer-seleted class in post_class
  * @param  array $classes Post class attribute.
  * @return array
  * @since 2.0.1
  */
 public function question_answer_post_class($classes)
 {
     global $post;
     if ('question' == $post->post_type) {
         if (ap_question_best_answer_selected($post->ID)) {
             $classes[] = 'answer-selected';
         }
         if (ap_is_featured_question($post->ID)) {
             $classes[] = 'featured-question';
         }
         $classes[] = 'answer-count-' . ap_count_answer_meta();
     } elseif ('answer' == $post->post_type) {
         if (ap_answer_is_best($post->ID)) {
             $classes[] = 'best-answer';
         }
     }
     return $classes;
 }
Example #2
0
/**
 * Answer meta to display
 * @param  false|integer $answer_id
 * @return string
 * @since 2.0.1
 */
function ap_display_answer_metas($answer_id = false)
{
    if (false === $answer_id) {
        $answer_id = get_the_ID();
    }
    $metas = array();
    if (ap_answer_is_best($answer_id)) {
        $metas['best_answer'] = '<span class="ap-best-answer-label">' . __('Best answer', 'ap') . '</span>';
    }
    $metas['history'] = ap_last_active_time($answer_id);
    /**
     * FILTER: ap_display_answer_meta
     * Used to filter answer display meta
     * @since 2.0.1
     */
    $metas = apply_filters('ap_display_answer_metas', $metas, $answer_id);
    $output = '';
    if (!empty($metas) && is_array($metas)) {
        foreach ($metas as $meta => $display) {
            $output .= "<span class='ap-display-meta-item {$meta}'>{$display}</span>";
        }
    }
    return $output;
}
Example #3
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>';
    }
}
Example #4
0
}
?>
<div id="answer_<?php 
the_ID();
?>
" <?php 
post_class();
?>
 data-id="<?php 
the_ID();
?>
" data-index="<?php 
echo @$i;
?>
" itemprop="suggestedAnswer<?php 
echo ap_answer_is_best() ? ' acceptedAnswer' : '';
?>
" itemtype="http://schema.org/Answer" itemscope="">
	<div class="ap-content">
		<div class="ap-single-vote"><?php 
ap_answer_the_vote_button();
?>
</div>
		<div class="ap-avatar">
			<a href="<?php 
ap_answer_the_author_link();
?>
"<?php 
ap_hover_card_attributes(ap_answer_get_author_id());
?>
>