public static function convert($comment) { global $current_user; $result = (object) $comment; $childs = get_children(array('post_parent' => $result->comment_ID)); $author = get_user_by('id', $comment->user_id); $result->id = $result->comment_ID; $result->et_votes = get_comment_meta($result->comment_ID, 'et_votes'); $result->et_votes_count = !empty($result->et_votes) ? count($result->et_votes) : 0; $result->content_filter = apply_filters('the_content', $result->comment_content); $result->content_edit = et_the_content_edit($comment->comment_content); $result->avatar = et_get_avatar($result->user_id ? $result->user_id : $result->comment_author_email, 30); $result->human_date = et_the_time(strtotime($result->comment_date)); $result->total_childs = sprintf(__('Comment(%d) ', ET_DOMAIN), count($childs)); $result->new_nonce = wp_create_nonce('insert_comment'); $result->author = $author->display_name; $result->author_url = get_author_posts_url($author->ID); return $result; }
<?php global $post; $question = QA_Questions::convert($post); $et_post_date = et_the_time(strtotime($question->post_date)); $category = !empty($question->question_category[0]) ? $question->question_category[0]->name : __('No Category', ET_DOMAIN); $category_link = !empty($question->question_category[0]) ? get_term_link($question->question_category[0]->term_id, 'question_category') : '#'; ?> <li <?php post_class('question-item pending-question'); ?> data-id="<?php echo $post->ID; ?> "> <div class="col-md-8 col-xs-8 q-left-content"> <div class="q-ltop-content"> <a href="<?php the_permalink(); ?> " class="question-title"> <?php the_title(); ?> </a> </div> <div class="q-lbtm-content"> <div class="question-excerpt"> <?php the_excerpt(); ?>
/** * convert comments */ function convert($comment, $thumb = 'thumbnail', $merge_post = true, $merge_author = true) { global $ae_post_factory; /** * add comment meta */ if (!empty($this->meta)) { foreach ($this->meta as $key => $value) { $comment->{$value} = get_comment_meta($comment->comment_ID, $value, true); } } // comment link $comment->comment_link = get_comment_link($comment->comment_ID); $comment->ID = $comment->comment_ID; $comment->id = $comment->comment_ID; // caculate date ago $comment->date_ago = et_the_time(strtotime($comment->comment_date)); if ($merge_post) { /** * add post data to comment */ if (!isset($this->post_arr[$comment->comment_post_ID])) { // check post exist or not $post = get_post($comment->comment_post_ID); if ($post && !is_wp_error($post)) { // get register post object by post factory $post_object = $ae_post_factory->get($post->post_type); // if not null convert post if ($post_object) { $comment->post_data = $post_object->convert($post, $thumb, false); } else { // keep the simple post $comment->post_data = $post; } // add post data to post_arr $this->post_arr[$post->ID] = $comment->post_data; } } else { // post data already exist $comment->post_data = $this->post_arr[$comment->comment_post_ID]; } } if ($merge_author) { /** * add author data to comment */ if (!isset($this->author_arr[$comment->user_id])) { // user_id not existed in author_arr $author = get_userdata($comment->user_id); if ($author) { $users = AE_Users::get_instance(); $comment->author_data = $users->convert($author); // add author_data to author_arr $this->author_arr[$comment->user_id] = $comment->author_data; } } else { // author data already exist $comment->author_data = $this->author_arr[$comment->user_id]; } } $this->current_comment = $comment; return apply_filters('ae_convert_comment', $this->current_comment); }
?> </div> <?php if ($answer->ID == $question->et_best_answer) { ?> <p class="alert-stt-answer-style"> <i class="fa fa-check-circle"></i> <?php _e("This answer accepted by", ET_DOMAIN); ?> <a href="javascript:void(0)"><?php the_author_meta('display_name', $question->post_author); ?> </a>. <?php echo et_the_time(strtotime(get_post_meta($answer->ID, 'et_is_best_answer', true))); ?> <?php printf(__("Earned %d points.", ET_DOMAIN), $badge_points->a_accepted); ?> </p> <?php } ?> </div> </div><!-- end left content --> <div class="col-md-4 q-right-content"> <ul class="question-statistic"> <li> <a href="javascript:void(0)" class="action" data-name="approve"> <span class="question-views">
<?php global $post; $answer = QA_Answers::convert($post); $question = QA_Questions::convert(get_post($answer->post_parent)); $et_post_date = et_the_time(strtotime($answer->post_date)); $badge_points = qa_get_badge_point(); $category = !empty($question->question_category[0]) ? $question->question_category[0]->name : __('No Category', ET_DOMAIN); $category_link = !empty($question->question_category[0]) ? get_term_link($question->question_category[0]->term_id, 'question_category') : '#'; ?> <li <?php post_class('question-item'); ?> data-id="<?php echo $post->ID; ?> "> <div class="avatar-user"> <a href="<?php the_permalink(); ?> "> <?php echo et_get_avatar($post->post_author, 55); ?> </a> </div> <div class="info-user"> <?php qa_user_badge($post->post_author, true, true); ?>
<span class="author-avatar"> <?php echo et_get_avatar($qa_answer->post_author, 30); ?> </span> <span class="author-name"><?php echo $qa_answer->author_name; ?> </span> </a> <?php qa_user_badge($qa_answer->post_author); ?> <span class="question-time"> <?php printf(__('Answered %s.', ET_DOMAIN), et_the_time(strtotime($qa_answer->post_date))); ?> </span> </div> <!--// Answer owner infomation --> <div class="col-md-4 col-xs-4 question-control"> <!-- share comment , report --> <ul> <li> <a class="share-social" href="javascript:void(0);" data-toggle="popover" data-placement="top" data-container="body" data-content='<?php echo qa_template_share($qa_answer->ID); ?> ' data-html="true"> <?php _e("Share", ET_DOMAIN);
/** # end change log action * below are the code catch action insert point and data * question, answer vote up * question, answer vote down * mark and unmark an answer to the best * insert question, answer */ function qa_list_changelog($args = array()) { global $user_ID; $qa_log = QA_Log::query($args); $change_log = QA_Log::get_instance(); if ($qa_log->have_posts()) { ?> <ul> <?php while ($qa_log->have_posts()) { $qa_log->the_post(); global $post; $log = $change_log->convert($post); $parent = get_post($post->post_parent); $i = '<i class="fa fa-circle"></i>'; $text = __("This is default text.", ET_DOMAIN); switch ($log->post_title) { case 'a_vote_up': if ($log->qa_be_voted == $user_ID) { $text = __("Your answer on question %s was voted up.", ET_DOMAIN); } else { $text = __("You voted up an answer on question %s.", ET_DOMAIN); } $i = '<i class="fa fa-thumbs-up"></i>'; break; case 'a_vote_down': if ($log->qa_be_voted == $user_ID) { $text = __("Your answer on question %s was voted down.", ET_DOMAIN); } else { $text = __("Your voted down an answer on question %s.", ET_DOMAIN); } $i = '<i class="fa fa-thumbs-down"></i>'; break; case 'q_vote_up': // $text = __("Your question %s was voted up.", ET_DOMAIN); if ($log->qa_be_voted == $user_ID) { $text = __("Your question %s was voted up.", ET_DOMAIN); } else { $text = __("You voted up question %s.", ET_DOMAIN); } $i = '<i class="fa fa-thumbs-up"></i>'; break; case 'q_vote_down': // $text = __("Your question %s was voted down.", ET_DOMAIN); if ($log->qa_be_voted == $user_ID) { $text = __("Your question %s was voted down.", ET_DOMAIN); } else { $text = __("You voted down question %s.", ET_DOMAIN); } $i = '<i class="fa fa-thumbs-down"></i>'; break; case 'post_question': $text = __("You asked %s.", ET_DOMAIN); $i = '<i class="fa fa-question-circle"></i>'; break; case 'edit_question': if ($log->qa_be_voted == $user_ID && $log->qa_be_voted != $log->qa_voted_by) { $text = __("Your question %s was edited.", ET_DOMAIN); } else { $text = __("You edited question %s.", ET_DOMAIN); } $i = '<i class="fa fa-question-circle"></i>'; break; case 'post_answer': $text = __("You answered question %s.", ET_DOMAIN); $i = '<i class="fa fa-comments"></i>'; break; case 'edit_answer': if ($log->qa_be_voted == $user_ID && $log->qa_be_voted != $log->qa_voted_by) { $text = __("Your answer on question %s was edited.", ET_DOMAIN); } else { $text = __("You edited answer on question %s.", ET_DOMAIN); } $i = '<i class="fa fa-comments"></i>'; break; case 'q_unvote': if ($log->qa_be_voted == $user_ID) { $text = __("Your question %s was unvoted.", ET_DOMAIN); } else { $text = __("You unvoted question %s.", ET_DOMAIN); } $i = '<i class="fa fa-undo"></i>'; break; case 'a_unvote': if ($log->qa_be_voted == $user_ID) { $text = __("Your answer on question %s was unvoted.", ET_DOMAIN); } else { $text = __("Your unvoted an answer on question %s.", ET_DOMAIN); } $i = '<i class="fa fa-undo"></i>'; break; case 'a_marked': if ($log->qa_be_voted == $user_ID) { $text = __("Your answer on question %s was marked as the accepted answer.", ET_DOMAIN); } else { $text = __("You marked question %s was answered.", ET_DOMAIN); } $i = '<i class="fa fa-check-circle"></i>'; break; case 'a_unmarked': if ($log->qa_be_voted == $user_ID) { $text = __("Your best answer on question %s was unaccepted.", ET_DOMAIN); } else { $text = __("You changed the best answer on question %s.", ET_DOMAIN); } $i = '<i class="fa fa-undo"></i>'; break; default: $text = ''; break; } $link = ''; if (!empty($parent)) { if ($parent->post_type == 'answer') { $permalink = get_permalink($parent->post_parent); $link = '<a href="' . $permalink . '">' . get_the_title($parent->post_parent) . '</a>'; } else { $permalink = get_permalink($parent->ID); $link = '<a href="' . $permalink . '">' . get_the_title($parent->ID) . '</a>'; } } ?> <li> <?php echo $i; ?> <span> <?php printf($text, $link); ?> <br> <span class="time-activity"> <?php echo et_the_time(strtotime($post->post_date)); ?> </span> </span> </li> <?php } ?> </ul> <?php } wp_reset_query(); }