Skip to content

Commit

Permalink
- added another argument to the gwapi_send_sms, for overriding whatev…
Browse files Browse the repository at this point in the history
…er you may want to
  • Loading branch information
bitnissen committed Jun 14, 2021
1 parent 90c98b8 commit cc00559
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions inc/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
* @param string $sender Sender text (11 chars or 15 digits)
* @param string $destaddr Type of SMS - Can be MOBILE (regular SMS) or DISPLAY (shown immediately on phone and usually not stored - also called a Flash SMS)
* @param array $encoding The $message must always be in UTF-8. Read more about the different encodings available here: https://gatewayapi.com/docs/appendix.html#term-ucs2
* @param array $additional_options Additional options, such as "label", "priority" etc.. Can be used to override any other options set by this function.
* @return int|WP_Error ID of message in gatewayapi.com on success
*/
function gwapi_send_sms($message, $recipients, $sender='', $destaddr='MOBILE', $encoding='UTF8')
function gwapi_send_sms($message, $recipients, $sender='', $destaddr='MOBILE', $encoding='UTF8', $additional_options = [])
{
// PREPARE THE RECIPIENTS
// ======================
Expand Down Expand Up @@ -71,6 +72,11 @@ function gwapi_send_sms($message, $recipients, $sender='', $destaddr='MOBILE', $
$req['recipients'][] = $rec;
}

// overrides?
if ($additional_options && is_array($additional_options)) {
$req = array_merge($req, $additional_options);
}

// SEND THE SMS
// ============
$req = apply_filters('gwapi_send_sms_request', $req);
Expand Down Expand Up @@ -139,4 +145,4 @@ function gwapi_send_sms($message, $recipients, $sender='', $destaddr='MOBILE', $
}

return new WP_Error('TECH_FAIL', 'No valid transports.');
}
}

0 comments on commit cc00559

Please sign in to comment.