=== Vendor Tasks for Dokan & ClickUp – Marketplace Automation ===
Contributors: mralaminahamed
Donate link: https://alaminahamed.com/donate
Tags: dokan, clickup, vendor, marketplace, task-automation
Requires at least: 6.6
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Turn Dokan vendor events into ClickUp tasks automatically — registrations, approvals, milestones, withdrawals, and more.

== Description ==

**Vendor Tasks for Dokan & ClickUp** connects your Dokan marketplace to ClickUp so your team never misses a vendor. The moment a vendor registers, gets approved, hits their first sale, or requests a withdrawal, a task appears in your ClickUp list — already filled in with everything you need to act. No copy-paste, no switching tabs, no missed follow-ups.

Run your vendor onboarding, vetting, and support workflow where your team already works.

= Why You'll Want It =

* **Never miss a new vendor.** A ClickUp task is created the instant someone registers, complete with their name, email, shop, phone, company, and a one-click link to their admin profile.
* **Track the whole vendor journey.** Approvals, disables, profile updates, product reviews, first-product and first-sale milestones, and withdrawal requests each fire their own task.
* **Two-way sync.** Change a task's status in ClickUp and the plugin can enable or disable that vendor back in WordPress — no admin login required.
* **Tell your team instantly.** Optional Slack notifications fire on task creation or failure.
* **Route the right vendor to the right list.** Send vendors to different ClickUp lists based on role or custom rules (Pro).

= A Settings Page You'll Actually Enjoy =

A fast, modern dashboard lives under **Dokan → ClickUp Integration**:

* **Overview** — connection health, live counters for tasks created, vendors synced, failed syncs, and active triggers, plus a recent-activity feed and setup checklist.
* **Connection** — paste your token, pick a workspace and list, and test the connection in one click. Your token is never shown in the browser.
* **Task Templates** — set the task name, priority, description style, and due-date offset independently for each of 13 lifecycle events.
* **Triggers** — flip each automation on or off.
* **Webhook** — receive ClickUp status changes with signed (HMAC) verification.
* **Routing** — conditional list routing rules (Pro).
* **Notifications** — Slack webhook and per-event toggles.
* **Plans** — compare Free vs Pro and activate a license.

Keyboard-friendly too: press `Ctrl/Cmd+K` to jump between tabs, and switch light/dark mode, accent colour, and density from the Tweaks panel.

= Built to Stay Out of Your Way =

* Vendor registration never blocks — if ClickUp is unreachable, the task is queued and retried automatically.
* Duplicate-proof: each vendor gets one task per event.
* Caches ClickUp lookups to respect API rate limits.
* HPOS and Cart/Checkout Blocks compatible.
* Translation-ready.

= Compatibility =

* WordPress 6.6+
* WooCommerce 3.0+ (tested up to 9.5)
* Dokan Lite or Pro 3.0+ (tested up to 3.15)
* PHP 7.4 – 8.3
* A ClickUp account with a personal API token

== Installation ==

= Requirements =

* WordPress 6.6 or greater
* WooCommerce 3.0+ active
* Dokan Lite or Dokan Pro 3.0+ active
* PHP 7.4 or greater
* A ClickUp account with API access

= From WordPress Admin =

1. Go to **Plugins → Add New**.
2. Search for "Vendor Tasks for Dokan ClickUp".
3. Click **Install Now**, then **Activate**.

= Manual Upload =

1. Download the plugin zip.
2. Go to **Plugins → Add New → Upload Plugin**.
3. Choose the zip, click **Install Now**, then **Activate**.

= Setup =

1. In ClickUp, open your avatar menu → **Settings → Apps** and generate a personal API token.
2. In WordPress, go to **Dokan → ClickUp Integration → Connection**.
3. Paste the token — the workspace dropdown loads automatically.
4. Pick a Workspace, then pick a List.
5. Set the default task priority and name template.
6. Click **Save**, then **Test Connection**.
7. Register a test vendor and confirm the task appears in ClickUp.

== Frequently Asked Questions ==

= Does this require Dokan Pro? =

No. Dokan Lite (free) is fully supported. Dokan Pro unlocks additional trigger events.

= How do I get a ClickUp API token? =

Log in to ClickUp → click your avatar → **Settings → Apps → Generate**. Paste the token into the plugin's Connection tab. The token is stored in `wp_options` on your own server and is never sent to the browser.

= What vendor data is sent to ClickUp? =

Name, email, shop name, phone, company (if set), registration date, WordPress user ID, and a direct link to the vendor admin profile. No passwords or payment data.

= Can I customise the task name? =

Yes. Use `{vendor_name}`, `{vendor_email}`, and `{shop_name}` in the task name template on the Task Templates tab. Each lifecycle event has its own independent template.

= Will I get duplicate tasks? =

No. A user meta flag (`_vendor_tasks_dokan_clickup_task_created`) blocks duplicates per vendor per event. Delete the meta key if you need to recreate a task.

= What happens if the ClickUp API is down? =

Vendor registration never blocks. The failure is logged, queued for automatic retry, and optionally sends a Slack notification. On persistent failure, the `vendor_tasks_dokan_clickup_task_failed` action fires so you can hook in custom logic.

= How do I debug issues? =

Enable logging in the settings page, then open **WooCommerce → Status → Logs** and select the `vendor-tasks-dokan-clickup-*` file.

= Is HPOS supported? =

Yes. The plugin declares compatibility with WooCommerce High-Performance Order Storage and Cart/Checkout Blocks.

= What are ClickUp's rate limits? =

