=== Ultimate Download Monitor ===
Contributors: ultimatemultimediaconsult
Tags: downloads, document library, gated content, woocommerce, google drive
Requires at least: 6.2
Requires PHP: 7.4
Stable tag: 1.17.1
License: GPLv2 or later

Secure download management with Download Monitor compatibility, forms, email locks, CAPTCHA, WooCommerce access, document libraries and efficient reports.

== Compatibility ==
The plugin intentionally uses the existing dlm_download and dlm_download_version post types and reads Download Monitor's _files version metadata. It preserves legacy [download] and [downloads] shortcodes, saved Download Monitor button blocks, and /download/ID-or-slug delivery links while adding [udm_download] and [udm_library]. Download Monitor 5.x cumulative counts, detailed events and daily report totals are migrated without deleting or renaming its tables.

== Installation ==
Upload and activate. Review Downloads > Settings. Test on staging before disabling the former Download Monitor plugin.

== Hosting compatibility ==
* Dedicated servers, VPS hosting and shared hosting are supported when the System Health checks pass.
* Protected storage is selected outside the detected public document root whenever permissions and open_basedir allow it.
* Public-directory fallbacks receive Apache/LiteSpeed and IIS deny files plus a live HTTP exposure test. Nginx installations receive an exact deny rule for the selected path.
* Download and gate routes emit browser, CDN and reverse-proxy no-store headers. Edge/full-page caches must also exclude the documented routes because they can run before WordPress.
* Local streams support byte ranges, disabled output compression and a timeout-extension attempt. Configure X-Accel-Redirect, X-Sendfile or object-storage delivery when a host imposes hard PHP worker limits on very large files.
* PDF sponsor variants are generated asynchronously. The original file is delivered while processing is pending or when Imagick PDF support is unavailable.
* A real server cron running at least every five minutes is recommended for subscriptions, analytics, retention, notifications and background PDF jobs. PPTX viewing needs no server job.

== Trial and licensing ==
* A new installation receives all premium features for 30 days.
* After the trial, adding, editing and publishing downloads, free file delivery, PDF viewing, counts and reports continue.
* Subscription and purchase monetisation, ads, AI, affiliates, gates, forms, geographic gates, metering and advanced access pause until a licence is activated.
* Premium settings and download-level rules are preserved during the pause and resume after activation.
* Locked screens show Upgrade and Activate Licence actions linked to the official purchase and licence pages.
* Licence plans are Pro ($29/year, 1 site), Prime ($59/year, 3 sites), Platinum ($99/year, 10 sites), Ultimate ($190/year, unlimited sites), and Omega ($999 lifetime, unlimited sites).
* Licence keys are activated and checked securely against the vendor store. Temporary store/API outages preserve the last confirmed valid entitlement.

== Download library ==
* `[udm_library]` displays a public document library with live AJAX title search, category filtering and pagination.
* Search is debounced to reduce requests, results announce changes for assistive technology, and normal query-string submission remains available when JavaScript is disabled.
* Use `category_filter="0"` to hide the category selector, `category="slug"` to lock a library to one category, and `view="list"` for a compact list presentation.

== PowerPoint presentations ==
* PPT and PPTX files are accepted by Media Library and Protected upload workflows. Browser viewing is available for PPTX; older binary PPT files should be saved as PPTX.
* Add `[udm_slide_viewer id="123"]` or the Ultimate PowerPoint Viewer block. Download buttons appear above and below the viewer by default and use the presentation's normal access and allowance rules.
* A sandboxed JavaScript renderer included with the plugin displays the slides vertically. No Microsoft login, Google viewer, external document service, LibreOffice installation or server conversion is required.
* The presentation must be delivered from this WordPress site or from a remote host that permits browser cross-origin access.

For automatic PDF monetisation, prefer a tracked sponsor banner on the download landing page. When an ad must travel with the file, use the cached appended sponsor page. Page-by-page header or footer stamping consumes substantially more CPU and memory, may enlarge files or disturb document content, and should not run during every download request.

