= NoticeWave Popup =
Contributors: agrata77
Tags: announcement, popup, notification, banner, whatsapp
Requires at least: 6.0
Tested up to: 7.0
Stable tag: 1.2.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Display targeted announcement popups with scheduling, display rules, and auto-dismiss timers — no coding required.

== Description ==

**NoticeWave Popup** lets you create and manage rich announcement popups for your WordPress site through a clean, step-by-step wizard. Show event notices, admission alerts, general updates, or any time-sensitive information to your visitors — with full control over when, where, and how they appear.

= Key Features =

* **5-step wizard interface** — configure each announcement through a guided Setup → Schedule → Audience → Content → Action flow.
* **Scheduling** — set a start date and end date. Announcements automatically appear and disappear on the correct day with no manual intervention needed.
* **Priority system** — when multiple active announcements exist, the one with the highest priority (1–100) is shown first. Lower-priority ones appear after visitors dismiss the first.
* **Audience targeting** — show a popup on all pages, the homepage only, or specific pages you choose.
* **Announcement types** — categorise as Event, Admission, Alert, or General; each type gets a distinct color badge in the admin list.
* **Rich content** — optional title, description (with HTML support via the WordPress content filter), and a banner image.
* **Call to action** — choose between a clickable button (custom URL), a clickable banner image, or no action at all. WhatsApp is natively supported with country flag + dial-code selection.
* **Auto-close timer** — optionally auto-dismiss the popup after 5, 10, or 30 seconds.
* **Cookie-based dismiss tracking** — once a visitor closes a popup, it is suppressed for a configurable number of days so it never feels spammy.
* **Accessibility** — full keyboard navigation, ARIA roles (`dialog`, `aria-modal`, `aria-labelledby`), focus trapping, and focus restoration on dismiss.
* **No external dependencies** — all assets (including the intl-tel-input library for WhatsApp dial codes) are bundled locally. No CDN calls, no tracking.
* **Fully translatable** — every admin and frontend string is wrapped in WordPress i18n functions and ready for `.po`/`.mo` translation files.

== Installation ==

= Automatic Installation =

1. Log in to your WordPress admin panel.
2. Navigate to **Plugins → Add New**.
3. Search for **NoticeWave Popup**.
4. Click **Install Now**, then **Activate**.

= Manual Installation =

1. Download the plugin `.zip` file.
2. Navigate to **Plugins → Add New → Upload Plugin**.
3. Choose the `.zip` file and click **Install Now**.
4. Click **Activate Plugin**.

= Getting Started =

1. After activation, find **Announcements** in the WordPress admin sidebar.
2. Click **Add New Announcement**.
3. Work through the 5 wizard steps: Setup, Schedule, Audience, Content, and Action.
4. Set the post status to **Published** and make sure the **Announcement status** toggle (Step 1) is enabled.
5. Visit your site — the popup will appear automatically.

== Frequently Asked Questions ==

= How does priority work? =

Each announcement has a priority value from 1 to 100. When multiple announcements are active and scheduled for the same page, the one with the highest number is shown first. After a visitor dismisses it, the next-highest priority announcement will appear on their next visit (subject to the cookie duration setting).

= Can I show different announcements on different pages? =

Yes. In Step 3 (Audience), choose **All Pages**, **Homepage Only**, or **Specific Pages** and select exactly which pages should display the popup.

= How do I stop an announcement from showing permanently? =

Either set an **End Date** in Step 2 (Schedule) so it expires automatically, or toggle the **Announcement status** switch in Step 1 to disable it manually. Disabled announcements are never shown regardless of dates.

= The popup still shows after the end date — why? =

The expiration check runs client-side using the visitor's local device time, so there is no server-round-trip delay. If the popup still appears, make sure your page caching plugin has been cleared after you saved the end date.

= Can visitors see the popup again after closing it? =

