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 campaign and clickref defaults.
  • Supports URL query overrides for campaign, clickref, and clickref2 through clickref6.
  • 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

  1. Copy the plugin directory into user/plugins/ in your YOURLS install.
  2. Activate Awin Affiliate in YOURLS admin.
  3. 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 minor or major. You can provide release notes in the workflow input, or leave it blank for GitHub generated notes. The workflow bumps plugin.php version, commits it to main, tags vX.Y.0, builds an install zip, and creates a GitHub Release.
  • Alpha release: every non-bot push to main creates a prerelease tagged alpha-<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/.