Mailgun for WordPress - Version 1.5.8.2

Version Description

(2017-02-27): = - Fix a bug causing empty tags to be sent with messages (#51) - Add mg_mutate_message_body hook to allow other plugins to modify the message body before send - Add mg_mutate_attachments hook to allow other plugins to modify the message attachments before send - Fix a bug causing the AJAX test to fail incorrectly.

Download this release

Release Info

Developer Mailgun
Plugin Icon 128x128 Mailgun for WordPress
Version 1.5.8.2
Comparing to
See all releases

Code changes from version 1.5.8.1 to 1.5.8.2

Files changed (5) hide show
  1. CHANGELOG.md +6 -0
  2. includes/admin.php +12 -0
  3. includes/wp-mail-api.php +8 -2
  4. mailgun.php +1 -1
  5. readme.txt +32 -1
CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
  Changelog
2
  =========
3
 
 
 
 
 
 
 
4
  1.5.8.1 (2017-02-06):
5
  - Fix "Undefined property: MailgunAdmin::$hook_suffix" (#48)
6
  - Fix "Undefined variable: from_name on every email process" (API and SMTP) (#49)
1
  Changelog
2
  =========
3
 
4
+ 1.5.8.2 (2017-02-27):
5
+ - Fix a bug causing empty tags to be sent with messages (#51)
6
+ - Add `mg_mutate_message_body` hook to allow other plugins to modify the message body before send
7
+ - Add `mg_mutate_attachments` hook to allow other plugins to modify the message attachments before send
8
+ - Fix a bug causing the AJAX test to fail incorrectly.
9
+
10
  1.5.8.1 (2017-02-06):
11
  - Fix "Undefined property: MailgunAdmin::$hook_suffix" (#48)
12
  - Fix "Undefined variable: from_name on every email process" (API and SMTP) (#49)
includes/admin.php CHANGED
@@ -389,8 +389,20 @@ class MailgunAdmin extends Mailgun
389
  );
390
 
391
  if ((bool) $useAPI) {
 
 
 
 
 
 
392
  $error_msg = mg_api_last_error();
393
  } else {
 
 
 
 
 
 
394
  $error_msg = mg_smtp_last_error();
395
  }
396
 
389
  );
390
 
391
  if ((bool) $useAPI) {
392
+ if (!function_exists('mg_api_last_error')) {
393
+ if (!include dirname(__FILE__).'/wp-mail-api.php') {
394
+ self::deactivate_and_die(dirname(__FILE__).'/wp-mail-api.php');
395
+ }
396
+ }
397
+
398
  $error_msg = mg_api_last_error();
399
  } else {
400
+ if (!function_exists('mg_smtp_last_error')) {
401
+ if (!include dirname(__FILE__).'/wp-mail-smtp.php') {
402
+ self::deactivate_and_die(dirname(__FILE__).'/wp-mail-smtp.php');
403
+ }
404
+ }
405
+
406
  $error_msg = mg_smtp_last_error();
407
  }
408
 
includes/wp-mail-api.php CHANGED
@@ -226,7 +226,7 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
226
  $body['recipient-variables'] = $rcpt_data['rcpt_vars'];
227
  }
228
 
229
- $body['o:tag'] = '';
230
  $body['o:tracking-clicks'] = !empty($mailgun['track-clicks']) ? $mailgun['track-clicks'] : 'no';
231
  $body['o:tracking-opens'] = empty($mailgun['track-opens']) ? 'no' : 'yes';
232
 
@@ -237,7 +237,7 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
237
  }
238
 
239
  // campaign-id now refers to a list of tags which will be appended to the site tag
240
- if (isset($mailgun['campaign-id'])) {
241
  $tags = explode(',', str_replace(' ', '', $mailgun['campaign-id']));
242
  if (empty($body['o:tag'])) {
243
  $body['o:tag'] = $tags;
@@ -325,6 +325,9 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
325
 
326
  $payload = null;
327
 
 
 
 
328
  // Iterate through pre-built params and build payload:
329
  foreach ($body as $key => $value) {
330
  if (is_array($value)) {
@@ -345,6 +348,9 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
345
  }
346
  }
347
 
 
 
 
348
  // If we have attachments, add them to the payload.
349
  if (!empty($attachments)) {
350
  $i = 0;
226
  $body['recipient-variables'] = $rcpt_data['rcpt_vars'];
227
  }
228
 
229
+ $body['o:tag'] = array();
230
  $body['o:tracking-clicks'] = !empty($mailgun['track-clicks']) ? $mailgun['track-clicks'] : 'no';
231
  $body['o:tracking-opens'] = empty($mailgun['track-opens']) ? 'no' : 'yes';
232
 
237
  }
238
 
239
  // campaign-id now refers to a list of tags which will be appended to the site tag
240
+ if (!empty($mailgun['campaign-id'])) {
241
  $tags = explode(',', str_replace(' ', '', $mailgun['campaign-id']));
242
  if (empty($body['o:tag'])) {
243
  $body['o:tag'] = $tags;
325
 
326
  $payload = null;
327
 
328
+ // Allow other plugins to apply body changes before writing the payload.
329
+ $body = apply_filters('mg_mutate_message_body', $body);
330
+
331
  // Iterate through pre-built params and build payload:
332
  foreach ($body as $key => $value) {
333
  if (is_array($value)) {
348
  }
349
  }
350
 
351
+ // Allow other plugins to apply attachent changes before writing to the payload.
352
+ $attachments = apply_filters('mg_mutate_attachments', $attachments);
353
+
354
  // If we have attachments, add them to the payload.
355
  if (!empty($attachments)) {
356
  $i = 0;
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.1
8
  * Author: Mailgun
9
  * Author URI: http://www.mailgun.com/
10
  * License: GPLv2 or later
4
  * Plugin Name: Mailgun
5
  * Plugin URI: http://wordpress.org/extend/plugins/mailgun/
6
  * Description: Mailgun integration for WordPress
7
+ * Version: 1.5.8.2
8
  * Author: Mailgun
9
  * Author URI: http://www.mailgun.com/
10
  * License: GPLv2 or later
readme.txt CHANGED
@@ -5,7 +5,7 @@ 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.7.1
8
- Stable tag: 1.5.8.1
9
  License: GPLv2 or later
10
 
11
 
@@ -63,6 +63,31 @@ MAILGUN_FROM_NAME Type: string
63
  MAILGUN_FROM_ADDRESS Type: string
64
  `
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  == Screenshots ==
68
 
@@ -76,6 +101,12 @@ MAILGUN_FROM_ADDRESS Type: string
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
79
  = 1.5.8.1 (2017-02-06): =
80
  - Fix "Undefined property: MailgunAdmin::$hook_suffix" (#48)
81
  - Fix "Undefined variable: from_name on every email process" (API and SMTP) (#49)
5
  Tags: mailgun, smtp, http, api, mail, email
6
  Requires at least: 3.3
7
  Tested up to: 4.7.1
8
+ Stable tag: 1.5.8.2
9
  License: GPLv2 or later
10
 
11
 
63
  MAILGUN_FROM_ADDRESS Type: string
64
  `
65
 
66
+ - What hooks are available for use with other plugins?
67
+
68
+ `mg_use_recipient_vars_syntax`
69
+ Mutates messages to use recipient variables syntax - see
70
+ https://documentation.mailgun.com/user_manual.html#batch-sending for more info.
71
+
72
+ Should accept a list of `To` addressses.
73
+
74
+ Should *only* return `true` or `false`.
75
+
76
+ `mg_mutate_message_body`
77
+ Allows an external plugin to mutate the message body before sending.
78
+
79
+ Should accept an array, `$body`.
80
+
81
+ Should return a new array to replace `$body`.
82
+
83
+ `mg_mutate_attachments`
84
+ Allows an external plugin to mutate the attachments on the message before
85
+ sending.
86
+
87
+ Should accept an array, `$attachments`.
88
+
89
+ Should return a new array to replace `$attachments`.
90
+
91
 
92
  == Screenshots ==
93
 
101
 
102
  == Changelog ==
103
 
104
+ = 1.5.8.2 (2017-02-27): =
105
+ - Fix a bug causing empty tags to be sent with messages (#51)
106
+ - Add `mg_mutate_message_body` hook to allow other plugins to modify the message body before send
107
+ - Add `mg_mutate_attachments` hook to allow other plugins to modify the message attachments before send
108
+ - Fix a bug causing the AJAX test to fail incorrectly.
109
+
110
  = 1.5.8.1 (2017-02-06): =
111
  - Fix "Undefined property: MailgunAdmin::$hook_suffix" (#48)
112
  - Fix "Undefined variable: from_name on every email process" (API and SMTP) (#49)