=== Plexvia Connector ===
Contributors: plexvia
Tags: chat, ai chat, customer support, site verification, chatbot
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WordPress site to Plexvia — verify ownership, inject the verification meta tag, and add the Plexvia AI chat widget to every page.

== Description ==

Plexvia Connector is the official plugin that links your WordPress site to your [Plexvia](https://plexvia.com) account. It does four things, all from one clean settings screen:

1. **Website verification** — prove you control this domain so Plexvia can work with your site. The plugin adds the required verification meta tag to your site's `<head>` and triggers verification with one click.
2. **Chat widget** — add a premium, polished AI chat experience to every page. The widget answers visitors instantly from your Plexvia knowledge and hands off to a teammate when a conversation needs a person. It is off until you switch it on.
3. **Content sync** — two separate, separately optional things. *Automatic sync* keeps your AI's answers in step with your content's lifecycle from the moment you switch it on: publish or update a page and Plexvia re-reads it; move it to draft and its answers are hidden; delete it and they're archived. *Sync existing content now* is a one-time button that reads the pages you have already published. Neither happens on its own — you can run the one-time sync without ever switching automatic sync on, and running it does not switch it on. Only the page's URL and the change are sent; Plexvia fetches the public page itself, and no content is pushed from WordPress.
4. **Connection maintenance** — a daily background task checks that this site's connection to Plexvia still works and retires your stored account session once this website has its own connection credential. It calls the Plexvia API and nothing else.

= Built for trust =

* The chat widget is **off by default** and only loads when you enable it and connect a chat agent.
* Content sync is **off by default**. Installing the plugin, connecting your Plexvia account and choosing a business read nothing from your site. Automatic lifecycle sync starts only when you switch it on, and your already-published pages are read only when you click **Sync existing content now** — each is its own deliberate choice, and neither implies the other.
* Your Plexvia account password is **never stored**. Signing in gives this website its own connection credential — limited to this one business, and to keeping your content and domain verification in step — and that is what the site runs on. Your account session is retired a day after that, so an account-wide credential is not left sitting in your database for the life of the install.
* Stored credentials are protected with AES-256-GCM at rest when the server provides the required OpenSSL support. If authenticated encryption is unavailable, the plugin clearly warns administrators that stored credentials are only encoded rather than encrypted.
* Admin-only secrets are **never** placed in your public pages. Only the public chat key is sent to the browser.
* Every admin action is protected by capability checks and nonces. All input is sanitized; all output is escaped.

= Design =

The widget follows a calm, modern aesthetic: soft surfaces, generous spacing, a glass header, refined typography, elegant motion, and accessible contrast. It is keyboard-friendly, screen-reader-labelled, respects reduced-motion preferences, and is fully responsive on mobile. Its styles are fully self-contained, so it looks the same on any theme.

== External services ==

This plugin connects to the Plexvia API and the Plexvia real-time service to provide its features. Both are required for the plugin to function. The service is provided by Plexvia (https://plexvia.com); see the Plexvia Terms (https://plexvia.com/terms) and Privacy Policy (https://plexvia.com/privacy).

What is sent, and when:

* **When you connect (administrator only):** your email and password are sent once to the Plexvia API (api.plexvia.com) to sign you in; the password is not stored in WordPress. The plugin then asks Plexvia for a connection credential belonging to this website and stores that, encrypted. Setup steps you take on the settings screen — listing your businesses, listing chat agents, creating the widget's public chat key — use your account session while you are signed in. Your account session is stored, encrypted, until it is retired.
* **When the plugin verifies your website (unattended):** your business ID and this website's own connection credential are sent to the Plexvia API, which then fetches this site's public home page to look for the verification meta tag. That credential can do two things and nothing else: keep this site's ingested pages in step, and prove this domain is yours. It cannot read your knowledge base, open conversations, or create other credentials, and you can revoke it from your Plexvia dashboard at any time.
* **When you turn on automatic content sync:** each time you publish, update, draft, or delete a public page or post, your server sends that page's URL and the change (publish, draft, or archive) — along with your business ID and this website's connection credential — to the Plexvia API (api.plexvia.com) so Plexvia can re-read, hide, or archive the page's knowledge accordingly. Nothing is sent automatically while that setting is off.
* **When you click Sync existing content now (administrator only):** the URLs of your currently published pages and posts are sent the same way, once, in background batches. This is a separate, explicit action: it works whether or not automatic sync is on, and it does not turn automatic sync on. In both cases no page content is sent from WordPress — Plexvia fetches the public page itself — and password-protected, private, draft and otherwise non-public content is skipped.
* **When the chat widget is enabled:** your visitors' browsers open a real-time WebSocket connection to Plexvia (wss://api.plexvia.com) using your public chat key, and the messages a visitor types in the widget are sent to Plexvia to generate a reply. A visitor identifier and the local chat transcript are stored in the visitor's browser (localStorage) so a conversation can resume across page loads; nothing is written to your database. The widget also shows a legal notice beside the message box before anything is sent, with links to Plexvia's Chatbot User Terms of Use and Privacy Policy — the documents that govern the visitor. Those links point to plexvia.com, so enabling the widget places two external links on your public site. The current version of those documents is supplied by Plexvia when the connection opens, and an identifier for the version shown is sent with the visitor's first message so Plexvia can record which notice was displayed. That identifier is an opaque version string — it contains nothing about the visitor.
* **Inside a chat reply (visitor-facing):** when an answer contains a phone number, an address, or a product from your Plexvia knowledge base, the widget renders it as a tappable card. An address card is a plain link to Google Maps (https://www.google.com/maps) — no map is embedded, no API key is used, and nothing is sent to Google unless the visitor taps it. A product card may show a product image, which the visitor's browser loads from wherever that image is hosted in your own catalogue; the request carries no referrer. Only `http`/`https` links and image sources are ever rendered.
* **During daily connection maintenance:** if the site is connected, the plugin calls the Plexvia API to check that its connection credential still works, to issue one if this site does not have one yet, and — once it does — to retire the stored account session, which is no longer needed. A site that does not yet have its own credential has its account session refreshed instead. These are the same authenticated Plexvia API endpoints the plugin already uses; no separate report is sent, and no other host is contacted.
* **For server-side Plexvia API requests:** the connector's HTTP User-Agent names the plugin and its version (`PlexviaConnector/1.0.0`). Your site's address is not included.

== Installation ==

1. Upload the `plexvia-connector` folder to `/wp-content/plugins/`, or install the plugin through the **Plugins → Add New** screen.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Open **Plexvia** in the admin menu.
4. On the **Connection** tab, sign in with your Plexvia account, then choose your business from the list. This connects the site; it does not read or send any of your content.
5. On the **Website verification** tab, generate a token (the meta tag is added automatically) and click **Verify now**.
6. (Optional) On the **Chat widget** tab, connect a chat agent, then switch the widget on. Enabling it also places links to Plexvia's Chatbot User Terms of Use and Privacy Policy beneath the chat message box on your public site.
7. (Optional) On the **Status & maintenance** tab, turn on **automatic content sync** if you want Plexvia to follow your content's lifecycle from now on, and/or click **Sync existing content now** to read your already-published pages into your knowledge base once. Either is useful on its own; neither switches the other on.

== Frequently Asked Questions ==

= How do I choose my business, and where do I get my chat key? =

After you sign in on the **Connection** tab, the plugin lists the businesses on your Plexvia account so you can pick the right one — no IDs to copy. (If the list can't be loaded, you can still paste your Business ID manually.) The chat key is created for you when you choose an agent on the **Chat widget** tab. You can also paste one from your Plexvia dashboard: it is a public key (it starts with `pk_`) created under API keys — it must have the `interactions:write` scope and a default agent.

= Does connecting my account send Plexvia my content? =

No. Connecting the site and choosing a business exchanges credentials and nothing else. Your pages are read only after you turn automatic content sync on, or click **Sync existing content now** — both under **Status & maintenance**. The button is a one-time import and works on its own: you can use it and leave automatic sync off for good.

= Is my password stored in WordPress? =

No. Your password is sent to Plexvia once, when you sign in, and is never written to your database.

= What does the plugin store, then? =

Two credentials, both encrypted at rest with AES-256-GCM, using a key derived from your site's secret keys. (If your server lacks the required OpenSSL support, the plugin warns administrators that stored credentials are only encoded, not encrypted.)

1. **This website's connection credential.** Issued to this site for the business you chose, and limited to two jobs: keeping your synced pages in step, and proving you control this domain. It cannot read your knowledge base, cannot open conversations, and cannot create other credentials.
2. **Your public chat key**, if you turn the widget on. This one is deliberately public — it is what your visitors' browsers use to open a chat — and it can do nothing but start a conversation with the agent you chose.

Your account session (the tokens from signing in) is stored encrypted too, until it is retired.

= Why am I signed out of the settings screen after a while? =

Because your account session is a setup credential, not a running one. It is what lets the plugin show your businesses and your chat agents and create the widget's key — all things you do while sitting at the settings screen. A day after this website is issued its own connection credential, the site no longer needs your account session, so the plugin stops storing it rather than keeping an account-wide credential in your database indefinitely.

Your site stays connected. Sign in again only when you want to change the chat agent, switch business, or reconnect.

= What does the chat widget put on my public pages? =

The widget itself, and — beneath its message box — links to Plexvia's Chatbot User Terms of Use and Privacy Policy. Those two documents govern the visitors who use the chat, so the Plexvia chat service requires them to be shown.

Nothing else. There is no "Powered by Plexvia" credit unless you ask for one: **Plexvia branding**, on the Chat widget tab, is off by default, and while it is off no credit, no empty placeholder and no hidden link is written into your pages. Turning it on adds a "Powered by Plexvia" line under the chat message box, and the same line to the footer of the plugin's own settings screen. The Terms and Privacy links are separate from that setting and are always shown.

= I copied my site to a staging server. Will it sync too? =

No. Credentials are bound to the site they were issued to, so a copy inherits an inert set rather than a working one — a staging clone cannot sync its copied pages into your live knowledge base, and cannot interfere with the original's connection. Connect the copy separately if you actually want it connected.

= The chat widget doesn't connect on my live site. Why? =

The widget connects to Plexvia directly from your visitors' browsers. For security, Plexvia must allow your site's domain before those connections are accepted. If the widget cannot connect, confirm with Plexvia that your domain is allowed for real-time chat.

= Does the plugin load any third-party JavaScript? =

No. All JavaScript and CSS are bundled with the plugin and served from your own site. The widget opens a data connection to Plexvia, but it never loads remote scripts and never evaluates code it receives.

= What happens when I delete the plugin? =

All plugin options, its scheduled maintenance and content-sync events, and its per-post sync bookkeeping are removed on uninstall, on single-site and across a multisite network.

== Screenshots ==

1. The Plexvia Connector settings screen — Connection tab.
2. Website verification with the exact meta tag shown and one-click verify.
3. The Chat widget tab with a live preview.
4. The Plexvia chat widget on the front end.

== Changelog ==

= 1.0.0 =
* Initial WordPress.org release.
* **Website verification.** Generate a verification token, have the meta tag added to your site's `<head>` automatically, and verify with one click. DNS TXT verification is supported as an alternative.
* **Plexvia AI chat widget.** A self-contained, accessible chat panel that answers visitors from your Plexvia knowledge, hands over to a human teammate, shows typing indicators and unread counts, runs your Plexvia flows as inline question cards, supports identity verification, renders phone, address and product answer tiles, and keeps its transcript in the visitor's own browser so a conversation survives a page change. Off by default; theme, position, colours, greeting, launcher label and unread behaviour are all configurable, with a live preview.
* **Content sync.** Optionally keep Plexvia in step with your content's lifecycle: publishing or updating a page re-reads it, drafting hides its answers, deleting archives them. Only the page's URL and the change are sent — Plexvia fetches the public page itself. Off by default. **Sync existing content now** is an independent one-time action that reads your already-published pages in background batches, skipping unchanged ones; it works with automatic sync off and never turns it on.
* **This site gets its own connection credential.** Signing in issues this website a credential scoped to one business and to two jobs (content sync and domain verification), and your account session is retired a day later rather than being kept indefinitely. Your password is never stored, and credentials are bound to the site they were issued to, so a staging clone cannot disturb the original.
* **Encrypted at rest.** Stored credentials are encrypted with AES-256-GCM using a key derived from your site's secret keys, with a clear administrator warning if the server cannot provide authenticated encryption.
* **Plexvia branding is optional and off.** A single **Plexvia branding** switch governs the "Powered by Plexvia" credit on the chat widget and in the plugin's own settings footer. It is off on a new install and stays off on upgrade until an administrator turns it on; with it off nothing of the credit — not an empty container, not a hidden link — is written into a page. The chat's Terms of Use and Privacy Policy links are not branding and are always shown.
* **Daily connection maintenance**, a setup checklist, live connection/verification/sync status, multisite support, full translation support, and complete data cleanup on uninstall.

== Upgrade Notice ==

= 1.0.0 =
First public release of Plexvia Connector.