== File storage and privacy ==
* Use Protected upload for every login, form, CAPTCHA, role, quota, purchase or subscription restricted file.
* Use the Media Library only when possession and sharing of the direct public attachment URL is acceptable.
* Public Google Drive and external URLs remain shareable. Private or paid Drive files should use OAuth/proxied delivery.
* PDF previews are public by design. Download and Save to Google Drive still honour global/per-download access, consume allowances and enter the delivery reports.

== Affiliate Growth ==
The optional premium affiliate module supports registration/application, approval, signed first-click or last-click referral attribution, all WooCommerce products, download subscriptions and compatible renewal orders. It includes affiliate and administrator coupons, configurable direct and three-level commissions, up to three direct partners, refund reversal, a verification hold, minimum payout, PayPal/bank/mobile-money payout profiles, currency-specific payout requests and a managed payout ledger.

Affiliates receive a WooCommerce My Account tab and a responsive command centre containing product link building, social sharing, campaign creatives, team statistics, conversion reporting, commissions and payouts. Administrators receive programme KPIs, affiliate management, payout processing, coupons and AI-assisted campaign-copy tools. Add `[udm_affiliate_area]` to a page; the plugin also creates and links this page automatically.

== Advanced Access Manager ==
* Per-download daily, monthly and yearly quotas.
* Site-wide daily, monthly and yearly quotas.
* Global and per-download availability date ranges.
* Allowed and blocked WordPress roles, including guest visitors.
* Allowed and blocked user IDs.
* Exact IPv4/IPv6 and CIDR allow/deny rules.
* Per-category daily, monthly and yearly quotas.
* Limits are counted per authenticated user or privacy-preserving guest IP hash.
* Blocked attempts are recorded in reports without increasing download counts.

