=== Arb Cloudflare Media Offload ===
Contributors: arbdigital
Tags: cloudflare, r2, offload, media, cdn, woocommerce, s3
Requires at least: 5.6
Tested up to: 6.7
Requires PHP: 7.0
Stable tag: 1.0.0
License: GPLv2 or later

Offload your WordPress / WooCommerce media to Cloudflare R2 (zero egress fees) and serve it through the Cloudflare CDN. A lightweight, no-AWS-SDK alternative to WP Offload Media — built for the Cloudflare free plan.

== Description ==

Arb Cloudflare Media Offload copies your uploads to a Cloudflare R2 bucket and rewrites their URLs to a Cloudflare-proxied delivery domain. Because R2 has **no egress fees**, the Cloudflare free plan can serve all your media at no bandwidth cost.

= Features =
* Cloudflare R2 storage (S3-compatible) with built-in AWS Signature V4 — no Composer / AWS SDK needed.
* Streams large files with cURL for a low memory footprint.
* Auto-offload new uploads (original + every thumbnail size).
* Bulk offload existing media with a live progress bar (batched AJAX, resumable).
* Optional removal of local files after offload to free server disk.
* URL rewriting to your Cloudflare delivery domain — including legacy URLs inside post content / page builders.
* Optional automatic Cloudflare cache purge when media is deleted/replaced.
* WooCommerce-friendly (handles product images, galleries, variations).
* Keys stored in wp-config.php (recommended) or the database.
* Built-in connection tester for both R2 and the Cloudflare API.

= Why R2 over Amazon S3? =
Amazon S3 charges for every GB downloaded (egress). Cloudflare R2 charges **zero** egress, and the free tier includes 10 GB storage. Combined with Cloudflare's free CDN, your media is fast and free to serve.

== Installation ==

1. Upload the `arb-cloudflare-offload` folder to `/wp-content/plugins/` (or upload the ZIP via Plugins → Add New).
2. Activate the plugin.
3. In Cloudflare: create an R2 bucket, then create an R2 API Token (Object Read & Write) and copy the Access Key ID + Secret Access Key.
4. Add to `wp-config.php` (above the "stop editing" line):

   define( 'ARB_CFO_R2_ACCESS_KEY', 'your-access-key-id' );
   define( 'ARB_CFO_R2_SECRET_KEY', 'your-secret-access-key' );

5. In Cloudflare, connect a custom domain to the bucket (R2 → bucket → Settings → Public access → Custom Domain), e.g. `media.arbsbuy.com`.
6. Go to Media → CF Offload, enter your Account ID, bucket name and the Delivery URL, Save, then click "Test R2 connection".
7. Click "Offload existing media".

== Changelog ==

= 1.0.0 =
* Initial release.
