=== KMG PhotoVault ===
Contributors: anthonyacosta
Tags: photography, gallery, watermark, client gallery, photo delivery
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Professional client photo delivery with automatic watermarking, password-protected galleries, and copyright rights management.

== Description ==

**KMG PhotoVault** is a professional photo delivery plugin for photographers. Upload your images, watermark them automatically, create a password-protected client gallery page, and deliver it with a single click.

Unlike general-purpose gallery plugins, PhotoVault is purpose-built for the photographer → client workflow: you control the watermark, the client never gets an unwatermarked file, and every download is tracked.

**Key Features (Free)**

* Upload JPEG, PNG, and WebP images — watermark is applied automatically before storage
* Images are stored *outside* the WordPress Media Library — no accidental public exposure
* Watermark text with intelligent auto-contrast (white on dark images, black on light images — never invisible)
* Password-protected gallery pages created automatically by the plugin
* Send gallery link and password to clients via email with one click
* 10 gallery layout types: Grid, Masonry, Carousel (Pro), Filmstrip (Pro), Lightbox Gallery, Blog-Style, Justified (Pro), List, Slideshow (Pro), and the classic Mosaic alias
* Drag-and-drop image reordering
* Copy shortcode to embed the gallery anywhere
* Up to 3 active galleries and 50 total images (Free plan)
* Page view tracking per gallery
* Download count tracking per image
* Welcome and thank-you messages per gallery
* Full-width page setup instructions for all major themes

**Pro Features**

* Unlimited galleries and images
* PNG/logo watermark (your brand, not just text)
* All 4 watermark positions: bottom-right, bottom-left, top-right, top-left
* Keep original (unwatermarked) files for future re-watermarking
* Re-watermark all images in a gallery with one click
* Slideshow layout
* Per-gallery watermark assignment
* Gallery expiry / auto-archiving
* **Copyright & Usage Rights footer** — a structured, professional license summary generated from your settings, displayed on each gallery page:
  * License duration, territory, permitted media, exclusivity
  * Usage type (personal, editorial, commercial)
  * Glossary explaining copyright vs. license to your clients
  * Per-gallery overrides

= How It Works =

1. Install and activate the plugin.
2. Go to **PhotoVault → All Galleries** and click **+ Add New Gallery**.
3. Enter a gallery name and set a password for your client.
4. After the page is created, upload your photos — watermarks are applied instantly.
5. Click **Send Gallery Link & Password** to email your client.
6. The client visits the protected page, enters the password, and sees the gallery.
7. All downloads are watermarked. No full-resolution unbranded files leave the server.

= File Storage & CDN Compatibility =

Images are stored in `wp-content/uploads/kmg-photovault/`, outside the Media Library. If you use a CDN offload plugin (WP Offload Media, Cloudflare R2, BunnyCDN, etc.), watermarked images will sync automatically. Original files (if "Keep Original" is enabled) are stored in a separate `/originals/` subfolder — you should exclude this from CDN sync in your offload plugin's settings.

= Privacy =

KMG PhotoVault does not collect, transmit, or share any user data. License validation communicates only with kennedymedia.com to verify your key.

== Installation ==

1. Upload the `kmg-photovault` folder to `/wp-content/plugins/`.
2. Activate the plugin via **Plugins → Installed Plugins**.
3. Go to **PhotoVault → Settings → Watermark** and set your watermark text.
4. Create your first gallery via **PhotoVault → All Galleries**.

**Upgrading to Pro**

