=== Nexu FTP Media ===
Contributors: nexuwp
Tags: ftp, media, cdn, offload, upload
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.70.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Transfer WordPress media files to FTP/SFTP server and serve them from CDN. Reduce hosting storage and improve performance.

== Description ==

Nexu FTP Media helps you offload your media library to an external FTP or SFTP server, reducing your hosting storage usage and enabling CDN delivery for better performance.

**Key Features:**

* Support for FTP, FTPS, and SFTP protocols
* Automatic upload of new media files
* Bulk sync existing media library
* Parallel file transfers for faster uploads
* Real-time progress tracking
* Intelligent URL rewriting for CDN delivery
* Compatible with major page builders (Elementor, Divi, WPBakery, etc.)
* WooCommerce and ACF support
* Secure password encryption
* Resume interrupted transfers
* Detailed logging and debugging

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/nexu-ftp-media/`
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to FTP Media menu to configure your FTP connection
4. Set your CDN URL in the URL & CDN tab
5. Start syncing your media library

== Frequently Asked Questions ==

= What protocols are supported? =

The plugin supports FTP, FTPS (FTP over SSL), and SFTP (SSH File Transfer Protocol).

= Is my FTP password secure? =

Yes, all passwords are encrypted using AES-256-CBC encryption before being stored in the database.

= Will my images break if I deactivate the plugin? =

URL rewriting happens on output only - your database is never modified. If you have not deleted local files, deactivating the plugin will simply revert to serving files locally.

= Can I resume an interrupted transfer? =

Yes, the plugin automatically saves transfer progress. If your browser closes or you navigate away, you can resume from where you left off.

== Changelog ==

= 1.61.0 =
* Fixed: Added strict remote integrity verification (download-back size/hash checks) before marking files as Transferred to prevent false-success uploads

= 1.60.0 =
* Improved: Public URL verification now tests additional candidate URL patterns (origin/path variants) and reports candidates in diagnostics for faster path mismatch debugging

= 1.59.0 =
* Changed: Remote upload success no longer fails when CDN/public URL is temporarily unreachable; warning is stored while rewrite remains availability-aware

= 1.58.0 =
* Fixed: Corrected debug logging variable in public URL verification failure path

= 1.57.0 =
* Fixed: Upload verification now probes both remote-path and WordPress-attachment URL candidates, stores resolved public URL, and uses it for future rewrites
* Fixed: Stale public URL meta is now cleaned during requeue/delete flows

= 1.56.0 =
* Fixed: Public URL verification now falls back to GET for all non-success HEAD responses and checks encoded URL variants to avoid false 404 failures

= 1.55.0 =
* Improved: Failed verification error now includes detailed diagnostics (public URL, remote path, and last HTTP/transport check result)

= 1.54.0 =
* Improved: Failed status now includes expandable error details toggle in Media Library and attachment edit views

= 1.53.0 =
* Fixed: URL rewriting now performs cached public URL reachability checks per attachment, preventing stale offloaded metadata from producing 404 links

= 1.52.0 =
* Fixed: Upload success now requires public CDN URL verification (HEAD/GET), preventing false success when rewritten links return 404

= 1.51.0 =
* Fixed: Attachment and Elementor rewrite paths now use per-attachment remote path mapping consistently to prevent 404 mismatches

= 1.50.0 =
* Fixed: URL rewriting now maps to the actual stored remote path to avoid 404 due to path mismatch
* Fixed: Auto-upload no longer skips files when stale offload meta exists but remote file is missing
* Changed: Admin/media status badges now rely strictly on status meta (no remote-path fallback)

= 1.49.0 =
* Fixed: Prevented URL rewriting when a transfer fails by requiring status=uploaded and clearing stale offload meta if remote file is missing
* Improved: Media modal attachment details now show FTP Status without custom JavaScript

= 1.48.0 =
* Fixed: Prevented false “Transferred” state when FTP servers disable SIZE/MDTM by verifying remote existence after upload
* Changed: Media Library status badge no longer uses JavaScript polling

= 1.47.0 =
* Improved: Media Library now shows live per-file transfer status (Pending/Uploading with progress/Transferred/Failed)

= 1.46.0 =
* Fixed: Failed files modal now returns only truly failed items for the current session (prevents loading unrelated files)

= 1.45.0 =
* Fixed: Auto-upload now schedules correctly for AJAX uploads and WooCommerce Action Scheduler environments

= 1.44.0 =
* Fixed: Media Library “Transferred” badges are now English and fully translatable

= 1.43.0 =
* Improved: Added “Transferred” badge to Media Library and attachment edit screens

= 1.42.0 =
* Improved: Failed files list now shows size/format badges next to filenames and highlights the failure reason

= 1.41.0 =
* Fixed: Failed files modal now shows only current-session failures (optional history supported)

= 1.40.0 =
* Improved: Failed files modal now supports scrolling, better RTL layout, and thumbnail links to Media edit pages

= 1.39.0 =
* Improved: Added a searchable “Failed files” details modal with per-file error messages

= 1.38.0 =
* Fixed: Prevented fatal error when third-party plugins pass attachment IDs as strings during URL rewriting

= 1.37.0 =
* Improved: Added header “Getting Started” guided tour modal

= 1.36.0 =
* Improved: Refined navigation tab dividers (subtle, professional separators)

= 1.35.0 =
* Improved: Added divider line between admin navigation tabs

= 1.34.0 =
* Improved: URL rewriting recognizes uploaded files via saved remote path meta (more reliable offload detection)

= 1.33.0 =
* Fixed: URL rewriting now supports HTML entities in media URLs (e.g., &zwnj; in Persian filenames)

= 1.32.0 =
* Fixed: URL rewriting now works reliably with Elementor/JetEngine outputs (no hard block on CDN health check)
* Improved: Better attachment ID detection for non-Latin filenames (fallback lookup)

= 1.31.0 =
* Improved: Header status now shows Background Sync Running while background transfer is active

= 1.30.0 =
* Fixed: RTL header layout order (icon + title start from right, no reversed layout)

= 1.29.0 =
* Fixed: RTL vertical tabs order (icon + label start from right, no reversed layout)

= 1.28.0 =
* Fixed: Prevented duplicate modals when background sync is active (shows only one modal)

= 1.27.0 =
* Fixed: Resume modal no longer shows empty 0/0 sessions (auto-cleans stale UI state)

= 1.26.0 =
* Fixed: Vertical tabs RTL layout (icons/text alignment, long labels, mobile RTL nav)

= 1.25.0 =
* Improved: Increased max concurrent connections to 12 (with stability warning above 6)

= 1.24.0 =
* Improved: Resume buttons now continue immediately (no extra manual \"Start\" click)
* Improved: Continue (Background) starts directly without requiring a scan

= 1.23.0 =
* Fixed: Resume button could start before scan completed (prevented "No files to sync. Run scan first.")

= 1.22.0 =
* Fixed: Modal buttons layout overflow on small screens (responsive wrap)

= 1.21.0 =
* Improved: Resume modal messaging for interrupted transfers (power off / browser close)
* Added: Resume option to continue as Background Mode (keeps running if browser closes)
* Added: Background-running modal prompt (Monitor now / Keep running / Stop)
* Fixed: UI session state is now stored separately (avoids corrupting transfer state)
* Fixed: Background state now stores compact queue to support huge libraries reliably

= 1.20.0 =
* Fixed: PHP "constant already defined" warnings when plugin loaded multiple times
* Fixed: Undefined array key "average_speed" warning in QueueProcessor
* Improved: Proper state initialization with all required stats keys

= 1.19.0 =
* Fixed: Background mode speed - removed slow loopback method
* Improved: Background mode now processes batch_size files per cron run (reads from settings)
* Improved: Reduced delay between batches from 5s to 1s with immediate spawn_cron()
* Improved: Extended batch time limit to 50s for more files per cycle

= 1.18.0 =
* Added: Stylish tooltips on sync mode selector explaining each mode
* Improved: Cleaner mode selector UI without inline text clutter

= 1.16.0 =
* Improved: Background sync now shows FULL progress in main transfer section on page load
* Improved: Active transfers section shows current background file being uploaded
* Improved: Queue count, failed count, bytes transferred all update in real-time
* Added: Inline background controls (Pause/Resume/Stop) in the transfer section
* Fixed: Page refresh now properly restores full UI state when background sync is running

= 1.15.0 =
* NEW: Background Sync Mode - transfers continue even if browser is closed (via WP-Cron)
* NEW: Background status banner shows real-time progress on page load
* NEW: Sync mode selector (Browser vs Background)
* Fixed: Extension filter bug ("unnamed-file.jpg" → "jpg") - extensions now save correctly
* Added: Reset Extensions button to restore defaults
* Improved: Auto-fix for previously corrupted extension data

= 1.14.0 =
* Improved: Sync console now shows Worker number per upload (proves real concurrency)
* Improved: Server response now includes PID and duration for each upload request (debug/verification)

= 1.13.0 =
* Improved: Upload speed and reliability (removed double FTP connect per upload)
* Improved: Sync tab retry logs now show the real error reason
* Improved: Dynamic per-item timeout to reduce unnecessary retries

= 1.12.0 =
* Fixed: FTP uploads no longer hang during Sync by using a fresh FTP connection per upload (reliable data connection)
* Fixed: Windows remote path generation to prevent \"C:\\\" paths on FTP

= 1.11.0 =
* Fixed: Sync now performs a write+mkdir preflight before starting parallel workers
* Improved: Upload and progress polling requests now have timeouts to prevent infinite loading

= 1.10.0 =
* Fixed: Sync tab fatal error when loading settings (SettingsRepository null)

= 1.9.0 =
* Improved: Styled the Transfer tab action list for a consistent Nexu UI

= 1.8.0 =
* Fixed: Test Connection no longer hangs indefinitely on restricted root paths
* Improved: Added request-level timeouts for FTP/SFTP uploads and UI connection test
* Improved: FTP passive mode reliability (FTP_USEPASVADDRESS handling)

= 1.7.0 =
* Fixed: Settings save now reports success when values are unchanged (prevents false \"Failed to save\" messages)

= 1.6.0 =
* Fixed: Test Connection now uses the saved password when the password field is left empty

= 1.5.0 =
* Fixed: Saving Connection settings no longer clears the existing password when left empty

= 1.4.0 =
* Improved: Vertical navigation tabs now match Nexu Activity Log design (title + meta, active/hover polish)

= 1.3.0 =
* Added: Self-test runner (CLI) to validate queue, chunked uploads, and progress isolation
* Added: PHPUnit test suite scaffolding for transfer system and AJAX progress endpoint
* Improved: QueueProcessor now supports dependency injection for reliable testing

= 1.2.0 =
* Fixed: Critical bug in URL rewriter filter settings (filter_areas compatibility)
* Fixed: Session resume modal now detects pending sessions correctly
* Fixed: Cron schedules now register on every request (not just activation)
* Fixed: Logger now uses WP_Filesystem for file operations
* Fixed: Removed deprecated load_plugin_textdomain() call
* Improved: Full WordPress Coding Standards compliance

= 1.1.0 =
* Added: Individual progress bars for each active file transfer
* Added: Speed chart showing transfer speeds over 5 minutes
* Added: File type breakdown in scan results with icons
* Added: Improved session resume modal with detailed statistics
* Improved: Chunked uploads with resume capability for large files
* Improved: Better error handling and retry logic

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 1.11.0 =
Improved Sync reliability with preflight and request timeouts.

= 1.10.0 =
Fixed a fatal error in the Sync tab.

= 1.9.0 =
Improved Transfer tab UI styling.

= 1.8.0 =
Improved FTP connection testing and prevented indefinite hangs.

= 1.7.0 =
Fixed false save failure messages when settings are unchanged.

= 1.6.0 =
Fixed Test Connection behavior when password field is left empty.

= 1.5.0 =
Fixed connection password saving behavior.

= 1.4.0 =
Improved the vertical navigation tabs UI to match Nexu Activity Log.

= 1.3.0 =
Added a CLI self-test runner plus automated test scaffolding.

= 1.2.0 =
Critical bug fixes for URL rewriting and session management. Update recommended.

= 1.1.0 =
Major improvements to transfer system with individual progress bars, speed chart, and better resume capability.

= 1.0.0 =
Initial release of Nexu FTP Media.
