Esempio n. 1
0
 public function delete()
 {
     try {
         if (empty($_POST['ID']) && empty($_POST['comment_ID'])) {
             throw new Exception(__('Error occurred', ET_DOMAIN));
         }
         if (isset($_POST['do_action']) && $_POST['do_action'] == "deleteComment") {
             $msg = __("Comment deleted successfully!", ET_DOMAIN);
             $post = get_comment($_POST['ID']);
             wp_delete_comment($_POST['comment_ID']);
         } else {
             if (isset($_POST['post_type']) && $_POST['post_type'] == "answer") {
                 $msg = __("Answer deleted successfully!", ET_DOMAIN);
                 $post = get_post($_POST['ID']);
                 QA_Answers::delete($_POST['ID']);
             } else {
                 $msg = __("Question deleted successfully!", ET_DOMAIN);
                 $post = get_post($_POST['ID']);
                 QA_Questions::delete($_POST['ID']);
             }
         }
         $resp = array('success' => true, 'msg' => $msg, 'redirect' => get_post_type_archive_link('question'), 'data' => $post);
     } catch (Exception $e) {
         $resp = array('success' => false, 'msg' => $e->getMessage());
     }
     return $resp;
 }