function cjtheme_insert_answer() { global $wpdb; $errors = null; parse_str($_POST['postdata'], $postdata); $user_info = cjtheme_user_info($postdata['user_id']); $time = current_time('mysql'); $comment_data = array('comment_post_ID' => $postdata['post_id'], 'comment_author' => $user_info['user_login'], 'comment_author_email' => $user_info['user_email'], 'comment_author_url' => '', 'comment_content' => esc_textarea($postdata['comment']), 'user_id' => $user_info['ID'], 'comment_date' => $time, 'comment_approved' => 1); $comment_id = wp_insert_comment($comment_data); if (strlen($postdata['comment']) >= 140) { gamf_add_points($user_info['ID'], 1, 'comment-140', 'You answered a question with more than 140 characters.'); } $post_info = cjtheme_post_info($postdata['post_id']); $nmessage = '<a href="' . site_url($user_info['user_login']) . '">' . $user_info['display_name'] . '</a> answered your <a href="' . get_permalink($post_info['ID']) . '">question</a>.'; $nmessage .= '<br>' . cjtheme_trim_text($post_info['post_content'], 160, '...'); cjtheme_notification_add($post_info['post_author'], $nmessage); $return['success'] = get_permalink($post_info['ID']) . '#answer-' . $comment_id; echo json_encode($return); die; }
query_posts($args); } ?> <div id="do-scroll" class="questions-loop"> <?php global $current_user; $current_user_info = cjtheme_user_info($current_user->ID); if (have_posts()) { ?> <div class="panel-group" id="home-qna-accordion" role="tablist" aria-multiselectable="true"> <?php $count = 1; while (have_posts()) { the_post(); $post_info = cjtheme_post_info($post->ID); $user_info = cjtheme_user_info($post_info['post_author']); $user_profile_url = site_url('members/' . $user_info['user_nicename']); $user_role_level = cjtheme_user_role_display($user_info); $read_more_link = '<a href="' . get_permalink($post->ID) . '">See more</a>'; $post_cat = wp_get_object_terms($post->ID, 'qna_type'); if ($post_cat) { $post_cat = '<a href="' . get_term_link($post_cat[0]->term_id, 'qna_type') . '">' . $post_cat[0]->name . '</a>'; } else { $post_cat = ''; } ?> <div id="question-<?php echo $post->ID; ?> " class="question panel panel-default">