=== smsportal ===
Contributors: smsportal
Tags: sms, woocommerce, contact form 7, notifications, android
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send SMS from WooCommerce, Contact Form 7 and Amelia through your own Android phone with smsportal.app.

== Description ==

smsportal connects your WordPress site to the smsportal.app SMS gateway. Messages are sent by the smsportal app on your own Android phone, using your own SIM card and plan.

**Connect in one click.** Click "Connect to smsportal.app", sign in, pick the phone and approve. Nothing to copy: the plugin receives its own access key, which you can revoke from either side.

**Automatic SMS (rules).** Pick an event, choose who gets the SMS (the customer, or a fixed number such as yours), write the text with variables like `{imie}` or `{numer_zamowienia}`, save. The editor counts characters and SMS parts and shows a preview with the data of the latest such event. Events:

* WooCommerce: new order, and order status changed to any status (completed, on hold, cancelled, and custom statuses).
* Contact Form 7: a form was sent (the customer's number comes from a form field you choose).
* Amelia: new booking, booking status changed, reminder a chosen number of hours before the appointment.
* Uncanny Automator: a "Send SMS (smsportal)" action for your recipes.

**One SMS per event.** Each event is sent at most once, even when an order status is set twice or a request is retried after a timeout. Messages are sent in the background, so pages do not slow down; when smsportal.app cannot be reached they are retried after 1, 5 and 15 minutes. You choose how late a message may still go out (12 hours by default).

**Statuses and replies.** The "Sent" tab shows each SMS with its status: waiting for the phone, sent, delivered, failed. Customer replies to SMS from this site appear in "Replies", are added to the WooCommerce order as a private note, and can be e-mailed to you. A reply of STOP (or NIE, REZYGNUJE, UNSUBSCRIBE) puts the number on the block list.

**Overview.** Phone online or offline, battery, network, SMS sent this month by this site and by the whole account, and a test SMS button.

**Privacy.** Phone numbers are masked in the admin screens. Sent SMS, replies and logs are deleted after 90 days. The plugin adds a suggested text to the privacy policy guide and supports the WordPress personal data export and erasure tools. Uninstalling removes all its data.

**For developers.** Send from your own code with `smsportal_send_sms( $to, $message, array( 'dedupe_key' => 'my-plugin|order-123|shipped' ) )`, or add your own events with the `smsportal_register_events` filter and fire them with `do_action( 'smsportal_fire_event', $event_id, $context )`.

= External service =

This plugin connects to the external service smsportal.app (https://smsportal.app) to send SMS messages and to receive delivery status and replies. When you click "Connect to smsportal.app", your browser goes to smsportal.app to sign in and approve access; your site then sends smsportal.app its admin return address and its webhook address (both on your own domain) and receives an access key, which is stored only in your WordPress database. When an SMS is sent, the recipient phone number, the message text and your API key are transmitted to smsportal.app. The overview screen asks smsportal.app for the phone state and the monthly counters. The service is operated by the plugin author.

* Terms of service: https://smsportal.app/en/terms
* Privacy policy: https://smsportal.app/en/privacy

smsportal.app is not affiliated with SMSPortal (Pty) Ltd of South Africa.

== Installation ==

1. Download `smsportal-wordpress.zip` from https://smsportal.app/downloads/smsportal-wordpress.zip and upload it under Plugins > Add New > Upload Plugin. After publication in the wordpress.org plugin directory you can also search for "smsportal" on the Plugins screen.
2. Activate the plugin.
3. Install the smsportal app on an Android phone and sign in (https://smsportal.app).
4. Open the smsportal menu in the admin sidebar and click "Connect to smsportal.app".
5. Under "Rules", add your first automatic SMS.

Your site must use https (http works only on localhost).

== Frequently Asked Questions ==

= Do I need an Android phone? =

Yes. SMS are sent by the smsportal app on your own Android phone, with your own SIM card. iPhones cannot send SMS from apps, so they are not supported.

= What does an SMS cost? =

What your mobile plan charges for an SMS (many plans include unlimited SMS). smsportal.app has a free plan and paid plans with higher monthly limits; see https://smsportal.app/en/pricing.

= What happens when the phone is offline? =

The SMS waits on smsportal.app until the phone comes back. If that takes longer than the time set in the rule (12 hours by default), it is dropped and shown as expired, so a customer does not get an "order shipped" SMS a day late.

= What happens when my plan's limit is used up? =

The SMS gets the status "Plan limit" and is not retried. New events send again once the limit resets or you change the plan.

= Will a customer get the same SMS twice? =

No. Each event (for example "order 1042 completed") sends at most one SMS, even when the status is set again or the request is retried.

= Can customers reply? =

Yes. Replies to SMS sent by this site appear under "Replies", on the WooCommerce order as a private note, and in an e-mail to you (you can turn the e-mail off in Settings). Other SMS that reach your phone are not sent to the site.

= How do I stop SMS to a number? =

A customer who replies STOP is blocked automatically. You can also block or unblock numbers by hand under "Blocked".

= Can someone abuse a public form to send SMS from my phone? =

SMS to numbers typed by customers (forms, guest checkout, bookings, the Uncanny Automator "Send SMS" action) are limited: they go only to your country's numbers (add more countries under Settings > Allowed recipient countries), at most 3 an hour and 10 in 24 hours to one number, and at most 30 an hour from one rule (appointment reminders are exempt from the per-rule cap). An SMS stopped by a limit is shown under "Sent" with the reason, and the plugin screens show a warning. Fixed numbers in rules and `smsportal_send_sms()` are not limited, unless you pass `'check_limits' => true`. Also turn on your form's spam protection (for Contact Form 7: Akismet, reCAPTCHA or Cloudflare Turnstile). Developers can change the limits with the `smsportal_rate_limits` and `smsportal_allowed_calling_codes` filters.

= What happens on a staging copy of my site? =

A copy with a different site address does not send SMS: the connection belongs to the original site. The plugin screens on the copy let you either keep the connection (the site really moved) or connect the copy on its own.

= Can I use it with my own self-hosted smsportal server? =

Yes: set `define( 'SMSPORTAL_URL', 'https://sms.example.com' );` in `wp-config.php`.

== Screenshots ==

1. Overview: connection, phone state, SMS this month and the latest SMS.
2. Rule editor: event, recipient, text with variables, SMS counter and preview.

== Changelog ==

= 0.1.1 =
* New light look in the style of the smsportal.app dashboard: cards, segmented section switcher, status pills, a connection pill with the phone state in the header, and the account usage bar on the overview.
* The menu entry is now "smsportal.app" with the smsportal logo as its icon.

= 0.1.0 =
* First release: one-click connection to smsportal.app, rules for WooCommerce, Contact Form 7, Amelia and Uncanny Automator, background sending with retries, delivery statuses, customer replies and order notes, block list with STOP, privacy tools, Polish translation.
