=== AffKeeper ===
Contributors: affkeeper
Tags: affiliate links, link cloaking, url shortener, broken links, aliexpress
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Affiliate & redirect URL shortener on your own domain that never points to a dead product. Know when a product sells out or a link breaks.

== Description ==

The problem with affiliate links: the product behind them can sell out or get delisted — and you
keep sending readers (and paid traffic) to a page nobody can buy from. AffKeeper watches your links
so you find out before you lose the sale.

**Works instantly, no account needed:**

* A full **URL shortener** on **your own domain** (`yoursite.com/go/product`) — clean short
  links that redirect locally and instantly, with click counting. The `/go/` prefix is configurable.
* Insert links with a shortcode: `[affkeeper slug="abc123"]Buy now[/affkeeper]` (add `domain="…"` when the same slug exists on more than one of your domains)
* Affiliate links render with `rel="nofollow sponsored"` automatically (correct disclosure);
  plain redirects get `rel="nofollow"`.
* A **Links** screen in wp-admin: search, filter, edit in place.

**Connect a free AffKeeper account to add monitoring:**

* **Product availability** — know when an AliExpress product goes *out of stock*, *low stock* or
  gets *removed*. Your first affiliate link is monitored out of the box; connect your own (free)
  AliExpress API keys to monitor all of them on your private API quota.
* **Broken-link checks** — monitored redirect links are tested for 404/410, server errors and
  unreachable hosts.
* **Email alerts** the moment a monitored product becomes unbuyable — or a redirect breaks.
* **You choose what's monitored** — a per-link "Monitor in AffKeeper" toggle. Local links are
  unlimited and free; only monitored ones use a plan slot. Affiliate links default to on.
* **Real analytics in your panel** — click totals sync within seconds, plus referrer and device
  breakdowns per click (and countries, when your server provides a geo header).
* **Auto-fallback** for links hosted on AffKeeper domains — clicks go to a replacement product or
  category page while the original is unavailable, so the traffic still converts. (Links hosted on
  your own site always redirect from your site, so they alert instead of rerouting.)
* One dashboard for links across all your sites, with clicks and history per your plan.
* Your local links sync to the account automatically — the redirect stays on your domain, so
  nothing in your posts ever breaks.

A dashboard widget shows 30-day clicks and warns when links point to unavailable products; the
Links screen floats dead products to the top so the next action is obvious.

== External services ==

This plugin communicates only with the AffKeeper service at https://affkeeper.com over its
authenticated REST API, and only after you enter an API key. What is transmitted:

* Your API key (authentication) and this site's hostname.
* For links you sync: their destination URLs, titles, slugs and short-link URLs.
* Click statistics: absolute totals and per-day counts for synced links.
* Per click of a synced link: the referrer URL and browser user-agent; when your server provides a
  geo header (e.g. Cloudflare), the visitor's two-letter country code. The visitor's IP address
  itself is never transmitted.

Read back: your links, their click counts and availability status. No data is sent anywhere else,
and nothing at all is sent until you connect an account.

Terms: https://affkeeper.com/terms/ — Privacy: https://affkeeper.com/privacy/

== Installation ==

1. Upload the plugin to `/wp-content/plugins/affkeeper` and activate it, or install it from the
   Plugins screen.
2. Go to **AffKeeper → Settings**.
3. Enter your panel URL and an API key (create one in the panel under Settings → API keys).
4. Click **Save & connect**.

== Frequently Asked Questions ==

= Do I need an AffKeeper account? =
No. Short links, redirects and click counting work entirely on your own site, without any account.
A free account adds monitoring: stock/removal detection for affiliate products, broken-link checks
and email alerts.

= Does it slow down my site? =
No. Availability data is cached for a few minutes, so the front end doesn't call the API on every
page load.

= What marketplaces are supported? =
AliExpress today (checked through the official AliExpress API). Your first affiliate link is
monitored on the house quota; your own free AliExpress API keys unlock monitoring for every link.
More marketplaces can be added on the service side without updating the plugin.

= What happens to my links if I delete the plugin? =
Uninstalling removes the plugin's settings and your API key. The local link table is kept on
purpose — those slugs and destinations are your content; reinstalling picks them up again.

= Do my links stop working if I cancel or disconnect? =
No. The redirects live on your own WordPress site and keep working no matter what — monitoring is
an add-on, never a dependency.

== Screenshots ==

1. The Links screen in wp-admin — availability badges, click counts, filters and search.
2. Add or edit a link — a clean slug on your own domain, monitoring and affiliate toggles.
3. The AffKeeper dashboard — links that need a look, with the 30-day click trend.
4. Per-link analytics in the panel — clicks by device, top referrers and history.
5. Account-wide stats — countries, devices and referrers across all your links.
6. The panel's Links list with live availability for every link.

== Changelog ==

= 1.0.2 =
* The plugin now speaks 20 languages — Spanish, Portuguese (Brazil), German, French, Italian, Dutch, Polish, Russian, Ukrainian, Turkish, Indonesian, Vietnamese, Thai, Japanese, Korean, Chinese (Simplified), Arabic, Hindi, Czech and Romanian. Your wp-admin language is picked up automatically.

= 1.0.1 =
* Panel-hosted links are now editable right from the Links screen (destination, slug alias, affiliate flag) — the panel remains the place for variants, monitoring settings and full stats.
* Dashboard widget styles moved to wp_add_inline_style().

= 1.0.0 =
* Initial public release.
* Local short links on your own domain with click counting — works without an account.
* `[affkeeper]` shortcode with automatic rel="sponsored" / rel="nofollow".
* Links admin screen: search, filters, sorting, pagination, availability and liveness badges.
* Connect an AffKeeper account: per-link monitoring toggle, stock and broken-link alerts.
* Two-way sync with the panel (destinations, slugs, click stats within seconds).
* Click analytics: referrer and device reporting; country via server geo headers — visitor IPs
  are never transmitted.
* Dashboard widget with 30-day clicks and attention alerts.
