=== SMS Gateway Center - SMS, RCS & Voice Notifications ===
Contributors: smsgatewaycenter
Tags: sms, whatsapp, otp, woocommerce, notifications
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.14
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send SMS, WhatsApp, RCS & Voice notifications from WooCommerce, forms, LMS courses, bookings, and WordPress login OTP - one account, every channel.

== Description ==

**SGC Connect** connects one SMS Gateway Center account to your WordPress site, and sends notifications on whichever channel you choose - SMS, WhatsApp, RCS, or Voice - with automatic fallback to the next channel if the first one fails.

= Works with =

Each integration appears as its own tab under **SGC Connect** only when that plugin is active on your site. For every event you choose the channels (SMS, WhatsApp, RCS, Voice), pick an already-approved template from your SMS Gateway Center account, and fill in its variables using the placeholder tokens listed on that tab.

**WooCommerce**

Notifies the customer's billing phone number.

* **New order placed**, **Order processing** (payment received), **Order shipped / completed**, **Order cancelled or failed** - one message per status change.
* **Cart abandoned** - sent once when a shopper has entered a phone number at checkout but not placed an order for 60 minutes. Works with both the block-based Cart/Checkout and the classic shortcode checkout. Reminders are sent by WP-Cron, so they depend on your site receiving visits (or a real server cron calling wp-cron.php).
* Tokens: `{order_id}`, `{first_name}`, `{order_total}`, `{store_name}`, `{cart_total}`, `{cart_url}`.

**Easy Digital Downloads**

EDD does not collect a phone number, so SGC Connect adds an optional **Mobile number** field under the email field on the checkout form. Customers who leave it blank are simply not messaged.

* Events: **order placed**, **order completed**, **order refunded**, **order payment failed**.
* Tokens: `{order_id}`, `{customer_name}`, `{order_total}`, `{store_name}`.

**Contact Form 7**

* Event: **a form is submitted**. The mobile number is taken from the first field whose name contains `phone`, `mobile` or `tel` (for example `your-phone`). Forms without such a field send nothing.
* Tokens: `{form_title}` and `{field:your-field-name}` for any submitted field, e.g. `{field:your-name}`.

**WPForms**

* Event: **a form is submitted**. The mobile number is taken from the form's **Phone** field.
* Tokens: `{form_title}` and `{field:1}` - use the numeric field ID shown in the WPForms builder.

**Ninja Forms**

* Event: **a form is submitted**. The mobile number is taken from the form's **Phone** field.
* Tokens: `{form_title}` and `{field:your_field_key}` - use the field key shown in the Ninja Forms builder.

**Formidable Forms**

* Event: **a form is submitted** (a new entry is created). The mobile number is taken from the form's **Phone** field.
* Tokens: `{form_title}` and `{field:your_field_key}` - use the field key shown in the Formidable builder.

**Gravity Forms**

* Event: **a form is submitted**. The mobile number is taken from the form's **Phone** field.
* Tokens: `{form_title}` and `{field:1}` - use the numeric field ID shown in the form editor.

**The Events Calendar + Event Tickets**

Free RSVP tickets are supported. SGC Connect adds an optional **Mobile number** field to the RSVP form.

* **RSVP confirmed** - sent immediately when someone RSVPs "going" (not for "not going").
* **Event starting soon** - sent once, 60 minutes before the event starts, to everyone who RSVP'd going and left a mobile number. Sent by WP-Cron.
* Tokens: `{event_title}`, `{event_date}`, `{venue_name}`, `{store_name}`.

**Appointment booking (Simply Schedule Appointments)**

Turn on the **Phone** field under **Customer Information** in your appointment type so customers can enter a number.

* **Appointment booked**, **Appointment canceled**, and **Appointment starting soon** (sent once, 60 minutes before the start time, by WP-Cron).
* Tokens: `{appointment_type}`, `{appointment_date}`, `{customer_name}`, `{store_name}`.

**LearnDash**