== Changelog ==
= 1.17.1 =
* Fixed a performance conflict where the background Download Monitor log reconciliation could run a slow, blocking database operation during unrelated admin pages and admin-ajax requests (including the post editor's autosave/Heartbeat activity), which could stall the editor, disable Publish/Update, and interrupt large file uploads such as video. Reconciliation now runs inline only when viewing Downloads > Reports or Downloads > System Health; automatic background catch-up continues on its existing hourly schedule instead.

= 1.17.0 =
* Added PayPal and Flutterwave payout automation for affiliate commissions. An admin can now click Pay via PayPal or Pay via Flutterwave on an approved payout request to send a real transfer, covering PayPal, bank transfer and mobile money. Manual Mark paid stays available as a fallback for every method.
* Affiliates now provide structured payout account details (PayPal email; bank name and account number, looked up live from Flutterwave; mobile money network and phone number) in addition to the existing free-text note.
* Added a Sandbox/Live mode toggle and optional webhook confirmation so a payout that is accepted but not yet finally settled is not left showing as paid.
* Fixed downloads listed in the Ultimate Downloads, Ultimate Most Popular Downloads and Ultimate Subscription Downloads widgets sometimes rendering as invisible white text on a white background in themes with a dark sidebar.

= 1.16.1 =
* Fixed a PHP syntax error in the affiliate documentation text that prevented the plugin from activating (introduced in 1.16.0; that version should not be used).

= 1.16.0 =
* Removed the sponsor-code field from every affiliate signup form. New affiliates are now attributed automatically to whoever's referral link they clicked (the plugin already sets a signed cookie for this); applying no longer requires typing anything beyond the opt-in checkbox.
* Added a "Default upline" setting (Downloads > Affiliates > Programme settings) so every affiliate who joins with no referral click still has an upline — enter any existing active affiliate's ID or referral link, on any site running the plugin.

= 1.15.0 =
* Added three sidebar widgets, also available as Legacy Widget blocks in the block widget editor: Ultimate Downloads (choose a category and how many to show), Ultimate Most Popular Downloads (ranked by delivery count, choose how many to show), and Ultimate Subscription Downloads (choose a category and how many to show).

= 1.14.1 =
* Fixed the actual root cause of settings saves silently reverting: the registered settings sanitizer discarded any direct save of the settings option that did not originate from the tabbed Settings screen, which affected the Affiliates screen, Privacy & Retention screen, and AI-generated popup copy.
* Added no-cache headers to the Affiliate Area page so a full-page cache or CDN can never serve one visitor's affiliate status, licence-gate state, or stats to another visitor.
* Fixed a race condition that allowed a duplicate/double-click payout request to claim the same pending commission twice.
* Fixed partial WooCommerce refunds incorrectly reversing an affiliate's entire order commission instead of only reversing on a full refund.

= 1.14.0 =
* Fixed affiliate settings persistence and separated saved configuration from licensed runtime entitlement.
* Added configurable three-level commissions and teams with up to three direct partners per affiliate.
* Added first/last-click attribution, renewal tracking, commission holds, payout thresholds and refund-safe commission handling.
* Added a payout ledger with payment profiles, currency-specific requests, approval, rejection, payment references and paid status.
* Added the Affiliate My Account tab, WordPress user status, product link builder, campaign creatives, coupons, team views and richer affiliate/admin analytics.
* Connected the configured AI provider to affiliate campaign-copy creation and expanded setup/troubleshooting documentation.

= 1.13.0 =
* Replaced server-side LibreOffice conversion with a PPTX renderer bundled directly inside the plugin.
* Removed the server-software requirement, background slide conversion, external viewer login and third-party document transfer.
* Added sandboxed, sequential in-browser slide rendering and responsive fitting for desktop and mobile screens.
* Simplified slide toolbars to the access-aware download controls and removed implementation commentary from the visitor interface.
* Added retained open-source licence notices for the locally bundled presentation libraries.

= 1.12.0 =
* Replaced Microsoft Office Online with private, server-side PPT/PPTX-to-PDF conversion using LibreOffice headless.
* Added asynchronous conversion, file-fingerprint caching in protected storage, timeout handling and safe automatic cleanup of superseded previews.
* Displayed generated slides in the plugin's internal PDF-style viewer without external login prompts or third-party presentation transfer.
* Added automatic LibreOffice discovery, a configurable executable path, System Health readiness reporting and administrator requeue controls.
* Preserved the public-preview policy while keeping top and bottom PowerPoint downloads fully governed by all normal access and metering rules.

= 1.11.0 =
* Added PPT and PPTX upload support for public Media Library and protected-storage download sources.
* Added `[udm_slide_viewer]` and the Ultimate PowerPoint Viewer Gutenberg block with configurable height, count display and download buttons above and below the viewer.
* Routed both slide-viewer download buttons through the standard access, gate, quota, purchase, subscription, modal, count and reporting pipeline.
* Added Microsoft Office Online rendering over the public preview endpoint, HTTPS fallback guidance and an explicit external-viewer privacy notice.
* Corrected dynamic-page cache detection for the download, PDF-viewer and PowerPoint-viewer Gutenberg blocks.
* Added correct PowerPoint MIME values to SEO/AIEO structured data and updated embedded AI help.

= 1.10.0 =
* Integrated the Pro, Prime, Platinum, Ultimate and Omega WooCommerce licence variations with detailed purchase cards and plan-aware store links.
* Hardened licence activation, periodic checking, deactivation and update entitlement against temporary API failures and ambiguous invalid responses.
* Added same-site REST dispatch for reliable licence validation when the plugin runs on the licensing store itself.
* Added AJAX search, category filtering, clearing and pagination to the public download library with accessible status messages and non-JavaScript fallbacks.
* Updated the built-in documentation and AI helper with licence-plan and library-filter guidance.

= 1.9.5 =
* Added checkbox selection to the filtered event explorer with Excel-compatible UTF-8 CSV export and permission-protected deletion of selected detailed rows.
* Added a database storage overview showing estimated row counts and combined data/index size for reporting and operational tables.
* Preserved cumulative download counts, imported history and compact daily summaries when individual detail rows or aged logs are deleted.
* Hardened CSV output against spreadsheet formula interpretation, switched large filtered exports to efficient cursor paging, and retained batched configurable cleanup for high-traffic sites.

= 1.9.4 =
* Made missing, inherited, legacy and unrecognized per-download access values resolve through the validated global policy; an invalid or absent global value safely defaults to Free.
* Added an explicit “Use global default” choice to the download editor while preserving deliberately configured login, form, CAPTCHA, purchase and subscription rules.

= 1.9.3 =
* Fixed `Unknown column 'region'` on upgraded sites with an explicit, repeat-safe event-ledger column and index repair.
* Reworked the event table definition into WordPress `dbDelta()` compatible one-field-per-line form and made reconciliation verify schema readiness before importing.
* Added report-range and geography indexes plus a five-minute cache for historical aggregate queries.
* Added configurable popup and affiliate-visit retention, bounded scheduled cleanup, and a manual timeframe-based log deletion tool that preserves totals and commercial records.

= 1.9.2 =
* Made detailed Download Monitor reconciliation independent of database-driver result-key casing by selecting stable source/download aliases and using case-insensitive field reads.
* Added explicit database formats, safe mapping finalization and per-cause reconciliation diagnostics with the last database error shown only to administrators.
* Advanced the database schema so upgrading automatically repairs incomplete event-ledger columns before reconciliation runs.

= 1.9.1 =
* Rebuilt the distributable with standards-compliant forward-slash ZIP paths so WordPress reliably discovers `ultimate-download-monitor/ultimate-download-monitor.php` after upload.
* Added packaged-copy activation checks for the plugin header, required includes, assets, version/schema consistency and nested release contamination.

= 1.9.0 =
* Fixed Download Monitor 5.x reconciliation by preserving the declared uppercase `ID` result key instead of silently rejecting every detailed log row.
* Imported authoritative cumulative counts from `dlm_downloads` and prevented reconciled post-handover events from being counted twice.
* Imported pre-handover `dlm_reports_log` daily totals into date trends and top-download reports without inventing users or locations.
* Added continued handling for legacy Download Monitor endpoint URLs, version links, shortcodes and saved download-button blocks after DLM is deactivated.
* Added a post-persistence live capture fallback and explicit reconciliation error reporting.

= 1.8.0 =
* Reconciled post-migration Download Monitor log rows into UDM reports automatically and on demand.
* Linked legacy rows already captured by the live hook instead of double-counting them.
* Made legacy deliveries advance the post-migration visible count while preserving the original baseline.
* Added delivery-capture diagnostics for recent traffic, successful deliveries, reconciliation backlog and untrackable raw file URLs.

= 1.7.0 =
* Added shared-hosting/VPS portability checks for document-root exposure, open_basedir, Nginx, LiteSpeed, Apache and IIS.
* Added a live protected-storage HTTP probe, exact Nginx deny rule and administrator-configurable host-approved storage path with validation.
* Hardened large-file streams with timeout extension, disabled compression, byte ranges and proxy-buffering/CDN controls.
* Added early cache exclusions and no-store headers for download, preview, gated and dynamic UDM pages.
* Moved PDF sponsor generation to Action Scheduler or WordPress Cron so download requests always deliver immediately.
* Added overdue cron notices, filterable AI prompts and substantially expanded documentation and AI-helper coverage.

= 1.6.0 =
* Unified every report KPI, chart, table and comparison on the same date, content, user, outcome and geography filters.
* Limited report geography choices to locations present in the event ledger and added tracked-versus-imported coverage guidance.
* Added OpenRouter with separate non-disclosed key handling, exact-model override, OpenRouter Auto routing, cost/quality control and connection testing.
* Added a live production-readiness audit and non-destructive repair for database tables, pages, hooks, storage and schedules.
* Bumped the schema version so upgrades repair all required analytics and affiliate tables automatically.

= 1.5.1 =
* Restored public PDF preview while keeping Download and Save to Google Drive protected, metered and counted.
* Added compact quick sign-in/registration with return-to-document behavior and removed nested denial/footer overlays.
* Captured member or gate identity for deliveries and added richer protected-URL-safe SEO/AIEO metadata and schema.

= 1.5.0 =
* Bridged Download Monitor's official delivery action and access filter into the Ultimate event ledger so legacy delivery routes populate reports without double-counting visible totals.
* Applied global and per-download access decisions to PDF previews and legacy deliveries, suppressed the native PDF save toolbar and routed saving through the authorised download button.
* Added an explicit All active subscription plans option in the download editor.
* Rebuilt reports with period comparisons, executive KPIs, interactive daily bars, signed-in/guest analysis, active-user and popular-file metrics, location rankings and a detailed event explorer.
* Added a configurable affiliate module for all WooCommerce products and plugin subscriptions, including registration, links, signed attribution, self-referral protection, multilevel commissions, downline limits, coupons, refunds, payouts, promotion tools, popups and affiliate/admin analytics.
* Added an automatically created Affiliate Area page and expanded storage, viewer, affiliate and privacy documentation.

= 1.4.3 =
* Replaced the fixed-answer CAPTCHA with randomized, signed, expiring and single-use maths challenges.
* Added built-in Cloudflare Turnstile and Google reCAPTCHA v2 configuration with mandatory server verification, hostname checks and provider extension hooks.
* Added the missing Download Plans fallback page and subscription-plan shortcode for browsers where modal JavaScript is unavailable.
* Added local licence-activation throttling and broader Throwable handling for malformed PDF/Imagick failures.
* Removed the unused parallel licence client and unreachable duplicate country list.
* Made AI Auto fail clearly when live provider model discovery is unavailable instead of silently choosing a potentially retired model ID.
* Added scheduled-job status, next/last run times and overdue warnings to System Health.

= 1.4.2 =
* Fixed PDF previews so download allowances cannot inject a full denial page into the viewer while login, purchase, subscription and form privacy rules remain enforced.
* Added interactive report trend points with hover values, keyboard focus and click-to-filter dates.
* Added a shared hierarchical country, state/region and district/city engine for gate forms and reports, using WooCommerce geography, bundled fallbacks and observed site data.
* Added branded product and subscription upgrade modals with site identity, unique prices, direct WooCommerce checkout and a built-in default image.
* Added popup display, click, checkout and paid-conversion tracking with report analytics.
* Extended configured AI automation to ad calls-to-action and subscription popup copy.

= 1.4.1 =
* Added centrally enforced 30-day premium trial expiry and upgrade/activation screens.
* Preserved free download publishing, delivery, PDF viewing, reports and saved premium configuration after expiry.
* Blocked premium handlers, checkout, renewals, AI, advertising, forms, gates and advanced access without an active entitlement.
* Standardised PDF advertising on cached appended sponsor pages and documented performance guidance.

= 1.4.0 =
* First stable production release; removed the beta suffix.
* Added auto-detected country, state/region and district/city gate-form fields with allowed-value filtering.
* Added provider model discovery and an Auto cost/performance policy with exact-model overrides.

= 1.4.0-beta.8 =
* Added selectable OpenAI, Google Gemini and Anthropic Claude integrations with separate API keys and models.
* Retained provider-agnostic WordPress Core AI connector support.
* Added safe key replacement, removal and beta.7 settings migration.

= 1.4.0-beta.7 =
* Restored reliable responsive PDF viewers without consuming download tokens or counts.
* Added AI-assisted summaries, tags, schema, links and PDF cover featured images.
* Added rich report filters for keyword, taxonomy and geographic dimensions.
* Reconciled legacy Download Monitor baselines with atomic UDM-only counting.
* Added protected-storage fallback plus Documentation and AI Help Chat tabs.

= 1.4.0-beta.6 =
* Added default login, subscription upgrade and single-product purchase dialogs.
* Added direct-to-checkout WooCommerce preparation without replacing WooCommerce orders or gateways.
* Added seven-day/custom-range visual reporting and matching CSV exports.
* Added button download counts and AJAX-searchable Gutenberg download selectors.
* Added protected PDF-ad processing safeguards and corrected PDF previews so they do not inflate downloads.

= 1.4.0-beta.5 =
* Added secure version ownership validation and consumable form-gate tokens.
* Added free and subscription allowances by day, week, month and year.
* Added WooCommerce product and built-in subscription access.
* Added reports, visitor tracking, PDF previews, forms and advertising.

= 1.1.0-beta.2 =
* Added the Advanced Access Manager.
* Added category quota fields.
* Added global and per-download access-rule inheritance.
* Improved denial screens for quota and restriction failures.
