=== SourceCodeEs Floating Contact Widget ===
Contributors:      sourcecodeplugins
Tags:              whatsapp, contact button, chat widget, floating button, click to chat
Requires at least: 5.8
Tested up to:      6.9
Stable tag:        1.0.5
Requires PHP:      7.4
License:           GPLv2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Add a configurable contact button to your website. Control position, display rules, schedule, style and analytics tracking from a simple admin panel.

== Description ==

**SourceCodeEs Floating Contact Widget** lets you add a professional floating contact button to your WordPress site in minutes. Configure everything from the admin panel — no coding required.

= Core features =

**General**
* Enable / disable with a single toggle
* International phone number with full sanitisation
* Custom pre-filled message
* Open chat in same tab or new tab

**Display rules**
* Show on the entire site, homepage only, posts, pages, selected post types, or specific IDs
* Hide on specific pages / posts
* Device visibility: desktop only, mobile only, or both
* Per-post / per-page custom message and hide override via meta box

**Trigger timing**
* Show immediately
* Show after N seconds
* Show after the visitor scrolls a configurable percentage of the page
* Exit-intent trigger (desktop)

**Working hours / schedule**
* Optionally restrict visibility to configured days and time windows
* Independent timezone setting (defaults to your WordPress site timezone)

**Style & customisation**
* Floating button or floating button + chat-box popup
* Icon only or icon + label text
* Four colour presets (green, dark green, teal, blue) + custom hex colour picker
* Button size 30–120 px
* Circle or square / rounded-corner shape
* Custom tooltip text

**Content placement**
* Shortcode: `[scefcw_button]` with optional attribute overrides
* Gutenberg block with inspector panel for per-placement overrides
* Supports both block themes and classic themes

**Analytics & advanced**
* Optional GA4 / Universal Analytics event on every click
* Configurable GA event name
* Optional GA4 / GTM / Universal Analytics event on every click
* Hide button for the current browser session after the visitor clicks
* Import / Export settings as JSON
* Reset to defaults button
* Full uninstall cleanup via uninstall.php

= Shortcode usage =

Place `[scefcw_button]` anywhere in a post or page. Optional attribute overrides:

    [scefcw_button phone="447911123456" message="Hello, I have a question" label="Chat now" tooltip="Open chat"]

= Gutenberg block =

Search for **SourceCodeEs Floating Contact Widget** in the block inserter. Use the inspector panel to override phone, message, label and tooltip on a per-block basis.

= Per-page overrides =

Each post and page has a **SourceCodeEs Floating Contact Widget** meta box in the editor sidebar where you can:
* Override the pre-filled message for that specific page
* Force-hide the button on that page regardless of global settings

= Compatibility =

* Works with any WordPress theme
* No jQuery dependency on the frontend
* Compatible with popular caching plugins (Varnish, WP Rocket, W3 Total Cache, LiteSpeed Cache)
* Tested with WordPress Multisite
* WPML / Polylang ready (all strings use translation functions)

= Privacy =

This plugin does not collect, transmit, or store any visitor data. The optional GA event tracking uses your own GA property and is subject to your site's own privacy policy.

== Installation ==

**From the WordPress plugin directory (recommended)**

1. Go to **Plugins → Add New** in your WordPress admin.
2. Search for **SourceCodeEs Floating Contact Widget**.
3. Click **Install Now**, then **Activate**.
4. Go to **Settings → SourceCodeEs Floating Contact Widget** and enter your phone number.

**Manual installation**

1. Download the plugin zip file.
2. Go to **Plugins → Add New → Upload Plugin**.
3. Upload the zip, install and activate.
4. Go to **Settings → SourceCodeEs Floating Contact Widget**.

== Frequently Asked Questions ==

= What format should I use for the phone number? =

Enter the full international number including country code, **digits only** — no spaces, dashes, brackets or leading `+`. For example, a UK number `+44 7911 123456` should be entered as `447911123456`.

= Why is the button not showing on my site? =

Check these in order: (1) the plugin is enabled on the General tab; (2) a phone number has been entered; (3) the Display rules allow the current page; (4) if working hours are enabled, check that the current time falls within a configured window; (5) check that your caching plugin is not serving a stale page.

= Does the button work without JavaScript? =

