=== Black Popup - Popups & Cart Sync ===
Contributors: blackpopup
Tags: popup, woocommerce, email, marketing, conversion
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.2.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Popups, supercharged: one platform, hundreds of use cases. Increase sales and subscribers with popups visitors actually love.

== Description ==

Black Popup - Popups & Cart Sync connects your WooCommerce storefront to the Black Popup popup platform. Storefront integration is **enabled by default**; you can turn it off under **Settings > Black Popup - Popups & Cart Sync**. Site ID is set automatically from your store domain (no manual copy/paste). If your Black Popup publish payload includes `siteId`, that value is used instead.

The plugin:

- Loads the Black Popup engine from our CDN
- Exposes `window.popupData` from saved plugin configuration
- Syncs `recent_products` and `cart_products` in the visitor browser (localStorage)
- Provides a secured cart-track REST endpoint for iframe-based add-to-cart from popups
- Provides an AJAX endpoint for cart line item sync

== External services ==

This plugin connects to external services operated by Black Popup when storefront integration is enabled (on by default). You may disable it at any time under **Settings > Black Popup - Popups & Cart Sync**.

**Black Popup popup runtime (script.blackpopup.com)**

* **What it is used for:** Loading and running popup campaigns, forms, and WooCommerce cart actions configured in your Black Popup account.
* **What data is sent and when (only while integration is enabled):**
  * On storefront page loads: Site ID, popup configuration (`window.popupData`), and WooCommerce product/cart context synced in the browser (`recent_products`, `cart_products`).
  * When a visitor submits a popup form or triggers add-to-cart: fields the popup collects (for example email), plus product IDs needed to add items to the cart.
  * Campaign analytics events (for example popup views) may be sent by the runtime when a popup is shown.
* **Service provider:** Black Popup — [Terms of use](https://www.blackpopup.com/terms), [Privacy policy](https://www.blackpopup.com/privacy)

By enabling this plugin's storefront integration you agree to these services' terms and privacy policies.

== Installation ==

1. Upload the `blackpopup-popups-cart-sync` folder to `/wp-content/plugins/` or install the zip in wp-admin.
2. Activate **Black Popup - Popups & Cart Sync**.
3. Connect WooCommerce REST API keys in your Black Popup account and **Publish** your popups (Site ID is saved automatically).
4. Optional: go to **Settings > Black Popup - Popups & Cart Sync** to disable storefront integration.

== Frequently Asked Questions ==

= Does this plugin require WooCommerce? =

WooCommerce is required for cart sync and add-to-cart features. The popup script is not loaded until you opt in, regardless of WooCommerce.

= Do I need to paste a Site ID in WordPress? =

No. The plugin uses your store domain (for example `myshop.com`) as Site ID automatically. Publishing from Black Popup still works with your existing JSON — no extra fields required.

= Can I turn off the storefront script? =

Yes. Uncheck **Enable Black Popup on the storefront** under Settings.

= Which REST namespace should I use? =

Use `blackpopup/v1`. Legacy `kite/v1` routes are kept for backward compatibility. Publish (`POST .../options/json`) works even when storefront opt-in is off; cart/track requires opt-in.

== Changelog ==

= 1.2.7 =
* Fix PHP 8 fatal error in script tag filter (str_replace count by reference).

= 1.2.6 =
* Site ID auto-set from store domain when publish JSON has no siteId (no backend changes required).

= 1.2.5 =
* Storefront integration enabled by default; optional disable in Settings.
* Removed manual Site ID field; Site ID saved automatically on publish from popup JSON.

= 1.2.4 =
* Publish endpoint `/options/json` is always registered (fix 404 when storefront opt-in is off).

= 1.2.3 =
* Storefront integration opt-in checkbox (off by default); no remote loading until enabled.
* Cart/track REST route requires nonce and same-site referer; routes not registered when disabled.
* AJAX cart sync requires nonce when enabled.
* External services legal links updated to app.blackpopup.com.

= 1.2.2 =
* Aligned package name, slug, folder, and text domain to blackpopup-popups-cart-sync.

= 1.2.1 =
* WordPress.org review fixes: wp_enqueue inline scripts, unique bppcs_ prefixes, external services documentation, text domain aligned to blackpopup-popups-cart-sync.

== Upgrade Notice ==

= 1.2.3 =
You must enable storefront integration in settings after upgrading; integration is off by default.
