=== PushAI – Self-Hosted Web Push Notifications ===
Contributors: cagriuckan
Author: PushAI
Author URI: https://codezenic.com
Plugin URI: https://wpushai.com
Tags: push notifications, web push, woocommerce, pwa, ai
Requires at least: 6.4
Tested up to: 7.0
Stable tag: 1.0.0
Requires PHP: 8.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Self-hosted web push for WordPress & WooCommerce. Unlimited subscribers, no per-subscriber fees. AI digests & Woo automation with Pro.

== Description ==

**PushAI** turns your WordPress site into a re-engagement channel. Visitors subscribe with a single click, and you reach them directly in their browser — even when your site is closed — using the native Web Push standard. There is no third-party SDK, no per-subscriber pricing, and no external delivery service: notifications are sent straight from your own server using your own [VAPID](https://datatracker.ietf.org/doc/html/rfc8292) credentials, which PushAI generates automatically.

Everything lives on your site. Subscribers are stored in your own database, delivery runs through a background queue so large sends never block your site, and every push link is automatically tagged with UTM parameters so the traffic shows up correctly in Google Analytics and your other reporting tools. The free plugin already covers the full lifecycle — subscribe button, automatic new-post notifications, a manual composer, per-user targeting, delivery history, and GDPR export/erasure.

PushAI is **device-aware**. When a logged-in visitor subscribes, PushAI keeps one active subscription per device type — one for mobile and one for desktop — so the same person can opt in independently on their phone and on their computer and receive each notification on whichever devices they enabled. Stale and duplicate subscriptions are pruned automatically.

**PushAI Pro** builds on this foundation with the three features self-hosted push plugins almost never offer out of the box: **AI-summarized post digests** (powered by OpenAI, Google Gemini, xAI Grok, DeepSeek, or any OpenRouter model — with a template fallback so digests always work), **deep WooCommerce automation** (order and stock alerts, order-status updates, abandoned-cart reminders, cross-sell follow-ups, and trending-product pushes), and a **built-in Progressive Web App (PWA)** that adds an installable web-app manifest and service worker so visitors can install your site to their home screen.

> **Actively developed.** PushAI is under continuous, active development. New automations, AI providers, and WooCommerce flows ship regularly, and every release is documented in the changelog below. Feature requests and feedback directly shape the roadmap — this is a living plugin, not a frozen one.

= Why choose PushAI? =

PushAI keeps your push notifications self-hosted, so the parts that usually cost you money and control stay on your side:

* **You own your subscriber list.** Subscriptions live in your WordPress database, never on a third-party platform.
* **Unlimited subscribers and notifications — on Free and Pro.** No per-subscriber pricing, no monthly send caps.
* **No third-party SDK or external delivery service.** Native Web Push + your own VAPID keys, straight from your server.
* **Transparent, flat pricing.** The free plugin stays free forever; Pro is one flat price no matter how big your audience gets.
* **AI digests built in (Pro).** Automatically summarize your latest posts and send them on a schedule — across multiple AI providers, with a template fallback.
* **WooCommerce automation (Pro).** Order, stock, status, abandoned-cart, cross-sell, and trending-product pushes — from your own store.
* **Built-in PWA (Pro).** Make your site installable with a managed manifest and service worker — no separate PWA plugin required.

= Standout features =

* **AI post digests (Pro)** — collect your recent posts and send a summarized push digest on a schedule, written by OpenAI, Gemini, Grok, DeepSeek, or OpenRouter, with a built-in template fallback.
* **WooCommerce automation (Pro)** — admin alerts for new/cancelled/refunded orders and low/out-of-stock products; customer order-status and order-note updates; abandoned-cart reminders; post-purchase cross-sell follow-ups; and "Trending Now" product pushes.
* **Built-in PWA (Pro)** — an installable web-app manifest and service worker, with configurable app name, icon, and theme color, so visitors can add your site to their home screen.
* **Separate mobile & desktop subscriptions** — one active subscription per device type per account, so a user can opt in independently on phone and desktop.
* **Automatic UTM tagging** — every push link is tagged with `utm_source`, `utm_medium`, and a source-aware `utm_campaign` so clicks are attributed in your analytics. Filterable, and can be disabled.

= Free vs Pro =

Both plans include unlimited subscribers and unlimited notifications, the self-hosted setup, and the developer API. Pro adds automation, AI digests, WooCommerce, the built-in PWA, and analytics on top of the free feature set. The full breakdown is below; you only pay for the automation and AI features.

= Free Features =

* ✅ One-click subscribe button (shortcode)
* ✅ Automatic new-post notifications
* ✅ Manual notification composer
* ✅ Per-user / specific-subscriber targeting
* ✅ Separate mobile & desktop subscriptions
* ✅ Guest subscriptions
* ✅ Automatic VAPID key generation
* ✅ Background delivery queue with retries
* ✅ Automatic UTM link tagging
* ✅ Delivery history & status
* ✅ Privacy / GDPR export & erasure
* ✅ Developer API (function + action hooks)
* ✅ Unlimited subscribers & notifications
* ✅ Self-hosted — you own your data
* **Pricing:** $0 forever

= Pro Features =

* 🚀 **Everything in Free, plus:**
* ✅ **Scheduled AI digests** (OpenAI, Gemini, Grok, DeepSeek, OpenRouter + template fallback)
* ✅ **WooCommerce order & stock alerts**
* ✅ **WooCommerce order-status & customer notes**
* ✅ **Abandoned-cart reminders**
* ✅ **Cross-sell follow-ups**
* ✅ **Trending Today** (post & product daily-view alerts)
* ✅ **Built-in PWA** (installable manifest + service worker)
* ✅ **Statistics & analytics** (7/30/90-day, CTR, conversion)
* ✅ **Signed click tracking**
* ✅ **Custom post type automation**
* ✅ **Comment notifications** (authors & replies)
* ✅ **On-site permission prompt** (customizable opt-in popup)
* **Pricing:** $39/yearly

[Upgrade to PushAI Pro](https://wpushai.com)

PushAI is developed and maintained by [PushAI](https://wpushai.com).

== Installation ==

1. Upload the plugin to `/wp-content/plugins/pushai`, or install it from your WordPress admin, then activate it.
2. Open **PushAI** in the WordPress admin menu.
3. On the **Settings** page, turn on the push service. VAPID credentials are generated automatically.
4. Add the `[pushai_button]` shortcode to a page, post, or widget so visitors can subscribe.
5. (Optional) Install **PushAI Pro** and activate your license to unlock AI digests, WooCommerce automation, and the built-in PWA.

**Note:** Web Push requires HTTPS in production. Browsers also allow `localhost` during development.

== Shortcode ==

Place a subscribe button anywhere with:

`[pushai_button]`

Optional attributes:

* `label` — default button text.
* `on` — text shown after notifications are enabled.
* `blocked` — text shown when the visitor has blocked notifications.
* `align` — `left`, `center`, or `right`.
* `class` — extra CSS classes.

Example:

`[pushai_button label="Enable browser notifications" align="center"]`

In PHP templates:

`<?php echo do_shortcode( '[pushai_button]' ); ?>`

The shortcode is also shown on the **PushAI → Settings** screen with a copy button.

== Developer API ==

Queue a notification from a theme or plugin:

`pushai_trigger_notification( array(
	'title' => 'Title',
	'body'  => 'Message',
	'url'   => home_url( '/' ),
	'image' => '',
) );`

The same notification can be triggered with a WordPress action:

`do_action( 'pushai_send_notification', array(
	'title' => 'Title',
	'body'  => 'Message',
	'url'   => home_url( '/' ),
) );`

= Targeting specific users =

By default a notification is delivered to every active subscription. To send it to specific WordPress users instead, pass `target_user_id` (a single user) or `target_user_ids` (an array of users). Only subscriptions tied to those user accounts receive the message.

Send to one user:

`pushai_trigger_notification( array(
	'title'          => 'Your order shipped',
	'body'           => 'Track it from your account.',
	'url'            => home_url( '/my-account/' ),
	'target_user_id' => 123,
) );`

Send to several users:

`pushai_trigger_notification( array(
	'title'           => 'Members-only update',
	'body'            => 'A new perk is available.',
	'target_user_ids' => array( 12, 45, 78 ),
) );`

Notes on targeting:

* Only users who subscribed **while logged in** can be targeted; guest subscriptions are stored without a user account and are never matched.
* A user with several browsers or devices receives the notification on each of their active subscriptions (mobile and desktop are tracked separately).
* If targeting arguments are supplied but none resolve to a valid user, the notification is rejected with a `WP_Error` instead of being broadcast to everyone.

= Supported arguments =

* `title` *(required)* — notification heading.
* `body` *(required)* — notification message.
* `url` — link opened when the notification is clicked. Defaults to the site home URL. UTM parameters are appended automatically.
* `image` — image URL shown in the notification.
* `target_user_id` — a single WordPress user ID to deliver to.
* `target_user_ids` — an array of WordPress user IDs to deliver to.
* `source_type` — a short label describing what triggered the notification (for example `post`, `manual`, or `developer`). Metadata only: it is stored with the record, shown in the admin history, used by the `source` index, and used to build the `utm_campaign` value — it does not affect who receives the message. Defaults to `developer`.
* `source_id` — the ID of the object that triggered the notification, paired with `source_type` (for example the post ID for a `post` source). Also metadata only and **not** a recipient — use `target_user_id`/`target_user_ids` to choose recipients. Defaults to `0`.

Available hooks:

* `pushai_should_create_post_notification` — filter whether a published post creates a notification.
* `pushai_should_send_to_subscription` — filter, per subscription, whether it should receive a given notification.
* `pushai_notification_payload` — filter the payload sent to the browser.
* `pushai_utm_parameters` — filter (or disable) the UTM parameters appended to push links.
* `pushai_notification_queued` — fires after a notification is queued.
* `pushai_notification_failed` — fires when a notification fails to send.
* `pushai_notification_delivery_completed` — fires after a delivery batch finishes, with success/failed/expired counts.
* `pushai_loaded` — fires once PushAI has initialized its services.

== Frequently Asked Questions ==

= Does PushAI need a third-party push service? =

No. Notifications are delivered directly from your server using the native Web Push protocol and your own VAPID keys. There is no per-subscriber cost and no external SDK.

= Where are subscribers stored? =

In your own WordPress database. You own your subscriber list.

= Can the same person subscribe on both their phone and their computer? =

Yes. PushAI keeps one active subscription per device type for each logged-in account — one mobile and one desktop — so a visitor can opt in independently on each device and receive notifications on whichever ones they enabled.

= Does it add tracking parameters to links? =

Yes. Every push link is automatically tagged with `utm_source`, `utm_medium`, and a source-aware `utm_campaign` (for example `post-42` or `ai-digest`) so clicks are attributed in Google Analytics and similar tools. You can customize or disable this with the `pushai_utm_parameters` filter.

= Does it work with WooCommerce? =

Yes, with PushAI Pro. Pro can alert admins about new, cancelled, and refunded orders and about low/out-of-stock products, send order-status changes and order notes to customers, remind customers about abandoned carts, follow up with cross-sell suggestions after a purchase, and push trending products. Customer-facing notifications require the customer to have a WordPress account with an active push subscription.

= Does PushAI include a PWA? =

Yes, with PushAI Pro. Pro can output an installable web-app manifest and register a service worker so visitors can add your site to their home screen, with a configurable app name, icon, and theme color. The free plugin focuses on push delivery.

= Which AI providers power the digests? =

PushAI Pro supports OpenAI, Google Gemini, xAI Grok, DeepSeek, and any model available through OpenRouter. Connect an API key for AI-written summaries, or run without one and Pro falls back to a built-in template so digests always send.

= Does it work on every browser? =

Web Push is supported in modern versions of Chrome, Firefox, Edge, and Safari (including iOS 16.4+ when the site is added to the Home Screen). PushAI only shows the subscribe control where Web Push can be used.

= Is HTTPS required? =

Yes, in production. Browsers also allow `localhost` for local development.

= How many subscribers and notifications can I send? =

Subscribers and notifications are unlimited on both the Free and Pro plans. There is no per-subscriber pricing and no monthly send cap.

= Does it cost more as my subscriber list grows? =

No. The free plugin is free forever, and Pro is a single flat price ($9/month or $79/year) regardless of how many subscribers you have. You only pay for automation and AI features, not for audience size.

= Is PushAI still being developed? =

Yes — actively. PushAI is under continuous development, with new automations, AI providers, and WooCommerce flows shipping regularly. Every release is documented in the changelog, and user feedback shapes the roadmap.

= Do I have to show "powered by" branding? =

No. PushAI does not add vendor branding to your subscribe control or to the notifications you send.

== Screenshots ==

1. Dashboard — subscriber counts, recent campaigns, delivery activity, and live Web Push service health at a glance.
2. Settings — enable the push service, automatic new-post notifications, guest subscriptions, email fallback, and the notification icon.
3. AI digests (Pro) — schedule summarized post digests with delivery times, lookback window, and a choice of AI providers.
4. Statistics (Pro) — subscriber growth, link clicks, most-clicked links, daily deliveries, and AI digest conversion over 7/30/90 days.
5. Notification templates (Pro) — customize the title and message for new-post, AI digest, and comment notifications with placeholders.
6. Progressive Web App (Pro) — make your site installable with a managed manifest: app name, theme color, display mode, and icon.
7. Subscribers — browse registered users and guests with their browser, device, subscription date, and status.
8. Notifications — delivery history plus the composer to send a campaign to all subscribers or target specific users.

== Bundled Libraries ==

PushAI bundles the following open-source libraries in its `vendor/` directory. All are MIT-licensed and GPL-compatible.

* [minishlink/web-push](https://github.com/web-push-libs/web-push-php) — Web Push delivery (MIT)
* [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) — HTTP client used by web-push (MIT)
* [web-token/jwt-library](https://github.com/web-token/jwt-framework) — JWT signing for VAPID (MIT)
* [spomky-labs/base64url](https://github.com/Spomky-Labs/base64url) — Base64url encoding (MIT)
* [spomky-labs/pki-framework](https://github.com/Spomky-Labs/pki-framework) — PKI utilities (MIT)
* [brick/math](https://github.com/brick/math) — Arbitrary-precision math (MIT)
* Various PSR interfaces and Symfony polyfills (MIT)

== Third-Party Services ==

PushAI communicates with two categories of external services. No personal data is sent without user action.

= Browser push services =

When a visitor subscribes and a notification is delivered, the encrypted push payload is sent directly from your server to the browser's native push service:

* **Google Chrome / Edge** — Google's Firebase Cloud Messaging (FCM): [Privacy Policy](https://policies.google.com/privacy)
* **Mozilla Firefox** — Mozilla's Autopush service: [Privacy Policy](https://www.mozilla.org/en-US/privacy/)
* **Apple Safari** — Apple Push Notification service (APNs): [Privacy Policy](https://www.apple.com/legal/privacy/)

This is the Web Push standard (RFC 8030). Only the encrypted notification payload (title, body, URL, optional image) is transmitted; the subscriber's email address or identity is never sent. You control the VAPID keys used to sign each push.

= PushAI license API (Pro only) =

Sites with a PushAI Pro license send license key verification requests to the PushAI license server at `wpushai.com`. This happens:

* When the license is first activated.
* On a periodic background check (at most once per day) to confirm the license remains valid.
* When the admin manually refreshes the license status.
* When WordPress checks for Pro plugin updates.

The request includes your site URL (so the license can be validated against the registered domain) and the license key. No personal data beyond these two values is transmitted. [PushAI Privacy Policy](https://wpushai.com/en/privacy-policy)

== Changelog ==

= 1.0.0 =
* Initial release.