=== Magexchat - Multi-Agent Chat ===
Contributors: magexweb
Tags: whatsapp, live chat, chat widget, multi agent, support
Requires at least: 5.0
Tested up to: 7.1
Requires PHP: 7.1
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Multi-agent WhatsApp chat plugin for WordPress with scheduling, availability control, and flexible display options.

== Description ==

Magexchat is a WordPress WhatsApp chat plugin designed for businesses that need multiple support agents, advanced availability control, and flexible frontend display options.

This powerful plugin allows you to create a professional WhatsApp chat experience on your WordPress website with multiple agents, scheduling capabilities, and complete customization options.

= Key Features =

* **Multiple WhatsApp Agents** - Add unlimited WhatsApp agents with individual settings
* **Online/Offline Status** - Automatic status detection based on schedule
* **Floating Chat Widget** - Beautiful floating widget that appears on your site
* **Gutenberg Block Support** - Native WordPress block editor integration
* **Shortcode Support** - Easy embedding with simple shortcodes
* **Page-Level Control** - Show/hide widget on specific pages or posts
* **Device Visibility** - Control visibility for desktop and mobile separately
* **Custom Design** - Fully customizable colors, labels, icons, and positions
* **WooCommerce Integration** - Display chat buttons on product pages
* **Secure & Optimized** - Built following WordPress security best practices

== Installation ==

= Automatic Installation =

1. Log in to your WordPress admin panel
2. Navigate to **Plugins → Add New**
3. Click **Upload Plugin**
4. Choose the `magexchat-multi-agent-chat.zip` file 
5. Click **Install Now**
6. Activate the plugin

= Manual Installation =

1. Extract the `magexchat-multi-agent-chat.zip` file
2. Upload the `magexchat-multi-agent-chat` folder to `/wp-content/plugins/` directory
3. Activate the plugin through the **Plugins** menu in WordPress
4. Go to **Magexchat → WA Agents** to start adding agents

= First Time Setup =

1. **Add Agents**: Go to **Magexchat→ Add New Agent** and click **Add New**
   * Enter agent name
   * Add WhatsApp number (with country code, e.g., +1234567890)
   * Upload agent avatar (optional)
   * Set availability
   * Configure button appearance

2. **Configure Floating Widget**: Go to **Magexchat → Floating Widget**
   * Select agents to display
   * Customise design and labels
   * Set display preferences (pages, posts, devices)

3. **Optional Settings**: Go to **Magexchat → Settings**
   * Configure WooCommerce integration

== Usage ==

= Floating Widget =

The floating widget appears automatically on your site based on your display settings.

1. Go to **Magexchat → Floating Widget**
2. Select agents to display in the widget
3. Customise design, labels, and position
4. Configure visibility settings (pages, posts, devices)
5. Save settings

The widget will automatically show/hide agents based on their availability schedule.

= Gutenberg Block =

1. Edit any page or post in the block editor
2. Click the **+** button to add a block
3. Search for **"Magexchat Button"**
4. Select the **Magexchat Button** block
5. Choose an agent or configure custom settings
6. Customize button appearance, colors, and shape
7. Publish your page

= Shortcode =

Use the shortcode to embed chat buttons anywhere in your content:

`[magexchat_button id="123"]`

Where `123` is the ID of your WhatsApp agent.

**Example:**
```
[magexchat_button id="123"]
```

**Parameters:**
* `id` (required) - The agent post ID

**Finding Agent ID:**
* Go to **Magexchat → Agents**
* Hover over an agent name and check the URL, or
* View the agent list - the ID is shown in the Shortcode column

= WooCommerce Integration =

1. Go to **Magexchat → Settings → WooCommerce**
2. Enable WooCommerce integration
3. Select agents to display on product pages
4. Save settings

Chat buttons will automatically appear on all WooCommerce product pages.

== Frequently Asked Questions ==

= How many agents can I add? =
Unlimited. You can add as many WhatsApp agents as you need.

= Does this work with WhatsApp Business? =
Yes. The plugin works with both regular WhatsApp and WhatsApp Business accounts.

= Can I customize the appearance? =
Yes. You can customize colors, labels, icons, button shapes, and positions for both the floating widget and individual buttons.

= Can I show different agents on different pages? =
Yes. You can control which pages and posts display the floating widget, and you can use shortcodes or blocks to show specific agents on specific pages.

= Does it work on mobile devices? =
Yes. The plugin is fully responsive and works on all devices. You can also control mobile visibility separately.

= Does this plugin slow down my website? =
No. The plugin is optimised for performance. Scripts are loaded only when required, and assets are conditionally loaded based on your settings.

= Is this plugin GDPR compliant? =
This plugin does not store personal user data. It only redirects users to WhatsApp. However, you should ensure your WhatsApp usage complies with GDPR if you're in the EU.

= Does it work with caching plugins? =
Yes. The plugin is compatible with all major caching plugins including WP Super Cache, W3 Total Cache, and WP Rocket.

= Can I use it with page builders? =
Yes. You can use the shortcode `[magexchat_button id="123"]` in any page builder that supports shortcodes, including Elementor, Beaver Builder, and Divi.

= What happens if an agent is offline? =
You can configure whether to show offline agents or hide them. If shown, they will display with an "Offline" status, and you can set custom offline messages.


== Changelog ==

= 1.0.0 =
* Initial release
* Multiple WhatsApp agent support
* Floating chat widget
* Gutenberg block integration
* Shortcode support
* WooCommerce integration
* Page and post visibility controls
* Desktop and mobile visibility options
* Custom design options

== Upgrade Notice ==

= 1.0.0 =
Initial release of Magexchat.

== Security ==

This plugin follows WordPress security best practices:

* All user inputs are sanitised and validated
* All outputs are properly escaped to prevent XSS attacks
* Nonces and capability checks protect all admin actions
* REST API endpoints are secured with permission callbacks
* AJAX requests are verified with nonce checks
* No direct file access allowed
* Database queries are limited and optimised
* No hardcoded credentials or sensitive data

== Uninstall ==

= Default behaviour (keep your data) =

By default, **uninstalling (deleting) this plugin does not remove your data**. Your WhatsApp agent posts, widget settings, WooCommerce integration options, and other plugin options stay in the database so you can reinstall later without losing configuration.

= Optional: remove all plugin data on uninstall =

If you want WordPress to delete all plugin data when the plugin files are removed:

1. Go to ** Magexchat → Settings** (or your plugin settings screen)
2. Open the **Uninstall** section
3. Enable **Delete plugin data on uninstall**
4. Save settings
5. **Delete** the plugin from **Plugins** (not only deactivate)

Only with that option enabled will uninstall remove plugin options and all `magex-wa-account` (agent) posts and their meta.

= Deactivation =

Deactivating the plugin does **not** delete any data.

= Multisite =

On multisite, uninstall runs the same cleanup step on **each site** in the network. The **Delete plugin data on uninstall** option is stored **per site** — only subsites where that option is enabled will have their plugin data removed; other subsites keep their data unless you enable the option there too before deleting the plugin.

= Export / backup =

There is no built-in export in this version. Before enabling data removal, back up your database or export content if you need a copy of agent configuration.

== Credits ==

This plugin uses the following third-party libraries:

* **Select2** - jQuery-based replacement for select boxes (MIT License)
* **jQuery Timepicker** - Time picker addon for jQuery UI (MIT License)

Developed by Magexweb.

== Support ==

For support, feature requests, or bug reports, please contact us via email on info@magexweb.com.

== License ==

This plugin is licensed under the GPLv2 or later license.
