=== DWD NCMEC Missing Kids Posters ===
Contributors: dizwebdesign
Requires at least: 6.0
Requires PHP: 7.4
Stable tag: 1.0.32
License: GPLv2 or later

Sync missing-child posters from the NCMEC Poster API into WordPress. Optional sharing and social updates via DWD SocialAutoShare 1.5+.

== Description ==

Imports and updates missing-child posters from the NCMEC Poster API (posterapi.ncmec.org). Administrators configure import scope (organization codes, location filters, or IP geolocation), sync interval, and content templates.

Requires NCMEC API credentials. For Facebook/Instagram sharing and updates, install DWD SocialAutoShare 1.5 or newer.

== Shortcodes ==

* `[ncmec_posters]` — responsive grid of active posters (attributes: status, limit, columns)

== Changelog ==

= 1.0.32 =
* Fix: speed up admin screens — no heavy missing-photo scan on every `init`; SQL count + short-lived cache for dashboard stats; shorter remote heartbeat timeout.

= 1.0.31 =
* Change: default sync interval is every 4 hours (240 minutes); existing 15/30/60 installs migrate automatically.
* Fix: pending photo backfill no longer calls the Photo API on every `init` — schedules deferred cron only; post-sync backfill capped to 1 photo; longer outbound request pacing.

= 1.0.30 =
* Fix: stop duplicate Media Library photos — reuse/reclaim existing attachments by MD5/basename, attach lock, and Tools cleanup to trash extras (name-primary-1…-4).

= 1.0.29 =
* Fix: global NCMEC API cool-down on HTTP 429 (honors Retry-After), request pacing, smaller photo backfill batches, skip sync/backfill/reconcile while cooling — stop hammering rate limits.

= 1.0.28 =
* Added: posters no longer returned by NCMEC (even without a foundDate) are marked removed, set private, and queued for archive after the same delay — without a social “found” update.

= 1.0.27 =
* Added: when a child is found (or NCMEC removes the poster), mark the live post found and set it private; after 7 days copy to archive.appleseednews.com via DWD Post Archive and keep the live post private.

= 1.0.26 =
* Added: color-coded Tools log viewer — errors in red, warnings in yellow.

= 1.0.25 =
* Fix: no inline sleep/retry loops on HTTP 429 — fail fast and queue a deferred photo retry so sync does not stall.

= 1.0.24 =
* Critical: attach photos on first sync (fresh poster detail + 429 retries). Defer social share until the featured image exists; auto-retry photo then share. Dashboard alert + “Attach missing photos now”.

= 1.0.23 =
* Fix: slower photo backfill when NCMEC rate-limits (30 minute backoff); avoid extra detail fetches that worsen throttling.

= 1.0.22 =
* Fix: photo backfill scans all posters (not only the newest page), so older posts without thumbnails are not skipped.

= 1.0.21 =
* Fix: on photo 404, refresh poster detail and try every photo candidate (stale MD5 hashes in cached JSON).

= 1.0.20 =
* Fix: resolve relative NCMEC photoUri paths (`/Poster/.../Photo/{md5}`) against posterapi.ncmec.org and fetch with auth; retry raw image Accept when JSON has no photoData.

= 1.0.19 =
* Fix: broader photo field detection; unwrap nested poster detail payloads; admin REST photo-status / backfill for diagnosing remaining thumbnails.

= 1.0.18 =
* Fix: photo backfill no longer skips posters with orphaned `_thumbnail_id` meta; clear invalid thumbnails and keep retrying.

= 1.0.17 =
* Fix: keep featured-image backfill running until all posters have thumbnails; respect rate limits; follow allowlisted photo URI redirects; record per-poster photo errors.

= 1.0.16 =
* Fix: queue featured-image backfill on upgrade so existing posters get photos without waiting for a full re-sync.

= 1.0.15 =
* Fix: NCMEC Photo API returns JSON (photoData/photoUri); decode base64 instead of treating the body as raw image bytes. Backfill featured images for posters missing thumbnails.

= 1.0.14 =
* Security: allowlist poster photoUri host to posterapi.ncmec.org; validate image MIME before sideload; ignore unsigned heartbeat site_token.

= 1.0.13 =
* Security: ignore unsigned remote wipe banned/blocked; wipe only via verified signed commands.

= 1.0.12 =
* Fix: Remove separate “Missing posters” admin menu; open posters from the NCMEC Dashboard tab / Posters submenu instead.

= 1.0.11 =
* Added: Always-on scheduled poster check logging (success/fail, fetched/created/updated/skipped, timing) in the Tools log, independent of API/debug toggles.

= 1.0.10 =
* Added: Poster statistics on Dashboard and Tools — total received, still missing, marked found, published/draft, photos, org breakdown, and lifetime sync counters.

= 1.0.9 =
* Fix: Missing state must use two-letter abbreviations (OH, not Ohio); normalize full names on save; Help and field tooltip updated.
* Added: Baseline from today — set sync watermark to start of today so the next sync skips historical backlog (also applied on DB migration v4).

= 1.0.8 =
* Fix: Strip UTF-8 BOM from PHP files that caused “The plugin generated unexpected output” on activation (including via DWD Plugins Hub).

= 1.0.7 =
* Added: Field help tooltips on all NCMEC settings and front-page fields (hover/focus on desktop, tap on mobile).
* Added: Organization codes reference table in Help modal — codes discovered from API tests, sync, dry runs, and imported posters.

= 1.0.6 =
* Added: Rank Math SEO integration — default titles/meta, sitemap inclusion for poster singles, noindex CPT archive (hub page owns listing URL), and auto meta description on sync.

= 1.0.5 =
* UI: Horizontal section tabs on all admin screens (dashboard, API settings, tools, front page, backup) with responsive layout and dashboard quick links replaced by tabs.

= 1.0.4 =
* Fix: With DWD Plugins Hub active, only one fly-out link (dashboard); Tools, settings, backup, and front page open from dashboard quick links.

= 1.0.3 =
* Fix: Separate admin slugs for Front page vs NCMEC API settings (no longer overwrite each other).
* Fix: Register Tools, Backup, Front page, and API settings under DWD Plugins Hub when the hub is active.

= 1.0.2 =
* Admin Help modal with setup guide and link to NCMEC Poster API registration.

= 1.0.1 =
* API and debug file logging (Tools screen), dry-run sync preview, enhanced connection test with first-page poster count, featured image download fix.

= 1.0.0 =
* Initial release: NCMEC API sync, ncmec_poster CPT, admin settings, manual/cron sync, SocialAutoShare bridge, front-end listing.
