=== Laleo Chat ===
Contributors: laleo
Tags: chat, live chat, voice, video, customer support
Requires at least: 5.8
Tested up to: 6.5
Requires PHP: 7.4
Stable tag: 1.1.7
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Adds Laleo live chat, live visitors, browser voice/video calls, and cloud widget setup to WordPress.

== Description ==

Laleo Chat lets a WordPress administrator create or connect a free Laleo account directly from wp-admin using email OTP. After verification, the plugin lists widgets on the connected account, recommends any widget that matches the WordPress domain, lets the admin create a new widget when needed, saves the selected widget UUID, loads the hosted widget on public pages, and exposes WordPress-scoped Live Visitors and Analytics screens.

When configured, the plugin outputs:

`window.LaleoChat.visitor = {"loggedIn":true,"source":"wordpress",...};`

`<script async src="https://laleo.chat/widget.js" data-laleo-widget="UUID"></script>`

The visitor context script is printed before the hosted widget script. For logged-in WordPress users, the plugin passes the user ID, email, display name, username, roles, and a `plan` value based on the primary role. Developers can customize the object with the `laleo_chat_visitor_context` filter. The widget is not loaded in wp-admin by default. Settings are included for sites that need to control admin-page loading behavior or exclude local WordPress paths.

WordPress admins also get:

* Email OTP signup/login from wp-admin.
* Existing widget selection with domain recommendation, plus new widget creation when needed.
* A Live Visitors screen that lists online visitors and waiting calls for this WordPress site, then opens visitor context, chat history, replies, callback forms, voice notes, internal notes, Direct User routing, contact tagging, activity, and calls natively in wp-admin.
* Secure top-level handoff links that open the full Laleo conversation and call console for a selected visitor when voice/video control or answering an active call is needed.
* A WordPress Analytics screen with visitors, pages, campaign tags, messages, calls, and plan/PSTN minute usage for the selected widget.
* Basic cloud widget settings for chat, voice, video, launcher text, avatar, ringtone, hold music, unavailable prompt, and PSTN accept prompt.
* ZIP-install update checks against Laleo so manually installed plugin copies can receive updates from the WordPress Updates screen.

== Installation ==

1. Upload the `laleo-chat` folder to `/wp-content/plugins/`, or install the `laleo-chat.zip` package from Plugins > Add New > Upload Plugin.
2. Activate `Laleo Chat` from the WordPress Plugins screen.
3. Go to Laleo Chat > Setup.
4. Enter your email address, click Send OTP, then enter the verification code.
5. If your Laleo account already has widgets, select the recommended matching widget or create a new one for this WordPress site.
6. Visit a public page on your site and verify the widget loads.

== Settings ==

Setup: Create or connect a free Laleo account with email OTP. The plugin stores a revocable WordPress plugin token in `wp_options` and uses it to manage this site's cloud widget.

Live Visitors: Shows online visitors and waiting calls for this WordPress site. Opening a visitor loads the conversation, messages, callback forms, voice notes, internal notes, Direct User controls, contact tagging, activity, visitor device/IP information, and calls inside wp-admin using the stored plugin token. A full console link opens Laleo in a top-level tab for browser voice/video controls and call answering so third-party cookie blocking does not loop the admin through login.

Analytics: Shows WordPress-scoped visitor, page, campaign, message, call, and usage reporting for the connected widget.

Widget Settings: Update cloud-controlled widget basics and upload avatar/recording assets from wp-admin.

Widget UUID: The canonical Laleo widget UUID, such as `123e4567-e89b-12d3-a456-426614174000`. This is filled after the recommended widget is preselected or after the admin chooses/creates a widget, then shown on Laleo Chat > Setup.

Admin pages: By default, the widget is disabled in wp-admin. Leave this checked unless you intentionally need the widget in wp-admin.

Logged-in visitor context: Enabled by default. Sends logged-in WordPress user context to Laleo before the widget loads so the Laleo dashboard can show useful customer metadata. Turn it off if the site should not send WordPress account details to Laleo.

Excluded paths: Optional WordPress-local path rules, one per line. Examples: `/account`, `/checkout/*`, `/private`. These rules prevent WordPress from enqueueing the Laleo script on matching pages. For non-WordPress sites or broader cross-platform exclusions, use the Excluded URLs and Excluded page zones in the Laleo widget settings.

