Comprehensive reference and usage guide for the plugin shipped in this repository.
Version: 1.0.0 Docs updated: 19 February 2026
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.
wp-content/plugins/ or install via the provided zip.kitgenix_affiliate_link_manager_do_rewrite_flush with a ~2 minute TTL)./go/my-link by default).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:
go) and redirect type (307/302 temporary, or 301 permanent).Settings are stored as an array option named kitgenix_affiliate_link_manager_settings. The settings class is includes/core/class-settings.php.
Available values:
go). This controls rewrite rule: ^{prefix}/([^/]+)/?$.307 (temporary, recommended), 302 (temporary), or 301 (permanent). Default: 307.The settings are registered in includes/admin/class-admin-options.php. Sanitization and nonce-protected saving are implemented in Admin_Options::sanitize().
Rewrite rules and redirect handling lives in includes/core/class-redirector.php.
Key behavior:
kitgenix_affiliate_slug./{prefix}/{slug} to index.php?kitgenix_affiliate_slug={slug}. The prefix is sanitized using WP helpers.template_redirect, the plugin checks the query var and attempts to find a matching post of type kitgenix_aff_link. If found, it validates the destination URL, increments clicks, and redirects using wp_redirect with the configured status. If not valid, a 404 template is rendered.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.
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:
Affiliate_Link_Post_Type::upsert_link(array $data) — create or update a link. Validates title and destination URL; prevents slug collisions; handles DB insert errors (including utf8mb4 charset issues).Affiliate_Link_Post_Type::delete_link(int $post_id) — moves the post to Trash using wp_trash_post.Affiliate_Link_Post_Type::get_destination_url(int $post_id) — read destination meta.Affiliate_Link_Post_Type::get_rel_value(int $post_id) — read and sanitize rel meta (defaults to nofollow sponsored).Affiliate_Link_Post_Type::increment_clicks(int $post_id) — increments the clicks meta.Primary classes and summaries (files):
Settings::get_prefix() — returns sanitized prefix (default go).Settings::get_redirect_status() — returns 307, 302, or 301 (default 307).Affiliate_Link_Post_Type::upsert_link($data) — returns post ID or WP_Error.Redirector::init() — hooks rewrite/tag and template redirect flow.Key actions and filters the plugin uses:
admin_menu — kitgenix_ensure_admin_menu() and Settings_UI::register_menu() add menus.admin_enqueue_scripts — enqueue admin CSS/JS in UI pages (Settings_UI::enqueue_assets).init — register post type and rewrite rules (Affiliate_Link_Post_Type::register_post_type, Redirector::add_rewrite).query_vars filter — adds kitgenix_affiliate_slug (see Redirector::add_query_vars).template_redirect — perform redirect when short URL matched.plugins_loaded — loader init.update_option_kitgenix_affiliate_link_manager_settings is observed by Core\Loader::maybe_flush_rewrites to flush rewrite rules when prefix changes.All admin form actions use nonces and capability checks:
admin-post.php?action=kitgenix_affiliate_link_save (WordPress hook admin_post_kitgenix_affiliate_link_save) -> Settings_UI::handle_link_save(). Requires manage_options, nonce action kitgenix_affiliate_link_save, and nonce field kitgenix_affiliate_link_nonce.admin-post.php?action=kitgenix_affiliate_link_delete (WordPress hook admin_post_kitgenix_affiliate_link_delete) -> Settings_UI::handle_link_delete(). Nonce: kitgenix_affiliate_link_delete.kitgenix_affiliate_link_manager_settings_nonce (nonce action kitgenix_affiliate_link_manager_settings_save) and verified in Admin_Options::sanitize(). Settings API group: kitgenix_affiliate_link_manager_settings_group. Redirect status field id: kitgenix_affiliate_redirect_status.plugins_api() function to fetch publicly available plugin metadata from WordPress.org.kitgenix_hub_wporg_active_installs_v1 and kitgenix_hub_wporg_ratings_v1.Admin assets included in the plugin:
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.
Settings → Permalinks and click Save to flush rewrite rules, or deactivate/reactivate the plugin to force a flush.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.
The plugin validates URLs. Ensure the destination is a valid absolute URL (including scheme, e.g. https://) and not blocked by host filters.
Kitgenix Affiliate Link Manager is released under GPLv3 or later (see plugin header in kitgenix-affiliate-link-manager.php).
Files referenced by this document: