=== IndieTech Popup Builder ===
Contributors: indietech, rafaelvolpi
Tags: popup, modal, gutenberg, exit-intent, targeting
Requires at least: 6.7
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A powerful popup plugin with Gutenberg editor support and advanced targeting options.

== Description ==

Popup by IndieTech is a feature-rich WordPress popup plugin that makes it easy to create and display engaging popups on your website. Built with the Gutenberg editor, you can create rich, interactive popup content using familiar WordPress blocks.

= Key Features =

* **Gutenberg Editor Support**: Create rich popup content using the WordPress block editor. All settings are in the document sidebar (Trigger, Behavior, Design, Location).
* **Advanced Triggering Options**:
  * Immediate display on page load
  * Time delay (show after X seconds, 0-30)
  * Scroll percentage (show when user scrolls X% of the page)
  * Exit intent (when cursor leaves the viewport from the top)
  * Button / Link: open on click of any element with a specific CSS class (e.g. a Gutenberg button block)
* **Smart Targeting (Location)**:
  * Include rules (multi-select): All pages, Homepage, CPT single (by post type), Specific page/post IDs, URL prefixes (one per line)
  * Exclude rules: Exclude by post/page IDs or URL prefixes
  * Exclusions are applied first; popup shows if any include rule matches and no exclude rule matches
* **Cookie Management**: Control how often users see popups
  * Cookie duration in days (0 = show every time, up to 365)
  * Choose when cookie is set: On Close or On Seen
* **Customizable Styling (Design)**:
  * Position: 9-position matrix (top/center/bottom x left/center/right)
  * Max width (200-1200px)
  * Overlay opacity (0-1)
  * Close button: Do not show, Show inside, or Show outside
* **Behavior Options**:
  * Close when clicking outside (overlay)
  * Disable page scroll when popup is open
* **Private popups**: Publish as Private to show only to logged-in users
* **Close link in content**: Use href="#popup:close" in popup content to close the modal
* **List view**: Custom columns for Status and Trigger (Immediate, Delay, Scroll %, Exit Intent)
* **Mobile Responsive**: Fully responsive design that works on all devices
* **GA4 / GTM Tracking**: Optional event tracking for popup open, close, and CTA clicks. Works with direct GA4 (gtag.js) and Google Tag Manager (dataLayer).
* **Gravity Forms Integration**: Optionally set a permanent cookie and auto-close the popup after a successful form submission inside it.
* **Accessible**: Built with Micromodal for accessible modals (focus trap, ARIA, keyboard)
* **Lightweight**: Optimized code; assets only load when there are active popups; transient cache for performance

= How It Works =

1. Create a new popup by going to Popups > Add New
2. Use the Gutenberg editor to add your content (text, images, forms, buttons, etc.)
3. In the document sidebar, configure Trigger, Behavior, Design, and Location
4. Publish (or set to Private for logged-in users only). Your popup will appear based on your targeting and trigger settings

= Use Cases =

* Lead generation forms
* Newsletter signups
* Promotional offers and announcements
* Important messages and alerts
* Exit intent offers
* Welcome messages
* Cookie consent notices
* Product launches and updates

== Installation ==

1. Upload the `indietech-popup-builder` folder to your `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to 'Popups > Add New' to create your first popup
4. Configure your popup settings and publish

== Frequently Asked Questions ==

= Do I need to know code to use this plugin? =

No! The plugin uses the familiar Gutenberg block editor, so you can create popup content just like editing a WordPress post or page.

= Can I use WordPress blocks in popups? =

Yes! All WordPress blocks are supported, including custom blocks from other plugins. This means you can add forms, buttons, images, videos, and any other block content to your popups.

= Can I control how often users see popups? =

Yes! You can set a cookie duration (in days) to control how often the popup appears to the same user. Set it to 0 to always show the popup. You can also choose whether the cookie is set when the user closes the popup or when they first see it.

= Can I target specific pages? =

Yes! You can use include rules (All, Homepage, CPT single, specific page/post IDs, or URL prefixes) and exclude rules (exclude by IDs or URL prefixes). Rules are multi-select; exclusions are applied first.

= Does it work on mobile devices? =

Yes! The plugin is fully responsive and works great on all devices including mobile phones and tablets.

= Is the plugin accessible? =

Yes! The plugin uses the Micromodal library which follows accessibility best practices, ensuring your popups are usable by all visitors including those using screen readers.

= Can I have multiple popups? =

Yes! You can create as many popups as you need. Only published (or private, for logged-in users) popups are displayed based on their targeting settings. The list view shows Status and Trigger columns for each popup.

= Can I schedule popups? =

Yes! Use WordPress's built-in scheduling feature. Set a future publish date to automatically display the popup on that date.

= Does the plugin slow down my site? =

No! The plugin is lightweight and only loads frontend assets when there are active popups. A transient cache is used so popup queries are not run on every page load. Popups are only rendered on pages where they match the targeting criteria.

= Can I close popups by clicking outside? =

Yes! This is an optional setting. You can enable or disable closing the popup when users click on the overlay/backdrop.

== Screenshots ==

1. Create popups using the familiar Gutenberg block editor
2. Configure trigger, behavior, design, and location in the document sidebar
3. Set include and exclude targeting rules (all, homepage, CPT single, IDs, URL prefixes)
4. Customize position (9-position matrix), width, overlay, and close button
5. Popup displayed on frontend with smooth overlay animation
6. Responsive design working on mobile devices

== Changelog ==

= 1.2.1 =
* Fixed close button requiring two clicks when the SVG icon inside it is the click target. Added `pointer-events: none` to the SVG so clicks always land on the button element.

= 1.2.0 =
* New trigger type: **Button / Link** — open a popup by clicking any block (button, link, image, etc.) with a specific CSS class. The sidebar shows the exact class to use (e.g. `popup-open-123`). No cookie is required; the popup can be reopened after closing.

= 1.1.2 =
* Fixed CPT single targeting not working on themes that call `query_posts()` before `wp_head()` (e.g. Inertia.js-based themes). Page context is now snapshotted on the `wp` action before any template code runs.
* Fixed JavaScript crash ("Cannot read properties of null: removeEventListener") on sites where other plugins or themes use `data-micromodal-trigger` attributes pointing to non-existent modals.
* Compatibility and code quality fixes to satisfy WordPress Plugin Check.
* Improved sanitization of request URLs and popup meta box settings.
* Corrected text domain to `indietech-popup-builder` and prepared the language directory for translations.
* Updated build/package configuration to exclude development files from distribution.

= 1.1.0 =
* Gutenberg sidebar for all popup settings (Trigger, Behavior, Design, Location)
* Targeting: multi-select include rules (All, Homepage, CPT single, Specific IDs, URL prefixes) and exclude rules (IDs, URL prefixes)
* Position: 9-position matrix (top/center/bottom x left/center/right)
* Close button options: none, inside, or outside
* Private popups (visible only to logged-in users)
* Close link in content: href="#popup:close"
* List columns: Status and Trigger
* Transient cache for active popups with cache invalidation on save/delete
* Editor live preview for max width and close button

= 1.0.0 =
* Initial release
* Gutenberg editor support with full block compatibility
* Advanced triggering options (immediate, time delay, scroll percentage, exit intent)
* Smart targeting (all pages, homepage, specific pages by ID or URL prefix)
* Cookie-based frequency control
* Customizable styling (position, width, overlay opacity)
* Behavior options (close on outside click, close button, scroll lock)
* Mobile responsive design
* Accessibility support with Micromodal
* Lightweight and optimized code

== Upgrade Notice ==

= 1.2.1 =
Fixes the close button requiring two clicks on some popup configurations.

= 1.2.0 =
New trigger: open a popup from any button or link by adding a CSS class. Set trigger to "Button / Link" and the sidebar shows you the exact class to use.

= 1.1.2 =
Fixes CPT single targeting on Inertia.js-based themes, a JS crash from third-party `data-micromodal-trigger` elements, and WordPress Plugin Check compatibility improvements.

= 1.1.0 =
Update for Gutenberg sidebar settings, advanced targeting (include/exclude, CPT single), 9-position matrix, private popups, and performance improvements (transient cache).

= 1.0.0 =
Initial release of Popup by IndieTech. Install to start creating powerful popups with Gutenberg support.