1. Purchase a license at [kennedymedia.com/kmg-photovault](https://kennedymedia.com/kmg-photovault/).
2. Go to **PhotoVault → Settings → License** and enter your key.
3. Pro features activate immediately.

== Frequently Asked Questions ==

= Can clients download the original, unwatermarked files? =

No. All download links serve only the watermarked version. The original files (if retained) are stored in a non-public directory and served only through a PHP passthrough that enforces the watermark rule.

= Does the plugin work with page builders like Divi and Elementor? =

Yes. The plugin creates a standard WordPress page and inserts a shortcode. For best results, set the gallery page to a full-width template in your page builder. See `FULL-WIDTH-SETUP.md` (included in the plugin) for step-by-step instructions for Divi, Elementor, Beaver Builder, block themes, and all other themes.

= What image formats are supported? =

JPEG, PNG, and WebP. Maximum upload size is 30 MB per image (also subject to your server's PHP upload limit).

= Does it work on shared hosting? =

Yes. The plugin uses PHP passthrough for file serving, which works on Apache, Nginx, and shared hosting environments without requiring `.htaccess` directory blocks or server configuration changes.

= What happens when I archive a gallery? =

Archiving sets the gallery page to Private — clients can no longer access it, even with the password. All images and data are kept intact. You can restore the gallery (make it Active again) at any time from the gallery's Manage page or the gallery list.

= Can I use the shortcode on pages other than the auto-created gallery page? =

Yes. Every gallery has a shortcode (e.g. `[kmg_photovault id="5"]`) visible in the Manage Gallery sidebar. You can paste this shortcode on any page or post — including your portfolio.

= Does the watermark auto-adjust for image color? =

Yes, by default. The "Auto" color setting samples the background brightness in the corner where the watermark will appear and chooses white text on dark backgrounds and black text on light backgrounds. This ensures legibility regardless of the photo. You can override this to always use white or always use black in **Settings → Watermark**.

= What is the Copyright & Usage Rights footer? =

A Pro feature that adds a professional legal footer to every gallery page explaining how the client may use the images. You configure the defaults (duration, territory, permitted media, exclusivity, and usage type) once in **Settings → Copyright & Usage**, and the plugin generates a readable paragraph. You can override the terms per gallery.

== Screenshots ==

1. All Galleries list with inline Add New Gallery panel
2. Gallery management — image grid with drag-and-drop reorder
3. Send to Client panel — email gallery link and password in one click
4. Watermark settings — auto-contrast color mode
5. Copyright & Usage Rights settings (Pro)
6. Frontend gallery — mosaic layout with lightbox
7. Frontend gallery — copyright footer (Pro)

== Changelog ==

= 1.0.3 =
* Feature: 10 gallery layout types — Grid (thumbnail grid, 2–6 columns), Masonry Tiles, Carousel/Slider (Pro), Filmstrip with scrollable thumbnail strip (Pro), Lightbox Gallery (single hero with full-screen browser), Blog-Style/Vertical List, Justified Gallery with equal-height rows (Pro), Simple List, Slideshow (Pro)
* Feature: CDN Push — "Push to CDN" button in gallery management transfers all local watermarked images to your CDN in batches and removes local files, freeing server disk space. Supports WP Offload Media (AS3CF) auto-detected, Generic S3-compatible API via wp-config.php constants, and a filter hook (kmg_pv_cdn_transfer_image) for custom adapters
* Feature: Once images are on CDN, gallery serves CDN URLs directly — no PHP passthrough needed, faster load times
* Fix: Delete image now confirmed to remove both watermarked and original files from disk as well as the DB record
* Developer: New KMG_PV_CDN class with adapter detection, AS3CF adapter, generic S3 adapter (no SDK required), and filter-based extension API
* Developer: DB migration adds cdn_url column to existing installs
* Developer: New DB methods: set_cdn_url(), get_local_images()

= 1.0.2 =
* Feature: Welcome and thank-you messages per gallery (with professional placeholder text)
* Feature: Copyright & Usage Rights footer (Pro) — structured form generates a legal paragraph covering duration, territory, permitted media, exclusivity, and usage type
* Feature: Per-gallery copyright overrides (Pro)
* Feature: Four watermark positions — bottom-right, bottom-left, top-right, top-left (Pro for non-default positions)
* Feature: Watermark color auto-contrast — samples background brightness and switches white/black automatically; can be overridden to a fixed color
* Fix: "Create Gallery" button on the All Galleries inline panel now fires correctly (delegated submit event)
* Fix: "Select Files" button now uses native `.click()` — resolves browser compatibility issues with jQuery `.trigger('click')` on hidden file inputs
* Fix: Stats now track page views (once per shortcode render) and download count per image separately; view count no longer incremented on every image load
* Fix: Slideshow transition replaced `display:none/block` toggling (caused full page reflow) with CSS opacity transition
* UI: "Add New Gallery" moved from a separate page to an inline slide-down panel on the All Galleries listing
* UI: Improved archive/restore explanation text — clearly states the client page becomes private when archived and can be restored at any time
* UI: Download count added to Gallery Info panel alongside page views
* Developer: Real Stripe Product ID (`prod_UQNxzdIIGQYwHD`) and Price IDs (monthly, annual, lifetime) documented in `class-kmg-pv-license.php`
* Developer: Added `FULL-WIDTH-SETUP.md` with step-by-step instructions for Divi, Elementor, Beaver Builder, block themes, and a universal functions.php snippet
* Developer: Database migration (`maybe_migrate_columns`) added to `KMG_PV_Activator` to safely add new columns to existing installs without data loss
* Developer: `KMG_PV_Activator::activate()` bumped to trigger migration on plugin update

= 1.0.1 =
* Fix: "Click to select files" button was not opening the file picker in some browsers (double-event binding issue)
* Fix: Gallery images returning 404 — rewrite rules now auto-flush when the stored plugin version doesn't match; plain-permalink fallback added for shared hosting without pretty permalinks enabled
* Fix: From Name setting in email not being retained after save (option read used an incorrect fallback)
* Fix: `remove_all_filters` on `wp_mail_*` was removing SMTP plugin filters; now only our specific filter closures are removed
* UI: "Add New Gallery" now uses an inline panel on the All Galleries page instead of a separate admin page
* UI: Removed Stripe/Pricing settings tab from the admin UI; Stripe URLs are now configured via PHP constants with full instructions in `class-kmg-pv-license.php`

= 1.0.0 =
* Initial release
* Automatic watermarking on upload (Imagick with GD fallback)
* Password-protected gallery pages created automatically
* Mosaic/grid, list, and slideshow (Pro) layouts with lightbox
* Drag-and-drop image reordering
* Send gallery link and password to clients via wp_mail()
* License system integrated with KMG license server
* Free tier: 3 galleries, 50 images, text watermark, bottom-right position
* Pro: unlimited galleries/images, PNG watermark, all positions, expiry, archiving, re-watermark, keep originals

== Upgrade Notice ==

= 1.1.5 =
Fixes watermark type persistence, welcome/thankyou message saving, copyright preview, and watermark delete. Adds CDN debug tool and default expiry date. Cleans all remaining PHPCS issues.

= 1.1.4 =
Adds per-watermark light/dark classification, auto watermark selection by image brightness, disable watermark per gallery, and fixes all PHPCS plugin check issues.

= 1.1.3 =
Fixes admin thumbnail timeouts. Thumbnails now load lazily 3 at a time and are cached to disk after first generation.
