=== Campaign Bars ===
Tags: announcement bar, notification bar, countdown, coupon, campaigns
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.3.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Create announcement bars with a friendly live editor, page targeting, schedules, countdowns, coupon copying, and optional local reports.

== Description ==

Campaign Bars gives your site a clear next step. Write an announcement, highlight a sale, copy a coupon code, or publish a quiet service notice.

Free includes:

* Unlimited campaigns with separate draft and published copy, stale-write conflict protection, and recoverable trash.
* Twenty saved draft/publication revisions per campaign; restore a draft, pause/resume the approved bar, or pause all bars without overwriting campaigns.
* A quick editor, desktop/mobile examples, and a private saved-draft preview on an actual published page. Preview links expire after 15 minutes and require the publisher who created them; preview measurement and campaign actions are disabled.
* Starter templates, separate visual presets, custom colors, top or bottom placement with offsets, optional buttons, and mobile copy.
* Announcements, fixed-end countdowns, and coupon-code copying.
* Page inclusion, always-excluded pages, device scope, and logged-in/logged-out audiences.
* Fixed start/end dates in your WordPress timezone, and browser-session frequency/dismissal preferences.
* Read-only visibility diagnostics for published rules: exclusions, schedules, audience, dismissal, frequency, required add-ons and competing campaigns. Unknown shopper context is explained explicitly.
* Guided consent connection and private consent test status for WP Consent API, Cookiebot, or custom integrations.
* Translation-ready PHP and JavaScript with a combined POT template and native WordPress script translations. Translated language catalogs are not bundled.
* Optional local aggregate views and clicks, campaign-level summaries, a 30-day report, and CSV export. Measurement defaults off, with consent required by default. Data is retained for 90 days.

Campaign Bars Pro is a separate add-on, distributed at campaignbars.com. Free includes sparse read-only Pro previews inside its own page. Free does not contain a paid feature implementation, expiration, account requirement, external telemetry, Pro downloader, or forced public branding.

All CSS and JavaScript assets are local and readable. The public bar retrieves published eligible content from your own site's admin-ajax endpoint so visitor state is resolved afresh on cached pages. Existing editors do not gain publishing access automatically. Purge page/CDN caches after installation, an update, or activating/deactivating Pro so previously cached pages receive the current scripts. After that, cached pages can discover the first campaign or a resumed campaign without a per-campaign cache purge.

== Installation ==

1. Upload the campaign-bars folder to wp-content/plugins, or upload campaign-bars.zip in Plugins > Add New > Upload Plugin.
2. Activate Campaign Bars.
3. Open Campaign Bars in the admin menu.
4. Give your campaign a name, write its message, and add a button destination if enabled.
5. Optionally choose page/device scope and dates. Checkout is excluded by default.
6. Save a draft or publish the bar.

== Frequently Asked Questions ==

= Is Free limited to one campaign? =

No. You can create unlimited campaigns. One eligible bar appears at a time. Free selects the newest eligible campaign; Pro adds priorities.

= Do I need WooCommerce? =

No. Free works without WooCommerce. Coupon copying is a display/copy feature and does not create or validate a store coupon. Pro's store-aware shipping and coupon application require WooCommerce.

= How does measurement and consent work? =

Measurement is disabled by default. In Campaign Bars > Settings, choose automatic detection, WP Consent API, Cookiebot, or a custom JavaScript connection. WP Consent API requires an explicit statistics allow choice; Cookiebot requires a recorded response allowing statistics. Save settings, then open the private consent test tab and use your normal consent banner. The editor shows connected / granted, waiting, denied, or no connection. Campaign Bars measurement is paused in that test tab. Accept and revoke using your consent tool; Campaign Bars never accepts consent for a visitor.

Custom integrations can set window.CampaignBarsAnalyticsConsent before loading, or dispatch a CampaignBarsConsent CustomEvent on document with detail: {analytics: true} after permission and false on revocation. Explicit provider mode uses the selected provider's state. Automatic mode also accepts the custom event. No external consent manager is bundled or loaded. Functional dismissal and frequency use session storage. Dismissal can quiet this publication, this page visit, or all bars for the browser session.

= Will editing a live campaign immediately change my site? =

No. Save draft preserves the published configuration. Only Publish bar replaces the live version. Publishing requires the publish_campaign_bars capability. A stale editor receives a conflict instead of overwriting a newer save. Resume uses the approved publication and keeps unpublished edits private. Saved history is not automatic draft saving: unsaved edits still need Save draft.

= Will checkout exclusions be overridden? =

No. Always-excluded pages, inclusion scope, and device scope apply before audience rules. These restrictions are mandatory even if an add-on combines audience conditions with OR.

= Does uninstall delete my campaigns? =

Data is preserved by default. Administrators can opt into deletion in Settings before uninstalling. The choice survives uninstalling Free and Pro in either order. Deactivation keeps campaigns and reports.

= How do I upgrade from 0.2.0? =

Back up the database and export important campaigns first. Version 0.3.0 migrates campaign drafts, publications and saved history into a private atomic campaign table. Original legacy records are retained, but subsequent edits are stored in the new table. Reinstalling 0.2.0 would read stale legacy data and is not a supported rollback. Update Free before matching Pro and clear page/CDN caches. Keep a verified pre-upgrade backup for recovery.

= What is included in this release? =

The features above are implemented. Site-specific theme, consent-tool, cache/CDN, mobile, and WooCommerce staging checks should be completed before a public launch. This download has not been submitted to or approved by WordPress.org.

== Changelog ==

= 0.3.0 =
* Prevent stale draft, publication, restore and settings writes with atomic revision checks.
* Add saved history, recoverable trash, safe resume, emergency pause and private real-page draft preview.
* Improve templates, publish review, page selection, measurement summaries and unsaved-state feedback.
* Preserve storefront focus across refreshes, bound layout offsets and clarify dismissal behavior.
* Migrate campaign state into a private atomic table; preserve legacy records for recovery, not downgrade synchronization.

= 0.2.0 =
* Add merchant visibility diagnostics and guided consent connection with a protected test tab.
* Translate editor and visitor JavaScript using WordPress wp-i18n; include complete PHP/JavaScript POT extraction.
* Retain the 0.1.1 save, cache, countdown and experiment lifecycle fixes.

= 0.1.1 =
* Correct countdown timing and bounded expiry refresh; preserve edits made during saving.
* Keep the public loader present before campaign publication and while campaigns are paused.

= 0.1.0 =
* Initial release: quick editor, published/draft isolation, campaigns, targeting, schedules, local aggregate reports, and read-only Pro discovery.

== Upgrade Notice ==

= 0.3.0 =
Back up before upgrading. Campaign data migrates to a private atomic table; reinstalling 0.2.0 is not a supported rollback. Update Free before matching Pro, then clear page/CDN caches.

= 0.2.0 =
Update Free before Pro. Clear page/CDN caches once after updating so the new consent bridge and translation dependencies load. Review the new consent setup in Settings.

= 0.1.1 =
Fixes countdown request loops, save-time edit loss, and campaign discovery on cached pages. Purge existing page/CDN caches once after updating.

= 0.1.0 =
Initial release. Measurement is disabled by default.
