=== 404ops Short Link Manager ===
Contributors: spwhite
Tags: url shortener, shortlinks, qr code, redirects, 404 error
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.11.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Branded short links with QR codes, privacy-first click analytics, a 404 log of the dead URLs visitors really hit, and one-click redirects.

== Description ==


Short Link Manager turns any destination URL into a branded `/go/your-slug` short link, makes a QR code for it, and tracks its clicks with a privacy-first analytics model. The free shortener, QR generator and click analytics run on your own site. The separate Pro add-on is described under External services.

It also watches your content. A nightly scan checks the HTTP status of links in published posts and pages and lists the broken ones on the Broken Links screen. A 404 log records the dead URLs visitors actually reach.

= Short links =

* A branded short link with a prefix you choose, a title, one category and any number of tags.
* 301, 302 or 307 redirects.
* Optional expiry by date or click count, with a fallback destination.
* Optional `nofollow` and `sponsored` attributes, applied where this plugin writes a link.
* A Short link button in the block editor creates a short link without leaving the post.
* A locally generated QR code (SVG) for every short link. No third-party QR service is contacted.
* Redirects send `Cache-Control: private, no-store`.

= Click analytics =

* Each redirect is logged with a timestamp, referrer host, device and browser, country, and a bot flag. The free plugin makes no external GeoIP lookup.
* IP handling is set per site: anonymize (the default), full, or none.
* Respects Do Not Track when enabled. Retention is configurable and pruned daily.
* Dashboard, Reports and per-link stats, drawn as inline SVG.

= Link health and redirects =

* Scheduled scanning in an off-peak window you choose, in time-limited batches with a rest between them, plus a one-click recheck.
* A separate redirect manager for plain path-to-URL 301 and 302 redirects.

= 404 log =

Every dead URL a visitor hits is recorded, with a hit counter, when it was first and last seen, and where the visitor came from.

= Import and export =

* CSV export of short links and click data.
* CSV import that lists the rows whose domain no longer resolves, so you can fix them.
* A one-way migrator from Pretty Links that can keep old Pretty Links addresses working. It is tested against Pretty Links' table layout, not yet on a real, populated site. Back up your database first.

== External services ==

The free plugin's link-health checking fetches URLs found in your site's content and author URLs on approved comments, and uses their HTTP status to see whether they still answer. The Pro add-on also checks short-link destinations, reads redirect Location headers and inspects bounded response content for suspicious pages. These requests go to the sites each link points at, not to a 404ops service. No data is sent to us.

If you enter your own API key on Settings → AI, this plugin connects directly to the provider you chose:

* **OpenAI** — terms: https://openai.com/policies/row-terms-of-use/ — privacy: https://openai.com/privacy/
* **Anthropic** — terms: https://www.anthropic.com/legal/consumer-terms — privacy: https://www.anthropic.com/legal/privacy
* **Google Gemini** — terms: https://ai.google.dev/gemini-api/terms — privacy: https://policies.google.com/privacy

Pressing "Test key" on that screen sends a minimal, fixed test message to confirm the key/model work — nothing about your site's content or links. This connection is stored and can be tested without a Pro licence. Actually asking the model to propose a fix for a broken link (Pro) additionally sends the destination URL, its HTTP status, and the fetched page's title/excerpt/content to that same provider. Pro internal-link suggestions send the selected post's title and bounded plain-text content, plus candidate pages' URLs, titles and short excerpts. Pro 404-redirect suggestions send the missing site-relative path, words from that path, and candidate live pages' URLs and titles; they do not send the 404 log's referrer, hit counts or visitor data. The suggestion calls are on demand from the editor or 404 Log, and may reuse a cached answer. These features send the described data to your chosen provider, never to 404ops. These repair and suggestion features require your own provider key.

This plugin also adds the **404ops → AI Connection** screen, which the 404ops plugins with AI features share. That screen can be set to any of six providers, and its "Test connection" button sends the same kind of minimal test message to whichever one you choose. The three above, plus:

