function cjtheme_user_badge_display($user_id, $icon = null) { global $wpdb; $badge = cjtheme_user_info($user_id, 'user_badge'); if ($badge != 'None') { return '<span class="role">' . $icon . $badge . '</span>'; } }
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; }
} ?> <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"> <div class="panel-heading" role="tab" id="heading-<?php
function cartoq_user_reputation_bar($post) { $post_author = $post->post_author; $post_author_info = cjtheme_user_info($post_author); $likes_count = cjtheme_user_likes_count($post_author_info['ID'], 'likes'); $thanks_count = cjtheme_user_likes_count($post_author_info['ID'], 'thanks'); $user_role = cjtheme_user_role_display($post_author_info['ID']); $rep_bar = '<ul class="stats">'; $rep_bar .= '<li class="stat"><i class="fa fa-thumbs-up"></i> ' . $likes_count . '</li>'; $rep_bar .= '<li class="stat"><i class="fa fa-star"></i> ' . $thanks_count . '</li>'; $rep_bar .= '<li class="stat label label-info"><i class="fa fa-trophy"></i> ' . $user_role . '</li>'; $rep_bar .= '</ul>'; return $rep_bar; }
<?php } ?> <header class="page-header"> <?php the_title('<h1 class="page-title">', '</h1>'); ?> </header><!-- .page-header --> <div class="page-content"> <?php if (!is_user_logged_in()) { wp_redirect(site_url()); } else { $user_info = cjtheme_user_info($current_user->ID); } $table_notifications = $wpdb->prefix . 'cjtheme_notifications'; $notifications = $wpdb->get_results("SELECT * FROM {$table_notifications} WHERE user_id = '{$user_info['ID']}' ORDER BY dated DESC"); $mark_read_url = cjtheme_string(cjtheme_current_url()) . 'mark-all=read'; if (isset($_GET['mark-all'])) { $wpdb->query("UPDATE {$table_notifications} SET unread = 0 WHERE user_id = '{$user_info['ID']}'"); wp_redirect(cjtheme_current_url('only')); die; } ?> <h2 class="sep-heading"> <span>Notifications</span> <a href="<?php echo $mark_read_url;
function cjtheme_wp_avatar_url($user_id_or_email, $args = null) { $user_id = cjtheme_user_info($user_id_or_email, 'ID'); $args = get_avatar_data($user_id, $args); $url = $args['url']; $url = apply_filters('cjtheme_wp_avatar_url', $user_id, $url); return $url; }
function cjtheme_update_bp_acmeta_thanks() { global $wpdb; $table_bp_acmeta = $wpdb->prefix . 'cjtheme_likes_thanks'; $check_existing = $wpdb->get_row("SELECT * FROM {$table_bp_acmeta} WHERE user_id = '{$_POST['user_id']}' AND comment_id = '{$_POST['comment_id']}'"); if (is_null($check_existing)) { $acmeta_data = array('comment_id' => $_POST['comment_id'], 'user_id' => $_POST['user_id'], 'thanks' => 1); cjtheme_insert($table_bp_acmeta, $acmeta_data); $comment_thanks = cjtheme_activity_comment_thanks($_POST['comment_id']); $comment_thanks = !is_null($comment_thanks) ? ' ' . $comment_thanks : ''; $comment = get_comment($_POST['comment_id']); if ($comment->user_id != $_POST['user_id']) { gamf_add_points(cjtheme_user_info($comment->user_id, 'ID'), '3', 'thank-answer', 'You received a thanks on your answer.'); } echo ' ' . $comment_thanks; } elseif ($check_existing->thanks == 0) { $acmeta_data = array('comment_id' => $_POST['comment_id'], 'user_id' => $_POST['user_id'], 'thanks' => 1); cjtheme_update($table_bp_acmeta, $acmeta_data, 'id', $check_existing->id); $comment_thanks = cjtheme_activity_comment_thanks($_POST['comment_id']); $comment_thanks = !is_null($comment_thanks) ? ' ' . $comment_thanks : ''; $comment = get_comment($_POST['comment_id']); if ($comment->user_id != $_POST['user_id']) { gamf_add_points(cjtheme_user_info($comment->user_id, 'ID'), '3', 'thank-answer', 'You received a thanks on your answer.'); $nmessage = '<a href="' . site_url(cjtheme_user_info($_POST['user_id'], 'user_login')) . '">' . cjtheme_user_info($_POST['user_id'], 'display_name') . '</a> said thanks for your <a href="' . get_permalink($comment->comment_post_ID) . '#answer-' . $comment->comment_ID . '">answer</a>.'; cjtheme_notification_add(cjtheme_user_info($comment->user_id, 'ID'), $nmessage); } echo ' ' . $comment_thanks; } else { $acmeta_data = array('comment_id' => $_POST['comment_id'], 'user_id' => $_POST['user_id'], 'thanks' => 0); cjtheme_update($table_bp_acmeta, $acmeta_data, 'id', $check_existing->id); $comment_thanks = cjtheme_activity_comment_thanks($_POST['comment_id']); $comment_thanks = !is_null($comment_thanks) ? ' ' . $comment_thanks : ''; $comment = get_comment($_POST['comment_id']); if ($comment->user_id != $_POST['user_id']) { gamf_add_points(cjtheme_user_info($comment->user_id, 'ID'), '-3', 'unthank-answer', 'You received a Thanks on your answer.'); $nmessage = '<a href="' . site_url(cjtheme_user_info($_POST['user_id'], 'user_login')) . '">' . cjtheme_user_info($_POST['user_id'], 'display_name') . '</a> unthanked your <a href="' . get_permalink($comment->comment_post_ID) . '#answer-' . $comment->comment_ID . '">answer</a>.'; cjtheme_notification_add(cjtheme_user_info($comment->user_id, 'ID'), $nmessage); } echo '' . $comment_thanks; } die; }
" class="margin-5-left cancel-link">Cancel</a> </div><!-- /.form-fields --> </form> <?php $answers = get_comments(array('post_id' => $post->ID)); ?> <div id="answers-<?php echo $post_info['ID']; ?> " class="answers-loop"> <?php if (!empty($answers)) { foreach ($answers as $key => $answer) { $comment_author_info = cjtheme_user_info($answer->comment_author); ?> <div id="answer-<?php echo $answer->comment_ID; ?> " class="answer clearfix"> <div class="user-info"> <div class="user-avatar"> <a href="<?php echo get_author_posts_url($comment_author_info['ID']); ?> "> <img src="<?php echo cjtheme_wp_avatar_url($answer->user_id); ?> " alt="">