=== Swapotamus ===
Tags: referrals, recommendations, widget, partnerships
Requires at least: 6.3
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your website to Swapotamus and add relevant partner recommendations without editing theme code.

== Description ==

Swapotamus helps website owners introduce visitors to relevant partner websites and receive referrals in return. A Swapotamus account and a registered website are required. Account access and service availability follow the current pilot terms at https://swapotamus.com/pilot.

* Connect from the Swapotamus dashboard without copying a script.
* Show recommendations in the footer, below articles (and the homepage footer), or wherever you add the Swapotamus block or [swapotamus] shortcode.
* Manage appearance, approvals, exclusions, and analytics in Swapotamus.
* Disable the widget without modifying your theme. Uninstalling removes plugin settings.

The plugin is off until an administrator explicitly allows the external service AND enables the widget. It does not make server-side requests to Swapotamus and does not store account passwords or API keys.

== Installation ==

1. Upload swapotamus.zip through Plugins → Add New Plugin → Upload Plugin, then activate it.
2. Open Settings → Swapotamus and choose Open Swapotamus to connect.
3. Sign in, select or add this website, and choose Connect WordPress in the WordPress plugin section.
4. Review the returned website ID and placement in WordPress. Check both consent and enablement options, then save.
5. Remove any old manually pasted Swapotamus snippet, clear your page cache, and open the public homepage.
6. Return to Swapotamus and choose Verify installation. Domain ownership and activation checks still apply.

If your WordPress admin uses a different hostname from the public site, copy the Website ID from the Swapotamus dashboard into Settings → Swapotamus instead. A WordPress admin installed in a subdirectory can use the connection flow from its plugin settings page. Verification checks the registered domain's HTTPS root homepage; a public site available only under a subdirectory must also place the widget on that root homepage.

For manual placement, add the Swapotamus block in the block editor or put [swapotamus] in a Shortcode block. Include a widget on the homepage for installation verification. A maximum of one widget is rendered per page. For custom placement, select manual mode so an automatic placement does not take precedence.

== External services ==

This plugin integrates with the Swapotamus service at https://swapotamus.com. When BOTH consent and enablement are saved and a widget is rendered on a public page, the visitor's browser downloads https://swapotamus.com/widget.js and requests /api/widget/{website-id}. The service receives the website ID and ordinary HTTP request information, including the visitor IP address and user agent and any referrer sent under the site's referrer policy. The widget sends referral-click events and sampled impression events to /api/events using short-lived service tokens. Recommendation links can include referral UTM parameters and the Swapotamus website ID.

The widget uses no cookies or browser storage. Destination logos may load from partner image hosts when logo display is enabled. The widget includes a Swapotamus attribution link. No recommendation requests or events are made from the editor placeholder. The admin connection buttons navigate to Swapotamus with the WordPress admin return URL and, when connected, the public website ID.

The externally hosted widget is part of the Swapotamus service; its readable source is available in the distributed source repository under widget/widget.ts and shared/widget-view.ts. The plugin's editor JavaScript is included unminified under assets/editor.js.

Service: https://swapotamus.com/
Terms: https://swapotamus.com/terms
Privacy: https://swapotamus.com/privacy
Support: https://swapotamus.com/support

== Frequently Asked Questions ==

= Why is nothing visible? =
Check both switches in Settings → Swapotamus, verify installation in your dashboard, and approve eligible partners. A correctly installed widget intentionally remains empty when no partners are available. A saved website ID alone does not confirm activation.

= How do I pause or disconnect? =
Uncheck Enable the widget and save to pause. Clear the Website ID and save to disconnect. Clear your WordPress/CDN page cache so previously cached pages stop including the script. Deactivation removes the plugin output; deletion also removes its settings. The website record in Swapotamus is retained and can be managed in the dashboard.

= Does this work on WordPress.com? =
Your WordPress.com plan must allow installing plugins. The plugin requires WordPress 6.3+ and PHP 7.4+.

= Does it edit my theme? =
No. It uses WordPress hooks, a dynamic editor block, or a shortcode. Themes must call wp_footer() to print the script. If your cache optimizer combines or delays scripts, exclude swapotamus.com/widget.js and preserve its data-site-id attribute. Remove older manually inserted Swapotamus snippets to avoid duplicates.

== Changelog ==

= 1.0.0 =
* Initial release: dashboard connection, placement controls, dynamic block, shortcode, and explicit service consent.