* **OpenRouter** — https://openrouter.ai — terms: https://openrouter.ai/terms — privacy: https://openrouter.ai/privacy
* **Ollama, or any other OpenAI-compatible endpoint** — whatever address you enter, normally a server you run yourself. No third party is involved unless you point it at somebody else's hosted endpoint, in which case that operator's terms and privacy policy apply.

The shared screen sends its fixed test message only when you explicitly press Test connection. Ollama and custom endpoints may work without a key if their operator allows it; configuring that shared connection does not add those providers to this plugin's three-provider repair/suggestion adapter.

= Pro analytics and country services =

These services are used only by the separate Pro add-on:

* **Google Analytics 4 (GA4)** — `www.google-analytics.com`, Measurement Protocol. Terms: https://marketingplatform.google.com/about/analytics/terms/us/ — privacy: https://policies.google.com/privacy . After you configure a Measurement ID and API secret in Settings → Integrations, each eligible recorded click is queued for a server-side WP-Cron send. The JSON contains the click timestamp, event name, link ID and slug, and a client ID taken from the salted truncated-IP visitor hash; with analytics IP handling set to none, a site-salted per-link value is used instead. The configured ID and secret accompany the request. This payload contains no raw visitor IP, browser or referrer. The explicit GA4 test button sends a synthetic link-ID-0, slug-test event to Google's debug endpoint, with a generated client ID and current timestamp, rather than real visitor data.
* **Meta Pixel (Conversions API)** — `graph.facebook.com`. Terms: https://www.facebook.com/legal/terms/businesstools — privacy: https://www.facebook.com/privacy/policy/ . After you configure a Pixel ID and access token, each eligible recorded click is queued for a server-side WP-Cron send. The JSON contains event name/time, website action source, your site's short-link URL, link ID and slug. It also includes the raw visitor IP only when analytics IP handling is full; anonymize and none do not include that field. The Pixel ID and access token accompany the request. The payload contains no visitor browser or referrer. Forwarding follows the recorder's tracking/Do-Not-Track controls and the configured bot filter. A send goes only to a provider with a complete ID/credential pair; no forwarding is scheduled unless at least one pair is complete.
* **GeoJS** — `get.geojs.io`. Terms: https://www.geojs.io/tos/ — privacy: https://www.geojs.io/privacy/ . Remote country lookup is off unless explicitly enabled for that site in the separate Pro add-on. If a country targeting rule needs a country and neither a host header nor a cached answer is available, a queued lookup sends the visitor IP to GeoJS. Analytics IP handling is independent. With Respect Do Not Track on, a DNT request does not queue a lookup. Disabling the preference invalidates requests still queued by this version. A request already in flight can finish. A developer can use the lookup URL filter to select a different recipient.

