answers.php
89 lines
| 1 | <?php |
| 2 | $question_id = 0; |
| 3 | if (isset($_GET['question_id'])){ |
| 4 | $question_id = (int) $_GET['question_id']; |
| 5 | } |
| 6 | |
| 7 | $question = tutils()->get_qa_question($question_id); |
| 8 | $answers = tutils()->get_qa_answer_by_question($question_id); |
| 9 | $profile_url = tutils()->profile_url($question->user_id); |
| 10 | |
| 11 | ?> |
| 12 | |
| 13 | <h2><?php _e('Answer', 'tutor'); ?></h2> |
| 14 | <div class="tutor-queston-and-answer-wrap"> |
| 15 | <div class="tutor_question_answer_wrap"> |
| 16 | <div class="tutor_original_question"> |
| 17 | <div class="tutor-question-wrap"> |
| 18 | <div class="question-top-meta"> |
| 19 | <div class="tutor-question-avater"> |
| 20 | <a href="<?php echo $profile_url; ?>"> <?php echo tutils()->get_tutor_avatar($question->user_id); ?></a> |
| 21 | </div> |
| 22 | <p class="review-meta"> |
| 23 | <a href="<?php echo $profile_url; ?>"><?php echo $question->display_name; ?></a> |
| 24 | <span class="tutor-text-mute"><?php echo sprintf(__('%s ago', 'tutor'), human_time_diff(strtotime |
| 25 | ($question->comment_date_gmt))) ; ?></span> |
| 26 | </p> |
| 27 | </div> |
| 28 | |
| 29 | <div class="tutor_question_area"> |
| 30 | <p><strong><?php echo $question->question_title; ?> </strong></p> |
| 31 | <?php echo wpautop(stripslashes($question->comment_content)); ?> |
| 32 | </div> |
| 33 | </div> |
| 34 | </div> |
| 35 | |
| 36 | <div class="tutor_admin_answers_list_wrap"> |
| 37 | <?php |
| 38 | if (is_array($answers) && count($answers)) { |
| 39 | foreach ($answers as $answer) { |
| 40 | $answer_profile = tutils()->profile_url($answer->user_id); |
| 41 | ?> |
| 42 | <div class="tutor_individual_answer <?php echo ($question->user_id == $answer->user_id) ? 'tutor-bg-white' : 'tutor-bg-light' |
| 43 | ?> "> |
| 44 | <div class="tutor-question-wrap"> |
| 45 | <div class="question-top-meta"> |
| 46 | <div class="tutor-question-avater"> |
| 47 | <a href="<?php echo $answer_profile; ?>"> <?php echo tutils()->get_tutor_avatar($answer->user_id); ?></a> |
| 48 | </div> |
| 49 | <p class="review-meta"> |
| 50 | <a href="<?php echo $answer_profile; ?>"><?php echo $answer->display_name; ?></a> |
| 51 | <span class="tutor-text-mute"> |
| 52 | <?php echo sprintf(__('%s ago', 'tutor'), human_time_diff(strtotime($answer->comment_date_gmt)) ) ; ?> |
| 53 | </span> |
| 54 | </p> |
| 55 | </div> |
| 56 | |
| 57 | <div class="tutor_question_area"> |
| 58 | <?php echo wpautop(stripslashes($answer->comment_content)); ?> |
| 59 | </div> |
| 60 | </div> |
| 61 | </div> |
| 62 | <?php |
| 63 | } |
| 64 | } |
| 65 | ?> |
| 66 | <div class="tutor-add-question-wrap"> |
| 67 | <form action="<?php echo admin_url('admin-post.php') ?>" id="tutor_admin_answer_form" method="post"> |
| 68 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 69 | <input type="hidden" value="tutor_place_answer" name="action"/> |
| 70 | <input type="hidden" value="<?php echo $question_id; ?>" name="question_id"/> |
| 71 | <div class="tutor-form-group"> |
| 72 | <?php |
| 73 | $editor_settings = array( |
| 74 | 'teeny' => true, |
| 75 | 'media_buttons' => false, |
| 76 | 'quicktags' => false, |
| 77 | 'editor_height' => 100, |
| 78 | ); |
| 79 | wp_editor(null, 'answer', $editor_settings); |
| 80 | ?> |
| 81 | </div> |
| 82 | <div class="tutor-form-group"> |
| 83 | <button type="submit" class="tutor-button tutor-button-primary" name="tutor_question_search_btn"><?php _e('Reply', 'tutor'); ?> </button> |
| 84 | </div> |
| 85 | </form> |
| 86 | </div> |
| 87 | </div> |
| 88 | </div> |
| 89 | </div> |