$attach_id, 'url' => wp_get_attachment_url($attach_id), 'mime' => get_post_mime_type($attach_id), 'name' => get_the_title($attach_id), 'filename' => basename( get_attached_file( $attach_id ) ), ); wp_send_json_success($attach_data); } else { wp_send_json_error(__('Attachment not found', 'squeeze')); } wp_die(); } /** * Check if attachment can be restored * * @param int $attach_id * @return bool */ function squeeze_can_restore($attach_id) { $original_img_path = wp_get_original_image_path((int) $attach_id); $backup_img_path = preg_replace("/(\.(?!.*\.))/", '.bak.', $original_img_path); $can_restore = file_exists($backup_img_path); return $can_restore; }