=== CueChat ===
Contributors: hive34
Tags: live chat, chat, customer support, woocommerce, chatbot
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Live chat for WordPress and WooCommerce: connect your CueChat account in one click, pick a chat widget and choose where it shows.

== Description ==

CueChat is a live chat for websites and online stores, made in Poland. This plugin adds the CueChat chat bubble to your WordPress site or WooCommerce store.

* Connect in one click: click "Connect with CueChat", log in to your CueChat account in the small window and confirm. No code to copy.
* Pick the chat widget (CueChat group) that answers on your site - with its own team, colours and working hours.
* Page rules: show a different widget, or hide the chat, on selected pages, posts, categories, WooCommerce products and product categories, page types (cart, checkout, my account...) or URL patterns.
* Live preview: check which widget shows at any address of your site before saving.
* Optionally hide the chat from logged-in administrators.
* Optionally pass the name and e-mail of a logged-in user (and the billing phone and order count of a WooCommerce customer) to your consultants, so they do not have to ask who they are talking to.
* The script is loaded asynchronously and does not slow your pages down. Page caches of WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache and Autoptimize are cleared after saving.
* Nothing is shown in wp-admin. Disconnect any time - in the plugin or in the CueChat panel.
* Advanced: a manual mode that accepts the install code from the CueChat panel stays available for special cases.

You need a CueChat account. You can create one at https://cuechat.app/.

== External services ==

This plugin connects to the CueChat service (https://cuechat.app), operated by the plugin author.

* Connecting: when you click "Connect with CueChat", a CueChat window opens (cuechat.app, page "wtyczka/polacz") with your site address, the admin return address and a random state value. After you log in and confirm, your site's server exchanges a one-time code for an access token through the CueChat API (cuechat.app, endpoint "api/wtyczka/token", server-to-server only). The token is stored only in your WordPress database and is never sent to visitors' browsers.
* Settings: the plugin reads the list of chat widgets (groups) of your account and saves this site's chat settings (chosen widget, page rules, options) through the CueChat API (cuechat.app, endpoints under "api/wtyczka/", server-to-server only, authorized with the access token). Twice a day WP-Cron refreshes this data. The plugin version, WordPress, WooCommerce and PHP versions are sent in a request header.
* Chat on the site: the script https://cuechat.app/embed.js and the chat window are loaded on every front-end page where the chat is enabled. When a visitor opens a page, their browser sends to CueChat the address and title of the page, the referring page, and the messages the visitor writes in the chat. If the option "Pass logged-in customer data" is enabled, the name, e-mail address and, for WooCommerce customers, billing phone number and number of orders of the logged-in user are sent as well.
* Terms of service: https://cuechat.app/regulamin
* Privacy policy: https://cuechat.app/polityka-prywatnosci

== Installation ==

1. In WordPress go to Plugins -> Add New, search for "CueChat", click Install Now, then Activate. (You can also upload the plugin ZIP file in Plugins -> Add New -> Upload Plugin.)
2. The CueChat screen opens. Click "Connect with CueChat", log in to your CueChat account in the small window and click "Connect".
3. Pick the widget (chat group) that should answer on your site and click "Save". The chat bubble appears on your site.
4. Optional: in "Page rules" choose pages where a different widget shows, or where the chat is hidden.

If you previously pasted the CueChat code into your theme by hand, remove it, so the chat is not added twice.

== Frequently Asked Questions ==

= Does it work with WooCommerce? =

Yes. The chat appears in the whole store. Rules can target products, product categories, the shop, cart, checkout and my account pages. With the "pass customer data" option enabled, consultants see the name, e-mail, billing phone and order count of a logged-in customer.

= Can I show a different chat on some pages? =

Yes - in the "Page rules" tab add a rule, e.g. "Product category: Furniture -> Show: Furniture team" or "URL starts with /checkout -> Hide chat". Rules are checked from the top, the first matching rule wins.

= What happens when I disconnect? =

Disconnecting in the plugin removes the chat from your site and revokes the access token. Your widget choice and rules stay in CueChat and come back after you connect again. Disconnecting the site in the CueChat panel only revokes the token - the chat keeps working with the last settings until you reconnect.

= My server cannot connect to cuechat.app =

Use the advanced manual mode: paste the install code from the CueChat panel (Groups -> Install code).

= Can I change the data passed to consultants? =

Use the filter `cuechat_visitor_data`. It receives an array with `name` and `fields` (label => value) and the WP_User object. Up to 6 fields are shown. Never pass passwords or tokens. The filters `cuechat_show_widget` and `cuechat_widget_group` let developers hide the chat or change the group in code.

== Changelog ==

= 2.0.2 =
* Settings sent from the admin screen are sanitized field by field; a pasted embed code is stored only as the recognized widget ID and group.
* External services section describes the API endpoints without listing them as links.

= 2.0.1 =
* Plugin name shortened to "CueChat" (same slug as the text domain) for the WordPress.org directory.

= 2.0.0 =
* Connect with your CueChat account in one click (no code to paste).
* New CueChat screen in the WordPress menu: widget cards, page rules (pages, posts, categories, WooCommerce products and categories, page types, URL patterns), live preview, settings.
* Settings are stored in CueChat and restored after reconnecting; the CueChat panel lists connected sites.
* Page cache plugins are cleared after saving.
* Version 1.x settings keep working as the advanced manual mode.

= 1.0.0 =
* First version: install code or account ID, async footer script, hide for administrators, pass logged-in user and WooCommerce customer data.

== Upgrade Notice ==

= 2.0.2 =
Security hardening of the admin settings screen.

= 2.0.1 =
Name change only - nothing to do after updating.

= 2.0.0 =
Connect your site with CueChat in one click and choose widgets per page. Your current code keeps working until you connect.
