echo ap_get_qa_views(); ?> </span> <?php _e('Views', 'ap'); ?> </a> <a class="ap-answer-count ap-tip" href="<?php echo ap_answers_link(); ?> " title="<?php _e('Total answers', 'ap'); ?> "> <span><?php echo ap_count_ans_meta(); ?> </span> <?php _e('Ans', 'ap'); ?> </a> </div> <div class="ap-list-inner"> <div class="ap-avatar"> <a href="<?php echo ap_user_link(); ?> "> <?php echo get_avatar(get_the_author_meta('ID'), 35);
function question_meta_box_content($post) { $ans_count = ap_count_ans_meta($post->ID); $vote_count = get_post_meta($post->ID, ANSPRESS_VOTE_META, true); ?> <ul> <li> <?php printf(_n('<strong>1</strong> Answer', '<strong>%d</strong> Answers', $ans_count, 'ap'), $ans_count); ?> </li> <li> <?php printf(_n('<strong>1</strong> Vote', '<strong>%d</strong> Votes', $vote_count, 'ap'), $vote_count); ?> </li> </ul> <?php }
function ap_get_user_question_list($user_id, $limit = 5, $title_limit = 50) { $q_args = array('post_type' => 'question', 'post_status' => 'publish', 'author' => $user_id, 'showposts' => $limit); $questions = get_posts($q_args); $o = '<ul class="ap-user-answers-list">'; foreach ($questions as $q) { $o .= '<li class="clearfix">'; $o .= '<div class="ap-mini-counts">'; $o .= ap_count_ans_meta($q->ID); $o .= '</div>'; $o .= '<a class="ap-answer-title answer-hyperlink" href="' . get_permalink($q->ID) . '">' . ap_truncate_chars($q->post_title, $title_limit) . '</a>'; $o .= '</li>'; } $o .= '</ul>'; return $o; }
</div> <div class="summery"> <a class="question-hyperlink" href="<?php the_permalink(); ?> " rel="bookmark"><?php the_title(); ?> </a> <?php //echo ap_get_question_label(null, true); ?> </div> <div class="ans-count"><span><?php echo ap_count_ans_meta() . ' ans'; ?> </span></div> </article><!-- list item --> <?php } } ?> <a class="ap-btn ap-btn-blue ap-view-all-btn block" href="<?php echo get_category_link($category); ?> "><?php _e('View all questions', 'categories-for-anspress'); ?> </a>
public function ap_suggest_questions() { $keyword = sanitize_text_field($_POST['q']); $questions = get_posts(array('post_type' => 'question', 'showposts' => 10, 's' => $keyword)); if ($questions) { $items = array(); foreach ($questions as $k => $p) { $count = ap_count_ans_meta($p->ID); $items[$k]['html'] = '<a class="ap-sqitem" href="' . get_permalink($p->ID) . '">' . get_avatar($p->post_author, 40) . '<div class="apqstitle">' . $p->post_title . '</div><span class="apsqcount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'ap'), $count) . '</span></a>'; } $result = array('status' => true, 'items' => $items); } else { $result = array('status' => false, 'message' => __('No related questions found', 'ap')); } die(json_encode($result)); }
public function question_view($post_id, $count) { $post = get_post($post_id); // return if not question if ($post->post_type != 'question') { return; } $popular_question = ap_badge_by_id('popular_question'); $popular_question = $popular_question['value']; $notable_question = ap_badge_by_id('notable_question'); $notable_question = $notable_question['value']; $famous_question = ap_badge_by_id('famous_question'); $famous_question = $famous_question['value']; if ($count > $popular_question && !ap_received_badge_on_post('popular_question', $post_id)) { ap_award_badge($post->post_author, 'popular_question', $post_id); } elseif ($count > $notable_question && !ap_received_badge_on_post('notable_question', $post_id)) { ap_award_badge($post->post_author, 'notable_question', $post_id); } elseif ($count > $famous_question && !ap_received_badge_on_post('famous_question', $post_id)) { ap_award_badge($post->post_author, 'famous_question', $post_id); } $limit = 7 * 86400; //days * seconds per day $post_age = current_time('timestamp') - mysql2date('U', $post->post_date_gmt); if ($post_age > $limit) { if ($count < 10 && ap_count_ans_meta($post_id) == 0) { ap_award_badge($post->post_author, 'tumbleweed', $post_id); } } }