=== Dadan ===
Contributors: dadanwp
Tags: video, embed, screen recorder, video recording, oembed
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.1.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Embed Dadan videos and add a Dadan record button with blocks, shortcodes or Elementor widgets. Requires a Dadan account.

== Description ==

**Dadan** connects WordPress to [Dadan](https://www.dadan.io/) (third-party video hosting and recording).

= Editors =

* Gutenberg **Dadan Video** and **Dadan Record** blocks
* Shortcodes `[dadan]` and `[dadan-recording]`
* **Elementor** widgets when Elementor 3.20+ is installed (optional — not required)
* **Instances** under Dadan → Instances (Record button, Theme, access gate, Advanced)

= Setup =

1. Activate this plugin.
2. Create a **public App ID** (`app_…`) in the [Dadan dashboard](https://app.dadan.io/) and **allowlist** your site Origin.
3. Configure **Dadan → Instances**. Never paste a secret API key.
4. Embed a share URL or add a Record block / widget / shortcode.

= Security notes =

* Only public App IDs (`app_…`) are accepted.
* Optional front-end gate: anyone / logged-in / editors (withholds the recorder from blocked visitors).
* Administrators control App ID; non-admins fall back to Instances.
* The Record studio JavaScript is loaded from Dadan’s servers (not bundled in this plugin for WordPress.org).

= Share URLs =

Preferred: `https://app.dadan.io/video/share/{code}`

Direct `/video/{hexId}` links are not embeddable; use a share URL.

== Installation ==

1. Upload `dadan.zip` via **Plugins → Add New → Upload Plugin**, or copy the `dadan` folder to `/wp-content/plugins/`.
2. Activate **Dadan**.
3. (Optional) Install Elementor 3.20+ for page-builder widgets.
4. Configure a public App ID and Origin allowlist as described above.

The Record studio is lazy-loaded from a versioned CDN URL such as `https://app.dadan.io/sdk/record-2.1.2.js` (see External services). The WordPress glue code ships unminified in `src/recorder-app.js`.

== Frequently Asked Questions ==

= Do I need Elementor? =

No. Blocks and shortcodes work without it. Elementor adds matching widgets when active.

= Do I need the old Dadan Video Embed or Dadan for Elementor plugins? =

No. This unified plugin replaces both. Deactivate and delete the old ones first.

= Why doesn’t recording start? =

Confirm a valid public App ID (`app_…`), allowlist the exact site Origin in Dadan, use HTTPS, and ensure the browser can reach Dadan’s CDN studio (`app.dadan.io/sdk/record-*.js`). Check the browser console for origin/permission/SRI errors.

= What data is sent to Dadan? =

When visitors record or watch embeds, the browser talks to Dadan’s servers for the player, studio script, APIs, and uploads. WordPress stores only your public App ID and display settings — not secret API keys.

= Is Dadan a third-party service? =

Yes. See [dadan.io](https://www.dadan.io/) for product terms and privacy policy.

== Changelog ==

= 2.1.3 =
* Redesigned instance settings: status header, Save and copy-shortcode buttons, regrouped tabs, cards with hints, switches, segmented controls and a live button preview. Saving returns to the same tab.
* Dadan admin page: setup checklist for new sites; record button and "add to your site" guide once connected. Fixes the page never loading the recorder.
* Instances list: Ready / Needs App ID status and copy buttons.
* Elementor widget: Content / Style split, icon choices, headings, hints and a connection status notice. Control IDs unchanged.
* Dadan Record block: instance picker for everyone (App ID is an admin override), correct connected state, regrouped panels.
* Clear message when Dadan rejects the App ID or site origin.

= 2.1.2 =
* Harden public localize (no unused Default credentials); Elementor no longer double-localizes.
* Embed height ignores WP portrait default; busy-take guard uses SDK `state`.
* Plugin Check: `wp_json_file_decode`, kses on CTA/iframe output, exclude `package.json` from zip.
* Perf/a11y: tighter SDK host scan, `aria-busy` on open, focus-visible CSS, URL regex caps.

= 2.1.1 =
* Pin Record studio to immutable versioned CDN URLs with SRI (CDN-2).
* Ship GPL WordPress glue locally; load only the generic studio API from the CDN as window.DadanRecord (CDN-3).
* Lazy-load the studio script/CSS (and React on public pages) on first Record click (CDN-6); React via WordPress core (W11).
* Exclude proprietary recorder-sdk build from WP.org packaging (CDN-4).
* Script translations for block/editor JS (W2); .distignore-driven zip + .gitattributes (W7).
* Readme metadata: five tags, short description ≤150 chars; Plugin URI points at integrations (W10).
* Requires at least WordPress 6.6 (react-jsx-runtime for the CDN studio — NEW-5).
* Privacy/perf: strip admin URLs from public localize; single enqueue; unique CTA ids; bare share codes; embed max-width.
* JS: refuse mid-recording reopen; no editor navigation on missing App ID; video-block record panel no longer pretends to insert.

= 2.1.0 =
* Option B / W1: Record studio loads from Dadan CDN with SRI (proprietary SDK not required in the WP.org zip).
* External services section updated (player, SDK APIs, uploads, IndexedDB).
* Security/compliance follow-ups from audit (access gate, Elementor strip, link[] hardening, uninstall multisite, restore-pending default off).
* Requires at least WordPress 6.3; Elementor widgets require Elementor 3.20+.

= 2.0.4 =
* Security: strip privileged Record block attrs after kses; ignore untrusted App ID / access at render (block + Elementor).
* Security: harden embed `link` parsing against array query params (PHP 8).
* Fix: system-audio migration runs once in admin only and preserves explicit settings.
* Uninstall removes the system-audio migration option.

= 2.0.3 =
* Theme colors: normalize Elementor alpha/rgba so Primary and CTA colors apply on the front end.
* Package slug `dadan` / `dadan.zip`.
* Maintainer docs: security checklist + WordPress.org submission guide.

= 2.0.0 =
* Unified plugin: Gutenberg + shortcodes + optional Elementor widgets.
* Shared Instances and Record SDK bundle.
* Security: public App ID allowlist, record access gate, privileged attr strip, local iframes, privacy suggestion.

== Upgrade Notice ==

= 2.1.3 =
Polished settings, Elementor and block editor UI; fixes the Dadan admin page record button. No settings migration needed.

= 2.1.2 =
Low/Info hardening: embed height, busy-take guard, public localize, Elementor enqueue, Plugin Check cleanups. CDN studio remains record-2.1.1.* (no reupload).

= 2.1.1 =
Requires WordPress 6.6+. Record studio URL is pinned to a versioned CDN file. Upload record-2.1.1.js/.css to app.dadan.io/sdk/ before upgrading CDN-mode sites.

= 2.1.0 =
WordPress.org / CDN mode loads the Record studio from app.dadan.io. Ensure that host is reachable, or use a private zip that still includes the local bundle.

= 2.0.3 =
Delete older Dadan / dadan-u2 / dadan-elementor folders before uploading to avoid “destination folder already exists”.

== External services ==

This plugin connects to Dadan (https://www.dadan.io/), a third-party video hosting and recording service operated by Link Solutions Ltd. Embedding and recording do not work without it. The plugin itself makes no server-side requests to Dadan: every connection below is made by the visitor's (or editor's) browser.

1. Dadan video player (embeds)
* What: an iframe loaded from https://app.dadan.io/video/embed.html
* When: each time a page containing a Dadan Video block, [dadan] shortcode, Dadan URL embed or Dadan Video Elementor widget is viewed.
* Data sent: the video share code and standard browser request data (IP address, user agent, page origin as referrer).

2. Dadan Record studio script (Option B)
* What: versioned files such as https://app.dadan.io/sdk/record-2.1.2.js and .css (integrity pinned via SRI in the plugin). WordPress glue stays in the plugin.
* When: after someone clicks a Dadan Record button (lazy-loaded). Admin/editor screens that open the recorder may load earlier when a local SDK is present.
* Data sent: standard browser request data for the script/style download.

3. Dadan Record SDK API (recording)
* What: https://app.dadan.io/api/sdk/session, https://app.dadan.io/api/Transcoder/records and https://app.dadan.io/api/video/download/…
* When: only after someone clicks a Dadan Record button and starts a recording.
* Data sent: the site's public App ID (app_…), the site origin, optional Folder ID / Team ID and video title configured by the site admin, plus IP address and user agent.

4. Dadan upload service (recorded media)
* What: https://upload-direct.dadan.io
* When: when a recording is finished and uploaded.
* Data sent: the recorded video and audio, which may include the visitor's camera image, microphone audio and/or screen contents, and an upload token issued by Dadan.

While recording, if “restore pending take” is enabled, the browser may temporarily keep an unfinished recording in IndexedDB (up to 24 hours) and upload-resume keys in localStorage. WordPress stores only the public App ID and display settings.

Dadan Terms of Service: https://www.dadan.io/terms-of-service
Dadan Privacy Policy: https://www.dadan.io/privacy-policy

== Privacy ==

This plugin does not implement its own analytics. When you configure recording or embeds, visitors interact with Dadan’s service under Dadan’s privacy policy. Site admins should mention Dadan embeds/recording in their site privacy policy if required by local law. The plugin also suggests privacy policy text under **Settings → Privacy**.