* **Student enrolled in a course** and **Student completes a course**. The number is read from the student's `billing_phone` (or `phone_number`) profile field, so students without one are skipped.
* Tokens: `{first_name}`, `{course_title}`.

**WordPress login and registration (OTP)**

* **Registration** - adds a Mobile Number field and a "Send OTP" button to the WordPress registration form; the account is only created once the correct code is entered.
* **Login** - an optional second factor for users who verified a phone at registration. After a correct password, the first login attempt sends a code and asks you to log in again with it.
* Codes are 6 digits, valid for 10 minutes and single-use. Put the `{otp}` token in your SMS, WhatsApp or RCS template. Voice plays a fixed pre-recorded clip and cannot read out a code, so use SMS, WhatsApp or RCS for OTP.

**You do not need all of these plugins installed.** SGC Connect only ever shows a settings tab for the plugins you actually have active - a WooCommerce-only store never sees a Gravity Forms tab, and none of that integration's code is even loaded on your site.

= External service: SMS Gateway Center =

This plugin is a connector for the **SMS Gateway Center** messaging service and does nothing until you connect your own account. When an event you enabled happens (an order, a form submission, a booking, an OTP request and so on), the plugin sends that message's recipient phone number and message content (or template variables) to your SMS Gateway Center account URL, which you enter under **SGC Connect > Connect Account**. The "Test Connection" button and the template pickers also contact your account to send a test SMS and to list your approved templates, senders and voice clips. Your API key or password is stored encrypted and sent only to your account URL.

