public function comment_inserted($comment_id, $comment_object) { if ($comment_object->comment_approved == '1') { $post = get_post($comment_object->comment_post_ID); if ($post->post_type == 'question') { ap_do_event('new_comment', $comment_object, 'question', ''); // set updated meta for sorting purpose update_post_meta($comment_object->comment_post_ID, ANSPRESS_UPDATED_META, current_time('mysql')); // add participant ap_add_parti($comment_object->comment_post_ID, $comment_object->user_id, 'comment', $comment_id); } elseif ($post->post_type == 'answer') { ap_do_event('new_comment', $comment_object, 'answer', $post->post_parent); $post_id = wp_get_post_parent_id($comment_object->comment_post_ID); // set updated meta for sorting purpose update_post_meta($post_id, ANSPRESS_UPDATED_META, current_time('mysql')); // add participant only ap_add_parti($post_id, $comment_object->user_id, 'comment', $comment_id); } } }
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); } }