YOURLS Awin Affiliate Plugin
April 29, 2026 ยท View on GitHub
A YOURLS plugin that adds Awin affiliate parameters to redirects for configured merchant domains.
Features
- Adds Awin tracking redirects for matching merchant domains.
- Supports merchant-level
campaignandclickrefdefaults. - Supports URL query overrides for
campaign,clickref, andclickref2throughclickref6. - Keeps normal YOURLS redirects for non-matching URLs.
- Provides a YOURLS admin settings page.
Compatibility
- YOURLS: requires 1.7.3+, tested up to 1.10.3.
- PHP: requires 7.4+, tested up to 8.5.
- Existing option key and settings shape stay compatible:
awin_affiliate_settings. - Redirect hook handling supports YOURLS action argument arrays and direct URL strings.
Structure
plugin.php: YOURLS plugin header, direct-access guard, runtime include, instantiation.includes/class-awin-affiliate-plugin.php: plugin runtime, admin page, settings, redirect logic.tests/: lightweight PHPUnit coverage using the YOURLS plugin test-suite bootstrap.
Installation
- Copy the plugin directory into
user/plugins/in your YOURLS install. - Activate Awin Affiliate in YOURLS admin.
- Open Awin Affiliate Settings from the Plugins menu.
Testing
phpunit -c tests/phpunit.xml
php -l plugin.php
php -l includes/class-awin-affiliate-plugin.php
Local YOURLS Dev
Start a disposable YOURLS instance with this plugin mounted read-only:
./scripts/dev-yourls up
Defaults:
- URL:
http://localhost:8088/admin/ - Login:
admin/adminpass - YOURLS image:
yourls:latest - Database: private Docker Compose MariaDB volume
The script installs YOURLS if needed, activates this plugin, and seeds a few GitHub shortlinks for testing.
Useful commands:
./scripts/dev-yourls logs
./scripts/dev-yourls down
./scripts/dev-yourls reset
License
MIT. See LICENSE.
Releases
GitHub Actions includes release automation in .github/workflows/release.yml.
- Stable release: run the Release workflow manually and choose
minorormajor. You can provide release notes in the workflow input, or leave it blank for GitHub generated notes. The workflow bumpsplugin.phpversion, commits it tomain, tagsvX.Y.0, builds an install zip, and creates a GitHub Release. - Alpha release: every non-bot push to
maincreates a prerelease taggedalpha-<run>-<attempt>-<sha>with an install zip and generated notes.
Release zips exclude development-only files such as .github/, dev/, scripts/, tests/, and test-suite/.