Version Description
(2018-08-14): = - Default to US region if no region is configured in settings - Add admin notification about region configuration - Log an error message when an email is sent with no explicit region configured
Download this release
Release Info
| Developer | Mailgun |
| Plugin | |
| Version | 1.5.13 |
| Comparing to | |
| See all releases | |
Code changes from version 1.5.12.3 to 1.5.13
- .gitignore +1 -0
- CHANGELOG.md +5 -0
- includes/admin.php +29 -2
- includes/options-page.php +1 -1
- includes/wp-mail-api.php +11 -5
- mailgun.php +21 -21
- readme.txt +7 -2
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
svn/
|
|
|
| 1 |
svn/
|
| 2 |
+
.idea/
|
CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
| 1 |
Changelog
|
| 2 |
=========
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
1.5.12.3 (2018-08-09)
|
| 5 |
- Fix Region select menu default when wp-config.php variable is set
|
| 6 |
- Fix front end email input validation
|
| 1 |
Changelog
|
| 2 |
=========
|
| 3 |
|
| 4 |
+
1.5.13 (2018-08-14)
|
| 5 |
+
- Default to US region if no region is configured in settings
|
| 6 |
+
- Add admin notification about region configuration
|
| 7 |
+
- Log an error message when an email is sent with no explicit region configured
|
| 8 |
+
|
| 9 |
1.5.12.3 (2018-08-09)
|
| 10 |
- Fix Region select menu default when wp-config.php variable is set
|
| 11 |
- Fix front end email input validation
|
includes/admin.php
CHANGED
|
@@ -328,7 +328,14 @@ class MailgunAdmin extends Mailgun
|
|
| 328 |
|| (!$this->get_option('password') && $this->get_option('useAPI') === '0')
|
| 329 |
) {
|
| 330 |
?>
|
| 331 |
-
<div id='mailgun-warning' class='notice notice-warning fade'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
<?php
|
| 333 |
|
| 334 |
}
|
|
@@ -338,10 +345,30 @@ class MailgunAdmin extends Mailgun
|
|
| 338 |
|| !$this->get_option('from-address'))
|
| 339 |
) {
|
| 340 |
?>
|
| 341 |
-
<div id='mailgun-warning' class='notice notice-warning fade'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
<?php
|
| 343 |
|
| 344 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
}
|
| 346 |
|
| 347 |
/**
|
| 328 |
|| (!$this->get_option('password') && $this->get_option('useAPI') === '0')
|
| 329 |
) {
|
| 330 |
?>
|
| 331 |
+
<div id='mailgun-warning' class='notice notice-warning fade'>
|
| 332 |
+
<p>
|
| 333 |
+
<strong>
|
| 334 |
+
<?php _e('Mailgun is almost ready. ', 'mailgun'); ?>
|
| 335 |
+
</strong>
|
| 336 |
+
<?php printf(__('You must <a href="%1$s">configure Mailgun</a> for it to work.', 'mailgun'), menu_page_url('mailgun', false)); ?>
|
| 337 |
+
</p>
|
| 338 |
+
</div>
|
| 339 |
<?php
|
| 340 |
|
| 341 |
}
|
| 345 |
|| !$this->get_option('from-address'))
|
| 346 |
) {
|
| 347 |
?>
|
| 348 |
+
<div id='mailgun-warning' class='notice notice-warning fade'>
|
| 349 |
+
<p>
|
| 350 |
+
<strong>
|
| 351 |
+
<?php _e('Mailgun is almost ready. ', 'mailgun'); ?>
|
| 352 |
+
</strong>
|
| 353 |
+
<?php printf(__('"Override From" option requires that "From Name" and "From Address" be set to work properly! <a href="%1$s">Configure Mailgun now</a>.', 'mailgun'), menu_page_url('mailgun', false)); ?>
|
| 354 |
+
</p>
|
| 355 |
+
</div>
|
| 356 |
<?php
|
| 357 |
|
| 358 |
}
|
| 359 |
+
|
| 360 |
+
if (!$this->get_option('region') && $this->get_option('useAPI') === '1') {
|
| 361 |
+
?>
|
| 362 |
+
<div id='mailgun-warning' class='notice notice-warning fade'>
|
| 363 |
+
<p>
|
| 364 |
+
<strong>
|
| 365 |
+
<?php _e('Mailgun is almost ready. ', 'mailgun'); ?>
|
| 366 |
+
</strong>
|
| 367 |
+
<?php printf(__('Mailgun now supports multiple regions! By default, we will use the US region, but we now have an EU region generally available. You can change regions <a href="%1$s">here</a>.', 'mailgun'), menu_page_url('mailgun', false)); ?>
|
| 368 |
+
</p>
|
| 369 |
+
</div>
|
| 370 |
+
<?php
|
| 371 |
+
}
|
| 372 |
}
|
| 373 |
|
| 374 |
/**
|
includes/options-page.php
CHANGED
|
@@ -53,7 +53,7 @@
|
|
| 53 |
<option value="us"<?php selected('us', $this->get_option('region')); ?>><?php _e('U.S./North America', 'mailgun') ?></option>
|
| 54 |
<option value="eu"<?php selected('eu', $this->get_option('region')); ?>><?php _e('Europe', 'mailgun') ?></option>
|
| 55 |
</select>
|
| 56 |
-
<p class="description"><?php _e('Choose a region - U.S./North America or Europe - from which to send email, and to store your customer data.', 'mailgun') ?></p>
|
| 57 |
<?php endif; ?>
|
| 58 |
</td>
|
| 59 |
</tr>
|
| 53 |
<option value="us"<?php selected('us', $this->get_option('region')); ?>><?php _e('U.S./North America', 'mailgun') ?></option>
|
| 54 |
<option value="eu"<?php selected('eu', $this->get_option('region')); ?>><?php _e('Europe', 'mailgun') ?></option>
|
| 55 |
</select>
|
| 56 |
+
<p class="description"><?php _e('Choose a region - U.S./North America or Europe - from which to send email, and to store your customer data. Please note that your sending domain must be set up in whichever region you choose.', 'mailgun') ?></p>
|
| 57 |
<?php endif; ?>
|
| 58 |
</td>
|
| 59 |
</tr>
|
includes/wp-mail-api.php
CHANGED
|
@@ -114,13 +114,19 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
| 114 |
extract(apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments')));
|
| 115 |
|
| 116 |
$mailgun = get_option('mailgun');
|
| 117 |
-
|
| 118 |
$apiKey = (defined('MAILGUN_APIKEY') && MAILGUN_APIKEY) ? MAILGUN_APIKEY : $mailgun['apiKey'];
|
| 119 |
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $mailgun['domain'];
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
if (!is_array($attachments)) {
|
| 126 |
$attachments = explode("\n", str_replace("\r\n", "\n", $attachments));
|
|
@@ -358,7 +364,7 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
| 358 |
),
|
| 359 |
);
|
| 360 |
|
| 361 |
-
$endpoint = mg_detect_region($
|
| 362 |
$endpoint = ($endpoint) ? $endpoint : 'https://api.mailgun.net/v3/';
|
| 363 |
$url = $endpoint."{$domain}/messages";
|
| 364 |
|
| 114 |
extract(apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments')));
|
| 115 |
|
| 116 |
$mailgun = get_option('mailgun');
|
| 117 |
+
$region = (defined('MAILGUN_REGION') && MAILGUN_REGION) ? MAILGUN_REGION : $mailgun['region'];
|
| 118 |
$apiKey = (defined('MAILGUN_APIKEY') && MAILGUN_APIKEY) ? MAILGUN_APIKEY : $mailgun['apiKey'];
|
| 119 |
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $mailgun['domain'];
|
| 120 |
|
| 121 |
+
if (empty($apiKey) || empty($domain)) {
|
| 122 |
+
return false;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
// If a region is not set via defines or through the options page, default to US region.
|
| 126 |
+
if (!((bool) $region)) {
|
| 127 |
+
error_log('[Mailgun] No region configuration was found! Defaulting to US region.');
|
| 128 |
+
$region = 'us';
|
| 129 |
+
}
|
| 130 |
|
| 131 |
if (!is_array($attachments)) {
|
| 132 |
$attachments = explode("\n", str_replace("\r\n", "\n", $attachments));
|
| 364 |
),
|
| 365 |
);
|
| 366 |
|
| 367 |
+
$endpoint = mg_detect_region($region);
|
| 368 |
$endpoint = ($endpoint) ? $endpoint : 'https://api.mailgun.net/v3/';
|
| 369 |
$url = $endpoint."{$domain}/messages";
|
| 370 |
|
mailgun.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
* Plugin Name: Mailgun
|
| 5 |
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
| 6 |
* Description: Mailgun integration for WordPress
|
| 7 |
-
* Version: 1.5.
|
| 8 |
* Author: Mailgun
|
| 9 |
* Author URI: http://www.mailgun.com/
|
| 10 |
* License: GPLv2 or later
|
|
@@ -78,8 +78,8 @@ class Mailgun
|
|
| 78 |
* Get specific option from the options table.
|
| 79 |
*
|
| 80 |
* @param string $option Name of option to be used as array key for retrieving the specific value
|
| 81 |
-
|
| 82 |
-
|
| 83 |
*
|
| 84 |
* @return mixed
|
| 85 |
*
|
|
@@ -103,7 +103,7 @@ class Mailgun
|
|
| 103 |
*
|
| 104 |
* @param object $phpmailer The PHPMailer object to modify by reference
|
| 105 |
*
|
| 106 |
-
* @return
|
| 107 |
*
|
| 108 |
* @since 0.1
|
| 109 |
*/
|
|
@@ -133,10 +133,10 @@ class Mailgun
|
|
| 133 |
* Deactivate this plugin and die.
|
| 134 |
* Deactivate the plugin when files critical to it's operation cannot be loaded
|
| 135 |
*
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
* @since 0.1
|
| 141 |
*/
|
| 142 |
public function deactivate_and_die($file)
|
|
@@ -154,8 +154,8 @@ class Mailgun
|
|
| 154 |
* Make a Mailgun api call.
|
| 155 |
*
|
| 156 |
* @param string $uri The endpoint for the Mailgun API
|
| 157 |
-
|
| 158 |
-
|
| 159 |
*
|
| 160 |
* @return array
|
| 161 |
*
|
|
@@ -164,8 +164,8 @@ class Mailgun
|
|
| 164 |
public function api_call($uri, $params = array(), $method = 'POST')
|
| 165 |
{
|
| 166 |
$options = get_option('mailgun');
|
| 167 |
-
|
| 168 |
-
|
| 169 |
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $options['domain'];
|
| 170 |
|
| 171 |
$region = mg_detect_region($getRegion);
|
|
@@ -394,15 +394,15 @@ class Mailgun
|
|
| 394 |
|
| 395 |
}
|
| 396 |
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
public function build_list_form($atts)
|
| 407 |
{
|
| 408 |
if (isset($atts['id']) && $atts['id'] != '') {
|
| 4 |
* Plugin Name: Mailgun
|
| 5 |
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
| 6 |
* Description: Mailgun integration for WordPress
|
| 7 |
+
* Version: 1.5.13
|
| 8 |
* Author: Mailgun
|
| 9 |
* Author URI: http://www.mailgun.com/
|
| 10 |
* License: GPLv2 or later
|
| 78 |
* Get specific option from the options table.
|
| 79 |
*
|
| 80 |
* @param string $option Name of option to be used as array key for retrieving the specific value
|
| 81 |
+
* @param array $options Array to iterate over for specific values
|
| 82 |
+
* @param bool $default False if no options are set
|
| 83 |
*
|
| 84 |
* @return mixed
|
| 85 |
*
|
| 103 |
*
|
| 104 |
* @param object $phpmailer The PHPMailer object to modify by reference
|
| 105 |
*
|
| 106 |
+
* @return void
|
| 107 |
*
|
| 108 |
* @since 0.1
|
| 109 |
*/
|
| 133 |
* Deactivate this plugin and die.
|
| 134 |
* Deactivate the plugin when files critical to it's operation cannot be loaded
|
| 135 |
*
|
| 136 |
+
* @param $file Files critical to plugin functionality
|
| 137 |
+
*
|
| 138 |
+
* @return void
|
| 139 |
+
*
|
| 140 |
* @since 0.1
|
| 141 |
*/
|
| 142 |
public function deactivate_and_die($file)
|
| 154 |
* Make a Mailgun api call.
|
| 155 |
*
|
| 156 |
* @param string $uri The endpoint for the Mailgun API
|
| 157 |
+
* @param array $params Array of parameters passed to the API
|
| 158 |
+
* @param string $method The form request type
|
| 159 |
*
|
| 160 |
* @return array
|
| 161 |
*
|
| 164 |
public function api_call($uri, $params = array(), $method = 'POST')
|
| 165 |
{
|
| 166 |
$options = get_option('mailgun');
|
| 167 |
+
$getRegion = (defined('MAILGUN_REGION') && MAILGUN_REGION) ? MAILGUN_REGION : $options['region'];
|
| 168 |
+
$apiKey = (defined('MAILGUN_APIKEY') && MAILGUN_APIKEY) ? MAILGUN_APIKEY : $options['apiKey'];
|
| 169 |
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $options['domain'];
|
| 170 |
|
| 171 |
$region = mg_detect_region($getRegion);
|
| 394 |
|
| 395 |
}
|
| 396 |
|
| 397 |
+
/**
|
| 398 |
+
* Initialize List Form.
|
| 399 |
+
*
|
| 400 |
+
* @param array $atts Form attributes
|
| 401 |
+
*
|
| 402 |
+
* @return string
|
| 403 |
+
*
|
| 404 |
+
* @since 0.1
|
| 405 |
+
*/
|
| 406 |
public function build_list_form($atts)
|
| 407 |
{
|
| 408 |
if (isset($atts['id']) && $atts['id'] != '') {
|
readme.txt
CHANGED
|
@@ -4,8 +4,8 @@ Mailgun for WordPress
|
|
| 4 |
Contributors: Mailgun, sivel, lookahead.io, m35dev
|
| 5 |
Tags: mailgun, smtp, http, api, mail, email
|
| 6 |
Requires at least: 3.3
|
| 7 |
-
Tested up to: 4.9.
|
| 8 |
-
Stable tag: 1.5.
|
| 9 |
License: GPLv2 or later
|
| 10 |
|
| 11 |
|
|
@@ -128,6 +128,11 @@ MAILGUN_FROM_ADDRESS Type: string
|
|
| 128 |
|
| 129 |
== Changelog ==
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
= 1.5.12.3 (2018-08-09): =
|
| 132 |
- Fix Region select menu default when wp-config.php variable is set
|
| 133 |
- Fix front end email input validation
|
| 4 |
Contributors: Mailgun, sivel, lookahead.io, m35dev
|
| 5 |
Tags: mailgun, smtp, http, api, mail, email
|
| 6 |
Requires at least: 3.3
|
| 7 |
+
Tested up to: 4.9.8
|
| 8 |
+
Stable tag: 1.5.13
|
| 9 |
License: GPLv2 or later
|
| 10 |
|
| 11 |
|
| 128 |
|
| 129 |
== Changelog ==
|
| 130 |
|
| 131 |
+
= 1.5.13 (2018-08-14): =
|
| 132 |
+
- Default to US region if no region is configured in settings
|
| 133 |
+
- Add admin notification about region configuration
|
| 134 |
+
- Log an error message when an email is sent with no explicit region configured
|
| 135 |
+
|
| 136 |
= 1.5.12.3 (2018-08-09): =
|
| 137 |
- Fix Region select menu default when wp-config.php variable is set
|
| 138 |
- Fix front end email input validation
|