No telemetry is sent (see "Telemetry" above — it is off by default and, in this release, never transmitted even when turned on). QR generation never contacts a third-party service. The free plugin has no built-in remote GeoIP request.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/404ops-short-link-manager`, or install through the WordPress Plugins screen directly.
2. Activate the plugin. A short setup wizard will walk you through the essentials.
3. **Check Settings → Permalinks is not set to "Plain."** Short links cannot work with Plain permalinks — see the FAQ below for why. Any other option works. The plugin will tell you on its own screens if this needs changing.
4. Open **404ops → Short Link Manager** in the admin menu to create short links, review analytics, and manage categories. Every 404ops plugin on the site shares that one "404ops" menu, so this plugin no longer takes a sidebar slot of its own.
5. The plugin's other screens — Links, Broken Links, Redirects, Categories & Tags, Reports, Tools and Settings — are reached from the navigation row across the top of every one of its pages, not from the sidebar.

== Frequently Asked Questions ==

= Does this plugin make any external requests? =

The free plugin checks URLs in published content and approved comments' author URLs, and can explicitly test the AI connection you configure. The separate Pro add-on can also fetch destination pages, send repair/link/redirect prompts to your BYOK AI provider, forward configured GA4/Meta click events, and perform the enabled country-lookup fallback. See External services for destinations, triggers, defaults and the exact data. No telemetry is transmitted, and QR codes are generated locally.

= Where is the data stored, and what happens if I uninstall? =

Everything is stored in your site's own database. **Uninstalling leaves all data in place by default.** If you want a completely clean removal, turn on Settings → Advanced → "Remove data on uninstall" before removing the plugin. On a single site, use the Plugins screen. On multisite, use the coordinated removal tool described below. Simply deactivating the plugin never touches your data, regardless of that setting.

= My short links return "Not Found" — what's wrong? =

Almost always Permalinks set to "Plain" (Settings → Permalinks). WordPress only installs the rewrite that hands a URL like `/go/your-slug` to WordPress when a permalink structure is set; with Plain, your web server answers those URLs with its own 404 and WordPress — and therefore this plugin — never runs at all. Choose any option other than Plain and your existing short links start working immediately, with no changes to them. The plugin shows a notice on its own screens when this is the problem, and the Dashboard's Site health panel reports it too.

If permalinks are already pretty and links still 404, re-save Settings → Permalinks to flush WordPress's rewrite rules.

= Does this work on WordPress Multisite? =

Each site has its own links, analytics, and settings. Network activation loads the plugin on every site. A new site initializes its tables when the plugin first loads there. Manage links from each site's dashboard.

Single-site uninstall honors **Remove all plugin data when uninstalled** in Advanced settings. On multisite, a host administrator must deactivate both packages on every site and network and use the version-matched removal tool from the 404ops product page. It checks active sites before uninstall and honors each site's saved Free removal preference. Network deactivation leaves schedules in place for sites that are still individually active. The maintenance tool removes schedules on opted-in sites. Inactive sites do not load the plugin. Retained events can run if the plugin is activated again. If you plan to permanently delete a site, back up its Short Link Manager data first. The removal tool only enumerates registered sites.

The managed removal tool requires the standard WordPress database connection and activation storage, a local shared plugin directory, and a host maintenance window. See the tool's README for the supported setup and recovery steps. WordPress's file-only commands and direct file removal can bypass the plugin's uninstall handler.

= Why is my 404 log empty? =

Two common causes, and the first is the same one that breaks short links:

**Permalinks are set to "Plain."** WordPress never runs for those URLs — your web server answers them with its own 404 — so there is nothing for this plugin to record. Choose any other permalink structure.

**A full-page cache or CDN is in front of your site.** A repeat visit to the same dead URL can be served from that cache without ever reaching PHP, so the hit is not counted. The *first* hit on each URL always gets through, so nothing goes missing from the list — the counts are a floor rather than an exact total. This plugin deliberately does not send cache-defeating headers on every 404 your site serves, because that would impose a real cost on every visitor to make a counter more precise.

Also worth checking: bot traffic is hidden by default (use the filter on the 404 Log to see it), and 404s from non-GET requests are not recorded at all — those are bots probing for form endpoints, not links anyone can follow.

= Does short-link click tracking work with a full-page cache or CDN? =

Short-link redirects always send `Cache-Control: private, no-store` so browsers and most CDNs won't cache them. But if this site runs behind a full-page cache plugin, exclude `/{prefix}/*` (default `/go/*`) from that plugin's caching rules — a page cache that serves a stale response before WordPress even runs can still cause clicks to under-count and destination edits to stop propagating.

= What's the difference between a 301, 302, and 307 redirect? =

301 signals a permanent move (search engines update their index); 302 and 307 both signal a temporary redirect, with 307 additionally guaranteeing the original HTTP method is preserved on the redirected request. Choose the type when creating a short link.

= I use the Classic Editor — where is the Short link button? =

There isn't one. The Short link button is a block editor formatting tool, and no classic-editor (TinyMCE) equivalent is registered, so on a site running the Classic Editor plugin the button simply does not appear and nothing else changes. Create the link on the Links screen and paste the short URL in, exactly as before — that workflow is unchanged and is not going away.

= Who is allowed to create short links from the editor? =

Administrators, by default — the same people who can already use the Links screen. A short link is a site-wide redirect rather than post content: it is live the moment it is created, it sends visitors from a URL on your domain to anywhere on the web, and it outlives the post it was made in. So it is deliberately not granted to Authors, Editors, or Contributors just because they can write posts. On a multi-author site where you do want your editors creating them, a developer can widen it with the `ops404_link_sentinel_editor_link_cap` filter; the toolbar button and the endpoint behind it both follow whatever that filter returns, so they can never disagree.

= Can I migrate from Pretty Links? =

Yes, from the Tools screen. Links, titles, disabled status, nofollow and sponsored flags, redirect types and click totals come across; per-click history does not. Pretty Links serves links at the site root and this plugin under its prefix, so the migrator can add a redirect from each old address. It is tested against Pretty Links' own table layout with a sample dataset, but not yet on a real, populated Pretty Links site, so back up first.

= Is the Pro AI agent going to publish changes without me reviewing them? =

No — every AI-proposed fix is written as a proposal you review and approve; nothing is applied automatically, and every applied change has a one-click revert.

= Where can I get help? =

Visit https://supportminer.404ops.com to open a support request.

== Credits ==

The admin screens use two typefaces bundled with the plugin and served from its own files, never from a remote host: Space Grotesk (Copyright 2020 The Space Grotesk Project Authors) and JetBrains Mono (Copyright 2020 The JetBrains Mono Project Authors), both licensed under the SIL Open Font License, Version 1.1 (https://openfontlicense.org). Each licence text ships beside its font in `vendor-prefixed/404ops/ui-kit/assets/fonts/`. The shared admin interface kit (`404ops/ui-kit`) and the AI client (`404ops/ai-client`, shipped under a plugin-specific namespace in `vendor-prefixed/`) are 404ops' own libraries, licensed GPL-2.0-or-later like this plugin. The plugin bundles no other third-party code.

== Screenshots ==

1. The dashboard with short-link and click-analytics summaries.
2. The new-link form with a short slug, destination URL and redirect options.
3. The Reports screen with click activity and top links.

== Changelog ==

= 1.11.6 =
* Added a coordinated multisite removal tool that respects each site's existing Free removal preference.
* Added per-site remote country lookup opt-in and checks before queued GeoJS requests.
* Kept licence management available during Free-first upgrades while stopping new requests from the retired lookup worker.

= 1.11.5 =
* Harden AI connection form nonce handling through the shared client patch.

= 1.11.4 =
* Added: guarded read-only status interfaces for stored aggregate counts.
* Added: five bundled draft language catalogs with checked WordPress loading.
* Improved: development test-session and catalog packaging checks.

= 1.11.3 =
* Changed: admin page slugs renamed to ops404-short-link-manager-*.

= 1.11.2 =
* Changed: folder, main file and text domain renamed to match the plugin name (404ops-short-link-manager).

= 1.11.1 =
* Updated the licence client (0.3.5): Pro keeps working after a licence expires.

= 1.11.0 =
* New: off-peak scheduled scanning. The daily broken-link scan starts in a nightly window you choose (default 02:00 for four hours, site time), checks content in time-limited batches with a rest at least as long as each batch, and stops when the window closes or nothing is left. The Pro Link Health scan starts in the same window.
* New (Pro): redirect import from a CSV file, Redirection, Yoast SEO Premium or Rank Math, with a dry-run preview of what happens to every row before anything is written.
* Improved: the Pretty Links migrator reads Pretty Links' real table layout. Disabled links stay disabled, redirect types carry across or say what changed, slugs under your link prefix keep their address, and it can redirect old Pretty Links addresses to the new short links.

= 1.10.11 =
* Updated the bundled licence client to 0.3.4.

= 1.10.10 =
* Readme: the permalinks FAQ points at the Dashboard's Site health panel (the separate Link Health screen is part of the Pro add-on). No code change.

= 1.10.9 =
* Pro update packages now publish with maintenance information and one shared licence client version.

= 1.10.8 =
* Pro update packages now publish with maintenance information.

= 1.10.7 =
* Updated the licence client and refreshed wording.

= 1.10.6 =
* Admin menu labels and headings drop the 404ops prefix.

= 1.10.5 =
* Docs: readme trimmed to the wordpress.org length limits for the description and changelog. Older release notes are omitted from the readme for length. No code changes.

= 1.10.4 =
* Docs: pricing and site tiers live on the storefront; remove the readme Pro price and renewal-price copy.
* Docs: correct the bundled font-licence path and remove an empty duplicate changelog entry.
* Docs: scope local analytics claims to Free and disclose Pro AI suggestion data, configured GA4/Meta click forwarding and the default-enabled Pro country-lookup fallback.

= 1.10.3 =
* Changed: Bundled libraries updated; translatable strings now use this plugin's text domain.

= 1.10.2 =
* Changed: requires WordPress 7.0 or newer (it was 6.9); tested up to WordPress 7.1.

= 1.10.1 =
* Changed: the plugin now requires WordPress 6.9 or newer and is tested up to WordPress 7.1.

= 1.10.0 =
* Maintenance: the plugin now bundles its own prefixed copy of the 404ops UI kit, so its admin screens share one 404ops menu and stylesheet with the other 404ops plugins and each plugin can update its UI independently.
* Maintenance (Pro): uses licence client 0.3, and every Pro add-on now registers its own copy of the licence client so the newest one wins when several are active. Update all 404ops Pro add-ons together.
* Readme: credits the bundled fonts and shared libraries.

Older releases are listed in CHANGELOG.md.

== Upgrade Notice ==

= 1.11.4 =
Includes checked draft translations and administrative status reporting. Human linguistic review is separate.

= 1.11.0 =
Off-peak scheduled scanning, Pro redirect import with a dry run, and a sturdier Pretty Links migrator. Safe to update.

= 1.10.10 =
Readme-only update. No code change.

= 1.10.5 =
Readme-only release for wordpress.org. No code changes. Safe to update.

= 1.10.4 =
Readme corrections for pricing, font licences, changelog formatting and existing Pro outbound-data disclosures. Free and Pro versions remain aligned.

= 1.10.3 =
Bundled libraries updated. Safe to update.

= 1.10.2 =
Requires WordPress 7.0 or newer (it was 6.9). Safe to update.

= 1.10.1 =
Requires WordPress 6.9 or newer. Safe to update.

= 1.10.0 =
Maintenance release: bundles its own prefixed UI kit; Pro moves to licence client 0.3 (update all 404ops Pro add-ons together). Safe to update.

= 1.9.1 =
Maintenance release: AI features use a private copy of the AI client; re-enter your AI connection once. Safe to update.

= 1.9.0 =
Pro: AI link suggestions in the editor and on the 404 log (BYOK). Free tier unchanged. Safe to update.

= 1.8.0 =
Cloaked delivery (optional, per link or rule) and a rules REST API for automation. Existing links keep direct delivery.

= 1.7.2 =
Pro adds geo, device and time-based redirect targeting. Free-tier behaviour is unchanged.

= 1.7.1 =
Internal licensing maintenance; no visible change.


= 1.6.1 =
Stored AI provider keys are now sealed with authenticated encryption; update recommended.
= 1.6.0 =
Closes several DNS-rebinding and input-validation gaps in outbound link checks and nonce verification, plus a redirect/404-log and a links-table-upgrade fix; recommended for all sites, especially those running Pro.

= 1.1.0 =
Scheduled daily link scanning is now part of the free plugin instead of Pro. Pro sites are unaffected — same single daily scan, and it now survives a licence lapse. No existing feature was moved into Pro.

= 1.0.3 =
Pro now shows an early warning notice before licence-related features would lapse, and no longer keeps a revoked licence active forever on a site whose WP-Cron never runs. Pro users should update.

= 1.0.2 =
Fixes Pro licence activation and update checks against the real licence server. Pro users should update.

= 1.0.1 =
Fixes first-time Pro licence activation. Pro users on a licence that has never activated before should update.

= 1.0.0 =
First public release. Short links with redirects and expiry, privacy-respecting click analytics, categories and tags, CSV import/export, a Pretty Links migrator, and a broken-link scanner with redirect manager. Pro adds keyword auto-linking, link-health scans, and a BYOK AI broken-link fixer.