The floating button requires JavaScript to handle trigger timing and the chat-box popup. However, the HTML anchor is rendered in the page so it can be displayed with a simple CSS fallback if you add `.scefcw-wrapper { opacity:1; visibility:visible; }` to your custom CSS.

Shortcode and block placements are always visible because they render inline with no trigger delay.

= Can I place more than one button? =

The floating button is a singleton. For multiple placements in content, use the shortcode or Gutenberg block as many times as you like — each can have its own message, label and phone number override.

= Does this plugin support Multisite? =

Yes. Settings are stored per-site. On uninstall, all site options are removed across the network.

= Can I translate this plugin? =

Yes. All user-facing strings use WordPress i18n functions with the text domain `sourcecodees-floating-contact-widget`. A `.pot` file is included in the `languages/` directory.

== Screenshots ==

1. Admin settings page – General tab
2. Admin settings page – Style tab with preview
3. Admin settings page – Schedule (working hours)
4. Floating button on the frontend (green, bottom right)
5. Chat box popup variant
6. Gutenberg block in the editor with inspector controls
7. Per-post meta box

== Changelog ==

= 1.0.5 =
* Replaced inline button/wrapper `style="..."` attributes with `wp_add_inline_style()`, generated programmatically from sanitised settings only.
* Wrapped every dynamic output point in `wp_kses()` with a precise per-tag/per-attribute allowlist so the inline SVG icon and rendered button HTML are escaped at output.
* JSON settings export now uses `wp_send_json()` (the WPCS-whitelisted output sink) instead of a manual `echo wp_json_encode()`.
* Settings page conditional rows hidden via a CSS class (`scefcw-hidden`) instead of inline `style="display:none;"` snippets, with the toggle JS updated to `toggleClass()`.
* All admin asset filenames realigned to the `scefcw-` prefix so the registered handles resolve correctly (`assets/css/scefcw-public.css`, `assets/js/scefcw-public.js`, etc.).
* Removed all `phpcs:ignore WordPress.Security.EscapeOutput` comments. The two remaining ignores (`NonceVerification` for the read-only `?tab=` parameter and the `?settings-updated=true` flag, and `ValidatedSanitizedInput` for the JSON import payload that is parsed and then run through `SCEFCW_Settings::sanitize()`) are documented inline.

= 1.0.4 =
* Removed the Custom CSS field from settings, per WordPress.org plugin guidelines that disallow plugins from accepting arbitrary code (CSS/JS/PHP). Use the WordPress Customizer's "Additional CSS" panel to override widget styles instead.

= 1.0.3 =
* Renamed plugin to **SourceCodeEs Floating Contact Widget** (slug: `sourcecodees-floating-contact-widget`) to comply with WordPress.org plugin naming guidelines requiring the distinctive brand term at the beginning.
* Updated text domain, block name, settings page slug, and language file accordingly.

= 1.0.2 =
* Removed server-side click counter (Statistics tab) — GA event tracking is unaffected.
* Fixed admin settings tabs not loading CSS/JS due to stale page hook slug after plugin rename.

= 1.0.1 =
* Fixed scheduling bug: unchecked days now correctly hide the button when working hours are enabled.
* Fixed timezone fallback: `timezone_name_from_abbr()` now uses `is_dst = -1` for reliable offset matching.
* Hardened `is_working_hours()`: missing or malformed start/end times now default to hidden instead of visible.
* Added defensive array guards in `get_all()` to prevent empty `working_hours` from bypassing day checks.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.5 =
Hardening pass for WordPress.org review: programmatic CSS via wp_add_inline_style(), late escaping at every output point, and aligned asset filenames. No setting changes required.

= 1.0.4 =
The Custom CSS field has been removed to comply with WordPress.org plugin guidelines. If you used it, copy your CSS into Appearance → Customize → Additional CSS before updating.

= 1.0.3 =
Plugin renamed to SourceCodeEs Floating Contact Widget to meet WordPress.org naming guidelines. Settings are preserved.

= 1.0.2 =
Removes the server-side click counter. GA event tracking continues to work normally.

= 1.0.1 =
Fixes a scheduling bug where unchecked days could still display the button. Update recommended for all users using the working hours feature.

= 1.0.0 =
Initial release. No upgrade steps required.