Service: [SMS Gateway Center](https://www.smsgatewaycenter.com/) - [Terms of Service](https://www.smsgatewaycenter.com/termsofservice/) - [Privacy Policy](https://www.smsgatewaycenter.com/privacy/)

= How it works =

1. Install SGC Connect and go to **SGC Connect > Connect Account**. Paste your SMS Gateway Center userid and password (or API key). Click Test Connection.
2. Open the tab for whichever plugin you use (WooCommerce, Contact Form 7, etc.) and turn on the events you want notified - each with its own channel choice and message template.
3. Done. Every matching event on your site now sends automatically, and you can see every send (and whether it succeeded) under **Message Log**.

Don't have an account yet? [Sign up free at SMSGatewayCenter.com](https://www.smsgatewaycenter.com/).

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/`, or install it from **Plugins > Add New**, then activate it.
2. Go to **SGC Connect > Connect Account**. Enter your SMS Gateway Center account URL and userid, plus either your API key (recommended) or password. Add your default Sender ID, and a WhatsApp Business number, RCS Bot ID and Voice Library ID if you use those channels.
3. Click **Test Connection** to send yourself a real test SMS.
4. Open the tab for the plugin you use (for example WooCommerce), turn on an event, tick the channels you want, choose a template and fill in its variables. Save.
5. Check **Message Log** to see each send and whether it succeeded.

== Frequently Asked Questions ==

= Which plugins does SGC Connect send SMS/WhatsApp/RCS/Voice notifications for? =

WooCommerce, Easy Digital Downloads, Contact Form 7, WPForms, Gravity Forms, Ninja Forms, Formidable Forms, The Events Calendar (with Event Tickets), appointment booking via Simply Schedule Appointments, LearnDash, and WordPress's own core login/registration screens. See the "Works with" section above for exactly what each one triggers.

= Do I need all these other plugins (WooCommerce, Gravity Forms, etc.) installed? =

No. SGC Connect detects which of them are active on your site and only shows settings for those. If you only run Contact Form 7, that is the only integration tab you will ever see.

= Will this slow my site down if I only use one integration? =

No. Code for an integration you don't have installed is never loaded at all - not just hidden, genuinely never read by PHP. The plugin's footprint scales with what you actually use.

= What if I want SMS to try first, then WhatsApp if that fails? =

Every event lets you pick more than one channel; whichever you check are tried in the order shown, moving to the next only if the previous one fails to deliver.

= Does the login OTP feature require SMS only, like most 2FA plugins? =

No - you can require it over SMS, WhatsApp, or RCS, or configure more than one as a fallback sequence.

= Where do I get an account? =

Sign up at [smsgatewaycenter.com](https://www.smsgatewaycenter.com/) - your userid, password and API key are all found under your account's Profile page.

== Screenshots ==

1. Connect Account - paste your credentials once, test the connection, done.
2. WooCommerce settings tab - one toggle, channel picker, and message template per order event.
3. The channel/fallback-order picker - choose SMS, WhatsApp, RCS and/or Voice, tried in the order you check them.
4. Message Log - every send, its channel, and whether it succeeded, without leaving WordPress.
5. Login & Registration OTP settings - multi-channel two-factor authentication for WordPress core login and signup.

== Changelog ==

= 1.0.14 =
* Renamed every plugin-declared function, class, constant, option, table, cron hook, AJAX action, meta key and JavaScript global to a longer, more distinctive "sgcconnect" prefix (previously "sgc", which was too short to guarantee uniqueness). No feature changes.

= 1.0.13 =
* Fixed several phpcs:ignore comments that were placed on the wrong line (a statement's opening line rather than the exact line PHPCS reports) and so weren't actually suppressing anything - found by running the official Plugin Check tool directly against this codebase rather than relying on the annotations alone. No behavior changes.

= 1.0.12 =
* Annotated every WordPress Plugin Check DB/nonce warning with the reasoning behind it (custom-table direct queries with no wp_cache_* equivalent; WordPress core's own login/registration hooks, which carry no nonce for a plugin to verify against) rather than leaving them unexplained. No behavior changes.

= 1.0.11 =
* Login/Registration OTP now sends the code through the same multi-channel SMS/WhatsApp/RCS system and fallback order every other event in this plugin uses, with the code filled into an {otp} template placeholder, instead of a separate SMS-only endpoint. Login OTP now actually sends a code on the first login attempt (it previously did not).
* Deferred WP-Cron scheduling (WooCommerce abandoned-cart, Events Calendar, and appointment reminders) from plugins_loaded to init, resolving a translation-loaded-too-early notice.
* Shortened the readme's short description to fit the directory's 150-character limit, and removed a comparative claim about other plugins.

= 1.0.10 =
* Removed the Plugin URI header (it was identical to the Author URI, which WordPress.org's plugin headers require to be distinct) - the Author URI (smsgatewaycenter.com) remains.

= 1.0.9 =
* Renamed the plugin to remove a restricted trademarked term from the display name, per WordPress.org plugin directory guidelines (WhatsApp remains a fully supported notification channel - only the plugin's own name changed).

= 1.0.8 =
* Add appointment booking integration (Simply Schedule Appointments): booking confirmation, cancellation notice, and an automatic reminder sent before the appointment.

= 1.0.7 =
* Add The Events Calendar + Event Tickets integration: RSVP confirmation and an automatic "starting soon" reminder before the event.

= 1.0.6 =
* Add Easy Digital Downloads integration: order placed, completed, refunded, and failed payment notifications.

= 1.0.5 =
* Add a WooCommerce abandoned-cart reminder, sent automatically once a cart has gone quiet for an hour.

= 1.0.4 =
* Add Ninja Forms and Formidable Forms integrations.

= 1.0.1 to 1.0.3 =
* Live template/variable pickers for SMS, WhatsApp and RCS - choose an already-approved template from your connected account instead of typing template IDs by hand.
* Per-event Voice library clip override.
* Security hardening: API key sent as an HTTP header rather than in the request body; account secrets stored encrypted.

= 1.0.0 =
* Initial release: WooCommerce, Contact Form 7, WPForms, Gravity Forms, and LearnDash integrations, plus WordPress core login/registration OTP, all through one account connection.

== Upgrade Notice ==

= 1.0.8 =
Adds appointment booking (Simply Schedule Appointments), Events Calendar, Easy Digital Downloads, Ninja Forms, Formidable Forms integrations, and a WooCommerce abandoned-cart reminder. No action needed to upgrade.
