public function ap_delete_post() { $args = explode('-', sanitize_text_field($_REQUEST['args'])); $action = 'delete_post_' . $args[0]; if (!ap_user_can_delete($args[0])) { $result = array('action' => false, 'message' => __('No Permission', 'ap')); } elseif (wp_verify_nonce($args[1], $action)) { $post = get_post($args[0]); wp_trash_post($args[0]); if ($post->post_type == 'question') { $result = array('action' => 'question', 'redirect_to' => get_permalink(ap_opt('base_page')), 'message' => __('Question deleted successfully.', 'ap')); } else { $current_ans = ap_count_ans($post->post_parent); $count_label = sprintf(_n('1 Answer', '%d Answers', $current_ans, 'ap'), $current_ans); $remove = !$current_ans ? true : false; $result = array('action' => 'answer', 'div' => '#answer_' . $args[0], 'count' => $current_ans, 'count_label' => $count_label, 'remove' => $remove, 'message' => __('Answer deleted successfully.', 'ap')); } } die(json_encode($result)); }
public function untrash_ans_on_question_untrash($post_id) { $post = get_post($post_id); if ($post->post_type == 'question') { ap_do_event('untrash_question', $post->ID, $post->post_author); ap_add_parti($post->ID, $post->post_author, 'question'); $arg = array('post_type' => 'answer', 'post_status' => 'trash', 'post_parent' => $post_id, 'showposts' => -1, 'caller_get_posts' => 1); $ans = get_posts($arg); if ($ans > 0) { foreach ($ans as $p) { ap_do_event('untrash_answer', $p->ID, $p->post_author); ap_add_parti($p->ID, $p->post_author, 'answer'); wp_untrash_post($p->ID); } } } if ($post->post_type == 'answer') { $ans = ap_count_ans($post->post_parent); ap_do_event('untrash_answer', $post->ID, $post->post_author); ap_add_parti($post->post_parent, $post->post_author, 'answer'); //update answer count update_post_meta($post->post_parent, ANSPRESS_ANS_META, $ans + 1); } }
<div class="ap-tlitem"> <?php echo ap_get_latest_history_html(get_the_ID(), true, true); ?> </div> <div class="ap-tlitem"> <span class="ap-icon-hit ap-tlicon"></span> <ul class="ap-question-meta"> <li> <?php printf(__('<span>Asked</span><strong><time itemprop="datePublished" datetime="%s">%s Ago</time></strong>', 'ap'), get_the_time('c', get_question_id()), ap_human_time(get_the_time('U'))); ?> </li> <li> <?php $count = ap_count_ans(get_the_ID()); printf(_n('<span>Answer</span><strong data-view="ap-answer-count-label">1 Answer</strong>', '<span>Answers</span><strong data-view="ap-answer-count-label">%d Answers</strong>', $count, 'ap'), $count); ?> </li> <li> <?php $view_count = ap_get_qa_views(); printf(_n('<span>Viewed</span><strong>1 Times</strong>', '<span>Viewed</span><strong>%d Times</strong>', $view_count, 'ap'), $view_count); ?> </li> <li> <?php printf(__('<span>Active</span><strong><time class="updated" itemprop="dateUpdated" datetime="%s">%s Ago</time></strong>', 'ap'), mysql2date('c', ap_last_active(get_question_id())), ap_human_time(mysql2date('U', ap_last_active(get_question_id())))); ?> </li> </ul>
function ap_ans_list_tab() { $order = get_query_var('sort'); if (empty($order)) { $order = ap_opt('answers_sort'); } $link = '?sort='; $ans_count = ap_count_ans(get_the_ID()); ?> <ul class="ap-ans-tab ap-tabs clearfix" role="tablist"> <li class="<?php echo $order == 'newest' ? ' active' : ''; ?> "><a href="<?php echo $link . 'newest'; ?> "><?php _e('Newest', 'ap'); ?> </a></li> <li class="<?php echo $order == 'oldest' ? ' active' : ''; ?> "><a href="<?php echo $link . 'oldest'; ?> "><?php _e('Oldest', 'ap'); ?> </a></li> <li class="<?php echo $order == 'voted' ? ' active' : ''; ?> "><a href="<?php echo $link . 'voted'; ?> "><?php _e('Voted', 'ap'); ?> </a></li> </ul> <?php }