=== Perkadoo ===
Contributors: perkadoo
Tags: streak, gamification, learndash, engagement, retention
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 0.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Daily streaks and milestone rewards for LearnDash lessons and member comments. Give members a reason to come back.

== Description ==

Members come back to keep their streak alive. Perkadoo adds a daily streak and milestone rewards to your WordPress site, so every finished lesson or approved comment becomes visible progress your members don't want to lose.

**What counts**

* **LearnDash lessons.** Each completed lesson counts once per member and course. You can limit tracking to one course.
* **Member comments.** Approved comments from signed-in members count, whether they come from the normal comment form or the WordPress REST API. Pending, spam, pingback and anonymous comments never count.
* **Your own hook.** Developers can count any confirmed server action with `do_action( 'perkadoo_action_completed', $user_id, $completion_id );`. The older `streakfox_action_completed` name still works.

Actions only count after WordPress confirms them on the server, so a member can't earn progress by calling a URL from the browser.

**What your members see**

Signed-in members get a small streak widget: their current streak, this week's days, the next milestone and any reward they've unlocked, such as a coupon code or a link to a bonus resource. Rewards stay behind a short-lived signed identity, so only the member who earned them can see them.

**What you get**

* Connect with one code. Paste a code from your Perkadoo setup and the plugin configures its keys.
* A safe test run. New programs start in test mode with separate test identities. Choose Go live in Perkadoo when you're happy, and the plugin follows automatically.
* Dependable delivery. Completions are queued in your database and retried with the same event ID, so a slow network never double counts.
* Proof. Perkadoo can compare members who see the streak with a holdout group who don't, so you know whether it brings people back.

**Requirements**

A Perkadoo account and a connected program are required. LearnDash is only needed if you want to count lessons. One Perkadoo program connects per WordPress installation.

**Pricing**

Setting up and testing is free; test activity is never billed. Paid plans are priced by active streakers (members with a counted action that month) and start at $9 a month for 500. See current plans at https://perkadoo.com/#pricing.

== External services ==

This plugin connects to Perkadoo, a third-party service run by the plugin authors. It can't count streaks without it. Nothing is sent until an administrator connects a program in Settings > Perkadoo.

**app.perkadoo.com (connection and status)**

* When an administrator clicks Connect Perkadoo, the plugin sends the one-time connection code and this site's home URL (`home_url()`) so Perkadoo can issue the program's keys.
* To follow the program's test/live status, the plugin sends the project key, the action key and the program's webhook secret. This happens when an administrator opens Settings > Perkadoo, and during background delivery at most once every 15 minutes, only while events are waiting to be sent.

**api.perkadoo.com (event delivery and the member widget)**

* After a member completes a counted action, WP-Cron sends the project key, the action key, a pseudonymous member ID, a completion ID, a timestamp and a test flag, with the program's webhook secret. The member ID is a keyed hash of the WordPress user ID; the key never leaves your site. Member names and email addresses are not sent.
* The widget in a signed-in member's browser loads that member's streak and rewards using the project key, the pseudonymous member ID and a signed identity token that expires after 10 minutes.

**cdn.perkadoo.com (widget files)**

* For signed-in members only, the browser loads the widget script (https://cdn.perkadoo.com/widget.js) and the fonts and images it uses from the same host. As with any web request, the CDN sees the member's IP address and browser user agent.
* `widget.js` is the Perkadoo service's own client. It isn't bundled with the plugin because it's updated with the service.

**perkadoo.com (optional credit link)**

* The widget shows no credit by default. If you tick "Show a small Made with Perkadoo link" in the settings, the widget shows a link to https://perkadoo.com. Nothing is loaded from it unless a member clicks.

Perkadoo terms of service: https://app.perkadoo.com/terms
Perkadoo privacy policy: https://app.perkadoo.com/privacy

== Installation ==

1. In WordPress, go to Plugins > Add New Plugin, search for "Perkadoo", then install and activate it.
2. In Perkadoo, create a program and choose the WordPress connection. Copy the connection code. Codes work once and expire after 10 minutes.
3. In WordPress, open Settings > Perkadoo, paste the code, choose what counts, and click Connect Perkadoo.
4. Sign in as a test member and complete the action. Confirm the progress in Perkadoo, then choose Go live.

Course restrictions and manual connection settings live under Advanced settings.

== Frequently Asked Questions ==

= Do I need LearnDash? =

Only if you want lessons to count. Approved member comments and the developer hook work on any WordPress site.

= What member data is sent to Perkadoo? =

A pseudonymous member ID (a keyed hash of the WordPress user ID), the completion ID and timestamp, and whether it's a test. Names and email addresses are never sent by this plugin. See the External services section for every request.

= Does it work with page caching? =

Yes, if signed-in pages aren't cached publicly. The widget only loads for signed-in members and fetches its identity with a no-store request. Most caching plugins skip logged-in users by default. Don't share signed-in pages through a public page cache.

= My site is quiet. Will events still arrive? =

Completions are saved immediately and sent by WP-Cron, which runs when your site gets traffic. On quiet sites, set up a real server cron that calls `wp-cron.php` every minute or so. Nothing is lost while waiting; events are retried with the same ID.

= What's the difference between test and live? =

New programs start in test mode. Test members get separate identities and their actions are left out of reports and billing. When you choose Go live in Perkadoo, the plugin switches over. Reload Settings > Perkadoo to pick it up straight away.

= How much does it cost? =

Testing is free. Paid plans are priced by active streakers and start at $9 a month for 500. See https://perkadoo.com/#pricing.

= What happens when I delete the plugin? =

Deactivating stops delivery and keeps your settings. Deleting the plugin removes its settings, keys and event queue from your database.

== Screenshots ==

1. The streak widget on a member's page, with their streak, week and next reward.
2. Connect your program with a single code and choose what counts.
3. Delivery status shows what reached Perkadoo and lets you retry failures.

== Changelog ==

= 0.5.0 =
* Streakfox is now Perkadoo. The plugin, its settings page and the widget credit use the new name.
* Sites that ran the Streakfox plugin keep their connection, member IDs and the `streakfox_action_completed` hook.

= 0.4.0 =
* The widget credit link is now off unless you turn it on.
* Load the widget with the WordPress script loader, deferred in the footer.
* Check program status only while events are waiting (at most every 15 minutes) and when you open the settings.
* Deleting the plugin now removes its settings, keys and event queue.
* Keep program keys out of autoloaded options.
* Translation ready.

= 0.3.0 =
* Connect with one temporary code instead of copying four values.
* Follow program test/live status automatically.
* Keep advanced configuration out of the ordinary setup flow.

= 0.2.0 =
* Count approved comments from both native forms and the WordPress REST API.
* Restrict LearnDash tracking to an optional course ID.
* Schedule prompt background delivery after a new completion, with recurring recovery.

= 0.1.0 =
* Signed member identity, lesson/comment hooks, durable event delivery, and connection settings.

== Upgrade Notice ==

= 0.5.0 =
Streakfox is now Perkadoo. Your connection and member streaks carry over when you activate it.

= 0.4.0 =
The widget credit link is now off by default, background status checks are less frequent, and deleting the plugin cleans up after itself.
