=== Easy Photo Publisher ===

Contributors: easywppublisher
Tags: lightroom, media, gallery, images, upload
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.1
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Publish images from Lightroom Classic directly to WordPress, manage media via REST, and show taxonomy-filtered galleries with an accessible lightbox.

== Description ==

Easy Photo Publisher complements the Adobe Lightroom Classic add-on **Easy WordPress Publisher**. 
Together they form a full publishing pipeline: send images directly from Lightroom to your WordPress site, 
update or replace them later, and (optionally) create blog posts using those images.

**Highlights**
- Direct publish from Lightroom Classic via the companion LrC module
- Create / update / delete media via a simple REST API
- Optional post creation with visibility control and Featured Image
- Gallery Shortcode: `[wpdet_gallery]` with taxonomy filters, sizing and a11y-friendly captions
- Accessible lightbox (keyboard/ARIA aware), toggled per shortcode
- Gallery selection: let visitors mark images and pull the selection into Lightroom (opt-in)
- Media taxonomies: enable Categories and Tags on attachments
- Theme template overrides (HTML-only)
- i18n-ready (`easy-wp-publisher`)

== Installation ==

1. Upload the plugin to `/wp-content/plugins/` or install via Plugins → Add New.
2. Activate the plugin.
3. (Optional) In **Settings → From Image to WordPress**, enable Categories/Tags for media (on by default after activation).
4. Install the companion Lightroom Classic module **Easy WordPress Publisher** and enter your site URL, username, and an Application Password.

== Quick Start ==

1.	In Lightroom Classic, publish an image using the "Easy WordPress Publisher" service.
2.	The image appears in your WordPress Media Library.
3.	On any page or post, insert the gallery shortcode:

[wpdet_gallery category="Portugal" limit="-1" order="DESC" min_width="240px" gap="1.5rem" size="large" class="" showcaption="true" lightbox="true"]

- limit="-1" shows all matching images
- showcaption="true|false" toggles captions
- lightbox="true|false" enables the accessible lightbox

== Shortcode Reference: [wpdet_gallery] ==

**Attributes**
- `category` — Category ID or slug to filter attachments (requires media taxonomies)
- `tags` — CSV of tag slugs (e.g. `tags="portugal,coast"`)
- `limit` — Number of images (default 12). Use `-1` for all.
- `order` — `ASC` or `DESC` (default `DESC`)
- `size` — `thumbnail|medium|large|full` (or any registered image size)
- `min_width` — Grid minimum width (CSS value, default `200px`)
- `gap` — Grid gap (CSS value, default `1.5rem`)
- `class` — Extra CSS classes on the wrapper
- `showcaption` — `true|false` (default `true`)
- `lightbox` — `true|false` (default `true`)

== Markup & Styles ==

- Wrapper template: `templates/wrapper.php`
- Item template: `templates/gallery.php`
- CSS: `templates/css/wpdet-gallery.css`
- Lightbox CSS/JS autoload when `lightbox="true"`

**Theme overrides (HTML-only)**

your-theme/
└── wpdet/
    └── templates/
        ├── wrapper.php     (uses tokens: {items}, {min_width}, {gap}, {extra_class})
        └── gallery.php     (uses tokens: {link_open}, {img}, {link_close}, {caption})

If present in a child theme, it’s used first; then the parent theme; finally the plugin fallback.

== Accessibility ==
- Lightbox uses proper roles (role="dialog"), aria-modal, labelled controls, focus trapping, and Esc to close.
- Close button is keyboard-operable (Enter/Space) and returns focus to the trigger.
- Captions are announced via a polite live region.

== Media Taxonomies (Categories/Tags on Attachments) ==

Enable in Settings → From Image to WordPress to use core Categories and Tags on media items. This allows taxonomy-filtered galleries.
- Works with the shortcode filters (category, tags)
- Adds taxonomy UI to the Media screens (without duplicating existing columns)

== Gallery Selection (Visitor Voting) ==