== Support ==

For help with your widget UUID or Laleo account, contact Laleo support through your normal Laleo support channel.

For WordPress installation issues, verify that:

* The plugin is active.
* A connected widget UUID is shown on Laleo Chat > Setup.
* Your theme calls `wp_head()` or `wp_footer()` so WordPress can print enqueued scripts.
* The current URL is not blocked by a saved excluded path.
* Security plugins or content security policy rules are not blocking `https://laleo.chat/widget.js`.

== Changelog ==

= 1.1.7 =
* Moves WordPress Live Visitors support calls onto documented `/api/v1` Laleo endpoints.
* Keeps native wp-admin chat, notes, contact tagging, visitor info, Direct User, callbacks, call history, and analytics aligned with the public API.
* Clarifies that browser voice/video answering opens the full Laleo console through a secure top-level action link.

= 1.1.6 =
* Adds Contact and Visitor info tabs to the WordPress Live Visitors conversation panel.
* Lets a WordPress operator attach a live visitor to an existing Laleo contact or create a lead from the visitor session.
* Shows saved browser/session metadata, IP intelligence, viewport, screen, attribution, and site-passed identity context inside wp-admin.

= 1.1.5 =
* Makes the WordPress Live Visitors screen continuously heartbeat while open instead of relying on a manual refresh button.
* Keeps the selected visitor conversation live by refreshing chat, activity, notes, voice messages, and calls without wiping the reply box.
* Adds WordPress-side tabs for Voice messages, Notes, Activity, Direct user, and Calls.
* Adds internal note saving and Direct User page push from wp-admin.
* Adds a Call visitor action that opens the full Laleo call console in a top-level tab and starts the browser call flow there.

= 1.1.4 =
* Replaced the embedded Laleo iframe handoff with a native wp-admin visitor conversation panel backed by the saved plugin token.
* Added in-WordPress chat history, reply, visitor profile, activity, and call history for the selected visitor.
* Added a WordPress Analytics screen with widget activity, top pages, campaign tags, recent messages, recent visitors, and account usage.
* Fixed the domain recommendation badge contrast.
* Opens the full Laleo call console as a top-level tab to avoid browser third-party cookie login loops inside wp-admin.

= 1.1.3 =
* Fixed the WordPress option sanitizer so OTP saves keep the new plugin token instead of preserving the old blank token while saving only the widget UUID.

= 1.1.2 =
* Stores new WordPress plugin tokens with a portable base64 wrapper so hosts with rotating or unusual WordPress salts do not lose the cloud connection after OTP.
* Preselects the recommended domain-matched widget after OTP while still showing the chooser so the admin can switch widgets or create a new one.

= 1.1.1 =
* Removed the duplicate WordPress Settings menu entry so Laleo lives under one top-level admin menu.
* Split email OTP account connection from widget selection so existing Laleo accounts can choose a widget after sign-in.
* Added an existing-widget chooser that recommends widgets matching the WordPress site domain.
* Added a create-new-widget action for accounts that want a separate WordPress widget.
* Added a cloud connection check that verifies the saved plugin token and widget UUID without reopening the login panel when only widget selection is needed.
* Added an in-plugin update check that refreshes WordPress update metadata and links to the native updater.

= 1.1.0 =
* Added email OTP signup/login directly inside WordPress.
* Added automatic site registration and widget UUID creation.
* Added Laleo Chat top-level admin menu with Setup, Live Visitors, and Widget Settings.
* Added live visitor and waiting-call list scoped to the configured WordPress widget.
* Added secure conversation handoff links from wp-admin to the Laleo console.
* Added cloud widget settings and asset uploads for avatar, ringtone, hold music, unavailable message, and PSTN accept prompt.
* Added native ZIP update checks for plugin copies installed outside WordPress.org.

= 1.0.2 =
* Added automatic logged-in WordPress visitor context before the hosted Laleo widget script.
* Added a setting to disable logged-in visitor context sharing.
* Added the `laleo_chat_visitor_context` developer filter for custom fields such as membership plan or account tier.

= 1.0.1 =
* Added WordPress-local excluded path rules.
* Expanded setup notes for whole-site installs and Laleo dashboard exclusions.

= 1.0.0 =
* Initial release.
