public function sync_deletion($id) { $attachment = Attachment::get($id); if (!$attachment) { return; } $status = $attachment->delete_from_cloud_storage(false, true); }
public function wp_get_attachment_url($url, $id) { $attachment = Attachment::get($id); if (!$this->url_fixes_needed($attachment)) { return $url; } $gcs_url = $attachment->get_cloud_storage_url(); if (!$gcs_url) { return $url; } return $gcs_url; }
private function ajax_get_attachment($data) { if (!isset($data['attachment_id'])) { return new WP_Error('attachment_id_missing', __('Missing attachment ID.', 'wp-gcs-offload')); } $attachment_id = absint($data['attachment_id']); $attachment = Attachment::get($attachment_id); if (!$attachment) { return new WP_Error('attachment_id_invalid', __('Invalid attachment ID.', 'wp-gcs-offload')); } return $attachment; }