Version Description
(2016-12-22): =
* Changed all bracketed array usages to array()
syntax for older PHP support
* Redesigned Content-Type
processing code to not make such large assumptions
* Mailgun logo is now loaded over HTTPS
* Fixed undefined variable issue with from email / from name code
Download this release
Release Info
Developer | Mailgun |
Plugin | Mailgun for WordPress |
Version | 1.5.3 |
Comparing to | |
See all releases |
Code changes from version 1.5.2 to 1.5.3
- CHANGELOG.md +6 -0
- includes/admin.php +11 -11
- includes/lists-page.php +1 -1
- includes/options-page.php +1 -1
- includes/widget.php +1 -1
- includes/wp-mail.php +29 -34
- mailgun.php +8 -8
- readme.txt +7 -1
CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1 |
Changelog
|
2 |
=========
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
1.5.2 (2016-12-22):
|
5 |
* Added option fields for setting a From name and address
|
6 |
|
1 |
Changelog
|
2 |
=========
|
3 |
|
4 |
+
1.5.3 (2016-12-22):
|
5 |
+
* Changed all bracketed array usages to `array()` syntax for older PHP support
|
6 |
+
* Redesigned `Content-Type` processing code to not make such large assumptions
|
7 |
+
* Mailgun logo is now loaded over HTTPS
|
8 |
+
* Fixed undefined variable issue with from email / from name code
|
9 |
+
|
10 |
1.5.2 (2016-12-22):
|
11 |
* Added option fields for setting a From name and address
|
12 |
|
includes/admin.php
CHANGED
@@ -36,18 +36,18 @@ class MailgunAdmin extends Mailgun
|
|
36 |
load_plugin_textdomain('mailgun', false, 'mailgun/languages');
|
37 |
|
38 |
// Activation hook
|
39 |
-
register_activation_hook($this->plugin_file,
|
40 |
|
41 |
if (!defined('MAILGUN_USEAPI') || !MAILGUN_USEAPI) {
|
42 |
// Hook into admin_init and register settings and potentially register an admin_notice
|
43 |
-
add_action('admin_init',
|
44 |
|
45 |
// Activate the options page
|
46 |
-
add_action('admin_menu',
|
47 |
}
|
48 |
|
49 |
// Register an AJAX action for testing mail sending capabilities
|
50 |
-
add_action('wp_ajax_mailgun-test',
|
51 |
}
|
52 |
|
53 |
/**
|
@@ -92,11 +92,11 @@ class MailgunAdmin extends Mailgun
|
|
92 |
public function admin_menu()
|
93 |
{
|
94 |
if (current_user_can('manage_options')) {
|
95 |
-
$this->hook_suffix = add_options_page(__('Mailgun', 'mailgun'), __('Mailgun', 'mailgun'), 'manage_options', 'mailgun',
|
96 |
-
add_options_page(__('Mailgun Lists', 'mailgun'), __('Mailgun Lists', 'mailgun'), 'manage_options', 'mailgun-lists',
|
97 |
-
add_action("admin_print_scripts-{$this->hook_suffix}",
|
98 |
-
add_filter("plugin_action_links_{$this->plugin_basename}",
|
99 |
-
add_action("admin_footer-{$this->hook_suffix}",
|
100 |
}
|
101 |
}
|
102 |
|
@@ -224,7 +224,7 @@ class MailgunAdmin extends Mailgun
|
|
224 |
$useAPI = $this->get_option('useAPI');
|
225 |
$password = $this->get_option('password');
|
226 |
if ((empty($apiKey) && $useAPI == '1') || (empty($password) && $useAPI == '0')) {
|
227 |
-
add_action('admin_notices',
|
228 |
}
|
229 |
}
|
230 |
|
@@ -237,7 +237,7 @@ class MailgunAdmin extends Mailgun
|
|
237 |
*/
|
238 |
public function register_settings()
|
239 |
{
|
240 |
-
register_setting('mailgun', 'mailgun',
|
241 |
}
|
242 |
|
243 |
/**
|
36 |
load_plugin_textdomain('mailgun', false, 'mailgun/languages');
|
37 |
|
38 |
// Activation hook
|
39 |
+
register_activation_hook($this->plugin_file, array(&$this, 'init'));
|
40 |
|
41 |
if (!defined('MAILGUN_USEAPI') || !MAILGUN_USEAPI) {
|
42 |
// Hook into admin_init and register settings and potentially register an admin_notice
|
43 |
+
add_action('admin_init', array(&$this, 'admin_init'));
|
44 |
|
45 |
// Activate the options page
|
46 |
+
add_action('admin_menu', array(&$this, 'admin_menu'));
|
47 |
}
|
48 |
|
49 |
// Register an AJAX action for testing mail sending capabilities
|
50 |
+
add_action('wp_ajax_mailgun-test', array(&$this, 'ajax_send_test'));
|
51 |
}
|
52 |
|
53 |
/**
|
92 |
public function admin_menu()
|
93 |
{
|
94 |
if (current_user_can('manage_options')) {
|
95 |
+
$this->hook_suffix = add_options_page(__('Mailgun', 'mailgun'), __('Mailgun', 'mailgun'), 'manage_options', 'mailgun', array(&$this, 'options_page'));
|
96 |
+
add_options_page(__('Mailgun Lists', 'mailgun'), __('Mailgun Lists', 'mailgun'), 'manage_options', 'mailgun-lists', array(&$this, 'lists_page'));
|
97 |
+
add_action("admin_print_scripts-{$this->hook_suffix}", array(&$this, 'admin_js'));
|
98 |
+
add_filter("plugin_action_links_{$this->plugin_basename}", array(&$this, 'filter_plugin_actions'));
|
99 |
+
add_action("admin_footer-{$this->hook_suffix}", array(&$this, 'admin_footer_js'));
|
100 |
}
|
101 |
}
|
102 |
|
224 |
$useAPI = $this->get_option('useAPI');
|
225 |
$password = $this->get_option('password');
|
226 |
if ((empty($apiKey) && $useAPI == '1') || (empty($password) && $useAPI == '0')) {
|
227 |
+
add_action('admin_notices', array(&$this, 'admin_notices'));
|
228 |
}
|
229 |
}
|
230 |
|
237 |
*/
|
238 |
public function register_settings()
|
239 |
{
|
240 |
+
register_setting('mailgun', 'mailgun', array(&$this, 'validation'));
|
241 |
}
|
242 |
|
243 |
/**
|
includes/lists-page.php
CHANGED
@@ -44,7 +44,7 @@ $lists_arr = $mailgun->get_lists();
|
|
44 |
|
45 |
<span class="alignright">
|
46 |
<a target="_blank" href="http://www.mailgun.com/">
|
47 |
-
<img src="
|
48 |
</a>
|
49 |
</span>
|
50 |
|
44 |
|
45 |
<span class="alignright">
|
46 |
<a target="_blank" href="http://www.mailgun.com/">
|
47 |
+
<img src="https://www.mailgun.com/static/img/mailgun.svg" alt="Mailgun" style="width: 10em;"/>
|
48 |
</a>
|
49 |
</span>
|
50 |
|
includes/options-page.php
CHANGED
@@ -22,7 +22,7 @@
|
|
22 |
?>
|
23 |
<div class="wrap">
|
24 |
<div id="icon-options-general" class="icon32"><br /></div>
|
25 |
-
<span class="alignright"><a target="_blank" href="http://www.mailgun.com/"><img src="
|
26 |
<h2><?php _e('Mailgun', 'mailgun'); ?></h2>
|
27 |
<p>A <a target="_blank" href="http://www.mailgun.com/">Mailgun</a> account is required to use this plugin and the Mailgun service.</p>
|
28 |
<p>If you need to register for an account, you can do so at <a target="_blank" href="http://www.mailgun.com/">http://www.mailgun.com/</a>.</p>
|
22 |
?>
|
23 |
<div class="wrap">
|
24 |
<div id="icon-options-general" class="icon32"><br /></div>
|
25 |
+
<span class="alignright"><a target="_blank" href="http://www.mailgun.com/"><img src="https://www.mailgun.com/static/img/mailgun.svg" alt="Mailgun" style="width: 10em;"/></a></span>
|
26 |
<h2><?php _e('Mailgun', 'mailgun'); ?></h2>
|
27 |
<p>A <a target="_blank" href="http://www.mailgun.com/">Mailgun</a> account is required to use this plugin and the Mailgun service.</p>
|
28 |
<p>If you need to register for an account, you can do so at <a target="_blank" href="http://www.mailgun.com/">http://www.mailgun.com/</a>.</p>
|
includes/widget.php
CHANGED
@@ -29,7 +29,7 @@ class list_widget extends WP_Widget
|
|
29 |
// Widget name will appear in UI
|
30 |
__('Mailgun List Widget', 'wpb_widget_domain'),
|
31 |
// Widget description
|
32 |
-
|
33 |
);
|
34 |
}
|
35 |
|
29 |
// Widget name will appear in UI
|
30 |
__('Mailgun List Widget', 'wpb_widget_domain'),
|
31 |
// Widget description
|
32 |
+
array('description' => __('Mailgun list widget', 'wpb_widget_domain'))
|
33 |
);
|
34 |
}
|
35 |
|
includes/wp-mail.php
CHANGED
@@ -99,7 +99,7 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
|
|
99 |
if (strpos($header, ':') === false) {
|
100 |
if (false !== stripos($header, 'boundary=')) {
|
101 |
$parts = preg_split('/boundary=/i', trim($header));
|
102 |
-
$boundary = trim(str_replace(
|
103 |
}
|
104 |
continue;
|
105 |
}
|
@@ -131,9 +131,9 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
|
|
131 |
list($type, $charset) = explode(';', $content);
|
132 |
$content_type = trim($type);
|
133 |
if (false !== stripos($charset, 'charset=')) {
|
134 |
-
$charset = trim(str_replace(
|
135 |
} elseif (false !== stripos($charset, 'boundary=')) {
|
136 |
-
$boundary = trim(str_replace(
|
137 |
$charset = '';
|
138 |
}
|
139 |
} else {
|
@@ -157,11 +157,17 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
|
|
157 |
|
158 |
// Attempt to apply external filters to these values before using our own.
|
159 |
if (has_filter('wp_mail_from')) {
|
160 |
-
$from_email = apply_filters(
|
|
|
|
|
|
|
161 |
}
|
162 |
|
163 |
if (has_filter('wp_mail_from_name')) {
|
164 |
-
$from_name = apply_filters(
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
// From email and name
|
@@ -232,37 +238,26 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
|
|
232 |
// text/html and *attempt* to strip tags and provide a text/plain
|
233 |
// version.
|
234 |
if (!isset($content_type)) {
|
235 |
-
//
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
$body['text'] = $message;
|
240 |
-
// <br /> tags need a space in front of them because otherwise,
|
241 |
-
// URLs with a EOL directly following get missed by Mailgun's
|
242 |
-
// URL eater.
|
243 |
-
$body['html'] = str_replace(["\r\n", "\r", "\n"], ' <br />', $message);
|
244 |
} else {
|
245 |
-
//
|
246 |
-
|
247 |
-
|
248 |
-
// final Content-Type of multipart.
|
249 |
-
if ($content_type === 'text/html') {
|
250 |
-
$body['html'] = $message;
|
251 |
-
// It won't be pretty, but just use the HTML message as the text
|
252 |
-
// part. No escape, no strip tags. In the case of WP's password
|
253 |
-
// reset, both of those would blow up the URL since it is wrapped
|
254 |
-
// in < >.
|
255 |
-
$body['text'] = $message;
|
256 |
-
} elseif ($content_type === 'text/plain') {
|
257 |
-
$content_type = 'text/html';
|
258 |
-
$body['text'] = $message;
|
259 |
-
// Add HTML line breaks for each newline.
|
260 |
-
$body['html'] = nl2br($message);
|
261 |
-
} else {
|
262 |
-
// Unknown Content-Type??
|
263 |
-
$body['text'] = $message;
|
264 |
-
$body['html'] = $message;
|
265 |
-
}
|
266 |
}
|
267 |
|
268 |
// If we don't have a charset from the input headers
|
99 |
if (strpos($header, ':') === false) {
|
100 |
if (false !== stripos($header, 'boundary=')) {
|
101 |
$parts = preg_split('/boundary=/i', trim($header));
|
102 |
+
$boundary = trim(str_replace(array("'", '"'), '', $parts[1]));
|
103 |
}
|
104 |
continue;
|
105 |
}
|
131 |
list($type, $charset) = explode(';', $content);
|
132 |
$content_type = trim($type);
|
133 |
if (false !== stripos($charset, 'charset=')) {
|
134 |
+
$charset = trim(str_replace(array('charset=', '"'), '', $charset));
|
135 |
} elseif (false !== stripos($charset, 'boundary=')) {
|
136 |
+
$boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset));
|
137 |
$charset = '';
|
138 |
}
|
139 |
} else {
|
157 |
|
158 |
// Attempt to apply external filters to these values before using our own.
|
159 |
if (has_filter('wp_mail_from')) {
|
160 |
+
$from_email = apply_filters(
|
161 |
+
'wp_mail_from',
|
162 |
+
isset($from_email) ? $from_email : null
|
163 |
+
);
|
164 |
}
|
165 |
|
166 |
if (has_filter('wp_mail_from_name')) {
|
167 |
+
$from_name = apply_filters(
|
168 |
+
'wp_mail_from_name',
|
169 |
+
isset($from_name) ? $from_name : null
|
170 |
+
);
|
171 |
}
|
172 |
|
173 |
// From email and name
|
238 |
// text/html and *attempt* to strip tags and provide a text/plain
|
239 |
// version.
|
240 |
if (!isset($content_type)) {
|
241 |
+
// Try to figure out the content type with mime_content_type.
|
242 |
+
$tmppath = tempnam(sys_get_temp_dir(), 'mg');
|
243 |
+
$tmp = fopen($tmppath, 'w+');
|
244 |
+
|
245 |
+
fwrite($tmp, $message);
|
246 |
+
fclose($tmp);
|
247 |
+
|
248 |
+
// Get mime type with mime_content_type
|
249 |
+
$content_type = mime_content_type($tmppath);
|
250 |
+
|
251 |
+
// Remove the tmpfile
|
252 |
+
unlink($tmppath);
|
253 |
+
}
|
254 |
+
|
255 |
+
if ('text/plain' === $content_type) {
|
256 |
$body['text'] = $message;
|
|
|
|
|
|
|
|
|
257 |
} else {
|
258 |
+
// Unknown Content-Type??
|
259 |
+
$body['text'] = $message;
|
260 |
+
$body['html'] = $message;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
}
|
262 |
|
263 |
// If we don't have a charset from the input headers
|
mailgun.php
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
* Plugin Name: Mailgun
|
24 |
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
25 |
* Description: Mailgun integration for WordPress
|
26 |
-
* Version: 1.5.
|
27 |
* Author: Mailgun
|
28 |
* Author URI: http://www.mailgun.com/
|
29 |
* License: GPLv2 or later
|
@@ -55,7 +55,7 @@ class Mailgun
|
|
55 |
}
|
56 |
}
|
57 |
} else {
|
58 |
-
add_action('phpmailer_init',
|
59 |
}
|
60 |
}
|
61 |
|
@@ -226,9 +226,9 @@ class Mailgun
|
|
226 |
);
|
227 |
}
|
228 |
|
229 |
-
echo json_encode(
|
230 |
} else {
|
231 |
-
echo json_encode(
|
232 |
}
|
233 |
|
234 |
wp_die();
|
@@ -411,16 +411,16 @@ class Mailgun
|
|
411 |
public function load_list_widget()
|
412 |
{
|
413 |
register_widget('list_widget');
|
414 |
-
add_shortcode('mailgun',
|
415 |
}
|
416 |
}
|
417 |
|
418 |
$mailgun = new Mailgun();
|
419 |
|
420 |
if (@include dirname(__FILE__).'/includes/widget.php') {
|
421 |
-
add_action('widgets_init',
|
422 |
-
add_action('wp_ajax_nopriv_add_list',
|
423 |
-
add_action('wp_ajax_add_list',
|
424 |
}
|
425 |
|
426 |
if (is_admin()) {
|
23 |
* Plugin Name: Mailgun
|
24 |
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
25 |
* Description: Mailgun integration for WordPress
|
26 |
+
* Version: 1.5.3
|
27 |
* Author: Mailgun
|
28 |
* Author URI: http://www.mailgun.com/
|
29 |
* License: GPLv2 or later
|
55 |
}
|
56 |
}
|
57 |
} else {
|
58 |
+
add_action('phpmailer_init', array(&$this, 'phpmailer_init'));
|
59 |
}
|
60 |
}
|
61 |
|
226 |
);
|
227 |
}
|
228 |
|
229 |
+
echo json_encode(array('status' => 200, 'message' => 'Thank you!'));
|
230 |
} else {
|
231 |
+
echo json_encode(array('status' => 500, 'message' => 'Uh oh. We weren\'t able to add you to the list'.count($list_addresses) ? 's.' : '. Please try again.'));
|
232 |
}
|
233 |
|
234 |
wp_die();
|
411 |
public function load_list_widget()
|
412 |
{
|
413 |
register_widget('list_widget');
|
414 |
+
add_shortcode('mailgun', array(&$this, 'build_list_form'));
|
415 |
}
|
416 |
}
|
417 |
|
418 |
$mailgun = new Mailgun();
|
419 |
|
420 |
if (@include dirname(__FILE__).'/includes/widget.php') {
|
421 |
+
add_action('widgets_init', array(&$mailgun, 'load_list_widget'));
|
422 |
+
add_action('wp_ajax_nopriv_add_list', array(&$mailgun, 'add_list'));
|
423 |
+
add_action('wp_ajax_add_list', array(&$mailgun, 'add_list'));
|
424 |
}
|
425 |
|
426 |
if (is_admin()) {
|
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
|
8 |
-
Stable tag: 1.5.
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
|
@@ -68,6 +68,12 @@ MAILGUN_SECURE Type: boolean
|
|
68 |
|
69 |
== Changelog ==
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
= 1.5.2 (2016-12-22): =
|
72 |
* Added option fields for setting a From name and address
|
73 |
|
5 |
Tags: mailgun, smtp, http, api, mail, email
|
6 |
Requires at least: 3.3
|
7 |
Tested up to: 4.7
|
8 |
+
Stable tag: 1.5.3
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
|
68 |
|
69 |
== Changelog ==
|
70 |
|
71 |
+
= 1.5.3 (2016-12-22): =
|
72 |
+
* Changed all bracketed array usages to `array()` syntax for older PHP support
|
73 |
+
* Redesigned `Content-Type` processing code to not make such large assumptions
|
74 |
+
* Mailgun logo is now loaded over HTTPS
|
75 |
+
* Fixed undefined variable issue with from email / from name code
|
76 |
+
|
77 |
= 1.5.2 (2016-12-22): =
|
78 |
* Added option fields for setting a From name and address
|
79 |
|