Yes. The **Dismiss cookie duration** setting (under **Announcements → Settings**) controls how many days the popup is suppressed after a visitor closes it. Set it to `0` to show the popup on every page load.

= Does the plugin support WhatsApp? =

Yes. In Step 5 (Action), select **WhatsApp** as the destination type, then choose your country flag and enter your local number. The plugin constructs a valid `wa.me` deep-link automatically. On mobile devices it uses the native `whatsapp://` URI scheme so the app opens directly.

= Is there any tracking or third-party data sharing? =

No. The plugin makes no external HTTP requests. All assets — including the country flag library — are bundled locally. No data is sent to any third-party server.

= Is it compatible with page caching plugins? =

Yes. Because date/expiry logic is evaluated in the visitor's browser (not on the server), the popup correctly respects its schedule even when WordPress serves a cached page.

= How do I translate the plugin? =

The plugin uses the text domain `noticewave-popup`. Create `.po` and `.mo` files in `wp-content/languages/plugins/` using a tool like Poedit. All admin and frontend strings are fully wrapped with WordPress i18n functions.

== Screenshots ==

1. The 5-step wizard — Step 1: Setup (status toggle, priority, announcement type).
2. Step 2: Schedule — set a start and end date for automatic display.
3. Step 3: Audience — target all pages, the homepage, or specific pages.
4. Step 4: Content — add a title, description, and banner image.
5. Step 5: Action — configure a CTA button, clickable banner, or WhatsApp link.
6. The announcements list table with live Status (Active / Scheduled / Expired / Inactive), Priority, Schedule, and Display columns.
7. A rendered popup example showing a banner image, title, description, and CTA button.

== Changelog ==

= 1.2.0 =
* Added: Priority input field directly in the wizard Setup step.
* Added: Automated background migration to assign default priority to legacy announcements.
* Added: Four-state Status column in the admin list (Active, Inactive, Expired, Scheduled) with color-coded indicators.
* Fixed: Announcement title not saving correctly on some live server configurations (migrated title mapping to `wp_insert_post_data` filter).
* Fixed: Quick-edit Priority field was reading post ID instead of stored priority value — causing silent data corruption on every quick-edit save.
* Fixed: Custom option cards (type, audience, CTA, timer) required multiple clicks in some browsers due to `display: none` on radio inputs; replaced with accessible visually-hidden technique.
* Fixed: Auto-close timer cancellation race condition where manual close and timer expiry could both fire simultaneously.
* Fixed: Date boundary evaluation now uses local device timezone instead of UTC, preventing off-by-one-day errors for visitors in UTC+ timezones.
* Improvement: Converted all JavaScript from ES5 `var` to block-scoped `const`/`let`.
* Improvement: All external CDN assets (intl-tel-input) replaced with locally bundled copies.
* Improvement: All admin UI strings are now fully wrapped in WordPress i18n functions.
* Improvement: Added required WordPress.org plugin headers (`Requires at least`, `Tested up to`, `Requires PHP`).

= 1.1.0 =
* Added: WhatsApp CTA support with country flag and dial-code selector (intl-tel-input).
* Added: Clickable banner mode — the banner image itself becomes the call-to-action link.
* Added: Auto-close timer (Off / 5 sec / 10 sec / 30 sec).
* Added: Text visibility toggles — independently show or hide title and description in the popup.
* Added: Page-specific cookie key — dismissing a popup on one page does not suppress it on other pages.
* Fixed: Accessibility — full keyboard navigation, ARIA dialog roles, focus trap, and focus restoration.

= 1.0.0 =
* Initial release.
* 5-step wizard for creating announcements.
* Scheduling with start and end dates.
* Display targeting (all pages, homepage, specific pages).
* Priority-based display ordering.
* Cookie-based dismiss suppression.

== Upgrade Notice ==

= 1.2.0 =
Recommended update. Fixes a silent data corruption bug in quick-edit priority saves. Also resolves a date timezone issue that could cause popups to appear or expire a day early/late for visitors outside UTC.
