answers.php
90 lines
| 1 | <?php |
| 2 | $question_id = 0; |
| 3 | if ( isset( $_GET['question_id'] ) ) { |
| 4 | $question_id = (int) tutor_sanitize_data($_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 esc_url( $profile_url ); ?>"> <?php echo tutils()->get_tutor_avatar( $question->user_id ); ?></a> |
| 21 | </div> |
| 22 | <p class="review-meta"> |
| 23 | <a href="<?php echo esc_url( $profile_url ); ?>"><?php echo esc_attr( $question->display_name ); ?></a> |
| 24 | <span class="tutor-text-mute"> |
| 25 | <?php echo wp_sprintf( __( '%s ago', 'tutor' ), human_time_diff( strtotime( $question->comment_date_gmt ) ) ); ?> |
| 26 | </span> |
| 27 | </p> |
| 28 | </div> |
| 29 | |
| 30 | <div class="tutor_question_area"> |
| 31 | <p><strong><?php echo esc_attr( $question->question_title ); ?> </strong></p> |
| 32 | <?php echo wp_kses_post( wpautop( stripslashes( $question->comment_content ) ) ); ?> |
| 33 | </div> |
| 34 | </div> |
| 35 | </div> |
| 36 | |
| 37 | <div class="tutor_admin_answers_list_wrap"> |
| 38 | <?php |
| 39 | if ( is_array( $answers ) && count( $answers ) ) { |
| 40 | foreach ( $answers as $answer ) { |
| 41 | $answer_profile = tutils()->profile_url( $answer->user_id ); |
| 42 | ?> |
| 43 | <div class="tutor_individual_answer <?php echo esc_attr( ( $question->user_id == $answer->user_id ) ? 'tutor-bg-white' : 'tutor-bg-light' ); ?>"> |
| 44 | <div class="tutor-question-wrap"> |
| 45 | <div class="question-top-meta"> |
| 46 | <div class="tutor-question-avater"> |
| 47 | <a href="<?php echo esc_url( $answer_profile ); ?>"> <?php echo tutils()->get_tutor_avatar( $answer->user_id ); ?></a> |
| 48 | </div> |
| 49 | <p class="review-meta"> |
| 50 | <a href="<?php echo esc_url( $answer_profile ); ?>"><?php echo esc_attr( $answer->display_name ); ?></a> |
| 51 | <span class="tutor-text-mute"> |
| 52 | <?php echo wp_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 wp_kses_post( 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 esc_attr( $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> |
| 90 |