/** * Post answer to question at ML * * @ajax( action: "post_ml_comment" , only_logged: true ) */ public function post_aswer() { check_ajax_referer('ml-comments-action', 'security'); if (is_null(ML()->ml_communication) || !isset($_POST['parentId']) || !isset($_POST['comment'])) { die; } $answered_question = ML_Questions::answer_question($_POST['parentId'], $_POST['comment']); if (is_null($answered_question)) { die; } $answer = array('Id' => 0, 'Author' => ML()->ml_nickname, 'Comment' => $answered_question->answer->text, 'ParentId' => $answered_question->id, 'UserAvatar' => ML_Product::get_main_image($answered_question->item_id), 'CanDelete' => false, 'CanReply' => false, 'Date' => date('H:m d/m/Y', strtotime($answered_question->answer->date_created))); wp_send_json($answer); }