Addons.php
6 years ago
Admin.php
6 years ago
Ajax.php
6 years ago
Assets.php
6 years ago
Course.php
6 years ago
Course_Settings_Tabs.php
6 years ago
Course_Widget.php
6 years ago
Dashboard.php
6 years ago
Email.php
6 years ago
FormHandler.php
6 years ago
Gutenberg.php
6 years ago
Instructor.php
6 years ago
Instructors_List.php
6 years ago
Lesson.php
6 years ago
Options.php
6 years ago
Post_types.php
6 years ago
Q_and_A.php
6 years ago
Question_Answers_List.php
6 years ago
Quiz.php
6 years ago
Quiz_Attempts_List.php
6 years ago
Rewrite_Rules.php
6 years ago
Shortcode.php
6 years ago
Student.php
6 years ago
Students_List.php
6 years ago
Taxonomies.php
6 years ago
Template.php
6 years ago
Theme_Compatibility.php
6 years ago
Tools.php
6 years ago
Tutor.php
6 years ago
TutorEDD.php
6 years ago
Tutor_Base.php
6 years ago
Tutor_List_Table.php
6 years ago
Upgrader.php
6 years ago
User.php
6 years ago
Utils.php
6 years ago
Video_Stream.php
6 years ago
Withdraw.php
6 years ago
Withdraw_Requests_List.php
6 years ago
WooCommerce.php
6 years ago
Q_and_A.php
53 lines
| 1 | <?php |
| 2 | namespace TUTOR; |
| 3 | |
| 4 | if ( ! defined( 'ABSPATH' ) ) |
| 5 | exit; |
| 6 | |
| 7 | class Q_and_A{ |
| 8 | |
| 9 | public function __construct() { |
| 10 | add_action('admin_post_tutor_place_answer', array($this, 'place_answer')); |
| 11 | } |
| 12 | |
| 13 | public function place_answer(){ |
| 14 | tutor_utils()->checking_nonce(); |
| 15 | |
| 16 | global $wpdb; |
| 17 | |
| 18 | $answer = wp_kses_post($_POST['answer']); |
| 19 | $question_id = (int) sanitize_text_field($_POST['question_id']); |
| 20 | $question = tutor_utils()->get_qa_question($question_id); |
| 21 | |
| 22 | $user_id = get_current_user_id(); |
| 23 | $user = get_userdata($user_id); |
| 24 | $date = date("Y-m-d H:i:s", tutor_time()); |
| 25 | |
| 26 | do_action('tutor_before_answer_to_question'); |
| 27 | |
| 28 | $data = apply_filters('tutor_answer_to_question_data', array( |
| 29 | 'comment_post_ID' => $question->comment_post_ID, |
| 30 | 'comment_author' => $user->user_login, |
| 31 | 'comment_date' => $date, |
| 32 | 'comment_date_gmt' => get_gmt_from_date($date), |
| 33 | 'comment_content' => $answer, |
| 34 | 'comment_approved' => 'approved', |
| 35 | 'comment_agent' => 'TutorLMSPlugin', |
| 36 | 'comment_type' => 'tutor_q_and_a', |
| 37 | 'comment_parent' => $question_id, |
| 38 | 'user_id' => $user_id, |
| 39 | )); |
| 40 | |
| 41 | $wpdb->insert($wpdb->comments, $data); |
| 42 | $answer_id = (int) $wpdb->insert_id; |
| 43 | |
| 44 | if ($answer_id){ |
| 45 | $wpdb->update($wpdb->comments, array('comment_approved' => 'answered'), array('comment_ID' =>$question_id ) ); |
| 46 | do_action('tutor_after_answer_to_question', $answer_id ); |
| 47 | } |
| 48 | |
| 49 | wp_redirect(wp_get_referer()); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | } |