// error out if the POST format isn't right if (!array_key_exists('id', $_POST)) { header('HTTP/1.0 400 Bad Request'); header('Content-Type: application/json'); echo json_encode(array('error' => __('You have not supplied the ID to delete.', 'total-slider'))); die; } // we need the slide ID $_POST['id'] = preg_replace('[^0-9a-zA-Z_]', '', $_POST['id']); if (empty($_POST['id'])) { header('HTTP/1.0 400 Bad Request'); header('Content-Type: application/json'); echo json_encode(array('error' => __('You have not supplied the ID to delete.', 'total-slider'))); die; } $result = $g->delete_slide($_POST['id']); if ($result) { header('Content-Type: application/json'); echo json_encode(array('success' => 'true')); die; } else { header('HTTP/1.1 500 Internal Server Error'); header('Content-Type: application/json'); echo json_encode(array('error' => __('The delete slide operation failed at the server. Perhaps it has already been deleted by someone else.', 'total-slider'))); die; } break; default: header('HTTP/1.1 403 Forbidden'); die('<h1>Forbidden</h1>'); break;