Per-gallery feature, off by default. Turn it on for a specific gallery with the shortcode
attribute `ratings="true"`, and change the visible label with `select_label="…"`. Each image
then shows an accessible selection checkbox below its caption. Example:

`[wpdet_gallery category="Portugal" ratings="true" select_label="Select your favourite"]`

The choice is stored as one shared on/off flag per image (no counter, no per-visitor state —
visitors may overwrite each other). The selection can then be pulled into Lightroom Classic
with the **Easy WordPress Publisher** add-on (version 1.0.4 or newer). Clear the stored
selection any time under Settings → Easy Photo Publisher → Gallery selection.

REST endpoints (namespace `wpdet/v1`):
- `GET  /capabilities` — feature discovery (public)
- `POST /rate/{id}` — set the on/off state (public; nonce-protected)
- `GET  /selection` — list selected image IDs (Application Password)
- `DELETE /selection` — reset, optionally scoped by `category`/`tags` (Application Password)

Minimum pairing: the selection feature needs this plugin **>= 1.1.0** and the Lightroom
add-on **>= 1.0.4**. Older pairings keep working for publishing; only the selection pull is unavailable.

== Validation ==
- MIME types: image/jpeg, image/png, image/webp, image/avif
- Max size: ~25 MB (configurable in code)

== Frequently Asked Questions ==

= Do I need the Lightroom Classic module? =
Yes. This WordPress plugin exposes REST endpoints and gallery features; the LrC module performs the upload.

= Can I show all images in a category? =
Yes, set `limit="-1"` in the shortcode.

= How do captions work? =
Captions come from the attachment’s “Caption” (post excerpt). Toggle with `showcaption="true|false"`.

= Can I change the HTML without touching PHP? =
Yes. Override the template files in your theme using the placeholder tokens described below.

== Changelog ==

1.1.1.
	• Fix: re-publishing an existing photo now keeps the original file path and URL (no more `-1` suffix). Page builders such as Divi that store the image URL keep working.
	• Fix: old thumbnails and WebP/AVIF siblings (e.g. EWWW Image Optimizer `photo.jpg.webp`) are removed before regeneration, so no stale variants are served.
	• Fix: the unscaled original of big images (`-scaled`) and freshly generated WebP files are no longer removed by the orphan cleanup.
	• New filter `wpdet_replace_keep_path` to restore the previous behaviour (new filename on re-publish).

1.1.0.
	• New: opt-in Gallery Selection. Visitors can mark images; the selection is exposed via REST (`/rate`, `/selection`) and can be pulled into Lightroom Classic.
	• New: `GET /capabilities` endpoint and `X-WPDet-Plugin-Version` response header for version-aware clients.
	• New: backend reset for the selection, scoped by category and/or tag slugs.
	• Accessible voting checkbox (real input + label, per-image aria-label, visible focus, ≥4.5:1 contrast).

1.0.0.
	•	Initial public version with REST create/update/delete, taxonomy support, gallery shortcode, accessible lightbox, and theme overrides.

1.0.3.
Added support for AVIF format

1.0.4.
	• Fixed some small code glitches
	• Tested with WordPress 7.0.

== Upgrade Notice ==

= 1.1.1. =
Re-publishing a photo keeps its file URL, so images embedded by URL (e.g. Divi backgrounds) no longer break.

= 1.1.0. =
Adds an opt-in visitor selection for galleries (pullable into Lightroom), a capabilities endpoint, and a scoped selection reset. The selection pull needs the Lightroom add-on 1.0.4 or newer.

= 1.0.4. =
Bug fixes: WP_Error handling in REST endpoints, visibility parameter validation, and duplicate function definition in utils.

= 1.0.3. =
Added support for AVIF format.

== Support & Documentation ==

- Documentation: https://medienkonzepte.de/easy-wordpress-publisher-a-lightroom-extension/
- Donate: https://buymeacoffee.com/webline

== Credits ==

Made with ❤️ by Detlef Beyer.