Contents

Overview

This plugin provides a lightweight admin UI to manage short affiliate redirect links and track simple click counts. It exposes a short URL path (default /go/{slug}) and redirects visitors to destination URLs while incrementing an internal click counter.

Primary entry and metadata are in kitgenix-affiliate-link-manager.php.

Requirements

Installation

  1. Copy the plugin folder into wp-content/plugins/ or install via the provided zip.
  2. Activate the plugin from the Plugins screen. On activation the plugin checks PHP/WordPress versions and flushes rewrite rules.
  3. After activation you'll be redirected once to the plugin settings page. As a fallback for hosts that don't reliably persist activation-time rewrite flushes, the plugin also schedules a one-time rewrite flush on the next request (via transient kitgenix_affiliate_link_manager_do_rewrite_flush with a ~2 minute TTL).

Quick start

  1. Open the Kitgenix top-level admin menu → Affiliate Links.
  2. Add a new link using the form: provide Name and Destination URL. Optionally set a custom slug (leave blank to auto-generate).
  3. Visit the generated short URL shown in the list (example: /go/my-link by default).

Admin UI

The admin UI is implemented in includes/admin/class-settings-ui.php. It registers a submenu under a shared Kitgenix top-level menu (helper in root plugin file).

Main features:

Settings

Settings are stored as an array option named kitgenix_affiliate_link_manager_settings. The settings class is includes/core/class-settings.php.

Available values:

The settings are registered in includes/admin/class-admin-options.php. Sanitization and nonce-protected saving are implemented in Admin_Options::sanitize().

Short URLs & Redirects

Rewrite rules and redirect handling lives in includes/core/class-redirector.php.

Key behavior:

Search engine compliance: when placing the short URL into your content, tag the link as sponsored/nofollow (for example: rel="nofollow sponsored") for affiliate disclosures. The admin UI also lets you store a per-link rel value (nofollow / sponsored / both) for convenience.

Short URL builder helper: Settings::build_short_url($slug) returns the full home URL for the configured prefix.

Data storage (post type & meta)

Affiliate links are stored as a custom post type declared in includes/core/class-affiliate-link-post-type.php.

Important constants:

Name Value / Description
Affiliate_Link_Post_Type::POST_TYPE kitgenix_aff_link — custom post type used to store links (<=20 chars).
Affiliate_Link_Post_Type::META_DESTINATION _kitgenix_affiliate_destination_url — destination URL meta key.
Affiliate_Link_Post_Type::META_CLICKS _kitgenix_affiliate_clicks — integer click counter meta key.
Affiliate_Link_Post_Type::META_REL _kitgenix_affiliate_rel — stored rel value for the short link (allowed: nofollow, sponsored, nofollow sponsored).

CRUD helpers:

Programming API & Classes

Primary classes and summaries (files):

Notable public methods

WordPress hooks used

Key actions and filters the plugin uses:

Security & Nonces

All admin form actions use nonces and capability checks:

Privacy & external services

Assets

Admin assets included in the plugin:

Uninstall behavior

Uninstall logic is in uninstall.php. When uninstalled via WP, the plugin removes only its option and transient keys but deliberately does not delete affiliate link posts or click data. Files removed:

Note: the rewrite-flush helper transient has a ~2 minute TTL and is intended to expire automatically, but uninstall will remove it if present.

Troubleshooting

Short URLs return 404

Can't save link / database insert errors

If you see DB insert errors referencing Incorrect string value, your MySQL/MariaDB may not support utf8mb4. The plugin catches this and returns a helpful WP_Error; to resolve, either remove emoji from names or convert the DB to utf8mb4.

Destination URL rejected

The plugin validates URLs. Ensure the destination is a valid absolute URL (including scheme, e.g. https://) and not blocked by host filters.

License & Credits

Kitgenix Affiliate Link Manager is released under GPLv3 or later (see plugin header in kitgenix-affiliate-link-manager.php).


Files referenced by this document: