=== in1me CDN & Backups with pCloud ===
Contributors: in1me
Tags: cdn, pcloud, media, backup, cloud storage
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 4.0.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

CDN media and full-site backup system with pCloud integration. Sync media, rewrite URLs, perform backups, and restore with one click.

== Description ==

**in1me CDN & Backups with pCloud** allows you to use your pCloud account as a CDN for your WordPress site, and provides a full-site backup and restore system. This plugin is not affiliated with or endorsed by pCloud AG.

= CDN & Media Features =

* **Media URL Rewriting** – Automatically rewrite all image and media URLs from your origin server to a pCloud-based CDN URL.
* **Automatic Sync** – Upload new media files to pCloud automatically when added to the WordPress media library.
* **Delete Sync** – Optionally remove files from pCloud when they are deleted from WordPress.
* **Thumbnail Support** – Sync all generated WordPress image sizes (thumbnails, medium, large, etc.).
* **Image Optimization Compatibility** – Works with Perfect Images, ShortPixel, Imagify, EWWW, and Smush.
* **WebP and AVIF Support** – Sync converted WebP and AVIF files to pCloud.
* **Bulk Sync** – Upload all existing media files to pCloud at once.

= Backup & Restore Features =

* **Full-Site Backups** – Back up your entire WordPress site including the database, themes, plugins, uploads, and wp-config.php.
* **Chunked Transfers** – Large files are split into manageable chunks and uploaded reliably to pCloud.
* **One-Click Restore** – Restore any backup with a single click. The restore process downloads files from pCloud, replaces local content, and imports the database.
* **Multi-Step Processing** – Both backup and restore run in multiple AJAX steps to prevent server timeouts.
* **Backup Upload** – Upload existing backup archives (.zip) from your computer to your pCloud backup storage.
* **Backup Management** – View, delete, and upload backups directly from the admin dashboard.

= General =

* **Modern Admin Interface** – Clean, easy-to-use dashboard with English and Arabic language support.
* **Bilingual Support** – Full RTL support with Arabic and English UI.
* **All Features Free** – Every feature is fully functional with no restrictions, limitations, or locked functionality.

== Third-Party Services ==

This plugin connects to the following external service:

= pCloud =

This plugin requires a [pCloud](https://www.pcloud.com/) account to function. pCloud is a cloud storage service used by this plugin to:

* **Store and serve media files** as a CDN (Content Delivery Network).
* **Store backup files** including database exports, themes, plugins, uploads, and configuration files.

**Data transmitted to pCloud:**

* Media files (images, videos, documents) from your WordPress media library.
* Database SQL exports (during backup).
* Theme and plugin ZIP archives (during backup).
* Upload directory ZIP archives (during backup).
* wp-config.php file (during backup).

**When data is transmitted:**

* When media files are uploaded to WordPress (if auto-sync is enabled).
* When a manual backup is initiated.
* When bulk sync is triggered by the admin.

**pCloud Links:**

* Service: [https://www.pcloud.com/](https://www.pcloud.com/)
* Terms of Service: [https://www.pcloud.com/terms_and_conditions.html](https://www.pcloud.com/terms_and_conditions.html)
* Privacy Policy: [https://www.pcloud.com/privacy_policy.html](https://www.pcloud.com/privacy_policy.html)
* Developer API: [https://docs.pcloud.com/](https://docs.pcloud.com/)

== Installation ==

1. Upload the plugin folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Go to **in1me CDN & Backups with pCloud** in the admin menu.
4. Create a pCloud application at [pCloud Developer Apps](https://docs.pcloud.com/my_apps/). Note: You may need to contact pCloud support to activate API access for your app.
5. Enter your App Key and App Secret in the plugin settings and save.
6. Click "Connect Account" to authorize your pCloud account.
7. Configure your pCloud folder path and CDN URL.
8. Enable CDN rewriting to start serving media from pCloud.

= Backup Setup =

1. Navigate to the "Backup & Restore" tab.
2. Create backups when needed.
3. Click "Create Backup Now" to create your first backup.
4. Use the "Restore" button on any backup to restore your site.

== Frequently Asked Questions ==

= How do I create a pCloud app? =
Go to [https://docs.pcloud.com/my_apps/](https://docs.pcloud.com/my_apps/) and create a new application. You will receive an App Key and an App Secret. You may need to contact pCloud support to activate API access for your app.

= What is a CDN URL? =
This is the URL that points to your files hosted on pCloud. Example: `https://cdn.yourdomain.com/wp-content/uploads`

= Is the plugin compatible with image optimization plugins? =
Yes, the plugin is compatible with Perfect Images, ShortPixel, Imagify, EWWW Image Optimizer, and Smush.

= What happens during a backup? =
The plugin exports your database, compresses your themes, plugins, and uploads into ZIP archives, and uploads them to your pCloud account in a structured folder.

= What happens during a restore? =
The plugin downloads backup files from pCloud, replaces your current themes and plugins, imports the database, and cleans up temporary files. Files remain stored on pCloud after restore.

= Is this plugin affiliated with pCloud? =
No. This plugin is developed by in1me and is not affiliated with, endorsed by, or officially connected to pCloud AG.

== Screenshots ==

1. The main dashboard showcasing CDN options and pCloud account settings.
2. The Backup & Restore system tab, allowing selective backups and restoration of specific components like uploads, database, or plugins.
3. Media synchronization settings to control file types, specific destination folders, and date-based filtering for targeted pCloud uploads.

== Changelog ==

= 4.0.5 =
* Fixed: Multi-step restore would fail after database step ("Restore state not found").
* Fixed: Restore state now uses file-based storage that survives database restoration.
* Fixed: Token-based authentication properly skips nonce check after database restore.
* Security: Improved OAuth CSRF protection with state parameter verification.

= 4.0.4 =
* Security: All temporary files now stored in system temp directory instead of uploads folder.
* Security: State data now stored in database via WordPress transients API instead of files.
* Security: Debug logs now use PHP error_log instead of publicly accessible files.
* Security: Added index.php protection to temp directory.
* Improved data privacy for backup/restore operations.

= 4.0.3 =
* Cleaned up scheduled backup options and cron hooks from the Free plugin.
* Standardized and improved the promotional notice for WordPress.org guidelines compliance.

= 4.0.2 =
* All features are now fully free and functional (CDN, manual backups).
* Improved security: Added nonce verification to all form actions and AJAX handlers.
* Improved security: Added capability checks to OAuth callback handler.
* Improved security: Removed unauthenticated AJAX endpoint for restore.
* Fixed: CDN URL is now properly escaped in content filter output.
* Fixed: Output buffer is now properly closed on shutdown.
* Fixed: Temporary backup files are now stored in the uploads directory instead of wp-content.
* Fixed: wp-config.php restore now uses WP_Filesystem API.
* Fixed: Language switcher now uses nonce verification.
* Improved promotional notice for guidelines compliance.

= 3.0.4 =
* Fix: Added .php to supported file types.
* Fix: Improved overall synchronization stability.

= 3.0.3 =
* Fix: Sync all files in uploads directory (CSS, JS, Fonts, etc.).
* Fix: Improve Exclude Paths logic for all file types.

= 3.0.2 =
* Updated plugin name for WordPress.org compliance.
* Improved readme with full feature documentation and third-party service disclosure.
* Fixed option name prefixes for WordPress.org compliance.
* Replaced move_uploaded_file with wp_handle_upload.
* Multi-step restore with dedicated progress bar.
* Increased database backup chunk size for better performance.

= 3.0.1 =
* First release.