100 requests per minute per token. Workspace and list lookups are cached for one hour; the overview stats endpoint caches for five minutes.

= Is the plugin translation-ready? =

Yes. Text domain: `alamin-vendor-tasks-dokan-clickup`. Drop MO files into `/languages/` or load via a translation plugin.

= Why do I see `dokan_` hooks and functions in the code? =

Those belong to the **Dokan plugin** (by WeDevs), not to this plugin. Hooks like `dokan_new_seller_created`, `dokan_vendor_enabled`, and `dokan_vendor_disabled` are provided by Dokan. This plugin subscribes to them with `add_action()` to react to vendor events. It does not define these hooks.

== Screenshots ==

1. Overview tab — connection health badge, four live stat cards (tasks created, vendors synced, failed syncs, active triggers), recent activity feed, and setup checklist.
2. Connection tab — masked API token field, dynamic workspace and list dropdowns, green "Connected" badge after a successful test.
3. Task Templates tab — 13 lifecycle events in collapsible rows; an expanded event showing task name template, priority selector, description type, and due-date offset.
4. Triggers tab — individual on/off automation switches for vendor status changes, product milestones, and withdrawals; Pro-only events clearly badged.
5. Plans tab — Free vs Pro feature comparison matrix, plan cards, and the license activation field.
6. Command palette — `Ctrl/Cmd+K` opens a keyboard-driven tab search overlay with arrow-key navigation and instant jump.
7. Tweaks panel — slide-in theme customiser with light/dark toggle, five accent swatches, and comfortable/compact density selector.

== Changelog ==

= 1.1.0 - 2026-06-14 =

* Added: `dokan_new_vendor` hook catches vendors created via the Dokan admin panel.
* Added: `dokan_rest_stores_create_store` hook catches vendors created via the Dokan REST API.
* Added: Shop URL, social profiles, trust status, and T&C accepted fields in task descriptions and name placeholders.
* Added: `StatusTriggers` (vendor approved/disabled) and `EmailNotifier` (failure emails) promoted to the free tier.
* Added: `TriggerAction::add_comment()` — shared helper used by all trigger modules to add ClickUp comments.
* Fixed: PHPStan Level 8 — replaced nullable-coalesce guards (`??`) with falsy-coalesce (`?:`) for Dokan Vendor getter methods.
* Fixed: Stale autoload map that caused a fatal error on activation after adding new classes.
* Chore: CI — upgraded all GitHub Actions to Node 24-native versions; added `WP_ROOT_PATH` env var for PHPUnit.

= 1.0.0 - 2025-10-03 =

Initial release.

* ClickUp API v2 client with workspace/list traversal and 1-hour object cache.
* Vendor registration detection via `dokan_new_seller_created`, `user_register`, and `woocommerce_created_customer`.
* Lifecycle event triggers: vendor approval, disable, profile sync, product review, milestones, withdrawals.
* React 18 admin dashboard with light/dark/accent/density theming.
* Overview tab with live stats and an activity log.
* Plans tab with Free/Pro feature matrix and license activation.
* Command palette (`Ctrl/Cmd+K`) and slide-in Tweaks panel.
* Per-event Task Templates tab — 13 configurable lifecycle events.
* Conditional list routing rules (Pro).
* Incoming ClickUp webhook with HMAC secret verification.
* Slack notifications on task creation or failure.
* Automatic retry queue for transient ClickUp API failures.
* HPOS and Cart/Checkout Blocks compatibility declared.

== Upgrade Notice ==

= 1.1.0 =
Adds shop URL, social profiles, trust status, and T&C fields to tasks. Vendor approval/disable triggers now included in the free tier. Recommended upgrade.

= 1.0.0 =
Initial release.

== Third-Party Plugins ==

This plugin integrates with the Dokan multi-vendor marketplace and requires it to function. No data is transmitted to third-party plugin developers by this plugin.

= Dokan (required) =

Provides the vendor marketplace and the lifecycle hooks this plugin reacts to (`dokan_new_seller_created`, `dokan_vendor_enabled`, `dokan_vendor_disabled`, and others). Dokan Lite (free) or Dokan Pro 3.0+ must be installed and active.

* Plugin: [Dokan by WeDevs](https://wordpress.org/plugins/dokan-lite/)
* Developer: [WeDevs](https://wedevs.com/)

= WooCommerce (required) =

Required by Dokan. Provides the order/customer data layer and the logging channel used for API traces.

* Plugin: [WooCommerce](https://wordpress.org/plugins/woocommerce/)

== External Services ==

This plugin sends data to external services only when configured to do so.

= ClickUp =

Vendor data is sent to the ClickUp API to create or update tasks. Data includes vendor name, email, shop name, phone, company, registration date, user ID, and an admin-only URL. No data is sent if no API token is configured.

* Service: [ClickUp](https://clickup.com/)
* API: `https://api.clickup.com/api/v2/`
* Terms: https://clickup.com/terms
* Privacy: https://clickup.com/privacy

= Slack (optional) =

If Slack integration is enabled, a notification is posted to your Slack workspace on task creation or failure. No data is sent unless the integration is enabled and a webhook URL is configured.

* Service: [Slack](https://slack.com/)
* Terms: https://slack.com/terms-of-service
* Privacy: https://slack.com/privacy-policy

== Privacy ==

The plugin transmits vendor data to ClickUp only when a lifecycle event fires. It sends vendor name, email, shop name, phone, company, registration date, user ID, and an admin-only profile link. No passwords, no payment data, no analytics. All settings are stored in the WordPress options table on your own server.
