Changeset 3831985
- Timestamp:
- 11/28/2026 06:28:09 PM (less than one hour ago)
- Location:
- smstunnel-for-cf7
- Files:
-
- 6 edited
- 1 copied
-
tags/1.2.3 (copied) (copied from smstunnel-for-cf7/trunk )
-
tags/1.2.3/languages/smstunnel-for-cf7.pot (modified) (7 diffs)
-
tags/1.2.3/readme.txt (modified) (2 diffs)
-
tags/1.2.3/smstunnel-cf7.php (modified) (10 diffs)
-
trunk/languages/smstunnel-for-cf7.pot (modified) (7 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/smstunnel-cf7.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
smstunnel-for-cf7/tags/1.2.3/languages/smstunnel-for-cf7.pot
r3509574 r3831985 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: SMSTunnel for CF7 1.2. 0\n"5 "Project-Id-Version: SMSTunnel for CF7 1.2.3\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smstunnel-for-cf7\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2026- 04-06T18:37:15+00:00\n"12 "POT-Creation-Date: 2026-11-01T22:16:13+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.12.0\n" … … 17 17 #. Plugin Name of the plugin 18 18 #: smstunnel-cf7.php 19 msgid "SMSTunnel for CF7"19 msgid "SMSTunnel SMS for Contact Form 7" 20 20 msgstr "" 21 21 … … 27 27 #. Description of the plugin 28 28 #: smstunnel-cf7.php 29 msgid "Send SMS notifications via SMSTunnel when Contact Form 7 forms are submitted. Adds an SMS tab to CF7 editor similar to the Mail tab. "29 msgid "Send SMS notifications via SMSTunnel when Contact Form 7 forms are submitted. Adds an SMS tab to CF7 editor similar to the Mail tab. Optional end-to-end encryption." 30 30 msgstr "" 31 31 … … 40 40 msgstr "" 41 41 42 #: smstunnel-cf7.php:11 242 #: smstunnel-cf7.php:114 43 43 msgid "<strong>SMSTunnel CF7</strong> requires <strong>Contact Form 7</strong> to be installed and activated." 44 44 msgstr "" 45 45 46 46 #. translators: %s: URL to SMSTunnel plugin page 47 #: smstunnel-cf7.php:12 447 #: smstunnel-cf7.php:126 48 48 #, php-format 49 49 msgid "<strong>SMSTunnel CF7</strong>: The SMSTunnel plugin is not active. SMS notifications will not be sent until you install and configure the <a href=\"%s\" target=\"_blank\">SMSTunnel</a> plugin." 50 50 msgstr "" 51 51 52 #: smstunnel-cf7.php:188 53 #: smstunnel-cf7.php:217 52 #: smstunnel-cf7.php:156 53 msgid "Get it on Google Play" 54 msgstr "" 55 56 #: smstunnel-cf7.php:167 57 msgid "You also need the SMSTunnel app on your phone." 58 msgstr "" 59 60 #: smstunnel-cf7.php:232 61 #: smstunnel-cf7.php:261 54 62 msgid "SMS" 55 63 msgstr "" 56 64 57 #: smstunnel-cf7.php:2 0465 #: smstunnel-cf7.php:248 58 66 msgid "" 59 67 "New form submission:\n" … … 63 71 msgstr "" 64 72 65 #: smstunnel-cf7.php:2 0973 #: smstunnel-cf7.php:253 66 74 msgid "" 67 75 "Thank you for contacting us!\n" … … 71 79 msgstr "" 72 80 73 #: smstunnel-cf7.php:2 2281 #: smstunnel-cf7.php:266 74 82 msgid "SMSTunnel plugin is not active." 75 83 msgstr "" 76 84 77 #: smstunnel-cf7.php:2 2385 #: smstunnel-cf7.php:267 78 86 msgid "Install and configure the SMSTunnel plugin to enable SMS notifications." 79 87 msgstr "" 80 88 81 #: smstunnel-cf7.php:2 3289 #: smstunnel-cf7.php:278 82 90 msgid "Send SMS notification when this form is submitted" 83 91 msgstr "" 84 92 85 #: smstunnel-cf7.php:2 4193 #: smstunnel-cf7.php:287 86 94 msgid "Recipient Phone Number(s)" 87 95 msgstr "" 88 96 89 #: smstunnel-cf7.php:2 4997 #: smstunnel-cf7.php:295 90 98 msgid "Enter phone number(s) in international format. Separate multiple numbers with commas." 91 99 msgstr "" 92 100 93 #: smstunnel-cf7.php: 25594 #: smstunnel-cf7.php:3 18101 #: smstunnel-cf7.php:301 102 #: smstunnel-cf7.php:357 95 103 msgid "Message Body" 96 104 msgstr "" 97 105 98 #: smstunnel-cf7.php: 261106 #: smstunnel-cf7.php:307 99 107 msgid "Use mail-tags to include form data. Maximum 1600 characters." 100 108 msgstr "" 101 109 102 #: smstunnel-cf7.php: 266103 msgid " Additional Options"110 #: smstunnel-cf7.php:314 111 msgid "The texts go out on every submission that passes the form's checks, even if the email fails." 104 112 msgstr "" 105 113 106 #: smstunnel-cf7.php:271 107 msgid "Send SMS even if mail sending fails" 108 msgstr "" 109 110 #: smstunnel-cf7.php:280 114 #: smstunnel-cf7.php:319 111 115 msgid "SMS (2)" 112 116 msgstr "" 113 117 114 #: smstunnel-cf7.php: 283118 #: smstunnel-cf7.php:322 115 119 msgid "SMS (2) is an additional SMS template often used as an autoresponder to send a confirmation to the form submitter." 116 120 msgstr "" 117 121 118 #: smstunnel-cf7.php: 290122 #: smstunnel-cf7.php:329 119 123 msgid "Use SMS (2)" 120 124 msgstr "" 121 125 122 #: smstunnel-cf7.php: 299126 #: smstunnel-cf7.php:338 123 127 msgid "Recipient Phone Number" 124 128 msgstr "" 125 129 126 #: smstunnel-cf7.php:3 09130 #: smstunnel-cf7.php:348 127 131 msgid "Use a mail-tag like <code>[your-phone]</code> to send to the phone number from the form." 128 132 msgstr "" 129 133 130 #: smstunnel-cf7.php:3 24134 #: smstunnel-cf7.php:363 131 135 msgid "Confirmation message sent to the form submitter. Maximum 1600 characters." 132 136 msgstr "" 133 137 134 #: smstunnel-cf7.php:3 35138 #: smstunnel-cf7.php:374 135 139 msgid "Available mail-tags:" 136 140 msgstr "" 137 141 138 #: smstunnel-cf7.php:3 45142 #: smstunnel-cf7.php:384 139 143 msgid "Special tags:" 140 144 msgstr "" 141 145 142 #: smstunnel-cf7.php:5 56146 #: smstunnel-cf7.php:587 143 147 msgid "Your SMS has been sent successfully." 144 148 msgstr "" -
smstunnel-for-cf7/tags/1.2.3/readme.txt
r3816067 r3831985 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.2. 27 Stable tag: 1.2.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 159 159 == Changelog == 160 160 161 = 1.2.3 = 162 * Removed: The "Send SMS even if mail sending fails" option. It never changed anything: the texts are sent before Contact Form 7 tries the email, so they already go out whether or not the email is sent. Nothing changes for your forms. 163 * Changed: The link in the "SMSTunnel plugin is not active" notice opens the SMSTunnel plugin page directly. 164 161 165 = 1.2.2 = 162 166 * Added: The official Google Play badge for the SMSTunnel app, in the SMS tab, in the notice shown when the SMSTunnel plugin is not active, and in this plugin's row on the Plugins page. -
smstunnel-for-cf7/tags/1.2.3/smstunnel-cf7.php
r3776930 r3831985 1 1 <?php 2 2 /** 3 * Plugin Name: SMSTunnel for CF73 * Plugin Name: SMSTunnel SMS for Contact Form 7 4 4 * Plugin URI: https://smstunnel.io/integrations/contact-form-7 5 5 * Description: Send SMS notifications via SMSTunnel when Contact Form 7 forms are submitted. Adds an SMS tab to CF7 editor similar to the Mail tab. Optional end-to-end encryption. 6 * Version: 1.2. 26 * Version: 1.2.3 7 7 * Author: SMSTunnel.io 8 8 * Author URI: https://smstunnel.io … … 23 23 } 24 24 25 define('SMSTUNNEL_CF7_VERSION', '1.2. 2');25 define('SMSTUNNEL_CF7_VERSION', '1.2.3'); 26 26 define('SMSTUNNEL_CF7_PLUGIN_DIR', plugin_dir_path(__FILE__)); 27 27 define('SMSTUNNEL_CF7_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 44 44 45 45 /** 46 * Idempotency guards (per-request). CF7 fires multiple hooks 47 * (before_send_mail, submit, mail_failed) which can each trigger a send; 48 * these flags ensure each SMS is dispatched only once per submission. 46 * Idempotency guards (per-request): each SMS is dispatched only once per submission. 49 47 */ 50 48 private $sms_sent_for_submission = false; … … 89 87 add_action('wpcf7_save_contact_form', array($this, 'save_sms_settings'), 10, 3); 90 88 91 // Send SMS on form submission - multiple hooks for reliability 89 // Send SMS on every valid submission. CF7 fires this before it tries the email, 90 // so the texts go out whether or not the email is sent. 92 91 add_action('wpcf7_before_send_mail', array($this, 'send_sms_notification')); 93 add_action('wpcf7_submit', array($this, 'send_sms_on_submit'), 10, 2);94 95 // Also hook into mail_failed for the "send on fail" option96 add_action('wpcf7_mail_failed', array($this, 'send_sms_on_mail_fail'));97 92 98 93 // Override response when SMS succeeded but mail failed … … 130 125 /* translators: %s: URL to SMSTunnel plugin page */ 131 126 __('<strong>SMSTunnel CF7</strong>: The SMSTunnel plugin is not active. SMS notifications will not be sent until you install and configure the <a href="%s" target="_blank">SMSTunnel</a> plugin.', 'smstunnel-for-cf7'), 132 'https://smstunnel.io/ wordpress'127 'https://smstunnel.io/integrations/smstunnel/' 133 128 ), 134 129 array( … … 195 190 'recipient' => '', 196 191 'body' => '', 197 'send_on_fail' => false,198 192 ); 199 193 … … 315 309 </td> 316 310 </tr> 317 <tr>318 <th scope="row"><?php esc_html_e('Additional Options', 'smstunnel-for-cf7'); ?></th>319 <td>320 <label>321 <input type="checkbox" name="smstunnel_sms_send_on_fail" value="1"322 <?php checked($sms['send_on_fail'], true); ?>>323 <?php esc_html_e('Send SMS even if mail sending fails', 'smstunnel-for-cf7'); ?>324 </label>325 </td>326 </tr>327 311 </tbody> 328 312 </table> 313 <p class="description"> 314 <?php esc_html_e('The texts go out on every submission that passes the form\'s checks, even if the email fails.', 'smstunnel-for-cf7'); ?> 315 </p> 329 316 330 317 <!-- SMS (2) Section --> … … 421 408 // Save SMS (1) settings 422 409 $sms = array( 423 'active' => isset($_POST['smstunnel_sms_active']) ? true : false, 424 'recipient' => isset($_POST['smstunnel_sms_recipient']) ? sanitize_textarea_field(wp_unslash($_POST['smstunnel_sms_recipient'])) : '', 425 'body' => isset($_POST['smstunnel_sms_body']) ? sanitize_textarea_field(wp_unslash($_POST['smstunnel_sms_body'])) : '', 426 'send_on_fail' => isset($_POST['smstunnel_sms_send_on_fail']) ? true : false, 410 'active' => isset($_POST['smstunnel_sms_active']) ? true : false, 411 'recipient' => isset($_POST['smstunnel_sms_recipient']) ? sanitize_textarea_field(wp_unslash($_POST['smstunnel_sms_recipient'])) : '', 412 'body' => isset($_POST['smstunnel_sms_body']) ? sanitize_textarea_field(wp_unslash($_POST['smstunnel_sms_body'])) : '', 427 413 ); 428 414 update_post_meta($form_id, '_smstunnel_sms', $sms); … … 450 436 451 437 /** 452 * Send SMS on wpcf7_submit hook (backup for mail_failed with send_on_fail)453 */454 public function send_sms_on_submit($contact_form, $result) {455 // Skip if mail was sent (already handled by wpcf7_before_send_mail)456 if ($result['status'] === 'mail_sent') {457 return;458 }459 460 // Send SMS on mail failure if enabled461 if ($result['status'] === 'mail_failed') {462 $form_id = $contact_form->id();463 $sms = $this->get_sms_settings($form_id);464 if (!empty($sms['send_on_fail'])) {465 $this->maybe_send_sms($contact_form);466 $this->maybe_send_sms_2($contact_form);467 }468 }469 }470 471 /**472 * Send SMS notification when mail fails (if enabled)473 */474 public function send_sms_on_mail_fail($contact_form) {475 $form_id = $contact_form->id();476 $sms = $this->get_sms_settings($form_id);477 478 if (!empty($sms['send_on_fail'])) {479 $this->maybe_send_sms($contact_form);480 }481 }482 483 /**484 438 * Actually send the SMS 485 439 */ 486 440 private function maybe_send_sms($contact_form) { 487 // Idempotency: CF7 fires several hooks per submission - only send once.441 // Idempotency: only send once per submission. 488 442 if ($this->sms_sent_for_submission) { 489 443 return; … … 524 478 $recipients = array_filter(array_map('trim', explode(',', $recipient))); 525 479 526 // Mark as handled for this submission (even if all recipients are invalid) 527 // to preserve idempotency across CF7's multiple hooks. 480 // Mark as handled for this submission (even if all recipients are invalid). 528 481 $this->sms_sent_for_submission = true; 529 482 -
smstunnel-for-cf7/trunk/languages/smstunnel-for-cf7.pot
r3509574 r3831985 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: SMSTunnel for CF7 1.2. 0\n"5 "Project-Id-Version: SMSTunnel for CF7 1.2.3\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smstunnel-for-cf7\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2026- 04-06T18:37:15+00:00\n"12 "POT-Creation-Date: 2026-11-01T22:16:13+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.12.0\n" … … 17 17 #. Plugin Name of the plugin 18 18 #: smstunnel-cf7.php 19 msgid "SMSTunnel for CF7"19 msgid "SMSTunnel SMS for Contact Form 7" 20 20 msgstr "" 21 21 … … 27 27 #. Description of the plugin 28 28 #: smstunnel-cf7.php 29 msgid "Send SMS notifications via SMSTunnel when Contact Form 7 forms are submitted. Adds an SMS tab to CF7 editor similar to the Mail tab. "29 msgid "Send SMS notifications via SMSTunnel when Contact Form 7 forms are submitted. Adds an SMS tab to CF7 editor similar to the Mail tab. Optional end-to-end encryption." 30 30 msgstr "" 31 31 … … 40 40 msgstr "" 41 41 42 #: smstunnel-cf7.php:11 242 #: smstunnel-cf7.php:114 43 43 msgid "<strong>SMSTunnel CF7</strong> requires <strong>Contact Form 7</strong> to be installed and activated." 44 44 msgstr "" 45 45 46 46 #. translators: %s: URL to SMSTunnel plugin page 47 #: smstunnel-cf7.php:12 447 #: smstunnel-cf7.php:126 48 48 #, php-format 49 49 msgid "<strong>SMSTunnel CF7</strong>: The SMSTunnel plugin is not active. SMS notifications will not be sent until you install and configure the <a href=\"%s\" target=\"_blank\">SMSTunnel</a> plugin." 50 50 msgstr "" 51 51 52 #: smstunnel-cf7.php:188 53 #: smstunnel-cf7.php:217 52 #: smstunnel-cf7.php:156 53 msgid "Get it on Google Play" 54 msgstr "" 55 56 #: smstunnel-cf7.php:167 57 msgid "You also need the SMSTunnel app on your phone." 58 msgstr "" 59 60 #: smstunnel-cf7.php:232 61 #: smstunnel-cf7.php:261 54 62 msgid "SMS" 55 63 msgstr "" 56 64 57 #: smstunnel-cf7.php:2 0465 #: smstunnel-cf7.php:248 58 66 msgid "" 59 67 "New form submission:\n" … … 63 71 msgstr "" 64 72 65 #: smstunnel-cf7.php:2 0973 #: smstunnel-cf7.php:253 66 74 msgid "" 67 75 "Thank you for contacting us!\n" … … 71 79 msgstr "" 72 80 73 #: smstunnel-cf7.php:2 2281 #: smstunnel-cf7.php:266 74 82 msgid "SMSTunnel plugin is not active." 75 83 msgstr "" 76 84 77 #: smstunnel-cf7.php:2 2385 #: smstunnel-cf7.php:267 78 86 msgid "Install and configure the SMSTunnel plugin to enable SMS notifications." 79 87 msgstr "" 80 88 81 #: smstunnel-cf7.php:2 3289 #: smstunnel-cf7.php:278 82 90 msgid "Send SMS notification when this form is submitted" 83 91 msgstr "" 84 92 85 #: smstunnel-cf7.php:2 4193 #: smstunnel-cf7.php:287 86 94 msgid "Recipient Phone Number(s)" 87 95 msgstr "" 88 96 89 #: smstunnel-cf7.php:2 4997 #: smstunnel-cf7.php:295 90 98 msgid "Enter phone number(s) in international format. Separate multiple numbers with commas." 91 99 msgstr "" 92 100 93 #: smstunnel-cf7.php: 25594 #: smstunnel-cf7.php:3 18101 #: smstunnel-cf7.php:301 102 #: smstunnel-cf7.php:357 95 103 msgid "Message Body" 96 104 msgstr "" 97 105 98 #: smstunnel-cf7.php: 261106 #: smstunnel-cf7.php:307 99 107 msgid "Use mail-tags to include form data. Maximum 1600 characters." 100 108 msgstr "" 101 109 102 #: smstunnel-cf7.php: 266103 msgid " Additional Options"110 #: smstunnel-cf7.php:314 111 msgid "The texts go out on every submission that passes the form's checks, even if the email fails." 104 112 msgstr "" 105 113 106 #: smstunnel-cf7.php:271 107 msgid "Send SMS even if mail sending fails" 108 msgstr "" 109 110 #: smstunnel-cf7.php:280 114 #: smstunnel-cf7.php:319 111 115 msgid "SMS (2)" 112 116 msgstr "" 113 117 114 #: smstunnel-cf7.php: 283118 #: smstunnel-cf7.php:322 115 119 msgid "SMS (2) is an additional SMS template often used as an autoresponder to send a confirmation to the form submitter." 116 120 msgstr "" 117 121 118 #: smstunnel-cf7.php: 290122 #: smstunnel-cf7.php:329 119 123 msgid "Use SMS (2)" 120 124 msgstr "" 121 125 122 #: smstunnel-cf7.php: 299126 #: smstunnel-cf7.php:338 123 127 msgid "Recipient Phone Number" 124 128 msgstr "" 125 129 126 #: smstunnel-cf7.php:3 09130 #: smstunnel-cf7.php:348 127 131 msgid "Use a mail-tag like <code>[your-phone]</code> to send to the phone number from the form." 128 132 msgstr "" 129 133 130 #: smstunnel-cf7.php:3 24134 #: smstunnel-cf7.php:363 131 135 msgid "Confirmation message sent to the form submitter. Maximum 1600 characters." 132 136 msgstr "" 133 137 134 #: smstunnel-cf7.php:3 35138 #: smstunnel-cf7.php:374 135 139 msgid "Available mail-tags:" 136 140 msgstr "" 137 141 138 #: smstunnel-cf7.php:3 45142 #: smstunnel-cf7.php:384 139 143 msgid "Special tags:" 140 144 msgstr "" 141 145 142 #: smstunnel-cf7.php:5 56146 #: smstunnel-cf7.php:587 143 147 msgid "Your SMS has been sent successfully." 144 148 msgstr "" -
smstunnel-for-cf7/trunk/readme.txt
r3816067 r3831985 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.2. 27 Stable tag: 1.2.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 159 159 == Changelog == 160 160 161 = 1.2.3 = 162 * Removed: The "Send SMS even if mail sending fails" option. It never changed anything: the texts are sent before Contact Form 7 tries the email, so they already go out whether or not the email is sent. Nothing changes for your forms. 163 * Changed: The link in the "SMSTunnel plugin is not active" notice opens the SMSTunnel plugin page directly. 164 161 165 = 1.2.2 = 162 166 * Added: The official Google Play badge for the SMSTunnel app, in the SMS tab, in the notice shown when the SMSTunnel plugin is not active, and in this plugin's row on the Plugins page. -
smstunnel-for-cf7/trunk/smstunnel-cf7.php
r3776930 r3831985 1 1 <?php 2 2 /** 3 * Plugin Name: SMSTunnel for CF73 * Plugin Name: SMSTunnel SMS for Contact Form 7 4 4 * Plugin URI: https://smstunnel.io/integrations/contact-form-7 5 5 * Description: Send SMS notifications via SMSTunnel when Contact Form 7 forms are submitted. Adds an SMS tab to CF7 editor similar to the Mail tab. Optional end-to-end encryption. 6 * Version: 1.2. 26 * Version: 1.2.3 7 7 * Author: SMSTunnel.io 8 8 * Author URI: https://smstunnel.io … … 23 23 } 24 24 25 define('SMSTUNNEL_CF7_VERSION', '1.2. 2');25 define('SMSTUNNEL_CF7_VERSION', '1.2.3'); 26 26 define('SMSTUNNEL_CF7_PLUGIN_DIR', plugin_dir_path(__FILE__)); 27 27 define('SMSTUNNEL_CF7_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 44 44 45 45 /** 46 * Idempotency guards (per-request). CF7 fires multiple hooks 47 * (before_send_mail, submit, mail_failed) which can each trigger a send; 48 * these flags ensure each SMS is dispatched only once per submission. 46 * Idempotency guards (per-request): each SMS is dispatched only once per submission. 49 47 */ 50 48 private $sms_sent_for_submission = false; … … 89 87 add_action('wpcf7_save_contact_form', array($this, 'save_sms_settings'), 10, 3); 90 88 91 // Send SMS on form submission - multiple hooks for reliability 89 // Send SMS on every valid submission. CF7 fires this before it tries the email, 90 // so the texts go out whether or not the email is sent. 92 91 add_action('wpcf7_before_send_mail', array($this, 'send_sms_notification')); 93 add_action('wpcf7_submit', array($this, 'send_sms_on_submit'), 10, 2);94 95 // Also hook into mail_failed for the "send on fail" option96 add_action('wpcf7_mail_failed', array($this, 'send_sms_on_mail_fail'));97 92 98 93 // Override response when SMS succeeded but mail failed … … 130 125 /* translators: %s: URL to SMSTunnel plugin page */ 131 126 __('<strong>SMSTunnel CF7</strong>: The SMSTunnel plugin is not active. SMS notifications will not be sent until you install and configure the <a href="%s" target="_blank">SMSTunnel</a> plugin.', 'smstunnel-for-cf7'), 132 'https://smstunnel.io/ wordpress'127 'https://smstunnel.io/integrations/smstunnel/' 133 128 ), 134 129 array( … … 195 190 'recipient' => '', 196 191 'body' => '', 197 'send_on_fail' => false,198 192 ); 199 193 … … 315 309 </td> 316 310 </tr> 317 <tr>318 <th scope="row"><?php esc_html_e('Additional Options', 'smstunnel-for-cf7'); ?></th>319 <td>320 <label>321 <input type="checkbox" name="smstunnel_sms_send_on_fail" value="1"322 <?php checked($sms['send_on_fail'], true); ?>>323 <?php esc_html_e('Send SMS even if mail sending fails', 'smstunnel-for-cf7'); ?>324 </label>325 </td>326 </tr>327 311 </tbody> 328 312 </table> 313 <p class="description"> 314 <?php esc_html_e('The texts go out on every submission that passes the form\'s checks, even if the email fails.', 'smstunnel-for-cf7'); ?> 315 </p> 329 316 330 317 <!-- SMS (2) Section --> … … 421 408 // Save SMS (1) settings 422 409 $sms = array( 423 'active' => isset($_POST['smstunnel_sms_active']) ? true : false, 424 'recipient' => isset($_POST['smstunnel_sms_recipient']) ? sanitize_textarea_field(wp_unslash($_POST['smstunnel_sms_recipient'])) : '', 425 'body' => isset($_POST['smstunnel_sms_body']) ? sanitize_textarea_field(wp_unslash($_POST['smstunnel_sms_body'])) : '', 426 'send_on_fail' => isset($_POST['smstunnel_sms_send_on_fail']) ? true : false, 410 'active' => isset($_POST['smstunnel_sms_active']) ? true : false, 411 'recipient' => isset($_POST['smstunnel_sms_recipient']) ? sanitize_textarea_field(wp_unslash($_POST['smstunnel_sms_recipient'])) : '', 412 'body' => isset($_POST['smstunnel_sms_body']) ? sanitize_textarea_field(wp_unslash($_POST['smstunnel_sms_body'])) : '', 427 413 ); 428 414 update_post_meta($form_id, '_smstunnel_sms', $sms); … … 450 436 451 437 /** 452 * Send SMS on wpcf7_submit hook (backup for mail_failed with send_on_fail)453 */454 public function send_sms_on_submit($contact_form, $result) {455 // Skip if mail was sent (already handled by wpcf7_before_send_mail)456 if ($result['status'] === 'mail_sent') {457 return;458 }459 460 // Send SMS on mail failure if enabled461 if ($result['status'] === 'mail_failed') {462 $form_id = $contact_form->id();463 $sms = $this->get_sms_settings($form_id);464 if (!empty($sms['send_on_fail'])) {465 $this->maybe_send_sms($contact_form);466 $this->maybe_send_sms_2($contact_form);467 }468 }469 }470 471 /**472 * Send SMS notification when mail fails (if enabled)473 */474 public function send_sms_on_mail_fail($contact_form) {475 $form_id = $contact_form->id();476 $sms = $this->get_sms_settings($form_id);477 478 if (!empty($sms['send_on_fail'])) {479 $this->maybe_send_sms($contact_form);480 }481 }482 483 /**484 438 * Actually send the SMS 485 439 */ 486 440 private function maybe_send_sms($contact_form) { 487 // Idempotency: CF7 fires several hooks per submission - only send once.441 // Idempotency: only send once per submission. 488 442 if ($this->sms_sent_for_submission) { 489 443 return; … … 524 478 $recipients = array_filter(array_map('trim', explode(',', $recipient))); 525 479 526 // Mark as handled for this submission (even if all recipients are invalid) 527 // to preserve idempotency across CF7's multiple hooks. 480 // Mark as handled for this submission (even if all recipients are invalid). 528 481 $this->sms_sent_for_submission = true; 529 482
Note:
See TracChangeset
for help on using the changeset viewer.