function wp_egrid_ajax_delete_photo_callback() { $photo_id = $_REQUEST['photo_id']; $filename = $_REQUEST['filename']; //delete record in database require 'model/project_model.php'; $projectModel = new ProjectModel(); $projectModel->delete_image_by_id($photo_id); //delete file $uploadFolder = wp_upload_dir(); $uploadFolder = $uploadFolder['baseurl']; $filename = $uploadFolder . DIRECTORY_SEPARATOR . 'wp_elastic_grid' . DIRECTORY_SEPARATOR . $filename; @unlink($filename); die; }