'Permission denied.')); } $r = wp_trash_post($entry_id); if ($r === false) { self::json_response(array('error' => 'Post already in trash.')); } self::json_response(array('success' => true)); } // ?? Not sure about this. I think this can literally do nothing. public static function delete_entry_nopriv() { self::json_response(array()); } // Ajax call to delete an entry - should create a more graceful experience in the delete entry process. public static function delete_entry_undo() { $entry_id = $_REQUEST['entry_id']; if (!current_user_can('delete_af-entry')) { self::json_response(array('error' => 'Permission denied.')); } $r = wp_untrash_post($entry_id); if ($r === false) { self::json_response(array('error' => 'Post not in trash.')); } self::json_response(array('success' => 'test')); } // ?? Not sure about this. I think this can literally do nothing. public static function delete_entry_undo_nopriv() { self::json_response(array()); } /** * Prepares and executes a json response. Sets the header content type, json encodes some output object, then exits. * * @param $output_obj - Object to json_encode and return as a json response. */ public static function json_response($output_obj) { header('Content-Type: application/json'); print(json_encode($output_obj)); die(); } } add_action('alchemyst_forms:loaded', array('Alchemyst_Forms_Ajax', 'init'));