Version Description
(2017-11-22): =
- Fix back to settings link on lists page (https://github.com/mailgun/wordpress-plugin/pull/65)
- Fix a bug causing text/html
emails to send as both text/plain
and text/html
parts
Download this release
Release Info
Developer | Mailgun |
Plugin | Mailgun for WordPress |
Version | 1.5.10 |
Comparing to | |
See all releases |
Code changes from version 1.7.1 to 1.5.10
- .gitignore +0 -1
- CHANGELOG.md +0 -49
- includes/admin.php +431 -474
- includes/lists-page.php +10 -10
- includes/mg-filter.php +17 -53
- includes/options-page.php +196 -392
- includes/wp-mail-api.php +12 -21
- languages/mailgun-template.po +4 -0
- mailgun.php +450 -479
- readme.txt +7 -58
.gitignore
CHANGED
@@ -1,2 +1 @@
|
|
1 |
svn/
|
2 |
-
.idea/
|
1 |
svn/
|
|
CHANGELOG.md
CHANGED
@@ -1,55 +1,6 @@
|
|
1 |
Changelog
|
2 |
=========
|
3 |
|
4 |
-
1.7.1 (2019-02-07)
|
5 |
-
- Reinstall settings page for multisites.
|
6 |
-
|
7 |
-
1.7 (2019-01-21)
|
8 |
-
- Remove settings page for multisites.
|
9 |
-
- Simplify admin notifications.
|
10 |
-
- Test plugin with PHP 7.2.
|
11 |
-
- Test plugin up to WordPress 5.0.3.
|
12 |
-
|
13 |
-
1.6.1 (2018-10-08)
|
14 |
-
- Restore Settings page form for all install types.
|
15 |
-
|
16 |
-
1.6 (2018-9-21)
|
17 |
-
- Refactor admin notifications
|
18 |
-
- Enable Settings page for all WordPress install types
|
19 |
-
- Enable Test Configuration for all WordPress install types
|
20 |
-
- Test plugin up to WordPress 4.9.8.
|
21 |
-
|
22 |
-
1.5.14 (2018-09-11)
|
23 |
-
- Force SSL-secured SMTP connections to use port 465 (SMTPS) to connect, 587 for plain and TLS
|
24 |
-
- Support region endpoint switching for SMTP
|
25 |
-
|
26 |
-
1.5.13.1 (2018-08-15)
|
27 |
-
- Fix line breaks in Test Configuration email
|
28 |
-
|
29 |
-
1.5.13 (2018-08-14)
|
30 |
-
- Default to US region if no region is configured in settings
|
31 |
-
- Add admin notification about region configuration
|
32 |
-
- Log an error message when an email is sent with no explicit region configured
|
33 |
-
|
34 |
-
1.5.12.3 (2018-08-09)
|
35 |
-
- Fix Region select menu default when wp-config.php variable is set
|
36 |
-
- Fix front end email input validation
|
37 |
-
|
38 |
-
1.5.12.2 (2018-08-09)
|
39 |
-
- Fix plugin not saving after update
|
40 |
-
|
41 |
-
1.5.12.1 (2018-08-06)
|
42 |
-
- Fix for backwards compatibility
|
43 |
-
|
44 |
-
1.5.12 (2018-08-02)
|
45 |
-
- Add EU endpoint for Mailgun HTTP API
|
46 |
-
- Fix broken logo image on Lists page
|
47 |
-
- Test plugin up to Wordpress 4.9.7
|
48 |
-
|
49 |
-
1.5.11 (2018-05-30):
|
50 |
-
- Fix an issue with authentication failing for newer API keys
|
51 |
-
- Test plugin up to Wordpress 4.9.6
|
52 |
-
|
53 |
1.5.10 (2017-11-22):
|
54 |
- Fix back to settings link on lists page (https://github.com/mailgun/wordpress-plugin/pull/65)
|
55 |
- Fix a bug causing `text/html` emails to send as both `text/plain` *and* `text/html` parts
|
1 |
Changelog
|
2 |
=========
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
1.5.10 (2017-11-22):
|
5 |
- Fix back to settings link on lists page (https://github.com/mailgun/wordpress-plugin/pull/65)
|
6 |
- Fix a bug causing `text/html` emails to send as both `text/plain` *and* `text/html` parts
|
includes/admin.php
CHANGED
@@ -1,484 +1,441 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
<script type="text/javascript">
|
137 |
-
/* <![CDATA[ */
|
138 |
-
var mailgunApiOrNot = function () {
|
139 |
-
if (jQuery('#mailgun-api').val() == 1) {
|
140 |
-
jQuery('.mailgun-smtp').hide()
|
141 |
-
jQuery('.mailgun-api').show()
|
142 |
} else {
|
143 |
-
|
144 |
-
|
145 |
}
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
mailgunApiOrNot()
|
151 |
-
jQuery('#mailgun-api').change(function
|
152 |
-
|
153 |
-
})
|
154 |
-
jQuery('#mailgun-test').click(function
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
}
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
jQuery('#mailgun-test').val('<?php _e('Test Configuration', 'mailgun'); ?>')
|
174 |
-
})
|
175 |
-
.success(function (data) {
|
176 |
-
alert(
|
177 |
-
'Mailgun ' + data.method + ' Test ' + data.message
|
178 |
-
+ '; status "' + data.error + '"'
|
179 |
-
)
|
180 |
})
|
181 |
-
.
|
182 |
-
|
|
|
|
|
|
|
183 |
})
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
})
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
<?php
|
335 |
-
printf(
|
336 |
-
__('Mailgun now supports multiple regions! The U.S. region will be used by default, but you can choose the EU region. You can configure your Mailgun settings in your wp-config.php file or <a href="%1$s">here</a>',
|
337 |
-
'mailgun'),
|
338 |
-
menu_page_url('mailgun', false)
|
339 |
-
);
|
340 |
-
?>
|
341 |
-
</p>
|
342 |
-
</div>
|
343 |
<?php
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
<?php _e('Mailgun is almost ready. ', 'mailgun'); ?>
|
354 |
-
</strong>
|
355 |
-
<?php
|
356 |
-
printf(
|
357 |
-
__('"Override From" option requires that "From Name" and "From Address" be set to work properly! <a href="%1$s">Configure Mailgun now</a>.',
|
358 |
-
'mailgun'),
|
359 |
-
menu_page_url('mailgun', false)
|
360 |
-
);
|
361 |
-
?>
|
362 |
-
</p>
|
363 |
-
</div>
|
364 |
<?php
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
else:
|
473 |
-
die(
|
474 |
-
json_encode(
|
475 |
-
array(
|
476 |
-
'message' => __('Failure', 'mailgun'),
|
477 |
-
'method' => $method,
|
478 |
-
'error' => $error_msg,
|
479 |
-
)
|
480 |
-
)
|
481 |
-
);
|
482 |
-
endif;
|
483 |
-
}
|
484 |
-
}
|
1 |
<?php
|
2 |
|
3 |
+
/*
|
4 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
5 |
+
* Copyright (C) 2016 Mailgun, et al.
|
6 |
+
*
|
7 |
+
* This program is free software; you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License along
|
18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
+
*/
|
21 |
+
|
22 |
+
class MailgunAdmin extends Mailgun
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* @var array Array of "safe" option defaults.
|
26 |
+
*/
|
27 |
+
private $defaults;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Setup backend functionality in WordPress.
|
31 |
+
*
|
32 |
+
* @return none
|
33 |
+
*
|
34 |
+
* @since 0.1
|
35 |
+
*/
|
36 |
+
public function __construct()
|
37 |
+
{
|
38 |
+
Mailgun::__construct();
|
39 |
+
|
40 |
+
// Load localizations if available
|
41 |
+
load_plugin_textdomain('mailgun', false, 'mailgun/languages');
|
42 |
+
|
43 |
+
// Activation hook
|
44 |
+
register_activation_hook($this->plugin_file, array(&$this, 'init'));
|
45 |
+
|
46 |
+
if (!defined('MAILGUN_USEAPI') || !MAILGUN_USEAPI) {
|
47 |
+
// Hook into admin_init and register settings and potentially register an admin_notice
|
48 |
+
add_action('admin_init', array(&$this, 'admin_init'));
|
49 |
+
|
50 |
+
// Activate the options page
|
51 |
+
add_action('admin_menu', array(&$this, 'admin_menu'));
|
52 |
+
}
|
53 |
+
|
54 |
+
// Register an AJAX action for testing mail sending capabilities
|
55 |
+
add_action('wp_ajax_mailgun-test', array(&$this, 'ajax_send_test'));
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Initialize the default options during plugin activation.
|
60 |
+
*
|
61 |
+
* @return none
|
62 |
+
*
|
63 |
+
* @since 0.1
|
64 |
+
*/
|
65 |
+
public function init()
|
66 |
+
{
|
67 |
+
$sitename = strtolower($_SERVER['SERVER_NAME']);
|
68 |
+
if (substr($sitename, 0, 4) == 'www.') {
|
69 |
+
$sitename = substr($sitename, 4);
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->defaults = array(
|
73 |
+
'useAPI' => '1',
|
74 |
+
'apiKey' => '',
|
75 |
+
'domain' => '',
|
76 |
+
'username' => '',
|
77 |
+
'password' => '',
|
78 |
+
'secure' => '1',
|
79 |
+
'sectype' => 'tls',
|
80 |
+
'track-clicks' => '',
|
81 |
+
'track-opens' => '',
|
82 |
+
'campaign-id' => '',
|
83 |
+
'override-from' => '0',
|
84 |
+
'tag' => $sitename,
|
85 |
+
);
|
86 |
+
if (!$this->options) {
|
87 |
+
$this->options = $this->defaults;
|
88 |
+
add_option('mailgun', $this->options);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Add the options page.
|
94 |
+
*
|
95 |
+
* @return none
|
96 |
+
*
|
97 |
+
* @since 0.1
|
98 |
+
*/
|
99 |
+
public function admin_menu()
|
100 |
+
{
|
101 |
+
if (current_user_can('manage_options')) {
|
102 |
+
$this->hook_suffix = add_options_page(__('Mailgun', 'mailgun'), __('Mailgun', 'mailgun'), 'manage_options', 'mailgun', array(&$this, 'options_page'));
|
103 |
+
add_options_page(__('Mailgun Lists', 'mailgun'), __('Mailgun Lists', 'mailgun'), 'manage_options', 'mailgun-lists', array(&$this, 'lists_page'));
|
104 |
+
add_action("admin_print_scripts-{$this->hook_suffix}", array(&$this, 'admin_js'));
|
105 |
+
add_filter("plugin_action_links_{$this->plugin_basename}", array(&$this, 'filter_plugin_actions'));
|
106 |
+
add_action("admin_footer-{$this->hook_suffix}", array(&$this, 'admin_footer_js'));
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Enqueue javascript required for the admin settings page.
|
112 |
+
*
|
113 |
+
* @return none
|
114 |
+
*
|
115 |
+
* @since 0.1
|
116 |
+
*/
|
117 |
+
public function admin_js()
|
118 |
+
{
|
119 |
+
wp_enqueue_script('jquery');
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Output JS to footer for enhanced admin page functionality.
|
124 |
+
*
|
125 |
+
* @since 0.1
|
126 |
+
*/
|
127 |
+
public function admin_footer_js()
|
128 |
+
{
|
129 |
+
?>
|
130 |
+
<script type="text/javascript">
|
131 |
+
/* <![CDATA[ */
|
132 |
+
var mailgunApiOrNot = function() {
|
133 |
+
if (jQuery("#mailgun-api").val() == 1) {
|
134 |
+
jQuery(".mailgun-smtp").hide();
|
135 |
+
jQuery(".mailgun-api").show();
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
} else {
|
137 |
+
jQuery(".mailgun-api").hide();
|
138 |
+
jQuery(".mailgun-smtp").show();
|
139 |
}
|
140 |
|
141 |
+
}
|
142 |
+
var formModified = false;
|
143 |
+
jQuery().ready(function() {
|
144 |
+
mailgunApiOrNot();
|
145 |
+
jQuery('#mailgun-api').change(function() {
|
146 |
+
mailgunApiOrNot();
|
147 |
+
});
|
148 |
+
jQuery('#mailgun-test').click(function(e) {
|
149 |
+
e.preventDefault();
|
150 |
+
if ( formModified ) {
|
151 |
+
var doTest = confirm('<?php _e('The Mailgun plugin configuration has changed since you last saved. Do you wish to test anyway?\n\nClick "Cancel" and then "Save Changes" if you wish to save your changes.', 'mailgun'); ?>');
|
152 |
+
if ( ! doTest ) {
|
153 |
+
return false;
|
154 |
+
}
|
155 |
}
|
156 |
+
jQuery(this).val('<?php _e('Testing...', 'mailgun'); ?>');
|
157 |
+
jQuery("#mailgun-test-result").text('');
|
158 |
+
jQuery.get(
|
159 |
+
ajaxurl,
|
160 |
+
{
|
161 |
+
action: 'mailgun-test',
|
162 |
+
_wpnonce: '<?php echo wp_create_nonce(); ?>'
|
163 |
+
}
|
164 |
+
)
|
165 |
+
.complete(function() {
|
166 |
+
jQuery("#mailgun-test").val('<?php _e('Test Configuration', 'mailgun'); ?>');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
})
|
168 |
+
.success(function(data) {
|
169 |
+
alert(
|
170 |
+
'Mailgun ' + data.method + ' Test ' + data.message
|
171 |
+
+ '; status "' + data.error + '"'
|
172 |
+
);
|
173 |
})
|
174 |
+
.error(function() {
|
175 |
+
alert('Mailgun Test <?php _e('Failure', 'mailgun'); ?>');
|
176 |
+
});
|
177 |
+
});
|
178 |
+
jQuery("#mailgun-form").change(function() {
|
179 |
+
formModified = true;
|
180 |
+
});
|
181 |
+
});
|
182 |
+
/* ]]> */
|
183 |
+
</script>
|
184 |
+
<?php
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Output the options page.
|
190 |
+
*
|
191 |
+
* @return none
|
192 |
+
*
|
193 |
+
* @since 0.1
|
194 |
+
*/
|
195 |
+
public function options_page()
|
196 |
+
{
|
197 |
+
if (!@include 'options-page.php') {
|
198 |
+
printf(__('<div id="message" class="updated fade"><p>The options page for the <strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</strong> is missing. Please reinstall the plugin.</p></div>', 'mailgun'), dirname(__FILE__).'/options-page.php');
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Output the lists page.
|
204 |
+
*
|
205 |
+
* @return none
|
206 |
+
*
|
207 |
+
* @since 0.1
|
208 |
+
*/
|
209 |
+
public function lists_page()
|
210 |
+
{
|
211 |
+
if (!@include 'lists-page.php') {
|
212 |
+
printf(__('<div id="message" class="updated fade"><p>The lists page for the <strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</strong> is missing. Please reinstall the plugin.</p></div>', 'mailgun'), dirname(__FILE__).'/lists-page.php');
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
// /options-general.php?page=mailgun-lists
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Wrapper function hooked into admin_init to register settings
|
220 |
+
* and potentially register an admin notice if the plugin hasn't
|
221 |
+
* been configured yet.
|
222 |
+
*
|
223 |
+
* @return none
|
224 |
+
*
|
225 |
+
* @since 0.1
|
226 |
+
*/
|
227 |
+
public function admin_init()
|
228 |
+
{
|
229 |
+
$this->register_settings();
|
230 |
+
$apiKey = $this->get_option('apiKey');
|
231 |
+
$useAPI = $this->get_option('useAPI');
|
232 |
+
$password = $this->get_option('password');
|
233 |
+
|
234 |
+
add_action('admin_notices', array(&$this, 'admin_notices'));
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Whitelist the mailgun options.
|
239 |
+
*
|
240 |
+
* @since 0.1
|
241 |
+
*
|
242 |
+
* @return none
|
243 |
+
*/
|
244 |
+
public function register_settings()
|
245 |
+
{
|
246 |
+
register_setting('mailgun', 'mailgun', array(&$this, 'validation'));
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Data validation callback function for options.
|
251 |
+
*
|
252 |
+
* @param array $options An array of options posted from the options page
|
253 |
+
*
|
254 |
+
* @return array
|
255 |
+
*
|
256 |
+
* @since 0.1
|
257 |
+
*/
|
258 |
+
public function validation($options)
|
259 |
+
{
|
260 |
+
$apiKey = trim($options['apiKey']);
|
261 |
+
$username = trim($options['username']);
|
262 |
+
if (!empty($apiKey)) {
|
263 |
+
$pos = strpos($apiKey, 'key-');
|
264 |
+
if ($pos === false || $pos > 4) {
|
265 |
+
$apiKey = "key-{$apiKey}";
|
266 |
+
}
|
267 |
+
|
268 |
+
$pos = strpos($apiKey, 'api:');
|
269 |
+
if ($pos !== false && $pos == 0) {
|
270 |
+
$apiKey = substr($apiKey, 4);
|
271 |
+
}
|
272 |
+
$options['apiKey'] = $apiKey;
|
273 |
+
}
|
274 |
+
|
275 |
+
if (!empty($username)) {
|
276 |
+
$username = preg_replace('/@.+$/', '', $username);
|
277 |
+
$options['username'] = $username;
|
278 |
+
}
|
279 |
+
|
280 |
+
foreach ($options as $key => $value) {
|
281 |
+
$options[$key] = trim($value);
|
282 |
+
}
|
283 |
+
|
284 |
+
if (empty($options['override-from'])) {
|
285 |
+
$options['override-from'] = $this->defaults['override-from'];
|
286 |
+
}
|
287 |
+
|
288 |
+
if (empty($options['sectype'])) {
|
289 |
+
$options['sectype'] = $this->defaults['sectype'];
|
290 |
+
}
|
291 |
+
// alternatively:
|
292 |
+
// foreach ($defaults as $key => $value) {
|
293 |
+
// if (empty($options[$key])) {
|
294 |
+
// $options[$key] = $value;
|
295 |
+
// }
|
296 |
+
// }
|
297 |
+
|
298 |
+
$this->options = $options;
|
299 |
+
|
300 |
+
return $options;
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Function to output an admin notice when the plugin has not
|
305 |
+
* been configured yet.
|
306 |
+
*
|
307 |
+
* @return none
|
308 |
+
*
|
309 |
+
* @since 0.1
|
310 |
+
*/
|
311 |
+
public function admin_notices()
|
312 |
+
{
|
313 |
+
$screen = get_current_screen();
|
314 |
+
if (!current_user_can('manage_options') || $screen->id == $this->hook_suffix
|
315 |
+
) {
|
316 |
+
return;
|
317 |
+
}
|
318 |
+
|
319 |
+
if ((!$this->get_option('apiKey') && $this->get_option('useAPI') === '1')
|
320 |
+
|| (!$this->get_option('password') && $this->get_option('useAPI') === '0')
|
321 |
+
) {
|
322 |
+
?>
|
323 |
+
<div id='mailgun-warning' class='notice notice-warning fade'><p><strong><?php _e('Mailgun is almost ready. ', 'mailgun'); ?></strong><?php printf(__('You must <a href="%1$s">configure Mailgun</a> for it to work.', 'mailgun'), menu_page_url('mailgun', false)); ?></p></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
<?php
|
325 |
+
|
326 |
+
}
|
327 |
+
|
328 |
+
if ($this->get_option('override-from') === '1'
|
329 |
+
&& (!$this->get_option('from-name')
|
330 |
+
|| !$this->get_option('from-address'))
|
331 |
+
) {
|
332 |
+
?>
|
333 |
+
<div id='mailgun-warning' class='notice notice-warning fade'><p><strong><?php _e('Mailgun is almost ready. ', 'mailgun'); ?></strong><?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)); ?></p></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
<?php
|
335 |
+
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Add a settings link to the plugin actions.
|
341 |
+
*
|
342 |
+
* @param array $links Array of the plugin action links
|
343 |
+
*
|
344 |
+
* @return array
|
345 |
+
*
|
346 |
+
* @since 0.1
|
347 |
+
*/
|
348 |
+
public function filter_plugin_actions($links)
|
349 |
+
{
|
350 |
+
$settings_link = '<a href="'.menu_page_url('mailgun', false).'">'.__('Settings', 'mailgun').'</a>';
|
351 |
+
array_unshift($links, $settings_link);
|
352 |
+
|
353 |
+
return $links;
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* AJAX callback function to test mail sending functionality.
|
358 |
+
*
|
359 |
+
* @return string
|
360 |
+
*
|
361 |
+
* @since 0.1
|
362 |
+
*/
|
363 |
+
public function ajax_send_test()
|
364 |
+
{
|
365 |
+
nocache_headers();
|
366 |
+
header('Content-Type: application/json');
|
367 |
+
|
368 |
+
if (!current_user_can('manage_options') || !wp_verify_nonce($_GET['_wpnonce'])) {
|
369 |
+
die(
|
370 |
+
json_encode(
|
371 |
+
array(
|
372 |
+
'message' => __('Unauthorized', 'mailgun'),
|
373 |
+
'method' => null,
|
374 |
+
'error' => __('Unauthorized', 'mailgun'),
|
375 |
+
)
|
376 |
+
)
|
377 |
+
);
|
378 |
+
}
|
379 |
+
|
380 |
+
$useAPI = (defined('MAILGUN_USEAPI') && MAILGUN_USEAPI) ? MAILGUN_USEAPI : $this->get_option('useAPI');
|
381 |
+
$secure = (defined('MAILGUN_SECURE') && MAILGUN_SECURE) ? MAILGUN_SECURE : $this->get_option('secure');
|
382 |
+
$sectype = (defined('MAILGUN_SECTYPE') && MAILGUN_SECTYPE) ? MAILGUN_SECTYPE : $this->get_option('sectype');
|
383 |
+
|
384 |
+
if ((bool) $useAPI) {
|
385 |
+
$method = __('HTTP API', 'mailgun');
|
386 |
+
} else {
|
387 |
+
$method = ((bool) $secure) ? __('Secure SMTP', 'mailgun') : __('SMTP', 'mailgun');
|
388 |
+
if ((bool) $secure) {
|
389 |
+
$method = $method . sprintf(__(' via %s', $sectype));
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
$admin_email = get_option('admin_email');
|
394 |
+
$result = wp_mail(
|
395 |
+
$admin_email,
|
396 |
+
__('Mailgun WordPress Plugin Test', 'mailgun'),
|
397 |
+
sprintf(__("This is a test email generated by the Mailgun WordPress plugin.\n\nIf you have received this message, the requested test has succeeded.\n\nThe method used to send this email was: %s.", 'mailgun'), $method),
|
398 |
+
array('Content-Type: text/plain')
|
399 |
+
);
|
400 |
+
|
401 |
+
if ((bool) $useAPI) {
|
402 |
+
if (!function_exists('mg_api_last_error')) {
|
403 |
+
if (!include dirname(__FILE__).'/wp-mail-api.php') {
|
404 |
+
self::deactivate_and_die(dirname(__FILE__).'/wp-mail-api.php');
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
$error_msg = mg_api_last_error();
|
409 |
+
} else {
|
410 |
+
if (!function_exists('mg_smtp_last_error')) {
|
411 |
+
if (!include dirname(__FILE__).'/wp-mail-smtp.php') {
|
412 |
+
self::deactivate_and_die(dirname(__FILE__).'/wp-mail-smtp.php');
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
$error_msg = mg_smtp_last_error();
|
417 |
+
}
|
418 |
+
|
419 |
+
if ($result) {
|
420 |
+
die(
|
421 |
+
json_encode(
|
422 |
+
array(
|
423 |
+
'message' => __('Success', 'mailgun'),
|
424 |
+
'method' => $method,
|
425 |
+
'error' => __('Success', 'mailgun'),
|
426 |
+
)
|
427 |
+
)
|
428 |
+
);
|
429 |
+
} else {
|
430 |
+
die(
|
431 |
+
json_encode(
|
432 |
+
array(
|
433 |
+
'message' => __('Failure', 'mailgun'),
|
434 |
+
'method' => $method,
|
435 |
+
'error' => $error_msg,
|
436 |
+
)
|
437 |
+
)
|
438 |
+
);
|
439 |
+
}
|
440 |
+
}
|
441 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lists-page.php
CHANGED
@@ -23,15 +23,15 @@ global $mailgun;
|
|
23 |
|
24 |
// check mailgun domain & api key
|
25 |
$missing_error = '';
|
26 |
-
$api_key =
|
27 |
-
$mailgun_domain =
|
28 |
-
if ($api_key != '')
|
29 |
-
if ($mailgun_domain == '')
|
30 |
$missing_error = '<strong style="color:red;">Missing or invalid Mailgun Domain</strong>. ';
|
31 |
-
|
32 |
-
else
|
33 |
$missing_error = '<strong style="color:red;">Missing or invalid API Key</strong>. ';
|
34 |
-
|
35 |
|
36 |
// import available lists
|
37 |
$lists_arr = $mailgun->get_lists();
|
@@ -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="https://
|
48 |
</a>
|
49 |
</span>
|
50 |
|
@@ -85,8 +85,8 @@ $lists_arr = $mailgun->get_lists();
|
|
85 |
<h3>Multi-list subscription</h3>
|
86 |
<p>
|
87 |
<?php _e('To allow users to subscribe to multiple lists on a single form, comma-separate the Mailgun list ids.', 'mailgun'); ?></p>
|
88 |
-
<p>
|
89 |
-
<?php _e('<strong>Example:</strong>
|
90 |
</p>
|
91 |
|
92 |
<?php endif; ?>
|
23 |
|
24 |
// check mailgun domain & api key
|
25 |
$missing_error = '';
|
26 |
+
$api_key = $this->get_option('apiKey');
|
27 |
+
$mailgun_domain = $this->get_option('domain');
|
28 |
+
if ($api_key != '') {
|
29 |
+
if ($mailgun_domain == '') {
|
30 |
$missing_error = '<strong style="color:red;">Missing or invalid Mailgun Domain</strong>. ';
|
31 |
+
}
|
32 |
+
} else {
|
33 |
$missing_error = '<strong style="color:red;">Missing or invalid API Key</strong>. ';
|
34 |
+
}
|
35 |
|
36 |
// import available lists
|
37 |
$lists_arr = $mailgun->get_lists();
|
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 |
|
85 |
<h3>Multi-list subscription</h3>
|
86 |
<p>
|
87 |
<?php _e('To allow users to subscribe to multiple lists on a single form, comma-separate the Mailgun list ids.', 'mailgun'); ?></p>
|
88 |
+
<p class="description">
|
89 |
+
<?php _e('<strong>Example:</strong> [mailgun id="list1@mydomain.com,list2@mydomain.com"]'); ?>
|
90 |
</p>
|
91 |
|
92 |
<?php endif; ?>
|
includes/mg-filter.php
CHANGED
@@ -19,16 +19,15 @@
|
|
19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
*/
|
21 |
|
22 |
-
|
23 |
/**
|
24 |
* Tries several methods to get the MIME Content-Type of a file.
|
25 |
*
|
26 |
-
* @param
|
27 |
-
* @param
|
28 |
*
|
29 |
-
* @return
|
30 |
*
|
31 |
-
* @since
|
32 |
*/
|
33 |
function get_mime_content_type($filepath, $default_type = 'text/plain')
|
34 |
{
|
@@ -59,9 +58,9 @@ function get_mime_content_type($filepath, $default_type = 'text/plain')
|
|
59 |
* `$from_addr` before being returned. The filtered result is null-tested
|
60 |
* before being returned.
|
61 |
*
|
62 |
-
* @return
|
63 |
*
|
64 |
-
* @since
|
65 |
*/
|
66 |
function mg_detect_from_name($from_name_header = null)
|
67 |
{
|
@@ -124,11 +123,13 @@ function mg_detect_from_name($from_name_header = null)
|
|
124 |
* might appear to be another option but some hosts may refuse to
|
125 |
* relay mail from an unknown domain.
|
126 |
*
|
127 |
-
* @link
|
|
|
|
|
128 |
*
|
129 |
-
* @return
|
130 |
*
|
131 |
-
* @since
|
132 |
*/
|
133 |
function mg_detect_from_address($from_addr_header = null)
|
134 |
{
|
@@ -193,11 +194,11 @@ function mg_detect_from_address($from_addr_header = null)
|
|
193 |
* )
|
194 |
* )
|
195 |
*
|
196 |
-
* @param
|
197 |
*
|
198 |
-
* @return
|
199 |
*
|
200 |
-
* @since
|
201 |
*/
|
202 |
function mg_parse_headers($headers = array())
|
203 |
{
|
@@ -258,11 +259,11 @@ function mg_parse_headers($headers = array())
|
|
258 |
* Takes a header array in the format produced by mg_parse_headers and
|
259 |
* dumps them down in to a submittable header format.
|
260 |
*
|
261 |
-
* @param
|
262 |
*
|
263 |
-
* @return
|
264 |
*
|
265 |
-
* @since
|
266 |
*/
|
267 |
function mg_dump_headers($headers = null)
|
268 |
{
|
@@ -286,40 +287,3 @@ function mg_dump_headers($headers = null)
|
|
286 |
return $header_string;
|
287 |
}
|
288 |
|
289 |
-
/**
|
290 |
-
* Set the API endpoint based on the region selected.
|
291 |
-
* Value can be "0" if not selected, "us" or "eu"
|
292 |
-
*
|
293 |
-
* @param string $getRegion Region value set either in config or Mailgun plugin settings.
|
294 |
-
*
|
295 |
-
* @return bool|string
|
296 |
-
*
|
297 |
-
* @since 1.5.12
|
298 |
-
*/
|
299 |
-
function mg_api_get_region($getRegion)
|
300 |
-
{
|
301 |
-
switch ($getRegion) {
|
302 |
-
case 'us': return 'https://api.mailgun.net/v3/';
|
303 |
-
case 'eu': return 'https://api.eu.mailgun.net/v3/';
|
304 |
-
default: return false;
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* Set the SMTP endpoint based on the region selected.
|
310 |
-
* Value can be "0" if not selected, "us" or "eu"
|
311 |
-
*
|
312 |
-
* @param string $getRegion Region value set either in config or Mailgun plugin settings.
|
313 |
-
*
|
314 |
-
* @return bool|string
|
315 |
-
*
|
316 |
-
* @since 1.5.12
|
317 |
-
*/
|
318 |
-
function mg_smtp_get_region($getRegion)
|
319 |
-
{
|
320 |
-
switch ($getRegion) {
|
321 |
-
case 'us': return 'smtp.mailgun.org';
|
322 |
-
case 'eu': return 'smtp.eu.mailgun.org';
|
323 |
-
default: return false;
|
324 |
-
}
|
325 |
-
}
|
19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
*/
|
21 |
|
|
|
22 |
/**
|
23 |
* Tries several methods to get the MIME Content-Type of a file.
|
24 |
*
|
25 |
+
* @param string $filepath
|
26 |
+
* @param string $default_type If all methods fail, fallback to $default_type
|
27 |
*
|
28 |
+
* @return string Content-Type
|
29 |
*
|
30 |
+
* @since 1.5.4
|
31 |
*/
|
32 |
function get_mime_content_type($filepath, $default_type = 'text/plain')
|
33 |
{
|
58 |
* `$from_addr` before being returned. The filtered result is null-tested
|
59 |
* before being returned.
|
60 |
*
|
61 |
+
* @return string
|
62 |
*
|
63 |
+
* @since 1.5.8
|
64 |
*/
|
65 |
function mg_detect_from_name($from_name_header = null)
|
66 |
{
|
123 |
* might appear to be another option but some hosts may refuse to
|
124 |
* relay mail from an unknown domain.
|
125 |
*
|
126 |
+
* @link http://trac.wordpress.org/ticket/5007.
|
127 |
+
*
|
128 |
+
* @param string $from_addr_header From address given by a header.
|
129 |
*
|
130 |
+
* @return string
|
131 |
*
|
132 |
+
* @since 1.5.8
|
133 |
*/
|
134 |
function mg_detect_from_address($from_addr_header = null)
|
135 |
{
|
194 |
* )
|
195 |
* )
|
196 |
*
|
197 |
+
* @param string|array $headers
|
198 |
*
|
199 |
+
* @return array
|
200 |
*
|
201 |
+
* @since 1.5.8
|
202 |
*/
|
203 |
function mg_parse_headers($headers = array())
|
204 |
{
|
259 |
* Takes a header array in the format produced by mg_parse_headers and
|
260 |
* dumps them down in to a submittable header format.
|
261 |
*
|
262 |
+
* @param array $headers Headers to dump
|
263 |
*
|
264 |
+
* @return string String of \r\n separated headers
|
265 |
*
|
266 |
+
* @since 1.5.8
|
267 |
*/
|
268 |
function mg_dump_headers($headers = null)
|
269 |
{
|
287 |
return $header_string;
|
288 |
}
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/options-page.php
CHANGED
@@ -1,397 +1,201 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
?>
|
23 |
-
<div class="wrap">
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
'href' => array(),
|
40 |
-
'target' => array()
|
41 |
-
)
|
42 |
-
)
|
43 |
-
), esc_url($url), '_blank'
|
44 |
-
);
|
45 |
-
echo $link;
|
46 |
-
?>
|
47 |
-
</p>
|
48 |
-
|
49 |
-
<p>
|
50 |
-
<?php
|
51 |
-
$url = 'https://signup.mailgun.com/new/signup';
|
52 |
-
$link = sprintf(
|
53 |
-
wp_kses(
|
54 |
-
__('If you need to register for an account, you can do so at <a href="%1$s" target="%2$s">Mailgun.com</a>.', 'mailgun'),
|
55 |
-
array('a' => array(
|
56 |
-
'href' => array(),
|
57 |
-
'target' => array()
|
58 |
-
)
|
59 |
-
)
|
60 |
-
), esc_url($url), '_blank'
|
61 |
-
);
|
62 |
-
echo $link;
|
63 |
-
?>
|
64 |
-
</p>
|
65 |
-
|
66 |
-
<h3><?php _e('Configuration', 'mailgun'); ?></h3>
|
67 |
-
<form id="mailgun-form" action="options.php" method="post">
|
68 |
-
<?php settings_fields('mailgun'); ?>
|
69 |
-
|
70 |
-
<table class="form-table">
|
71 |
-
<tr valign="top">
|
72 |
-
<th scope="row">
|
73 |
-
<?php _e('Select Your Region', 'mailgun'); ?>
|
74 |
-
</th>
|
75 |
-
<td>
|
76 |
-
<select id="mailgun-region" name="mailgun[region]">
|
77 |
-
<option value="us"<?php selected('us', $this->get_option('region')); ?>><?php _e('U.S./North America', 'mailgun') ?></option>
|
78 |
-
<option value="eu"<?php selected('eu', $this->get_option('region')); ?>><?php _e('Europe', 'mailgun') ?></option>
|
79 |
-
</select>
|
80 |
-
<p class="description">
|
81 |
-
<?php
|
82 |
-
_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');
|
83 |
-
?>
|
84 |
-
</p>
|
85 |
-
</td>
|
86 |
-
</tr>
|
87 |
-
<tr valign="top">
|
88 |
-
<th scope="row">
|
89 |
-
<?php _e('Use HTTP API', 'mailgun'); ?>
|
90 |
-
</th>
|
91 |
-
<td>
|
92 |
-
<select id="mailgun-api" name="mailgun[useAPI]">
|
93 |
-
<option value="1"<?php selected('1', $this->get_option('useAPI')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
94 |
-
<option value="0"<?php selected('0', $this->get_option('useAPI')); ?>><?php _e('No', 'mailgun'); ?></option>
|
95 |
-
</select>
|
96 |
-
<p class="description">
|
97 |
-
<?php
|
98 |
-
_e('Set this to "No" if your server cannot make outbound HTTP connections or if emails are not being delivered. "No" will cause this plugin to use SMTP. Default "Yes".', 'mailgun');
|
99 |
-
?>
|
100 |
-
</p>
|
101 |
-
</td>
|
102 |
-
</tr>
|
103 |
-
<tr valign="top">
|
104 |
-
<th scope="row">
|
105 |
-
<?php _e('Mailgun Domain Name', 'mailgun'); ?>
|
106 |
-
</th>
|
107 |
-
<td>
|
108 |
-
<input type="text" class="regular-text"
|
109 |
-
name="mailgun[domain]"
|
110 |
-
value="<?php esc_attr_e($this->get_option('domain')); ?>"
|
111 |
-
placeholder="samples.mailgun.org"
|
112 |
-
/>
|
113 |
-
<p class="description">
|
114 |
-
<?php _e('Your Mailgun Domain Name.', 'mailgun'); ?>
|
115 |
-
</p>
|
116 |
-
</td>
|
117 |
-
</tr>
|
118 |
-
<tr valign="top" class="mailgun-api">
|
119 |
-
<th scope="row">
|
120 |
-
<?php _e('API Key', 'mailgun'); ?>
|
121 |
-
</th>
|
122 |
-
<td>
|
123 |
-
<input type="text" class="regular-text" name="mailgun[apiKey]"
|
124 |
-
value="<?php esc_attr_e($this->get_option('apiKey')); ?>"
|
125 |
-
placeholder="key-3ax6xnjp29jd6fds4gc373sgvjxteol0"
|
126 |
-
/>
|
127 |
-
<p class="description">
|
128 |
-
<?php
|
129 |
-
_e('Your Mailgun API key. Only valid for use with the API.', 'mailgun');
|
130 |
-
?>
|
131 |
-
</p>
|
132 |
-
</td>
|
133 |
-
</tr>
|
134 |
-
<tr valign="top" class="mailgun-smtp">
|
135 |
-
<th scope="row">
|
136 |
-
<?php _e('Username', 'mailgun'); ?>
|
137 |
-
</th>
|
138 |
-
<td>
|
139 |
-
<input type="text" class="regular-text"
|
140 |
-
name="mailgun[username]"
|
141 |
-
value="<?php esc_attr_e($this->get_option('username')); ?>"
|
142 |
-
placeholder="postmaster"
|
143 |
-
/>
|
144 |
-
<p class="description">
|
145 |
-
<?php
|
146 |
-
_e('Your Mailgun SMTP username. Only valid for use with SMTP.', 'mailgun');
|
147 |
-
?>
|
148 |
-
</p>
|
149 |
-
</td>
|
150 |
-
</tr>
|
151 |
-
<tr valign="top" class="mailgun-smtp">
|
152 |
-
<th scope="row">
|
153 |
-
<?php _e('Password', 'mailgun'); ?>
|
154 |
-
</th>
|
155 |
-
<td>
|
156 |
-
<input type="text" class="regular-text"
|
157 |
-
name="mailgun[password]"
|
158 |
-
value="<?php esc_attr_e($this->get_option('password')); ?>"
|
159 |
-
placeholder="my-password"
|
160 |
-
/>
|
161 |
-
<p class="description">
|
162 |
-
<?php
|
163 |
-
_e('Your Mailgun SMTP password that goes with the above username. Only valid for use with SMTP.', 'mailgun');
|
164 |
-
?>
|
165 |
-
</p>
|
166 |
-
</td>
|
167 |
-
</tr>
|
168 |
-
<tr valign="top" class="mailgun-smtp">
|
169 |
-
<th scope="row">
|
170 |
-
<?php _e('Use Secure SMTP', 'mailgun'); ?>
|
171 |
-
</th>
|
172 |
-
<td>
|
173 |
-
<select name="mailgun[secure]">
|
174 |
-
<option value="1"<?php selected('1', $this->get_option('secure')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
175 |
-
<option value="0"<?php selected('0', $this->get_option('secure')); ?>><?php _e('No', 'mailgun'); ?></option>
|
176 |
-
</select>
|
177 |
-
<p class="description">
|
178 |
-
<?php
|
179 |
-
_e('Set this to "No" if your server cannot establish SSL SMTP connections or if emails are not being delivered. If you set this to "No" your password will be sent in plain text. Only valid for use with SMTP. Default "Yes".', 'mailgun');
|
180 |
-
?>
|
181 |
-
</p>
|
182 |
-
</td>
|
183 |
-
</tr>
|
184 |
-
<tr valign="top" class="mailgun-smtp">
|
185 |
-
<th scope="row">
|
186 |
-
<?php _e('Security Type', 'mailgun'); ?>
|
187 |
-
</th>
|
188 |
-
<td>
|
189 |
-
<select name="mailgun[sectype]">
|
190 |
-
<option value="ssl"<?php selected('ssl', $this->get_option('sectype')); ?>>SSL</option>
|
191 |
-
<option value="tls"<?php selected('tls', $this->get_option('sectype')); ?>>TLS</option>
|
192 |
-
</select>
|
193 |
-
<p class="description">
|
194 |
-
<?php
|
195 |
-
_e('Leave this at "TLS" unless mail sending fails. This option only matters for Secure SMTP. Default "TLS".', 'mailgun');
|
196 |
-
?>
|
197 |
-
</p>
|
198 |
-
</td>
|
199 |
-
</tr>
|
200 |
-
<tr valign="top">
|
201 |
-
<th scope="row">
|
202 |
-
<?php _e('Click Tracking', 'mailgun'); ?>
|
203 |
-
</th>
|
204 |
-
<td>
|
205 |
-
<select name="mailgun[track-clicks]">
|
206 |
-
<option value="htmlonly"<?php selected('htmlonly', $this->get_option('track-clicks')); ?>><?php _e('HTML Only', 'mailgun'); ?></option>
|
207 |
-
<option value="yes"<?php selected('yes', $this->get_option('track-clicks')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
208 |
-
<option value="no"<?php selected('no', $this->get_option('track-clicks')); ?>><?php _e('No', 'mailgun'); ?></option>
|
209 |
-
</select>
|
210 |
-
<p class="description">
|
211 |
-
<?php
|
212 |
-
$url = 'http://documentation.mailgun.com/user_manual.html#tracking-clicks';
|
213 |
-
$link = sprintf(
|
214 |
-
wp_kses(
|
215 |
-
__('If enabled, Mailgun will track links. <a href="%1$s" target="%2$s">Open Tracking Documentation</a>.', 'mailgun'),
|
216 |
-
array('a' => array(
|
217 |
-
'href' => array(),
|
218 |
-
'target' => array()
|
219 |
-
)
|
220 |
-
)
|
221 |
-
), esc_url($url), '_blank'
|
222 |
-
);
|
223 |
-
echo $link;
|
224 |
-
?>
|
225 |
-
</p>
|
226 |
-
</td>
|
227 |
-
</tr>
|
228 |
-
<tr valign="top">
|
229 |
-
<th scope="row">
|
230 |
-
<?php _e('Open Tracking', 'mailgun'); ?>
|
231 |
-
</th>
|
232 |
-
<td>
|
233 |
-
<select name="mailgun[track-opens]">
|
234 |
-
<option value="1"<?php selected('1', $this->get_option('track-opens')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
235 |
-
<option value="0"<?php selected('0', $this->get_option('track-opens')); ?>><?php _e('No', 'mailgun'); ?></option>
|
236 |
-
</select>
|
237 |
-
<p class="description">
|
238 |
-
<?php
|
239 |
-
$url = 'http://documentation.mailgun.com/user_manual.html#tracking-opens';
|
240 |
-
$link = sprintf(
|
241 |
-
wp_kses(
|
242 |
-
__('If enabled, HTML messages will include an open tracking beacon. <a href="%1$s" target="%2$s">Open Tracking Documentation</a>.', 'mailgun'),
|
243 |
-
array('a' => array(
|
244 |
-
'href' => array(),
|
245 |
-
'target' => array()
|
246 |
-
)
|
247 |
-
)
|
248 |
-
), esc_url($url), '_blank'
|
249 |
-
);
|
250 |
-
echo $link;
|
251 |
-
?>
|
252 |
-
</p>
|
253 |
-
</td>
|
254 |
-
</tr>
|
255 |
-
<tr valign="top">
|
256 |
-
<th scope="row">
|
257 |
-
<?php _e('From Address', 'mailgun'); ?>
|
258 |
-
</th>
|
259 |
-
<td>
|
260 |
-
<input type="text"
|
261 |
-
class="regular-text"
|
262 |
-
name="mailgun[from-address]"
|
263 |
-
value="<?php esc_attr_e($this->get_option('from-address')); ?>"
|
264 |
-
placeholder="wordpress@mydomain.com"
|
265 |
-
/>
|
266 |
-
<p class="description">
|
267 |
-
<?php
|
268 |
-
_e('The <address@mydomain.com> part of the sender information (<code>"Excited User <user@samples.mailgun.org>"</code>). This address will appear as the `From` address on sent mail. <strong>It is recommended that the @mydomain portion matches your Mailgun sending domain.</strong>', 'mailgun');
|
269 |
-
?>
|
270 |
-
</p>
|
271 |
-
</td>
|
272 |
-
</tr>
|
273 |
-
<tr valign="top">
|
274 |
-
<th scope="row">
|
275 |
-
<?php _e('From Name', 'mailgun'); ?>
|
276 |
-
</th>
|
277 |
-
<td>
|
278 |
-
<input type="text" class="regular-text"
|
279 |
-
name="mailgun[from-name]"
|
280 |
-
value="<?php esc_attr_e($this->get_option('from-name')); ?>"
|
281 |
-
placeholder="WordPress"
|
282 |
-
/>
|
283 |
-
<p class="description">
|
284 |
-
<?php
|
285 |
-
_e('The "User Name" part of the sender information (<code>"Excited User <user@samples.mailgun.org>"</code>).', 'mailgun');
|
286 |
-
?>
|
287 |
-
</p>
|
288 |
-
</td>
|
289 |
-
</tr>
|
290 |
-
<tr valign="top">
|
291 |
-
<th scope="row">
|
292 |
-
<?php _e('Override "From" Details', 'mailgun'); ?>
|
293 |
-
</th>
|
294 |
-
<td>
|
295 |
-
<select name="mailgun[override-from]">
|
296 |
-
<option value="1"<?php selected('1', $this->get_option('override-from', null, '0')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
297 |
-
<option value="0"<?php selected('0', $this->get_option('override-from', null, '0')); ?>><?php _e('No', 'mailgun'); ?></option>
|
298 |
-
</select>
|
299 |
-
<p class="description">
|
300 |
-
<?php
|
301 |
-
_e('If enabled, all emails will be sent with the above "From Name" and "From Address", regardless of values set by other plugins. Useful for cases where other plugins don\'t play nice with our "From Name" / "From Address" setting.', 'mailgun');
|
302 |
-
?>
|
303 |
-
</p>
|
304 |
-
</td>
|
305 |
-
</tr>
|
306 |
-
<tr valign="top">
|
307 |
-
<th scope="row">
|
308 |
-
<?php _e('Tag', 'mailgun'); ?>
|
309 |
-
</th>
|
310 |
-
<td>
|
311 |
-
<input type="text" class="regular-text"
|
312 |
-
name="mailgun[campaign-id]"
|
313 |
-
value="<?php esc_attr_e($this->get_option('campaign-id')); ?>"
|
314 |
-
placeholder="tag"
|
315 |
-
/>
|
316 |
-
<p class="description">
|
317 |
-
<?php
|
318 |
-
_e('If added, this tag will exist on every outbound message. Statistics will be populated in the Mailgun Control Panel. Use a comma to define multiple tags. ', 'mailgun');
|
319 |
-
_e('Learn more about', 'mailgun');
|
320 |
-
|
321 |
-
$url1 = 'https://documentation.mailgun.com/user_manual.html#tracking-messages';
|
322 |
-
$url2 = 'https://documentation.mailgun.com/user_manual.html#tagging';
|
323 |
-
$link = sprintf(
|
324 |
-
wp_kses(
|
325 |
-
__('<a href="%1$s" target="%3$s">Tracking</a> and <a href="%2$s" target="%3$s">Tagging</a>', 'mailgun'),
|
326 |
-
array('a' => array(
|
327 |
-
'href' => array(),
|
328 |
-
'target' => array()
|
329 |
-
)
|
330 |
-
)
|
331 |
-
), esc_url($url1), esc_url($url2), '_blank'
|
332 |
-
);
|
333 |
-
echo $link;
|
334 |
-
?>
|
335 |
-
</p>
|
336 |
-
</td>
|
337 |
-
</tr>
|
338 |
-
</table>
|
339 |
-
<h3><?php _e('Lists', 'mailgun'); ?></h3>
|
340 |
-
<table class="form-table">
|
341 |
-
<tr valign="top">
|
342 |
-
<th scope="row">
|
343 |
-
<?php _e('Shortcode', 'mailgun'); ?>
|
344 |
-
</th>
|
345 |
-
<td>
|
346 |
-
<div>
|
347 |
-
<code>[mailgun id="<em>{mailgun list id}</em>" collect_name="true"]</code>
|
348 |
-
</div>
|
349 |
-
<div>
|
350 |
-
<p class="description">
|
351 |
-
<?php
|
352 |
-
_e('Use the shortcode above to associate a widget instance with a mailgun list', 'mailgun');
|
353 |
-
?>
|
354 |
-
</p>
|
355 |
-
</div>
|
356 |
-
</td>
|
357 |
-
</tr>
|
358 |
-
<tr valign="top">
|
359 |
-
<th scope="row">
|
360 |
-
<?php _e('Lists', 'mailgun'); ?>
|
361 |
-
</th>
|
362 |
-
<td>
|
363 |
-
<?php
|
364 |
-
$url = '?page=mailgun-lists';
|
365 |
-
|
366 |
-
$link = sprintf(
|
367 |
-
wp_kses(
|
368 |
-
__('<a href="%1$s" target="%2$s">View available lists</a>.', 'mailgun'),
|
369 |
-
array('a' => array(
|
370 |
-
'href' => array(),
|
371 |
-
)
|
372 |
-
)
|
373 |
-
), esc_url($url)
|
374 |
-
);
|
375 |
-
echo $link;
|
376 |
-
?>
|
377 |
-
</td>
|
378 |
-
</tr>
|
379 |
-
</table>
|
380 |
-
<p>
|
381 |
-
<?php
|
382 |
-
_e('Before attempting to test the configuration, please click "Save Changes".', 'mailgun');
|
383 |
-
?>
|
384 |
-
</p>
|
385 |
-
<p class="submit">
|
386 |
-
<input type="submit"
|
387 |
-
class="button-primary"
|
388 |
-
value="<?php _e('Save Changes', 'mailgun'); ?>"
|
389 |
-
/>
|
390 |
-
<input type="button"
|
391 |
-
id="mailgun-test"
|
392 |
-
class="button-secondary"
|
393 |
-
value="<?php _e('Test Configuration', 'mailgun'); ?>"
|
394 |
-
/>
|
395 |
-
</p>
|
396 |
-
</form>
|
397 |
-
</div>
|
1 |
<?php
|
2 |
|
3 |
+
/*
|
4 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
5 |
+
* Copyright (C) 2016 Mailgun, et al.
|
6 |
+
*
|
7 |
+
* This program is free software; you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License along
|
18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
+
*/
|
21 |
|
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://assets.mailgun.com/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>
|
29 |
+
<form id="mailgun-form" action="options.php" method="post">
|
30 |
+
<?php settings_fields('mailgun'); ?>
|
31 |
+
<h3><?php _e('Configuration', 'mailgun'); ?></h3>
|
32 |
+
<table class="form-table">
|
33 |
+
<tr valign="top">
|
34 |
+
<th scope="row">
|
35 |
+
<?php _e('Use HTTP API', 'mailgun'); ?>
|
36 |
+
</th>
|
37 |
+
<td>
|
38 |
+
<select id="mailgun-api" name="mailgun[useAPI]">
|
39 |
+
<option value="1"<?php selected('1', $this->get_option('useAPI')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
40 |
+
<option value="0"<?php selected('0', $this->get_option('useAPI')); ?>><?php _e('No', 'mailgun'); ?></option>
|
41 |
+
</select>
|
42 |
+
<p class="description"><?php _e('Set this to "No" if your server cannot make outbound HTTP connections or if emails are not being delivered. "No" will cause this plugin to use SMTP. Default "Yes".', 'mailgun'); ?></p>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
+
<tr valign="top">
|
46 |
+
<th scope="row">
|
47 |
+
<?php _e('Mailgun Domain Name', 'mailgun'); ?>
|
48 |
+
</th>
|
49 |
+
<td>
|
50 |
+
<input type="text" class="regular-text" name="mailgun[domain]" value="<?php esc_attr_e($this->get_option('domain')); ?>" placeholder="samples.mailgun.org" />
|
51 |
+
<p class="description"><?php _e('Your Mailgun Domain Name.', 'mailgun'); ?></p>
|
52 |
+
</td>
|
53 |
+
</tr>
|
54 |
+
<tr valign="top" class="mailgun-api">
|
55 |
+
<th scope="row">
|
56 |
+
<?php _e('API Key', 'mailgun'); ?>
|
57 |
+
</th>
|
58 |
+
<td>
|
59 |
+
<input type="text" class="regular-text" name="mailgun[apiKey]" value="<?php esc_attr_e($this->get_option('apiKey')); ?>" placeholder="key-3ax6xnjp29jd6fds4gc373sgvjxteol0" />
|
60 |
+
<p class="description"><?php _e('Your Mailgun API key, that starts with and includes "key-". Only valid for use with the API.', 'mailgun'); ?></p>
|
61 |
+
</td>
|
62 |
+
</tr>
|
63 |
+
<tr valign="top" class="mailgun-smtp">
|
64 |
+
<th scope="row">
|
65 |
+
<?php _e('Username', 'mailgun'); ?>
|
66 |
+
</th>
|
67 |
+
<td>
|
68 |
+
<input type="text" class="regular-text" name="mailgun[username]" value="<?php esc_attr_e($this->get_option('username')); ?>" placeholder="postmaster" />
|
69 |
+
<p class="description"><?php _e('Your Mailgun SMTP username. Only valid for use with SMTP.', 'mailgun'); ?></p>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
<tr valign="top" class="mailgun-smtp">
|
73 |
+
<th scope="row">
|
74 |
+
<?php _e('Password', 'mailgun'); ?>
|
75 |
+
</th>
|
76 |
+
<td>
|
77 |
+
<input type="text" class="regular-text" name="mailgun[password]" value="<?php esc_attr_e($this->get_option('password')); ?>" placeholder="my-password" />
|
78 |
+
<p class="description"><?php _e('Your Mailgun SMTP password that goes with the above username. Only valid for use with SMTP.', 'mailgun'); ?></p>
|
79 |
+
</td>
|
80 |
+
</tr>
|
81 |
+
<tr valign="top" class="mailgun-smtp">
|
82 |
+
<th scope="row">
|
83 |
+
<?php _e('Use Secure SMTP', 'mailgun'); ?>
|
84 |
+
</th>
|
85 |
+
<td>
|
86 |
+
<select name="mailgun[secure]">
|
87 |
+
<option value="1"<?php selected('1', $this->get_option('secure')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
88 |
+
<option value="0"<?php selected('0', $this->get_option('secure')); ?>><?php _e('No', 'mailgun'); ?></option>
|
89 |
+
</select>
|
90 |
+
<p class="description"><?php _e('Set this to "No" if your server cannot establish SSL SMTP connections or if emails are not being delivered. If you set this to "No" your password will be sent in plain text. Only valid for use with SMTP. Default "Yes".', 'mailgun'); ?></p>
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
<tr valign="top" class="mailgun-smtp">
|
94 |
+
<th scope="row">
|
95 |
+
<?php _e('Security Type', 'mailgun'); ?>
|
96 |
+
</th>
|
97 |
+
<td>
|
98 |
+
<select name="mailgun[sectype]">
|
99 |
+
<option value="ssl"<?php selected('ssl', $this->get_option('sectype')); ?>>SSL</option>
|
100 |
+
<option value="tls"<?php selected('tls', $this->get_option('sectype')); ?>>TLS</option>
|
101 |
+
</select>
|
102 |
+
<p class="description"><php _e('Leave this at "TLS" unless mail sending fails. This option only matters for Secure SMTP. Default "TLS".', 'mailgun'); ?></p>
|
103 |
+
</td>
|
104 |
+
</tr>
|
105 |
+
<tr valign="top">
|
106 |
+
<th scope="row">
|
107 |
+
<?php _e('Click Tracking', 'mailgun'); ?>
|
108 |
+
</th>
|
109 |
+
<td>
|
110 |
+
<select name="mailgun[track-clicks]">
|
111 |
+
<option value="htmlonly"<?php selected('htmlonly', $this->get_option('track-clicks')); ?>><?php _e('HTML Only', 'mailgun'); ?></option>
|
112 |
+
<option value="yes"<?php selected('yes', $this->get_option('track-clicks')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
113 |
+
<option value="no"<?php selected('no', $this->get_option('track-clicks')); ?>><?php _e('No', 'mailgun'); ?></option>
|
114 |
+
</select>
|
115 |
+
<p class="description"><?php _e('If enabled, Mailgun will and track links.', 'mailgun'); ?> <a href="http://documentation.mailgun.com/user_manual.html#tracking-clicks" target="_blank">Click Tracking Documentation</a></p>
|
116 |
+
</td>
|
117 |
+
</tr>
|
118 |
+
<tr valign="top">
|
119 |
+
<th scope="row">
|
120 |
+
<?php _e('Open Tracking', 'mailgun'); ?>
|
121 |
+
</th>
|
122 |
+
<td>
|
123 |
+
<select name="mailgun[track-opens]">
|
124 |
+
<option value="1"<?php selected('1', $this->get_option('track-opens')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
125 |
+
<option value="0"<?php selected('0', $this->get_option('track-opens')); ?>><?php _e('No', 'mailgun'); ?></option>
|
126 |
+
</select>
|
127 |
+
<p class="description"><?php _e('If enabled, HTML messages will include an open tracking beacon.', 'mailgun'); ?> <a href="http://documentation.mailgun.com/user_manual.html#tracking-opens" target="_blank">Open Tracking Documentation</a></p>
|
128 |
+
</td>
|
129 |
+
</tr>
|
130 |
+
<tr valign="top">
|
131 |
+
<th scope="row">
|
132 |
+
<?php _e('From Address', 'mailgun'); ?>
|
133 |
+
</th>
|
134 |
+
<td>
|
135 |
+
<input type="text" class="regular-text" name="mailgun[from-address]" value="<?php esc_attr_e($this->get_option('from-address')); ?>" placeholder="wordpress@mydomain.com" />
|
136 |
+
<p class="description"><?php _e('The <address@mydomain.com> part of the sender information (<code>"Excited User <user@samples.mailgun.org>"</code>). This address will appear as the `From` address on sent mail. <strong>It is recommended that the @mydomain portion matches your Mailgun sending domain.</strong>', 'mailgun'); ?></p>
|
137 |
+
</td>
|
138 |
+
</tr>
|
139 |
+
<tr valign="top">
|
140 |
+
<th scope="row">
|
141 |
+
<?php _e('From Name', 'mailgun'); ?>
|
142 |
+
</th>
|
143 |
+
<td>
|
144 |
+
<input type="text" class="regular-text" name="mailgun[from-name]" value="<?php esc_attr_e($this->get_option('from-name')); ?>" placeholder="WordPress" />
|
145 |
+
<p class="description"><?php _e('The "User Name" part of the sender information (<code>"Excited User <user@samples.mailgun.org>"</code>).', 'mailgun'); ?></p>
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
+
<tr valign="top">
|
149 |
+
<th scope="row">
|
150 |
+
<?php _e('Override "From" Details', 'mailgun'); ?>
|
151 |
+
</th>
|
152 |
+
<td>
|
153 |
+
<select name="mailgun[override-from]">
|
154 |
+
<option value="1"<?php selected('1', $this->get_option('override-from', null, '0')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
155 |
+
<option value="0"<?php selected('0', $this->get_option('override-from', null, '0')); ?>><?php _e('No', 'mailgun'); ?></option>
|
156 |
+
</select>
|
157 |
+
<p class="description"><?php _e('If enabled, all emails will be sent with the above "From Name" and "From Address", regardless of values set by other plugins. Useful for cases where other plugins don\'t play nice with our "From Name" / "From Address" setting.', 'mailgun'); ?></p>
|
158 |
+
</td>
|
159 |
+
</tr>
|
160 |
+
<tr valign="top">
|
161 |
+
<th scope="row">
|
162 |
+
<?php _e('Tag', 'mailgun'); ?>
|
163 |
+
</th>
|
164 |
+
<td>
|
165 |
+
<input type="text" class="regular-text" name="mailgun[campaign-id]" value="<?php esc_attr_e($this->get_option('campaign-id')); ?>" placeholder="tag" />
|
166 |
+
<p class="description"><?php _e('If added, this tag will exist on every outbound message. Statistics will be populated in the Mailgun Control Panel. Use a comma to define multiple tags.', 'mailgun'); ?> <?php _e('Learn more about', 'mailgun'); ?> <a href="https://documentation.mailgun.com/user_manual.html#tracking-messages" target="_blank">Tracking</a> <?php _e('and', 'mailgun'); ?> <a href="https://documentation.mailgun.com/user_manual.html#tagging" target="_blank">Tagging</a>.</p>
|
167 |
+
</td>
|
168 |
+
</tr>
|
169 |
+
</table>
|
170 |
+
<h3><?php _e('Lists', 'mailgun'); ?></h3>
|
171 |
+
<table class="form-table">
|
172 |
+
<tr valign="top">
|
173 |
+
<th scope="row">
|
174 |
+
<?php _e('Shortcode', 'mailgun'); ?>
|
175 |
+
</th>
|
176 |
+
<td>
|
177 |
+
<div>
|
178 |
+
<strong>[mailgun id="<em>{mailgun list id}</em>" collect_name="true"]</strong>
|
179 |
+
</div>
|
180 |
+
<div>
|
181 |
+
<p class="description"><?php _e('Use the shortcode above to associate a widget instance with a mailgun list', 'mailgun'); ?></p>
|
182 |
+
</div>
|
183 |
+
</td>
|
184 |
+
</tr>
|
185 |
+
<tr valign="top">
|
186 |
+
<th scope="row">
|
187 |
+
<?php _e('Lists', 'mailgun'); ?>
|
188 |
+
</th>
|
189 |
+
<td>
|
190 |
+
<a href="?page=mailgun-lists">View available lists</a>
|
191 |
+
</td>
|
192 |
+
</tr>
|
193 |
+
</table>
|
194 |
|
195 |
+
<p><?php _e('Before attempting to test the configuration, please click "Save Changes".', 'mailgun'); ?></p>
|
196 |
+
<p class="submit">
|
197 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes', 'mailgun'); ?>" />
|
198 |
+
<input type="button" id="mailgun-test" class="button-secondary" value="<?php _e('Test Configuration', 'mailgun'); ?>" />
|
199 |
+
</p>
|
200 |
+
</form>
|
201 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/wp-mail-api.php
CHANGED
@@ -28,11 +28,11 @@ if (!include dirname(__FILE__).'/mg-filter.php') {
|
|
28 |
* mg_api_last_error is a compound getter/setter for the last error that was
|
29 |
* encountered during a Mailgun API call.
|
30 |
*
|
31 |
-
* @param
|
32 |
*
|
33 |
-
* @return
|
34 |
*
|
35 |
-
* @since
|
36 |
*/
|
37 |
function mg_api_last_error($error = null)
|
38 |
{
|
@@ -98,15 +98,15 @@ function mg_mutate_to_rcpt_vars_cb($to_addrs)
|
|
98 |
* Based off of the core wp_mail function, but with modifications required to
|
99 |
* send email using the Mailgun HTTP API
|
100 |
*
|
101 |
-
* @param
|
102 |
-
* @param
|
103 |
-
* @param
|
104 |
-
* @param
|
105 |
-
* @param
|
106 |
*
|
107 |
-
* @return
|
108 |
*
|
109 |
-
* @since
|
110 |
*/
|
111 |
function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
112 |
{
|
@@ -114,7 +114,6 @@ 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 |
-
$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 |
|
@@ -122,12 +121,6 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
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));
|
133 |
}
|
@@ -348,7 +341,7 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
348 |
// // }
|
349 |
// }
|
350 |
|
351 |
-
// Allow other plugins to apply
|
352 |
$attachments = apply_filters('mg_mutate_attachments', $attachments);
|
353 |
if ( ($attachment_payload = mg_build_attachments_payload($attachments, $boundary)) != null ) {
|
354 |
$payload .= $attachment_payload;
|
@@ -364,9 +357,7 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
364 |
),
|
365 |
);
|
366 |
|
367 |
-
$
|
368 |
-
$endpoint = ($endpoint) ? $endpoint : 'https://api.mailgun.net/v3/';
|
369 |
-
$url = $endpoint."{$domain}/messages";
|
370 |
|
371 |
// TODO: Mailgun only supports 1000 recipients per request, since we are
|
372 |
// overriding this function, let's add looping here to handle that
|
28 |
* mg_api_last_error is a compound getter/setter for the last error that was
|
29 |
* encountered during a Mailgun API call.
|
30 |
*
|
31 |
+
* @param string $error OPTIONAL
|
32 |
*
|
33 |
+
* @return string Last error that occurred.
|
34 |
*
|
35 |
+
* @since 1.5.0
|
36 |
*/
|
37 |
function mg_api_last_error($error = null)
|
38 |
{
|
98 |
* Based off of the core wp_mail function, but with modifications required to
|
99 |
* send email using the Mailgun HTTP API
|
100 |
*
|
101 |
+
* @param string|array $to Array or comma-separated list of email addresses to send message.
|
102 |
+
* @param string $subject Email subject
|
103 |
+
* @param string $message Message contents
|
104 |
+
* @param string|array $headers Optional. Additional headers.
|
105 |
+
* @param string|array $attachments Optional. Files to attach.
|
106 |
*
|
107 |
+
* @return bool Whether the email contents were sent successfully.
|
108 |
*
|
109 |
+
* @since 0.1
|
110 |
*/
|
111 |
function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
112 |
{
|
114 |
extract(apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments')));
|
115 |
|
116 |
$mailgun = get_option('mailgun');
|
|
|
117 |
$apiKey = (defined('MAILGUN_APIKEY') && MAILGUN_APIKEY) ? MAILGUN_APIKEY : $mailgun['apiKey'];
|
118 |
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $mailgun['domain'];
|
119 |
|
121 |
return false;
|
122 |
}
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
if (!is_array($attachments)) {
|
125 |
$attachments = explode("\n", str_replace("\r\n", "\n", $attachments));
|
126 |
}
|
341 |
// // }
|
342 |
// }
|
343 |
|
344 |
+
// Allow other plugins to apply attachent changes before writing to the payload.
|
345 |
$attachments = apply_filters('mg_mutate_attachments', $attachments);
|
346 |
if ( ($attachment_payload = mg_build_attachments_payload($attachments, $boundary)) != null ) {
|
347 |
$payload .= $attachment_payload;
|
357 |
),
|
358 |
);
|
359 |
|
360 |
+
$url = "https://api.mailgun.net/v3/{$domain}/messages";
|
|
|
|
|
361 |
|
362 |
// TODO: Mailgun only supports 1000 recipients per request, since we are
|
363 |
// overriding this function, let's add looping here to handle that
|
languages/mailgun-template.po
CHANGED
@@ -61,6 +61,10 @@ msgstr ""
|
|
61 |
msgid "Mailgun is almost ready. "
|
62 |
msgstr ""
|
63 |
|
|
|
|
|
|
|
|
|
64 |
#: includes/admin.php:309
|
65 |
msgid ""
|
66 |
"\"Override From\" option requires that \"From Name\" and \"From Address\" be "
|
61 |
msgid "Mailgun is almost ready. "
|
62 |
msgstr ""
|
63 |
|
64 |
+
#: includes/admin.php:301
|
65 |
+
msgid "You must <a href=\"%1$s\">configure Mailgun</a> for it to work."
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
#: includes/admin.php:309
|
69 |
msgid ""
|
70 |
"\"Override From\" option requires that \"From Name\" and \"From Address\" be "
|
mailgun.php
CHANGED
@@ -1,486 +1,457 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
</form>
|
360 |
-
<div class="widget-list-panel result-panel" style="display:none;">
|
361 |
-
<span>Thank you for subscribing!</span>
|
362 |
-
</div>
|
363 |
-
</div>
|
364 |
-
|
365 |
-
<script>
|
366 |
-
jQuery(document).ready(function () {
|
367 |
-
|
368 |
-
jQuery('.mailgun-list-submit-button').on('click', function () {
|
369 |
-
|
370 |
-
var form_id = jQuery(this).data('form-id')
|
371 |
-
|
372 |
-
if (jQuery('.mailgun-list-name').length > 0 && jQuery('.' + form_id + ' .mailgun-list-name:checked').length < 1) {
|
373 |
-
alert('Please select a list to subscribe to.')
|
374 |
-
return
|
375 |
-
}
|
376 |
-
|
377 |
-
if (jQuery('.' + form_id + ' .mailgun-list-widget-name input') && jQuery('.' + form_id + ' .mailgun-list-widget-name input').val() === '') {
|
378 |
-
alert('Please enter your subscription name.')
|
379 |
-
return
|
380 |
-
}
|
381 |
-
|
382 |
-
if (jQuery('.' + form_id + ' .mailgun-list-widget-email input').val() === '') {
|
383 |
-
alert('Please enter your subscription email.')
|
384 |
-
return
|
385 |
-
}
|
386 |
-
|
387 |
-
jQuery.ajax({
|
388 |
url: '<?php echo admin_url('admin-ajax.php?action=add_list'); ?>',
|
389 |
-
action:
|
390 |
type: 'post',
|
391 |
dataType: 'json',
|
392 |
-
data: jQuery('.'
|
393 |
-
success: function
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
// error
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
}
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Plugin Name: Mailgun
|
5 |
+
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
6 |
+
* Description: Mailgun integration for WordPress
|
7 |
+
* Version: 1.5.10
|
8 |
+
* Author: Mailgun
|
9 |
+
* Author URI: http://www.mailgun.com/
|
10 |
+
* License: GPLv2 or later
|
11 |
+
* Text Domain: mailgun
|
12 |
+
* Domain Path: /languages/.
|
13 |
+
*/
|
14 |
+
|
15 |
+
/*
|
16 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
17 |
+
* Copyright (C) 2016 Mailgun, et al.
|
18 |
+
*
|
19 |
+
* This program is free software; you can redistribute it and/or modify
|
20 |
+
* it under the terms of the GNU General Public License as published by
|
21 |
+
* the Free Software Foundation; either version 2 of the License, or
|
22 |
+
* (at your option) any later version.
|
23 |
+
*
|
24 |
+
* This program is distributed in the hope that it will be useful,
|
25 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27 |
+
* GNU General Public License for more details.
|
28 |
+
*
|
29 |
+
* You should have received a copy of the GNU General Public License along
|
30 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
31 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
32 |
+
*/
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Entrypoint for the Mailgun plugin. Sets up the mailing "strategy" -
|
36 |
+
* either API or SMTP.
|
37 |
+
*
|
38 |
+
* Registers handlers for later actions and sets up config variables with
|
39 |
+
* Wordpress.
|
40 |
+
*/
|
41 |
+
class Mailgun
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* Setup shared functionality for Admin and Front End.
|
45 |
+
*
|
46 |
+
* @return none
|
47 |
+
*
|
48 |
+
* @since 0.1
|
49 |
+
*/
|
50 |
+
public function __construct()
|
51 |
+
{
|
52 |
+
$this->options = get_option('mailgun');
|
53 |
+
$this->plugin_file = __FILE__;
|
54 |
+
$this->plugin_basename = plugin_basename($this->plugin_file);
|
55 |
+
$this->api_endpoint = 'https://api.mailgun.net/v3/';
|
56 |
+
|
57 |
+
// Either override the wp_mail function or configure PHPMailer to use the
|
58 |
+
// Mailgun SMTP servers
|
59 |
+
// When using SMTP, we also need to inject a `wp_mail` filter to make "from" settings
|
60 |
+
// work properly. Fixes issues with 1.5.7+
|
61 |
+
if ($this->get_option('useAPI') || (defined('MAILGUN_USEAPI') && MAILGUN_USEAPI)) {
|
62 |
+
if (!function_exists('wp_mail')) {
|
63 |
+
if (!include dirname(__FILE__).'/includes/wp-mail-api.php') {
|
64 |
+
self::deactivate_and_die(dirname(__FILE__).'/includes/wp-mail-api.php');
|
65 |
+
}
|
66 |
+
}
|
67 |
+
} else {
|
68 |
+
// Using SMTP, include the SMTP filter
|
69 |
+
if (!function_exists('mg_smtp_mail_filter')) {
|
70 |
+
if (!include dirname(__FILE__).'/includes/wp-mail-smtp.php') {
|
71 |
+
self::deactivate_and_die(dirname(__FILE__).'/includes/wp-mail-smtp.php');
|
72 |
+
}
|
73 |
+
}
|
74 |
+
add_filter('wp_mail', 'mg_smtp_mail_filter');
|
75 |
+
add_action('phpmailer_init', array(&$this, 'phpmailer_init'));
|
76 |
+
add_action('wp_mail_failed', 'wp_mail_failed');
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Get specific option from the options table.
|
82 |
+
*
|
83 |
+
* @param string $option Name of option to be used as array key for retrieving the specific value
|
84 |
+
*
|
85 |
+
* @return mixed
|
86 |
+
*
|
87 |
+
* @since 0.1
|
88 |
+
*/
|
89 |
+
public function get_option($option, $options = null, $default = false)
|
90 |
+
{
|
91 |
+
if (is_null($options)) {
|
92 |
+
$options = &$this->options;
|
93 |
+
}
|
94 |
+
if (isset($options[$option])) {
|
95 |
+
return $options[$option];
|
96 |
+
} else {
|
97 |
+
return $default;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Hook into phpmailer to override SMTP based configurations
|
103 |
+
* to use the Mailgun SMTP server.
|
104 |
+
*
|
105 |
+
* @param object $phpmailer The PHPMailer object to modify by reference
|
106 |
+
*
|
107 |
+
* @return none
|
108 |
+
*
|
109 |
+
* @since 0.1
|
110 |
+
*/
|
111 |
+
public function phpmailer_init(&$phpmailer)
|
112 |
+
{
|
113 |
+
$username = (defined('MAILGUN_USERNAME') && MAILGUN_USERNAME) ? MAILGUN_USERNAME : $this->get_option('username');
|
114 |
+
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $this->get_option('domain');
|
115 |
+
$username = preg_replace('/@.+$/', '', $username)."@{$domain}";
|
116 |
+
$secure = (defined('MAILGUN_SECURE') && MAILGUN_SECURE) ? MAILGUN_SECURE : $this->get_option('secure');
|
117 |
+
$sectype = (defined('MAILGUN_SECTYPE') && MAILGUN_SECTYPE) ? MAILGUN_SECTYPE : $this->get_option('sectype');
|
118 |
+
$password = (defined('MAILGUN_PASSWORD') && MAILGUN_PASSWORD) ? MAILGUN_PASSWORD : $this->get_option('password');
|
119 |
+
|
120 |
+
$phpmailer->Mailer = 'smtp';
|
121 |
+
$phpmailer->Host = 'smtp.mailgun.org';
|
122 |
+
$phpmailer->Port = (bool) $secure ? 465 : 587;
|
123 |
+
$phpmailer->SMTPAuth = true;
|
124 |
+
$phpmailer->Username = $username;
|
125 |
+
$phpmailer->Password = $password;
|
126 |
+
|
127 |
+
$phpmailer->SMTPSecure = (bool) $secure ? $sectype : 'none';
|
128 |
+
// Without this line... wp_mail for SMTP-only will always return false. But why? :(
|
129 |
+
$phpmailer->Debugoutput = 'mg_smtp_debug_output';
|
130 |
+
$phpmailer->SMTPDebug = 2;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Deactivate this plugin and die.
|
135 |
+
*
|
136 |
+
* Used to deactivate the plugin when files critical to it's operation can not be loaded
|
137 |
+
*
|
138 |
+
* @since 0.1
|
139 |
+
*
|
140 |
+
* @return none
|
141 |
+
*/
|
142 |
+
public function deactivate_and_die($file)
|
143 |
+
{
|
144 |
+
load_plugin_textdomain('mailgun', false, 'mailgun/languages');
|
145 |
+
$message = sprintf(__('Mailgun has been automatically deactivated because the file <strong>%s</strong> is missing. Please reinstall the plugin and reactivate.'), $file);
|
146 |
+
if (!function_exists('deactivate_plugins')) {
|
147 |
+
include ABSPATH.'wp-admin/includes/plugin.php';
|
148 |
+
}
|
149 |
+
deactivate_plugins(__FILE__);
|
150 |
+
wp_die($message);
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Make a Mailgun api call.
|
155 |
+
*
|
156 |
+
* @param string $endpoint The Mailgun endpoint uri
|
157 |
+
*
|
158 |
+
* @return array
|
159 |
+
*
|
160 |
+
* @since 0.1
|
161 |
+
*/
|
162 |
+
public function api_call($uri, $params = array(), $method = 'POST')
|
163 |
+
{
|
164 |
+
$options = get_option('mailgun');
|
165 |
+
$apiKey = (defined('MAILGUN_APIKEY') && MAILGUN_APIKEY) ? MAILGUN_APIKEY : $options['apiKey'];
|
166 |
+
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $options['domain'];
|
167 |
+
|
168 |
+
$time = time();
|
169 |
+
$url = $this->api_endpoint.$uri;
|
170 |
+
$headers = array(
|
171 |
+
'Authorization' => 'Basic '.base64_encode("api:{$apiKey}"),
|
172 |
+
);
|
173 |
+
|
174 |
+
switch ($method) {
|
175 |
+
case 'GET':
|
176 |
+
$params['sess'] = '';
|
177 |
+
$querystring = http_build_query($params);
|
178 |
+
$url = $url.'?'.$querystring;
|
179 |
+
$params = '';
|
180 |
+
break;
|
181 |
+
case 'POST':
|
182 |
+
case 'PUT':
|
183 |
+
case 'DELETE':
|
184 |
+
$params['sess'] = '';
|
185 |
+
$params['time'] = $time;
|
186 |
+
$params['hash'] = sha1(date('U'));
|
187 |
+
break;
|
188 |
+
}
|
189 |
+
|
190 |
+
// make the request
|
191 |
+
$args = array(
|
192 |
+
'method' => $method,
|
193 |
+
'body' => $params,
|
194 |
+
'headers' => $headers,
|
195 |
+
'sslverify' => true,
|
196 |
+
);
|
197 |
+
|
198 |
+
// make the remote request
|
199 |
+
$result = wp_remote_request($url, $args);
|
200 |
+
if (!is_wp_error($result)) {
|
201 |
+
return $result['body'];
|
202 |
+
} else {
|
203 |
+
return $result->get_error_message();
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Get account associated lists.
|
209 |
+
*
|
210 |
+
* @return array
|
211 |
+
*
|
212 |
+
* @since 0.1
|
213 |
+
*/
|
214 |
+
public function get_lists()
|
215 |
+
{
|
216 |
+
$results = array();
|
217 |
+
|
218 |
+
$lists_json = $this->api_call('lists', array(), 'GET');
|
219 |
+
$lists_arr = json_decode($lists_json, true);
|
220 |
+
if (isset($lists_arr['items']) && !empty($lists_arr['items'])) {
|
221 |
+
$results = $lists_arr['items'];
|
222 |
+
}
|
223 |
+
|
224 |
+
return $results;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Handle add list ajax post.
|
229 |
+
*
|
230 |
+
* @return string json
|
231 |
+
*
|
232 |
+
* @since 0.1
|
233 |
+
*/
|
234 |
+
public function add_list()
|
235 |
+
{
|
236 |
+
$response = array();
|
237 |
+
|
238 |
+
$name = isset($_POST['name']) ? $_POST['name'] : null;
|
239 |
+
$email = isset($_POST['email']) ? $_POST['email'] : null;
|
240 |
+
|
241 |
+
$list_addresses = $_POST['addresses'];
|
242 |
+
|
243 |
+
if (!empty($list_addresses)) {
|
244 |
+
foreach ($list_addresses as $address => $val) {
|
245 |
+
$response[] = $this->api_call(
|
246 |
+
"lists/{$address}/members",
|
247 |
+
array(
|
248 |
+
'address' => $email,
|
249 |
+
'name' => $name,
|
250 |
+
)
|
251 |
+
);
|
252 |
+
}
|
253 |
+
|
254 |
+
echo json_encode(array('status' => 200, 'message' => 'Thank you!'));
|
255 |
+
} else {
|
256 |
+
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.'));
|
257 |
+
}
|
258 |
+
|
259 |
+
wp_die();
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Frontend List Form.
|
264 |
+
*
|
265 |
+
* @param string $list_address Mailgun address list id
|
266 |
+
* @param array $args widget arguments
|
267 |
+
* @param string $instance widget instance params
|
268 |
+
*
|
269 |
+
* @since 0.1
|
270 |
+
*/
|
271 |
+
public function list_form($list_address, $args = array(), $instance = array())
|
272 |
+
{
|
273 |
+
$widget_class_id = "mailgun-list-widget-{$args['widget_id']}";
|
274 |
+
$form_class_id = "list-form-{$args['widget_id']}";
|
275 |
+
|
276 |
+
// List addresses from the plugin config
|
277 |
+
$list_addresses = array_map('trim', explode(',', $list_address));
|
278 |
+
|
279 |
+
// All list info from the API; used for list info when more than one list is available to subscribe to
|
280 |
+
$all_list_addresses = $this->get_lists(); ?>
|
281 |
+
<div class="mailgun-list-widget-front <?php echo $widget_class_id; ?> widget">
|
282 |
+
<form class="list-form <?php echo $form_class_id; ?>">
|
283 |
+
<div class="mailgun-list-widget-inputs">
|
284 |
+
<?php if (isset($args['list_title'])) : ?>
|
285 |
+
<div class="mailgun-list-title">
|
286 |
+
<h4 class="widget-title">
|
287 |
+
<span><?php echo $args['list_title']; ?></span>
|
288 |
+
</h4>
|
289 |
+
</div>
|
290 |
+
<?php endif; ?>
|
291 |
+
<?php if (isset($args['list_description'])) : ?>
|
292 |
+
<div class="mailgun-list-description">
|
293 |
+
<p class="widget-description">
|
294 |
+
<span><?php echo $args['list_description']; ?></span>
|
295 |
+
</p>
|
296 |
+
</div>
|
297 |
+
<?php endif; ?>
|
298 |
+
<?php if (isset($args['collect_name']) && intval($args['collect_name']) === 1) : ?>
|
299 |
+
<p class="mailgun-list-widget-name">
|
300 |
+
<strong>Name:</strong>
|
301 |
+
<input type="text" name="name" />
|
302 |
+
</p>
|
303 |
+
<?php endif; ?>
|
304 |
+
<p class="mailgun-list-widget-email">
|
305 |
+
<strong>Email:</strong>
|
306 |
+
<input type="text" name="email" />
|
307 |
+
</p>
|
308 |
+
</div>
|
309 |
+
|
310 |
+
<?php if (count($list_addresses) > 1) : ?>
|
311 |
+
<ul class="mailgun-lists" style="list-style: none;">
|
312 |
+
<?php foreach ($all_list_addresses as $la) : ?>
|
313 |
+
<?php if (!in_array($la['address'], $list_addresses)) {
|
314 |
+
continue;
|
315 |
+
} ?>
|
316 |
+
<li>
|
317 |
+
<input type="checkbox" class="mailgun-list-name" name="addresses[<?php echo $la['address']; ?>]" /> <?php echo $la['name']; ?>
|
318 |
+
</li>
|
319 |
+
<?php endforeach; ?>
|
320 |
+
</ul>
|
321 |
+
<?php else : ?>
|
322 |
+
<input type="hidden" name="addresses[<?php echo $list_addresses[0]; ?>]" value="on" />
|
323 |
+
<?php endif; ?>
|
324 |
+
|
325 |
+
<input class="mailgun-list-submit-button" data-form-id="<?php echo $form_class_id; ?>" type="button" value="Subscribe" />
|
326 |
+
<input type="hidden" name="mailgun-submission" value="1" />
|
327 |
+
|
328 |
+
</form>
|
329 |
+
<div class="widget-list-panel result-panel" style="display:none;">
|
330 |
+
<span>Thank you for subscribing!</span>
|
331 |
+
</div>
|
332 |
+
</div>
|
333 |
+
|
334 |
+
<script>
|
335 |
+
|
336 |
+
jQuery(document).ready(function(){
|
337 |
+
|
338 |
+
jQuery('.mailgun-list-submit-button').on('click', function() {
|
339 |
+
|
340 |
+
var form_id = jQuery(this).data('form-id');
|
341 |
+
|
342 |
+
if(jQuery('.mailgun-list-name').length > 0 && jQuery('.'+form_id+' .mailgun-list-name:checked').length < 1) {
|
343 |
+
alert('Please select a list to subscribe to.');
|
344 |
+
return;
|
345 |
+
}
|
346 |
+
|
347 |
+
if(jQuery('.'+form_id+' .mailgun-list-widget-name input') && jQuery('.'+form_id+' .mailgun-list-widget-name input').val() === '') {
|
348 |
+
alert('Please enter your subscription name.');
|
349 |
+
return;
|
350 |
+
}
|
351 |
+
|
352 |
+
if(jQuery('.'+form_id+' .mailgun-list-widget-email input').val() === '') {
|
353 |
+
alert('Please enter your subscription email.');
|
354 |
+
return;
|
355 |
+
}
|
356 |
+
|
357 |
+
jQuery.ajax({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
url: '<?php echo admin_url('admin-ajax.php?action=add_list'); ?>',
|
359 |
+
action:'add_list',
|
360 |
type: 'post',
|
361 |
dataType: 'json',
|
362 |
+
data: jQuery('.'+form_id+'').serialize(),
|
363 |
+
success: function(data) {
|
364 |
+
|
365 |
+
data_msg = data.message;
|
366 |
+
already_exists = false;
|
367 |
+
if(data_msg !== undefined){
|
368 |
+
already_exists = data_msg.indexOf('Address already exists') > -1;
|
369 |
+
}
|
370 |
+
|
371 |
+
// success
|
372 |
+
if((data.status === 200)) {
|
373 |
+
jQuery('.<?php echo $widget_class_id; ?> .widget-list-panel').css('display', 'none');
|
374 |
+
jQuery('.<?php echo $widget_class_id; ?> .list-form').css('display', 'none');
|
375 |
+
jQuery('.<?php echo $widget_class_id; ?> .result-panel').css('display', 'block');
|
376 |
// error
|
377 |
+
} else {
|
378 |
+
alert(data_msg);
|
379 |
+
}
|
380 |
}
|
381 |
+
});
|
382 |
+
});
|
383 |
+
});
|
384 |
+
|
385 |
+
</script>
|
386 |
+
|
387 |
+
<?php
|
388 |
+
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Initialize List Form.
|
393 |
+
*
|
394 |
+
* @param array $atts Form attributes
|
395 |
+
*
|
396 |
+
* @since 0.1
|
397 |
+
*/
|
398 |
+
public function build_list_form($atts)
|
399 |
+
{
|
400 |
+
if (isset($atts['id']) && $atts['id'] != '') {
|
401 |
+
$args['widget_id'] = md5(rand(10000, 99999) + $atts['id']);
|
402 |
+
|
403 |
+
if (isset($atts['collect_name'])) {
|
404 |
+
$args['collect_name'] = true;
|
405 |
+
}
|
406 |
+
|
407 |
+
if (isset($atts['title'])) {
|
408 |
+
$args['list_title'] = $atts['title'];
|
409 |
+
}
|
410 |
+
|
411 |
+
if (isset($atts['description'])) {
|
412 |
+
$args['list_description'] = $atts['description'];
|
413 |
+
}
|
414 |
+
|
415 |
+
ob_start();
|
416 |
+
$this->list_form($atts['id'], $args);
|
417 |
+
$output_string = ob_get_contents();
|
418 |
+
ob_end_clean();
|
419 |
+
|
420 |
+
return $output_string;
|
421 |
+
} else {
|
422 |
+
?>
|
423 |
+
<span>Mailgun list ID needed to render form!</span>
|
424 |
+
<br />
|
425 |
+
<strong>Example :</strong> [mailgun id="[your list id]"]
|
426 |
+
<?php
|
427 |
+
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Initialize List Widget.
|
433 |
+
*
|
434 |
+
* @since 0.1
|
435 |
+
*/
|
436 |
+
public function load_list_widget()
|
437 |
+
{
|
438 |
+
register_widget('list_widget');
|
439 |
+
add_shortcode('mailgun', array(&$this, 'build_list_form'));
|
440 |
+
}
|
441 |
+
}
|
442 |
+
|
443 |
+
$mailgun = new Mailgun();
|
444 |
+
|
445 |
+
if (@include dirname(__FILE__).'/includes/widget.php') {
|
446 |
+
add_action('widgets_init', array(&$mailgun, 'load_list_widget'));
|
447 |
+
add_action('wp_ajax_nopriv_add_list', array(&$mailgun, 'add_list'));
|
448 |
+
add_action('wp_ajax_add_list', array(&$mailgun, 'add_list'));
|
449 |
+
}
|
450 |
+
|
451 |
+
if (is_admin()) {
|
452 |
+
if (@include dirname(__FILE__).'/includes/admin.php') {
|
453 |
+
$mailgunAdmin = new MailgunAdmin();
|
454 |
+
} else {
|
455 |
+
Mailgun::deactivate_and_die(dirname(__FILE__).'/includes/admin.php');
|
456 |
+
}
|
457 |
+
}
|
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:
|
8 |
-
Stable tag: 1.
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
|
@@ -18,7 +18,7 @@ Easily send email from your WordPress site through Mailgun using the HTTP API or
|
|
18 |
|
19 |
One particularly useful feature of this plugin is that it provides you with a way to send email when the server you are on does not support SMTP or where outbound SMTP is restricted since the plug-in uses the Mailgun HTTP API for sending email by default. All you need to use the plugin is a [Mailgun account](http://www.mailgun.com/). Mailgun has a free account that lets you send up to 200 emails per day, which is great for testing. Paid subscriptions are available for increased limits.
|
20 |
|
21 |
-
The latest version of this plugin
|
22 |
|
23 |
The current version of this plugin only handles sending emails, tracking and tagging and list subscription.
|
24 |
|
@@ -53,14 +53,12 @@ define( 'MG_DEBUG_SMTP', true );
|
|
53 |
Yes, using the following constants that can be placed in wp-config.php:
|
54 |
|
55 |
`
|
56 |
-
|
57 |
-
ex. define('MAILGUN_REGION', 'us');
|
58 |
-
MAILGUN_USEAPI Type: boolean Choices: '0' or '1' (0 = false/no)
|
59 |
MAILGUN_APIKEY Type: string
|
60 |
MAILGUN_DOMAIN Type: string
|
61 |
MAILGUN_USERNAME Type: string
|
62 |
MAILGUN_PASSWORD Type: string
|
63 |
-
MAILGUN_SECURE Type: boolean
|
64 |
MAILGUN_SECTYPE Type: string Choices: 'ssl' or 'tls'
|
65 |
MAILGUN_FROM_NAME Type: string
|
66 |
MAILGUN_FROM_ADDRESS Type: string
|
@@ -72,7 +70,7 @@ MAILGUN_FROM_ADDRESS Type: string
|
|
72 |
Mutates messages to use recipient variables syntax - see
|
73 |
https://documentation.mailgun.com/user_manual.html#batch-sending for more info.
|
74 |
|
75 |
-
Should accept a list of `To`
|
76 |
|
77 |
Should *only* return `true` or `false`.
|
78 |
|
@@ -97,7 +95,7 @@ MAILGUN_FROM_ADDRESS Type: string
|
|
97 |
Mutates messages to use recipient variables syntax - see
|
98 |
https://documentation.mailgun.com/user_manual.html#batch-sending for more info.
|
99 |
|
100 |
-
Should accept a list of `To`
|
101 |
|
102 |
Should *only* return `true` or `false`.
|
103 |
|
@@ -129,55 +127,6 @@ MAILGUN_FROM_ADDRESS Type: string
|
|
129 |
|
130 |
== Changelog ==
|
131 |
|
132 |
-
= 1.7.1 (2019-02-07): =
|
133 |
-
- Reinstall settings page for multisites.
|
134 |
-
|
135 |
-
= 1.7 (2019-01-21): =
|
136 |
-
- Remove settings page for multisites.
|
137 |
-
- Simplify admin notifications.
|
138 |
-
- Test plugin with PHP 7.2.
|
139 |
-
- Test plugin up to WordPress 5.0.3.
|
140 |
-
|
141 |
-
= 1.6.1 (2018-10-08): =
|
142 |
-
- Restore Settings page form for all install types.
|
143 |
-
|
144 |
-
= 1.6 (2018-9-21): =
|
145 |
-
- Refactor admin notifications
|
146 |
-
- Enable Settings page for all WordPress install types
|
147 |
-
- Enable Test Configuration for all WordPress install types
|
148 |
-
- Test plugin up to WordPress 4.9.8.
|
149 |
-
|
150 |
-
= 1.5.14 (2018-09-11): =
|
151 |
-
- Force SSL-secured SMTP connections to use port 465 (SMTPS) to connect, 587 for plain and TLS
|
152 |
-
- Support region endpoint switching for SMTP
|
153 |
-
|
154 |
-
= 1.5.13.1 (2018-08-15): =
|
155 |
-
- Fix line breaks in Test Configuration email
|
156 |
-
|
157 |
-
= 1.5.13 (2018-08-14): =
|
158 |
-
- Default to US region if no region is configured in settings
|
159 |
-
- Add admin notification about region configuration
|
160 |
-
- Log an error message when an email is sent with no explicit region configured
|
161 |
-
|
162 |
-
= 1.5.12.3 (2018-08-09): =
|
163 |
-
- Fix Region select menu default when wp-config.php variable is set
|
164 |
-
- Fix front end email input validation
|
165 |
-
|
166 |
-
= 1.5.12.2 (2018-08-09): =
|
167 |
-
- Fix plugin not saving after update
|
168 |
-
|
169 |
-
= 1.5.12.1 (2018-08-06): =
|
170 |
-
- Fix for backwards compatibility
|
171 |
-
|
172 |
-
= 1.5.12 (2018-08-02): =
|
173 |
-
- Add EU endpoint for Mailgun HTTP API
|
174 |
-
- Fix broken logo image on Lists page
|
175 |
-
- Test plugin up to Wordpress 4.9.7
|
176 |
-
|
177 |
-
= 1.5.11 (2018-05-30): =
|
178 |
-
- Fix an issue with authentication failing for newer API keys
|
179 |
-
- Test plugin up to Wordpress 4.9.6
|
180 |
-
|
181 |
= 1.5.10 (2017-11-22): =
|
182 |
- Fix back to settings link on lists page (https://github.com/mailgun/wordpress-plugin/pull/65)
|
183 |
- Fix a bug causing `text/html` emails to send as both `text/plain` *and* `text/html` parts
|
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.8
|
8 |
+
Stable tag: 1.5.10
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
|
18 |
|
19 |
One particularly useful feature of this plugin is that it provides you with a way to send email when the server you are on does not support SMTP or where outbound SMTP is restricted since the plug-in uses the Mailgun HTTP API for sending email by default. All you need to use the plugin is a [Mailgun account](http://www.mailgun.com/). Mailgun has a free account that lets you send up to 200 emails per day, which is great for testing. Paid subscriptions are available for increased limits.
|
20 |
|
21 |
+
The latest version of this plugin adds support for Mailgun list subscription. Using the shortcode, you can place a form on an article or page to allow the visitor to subscribe to one or more lists. Using the widget, you can provide subscription functionality in sidebars or anywhere widgets are supported e.g. footers.
|
22 |
|
23 |
The current version of this plugin only handles sending emails, tracking and tagging and list subscription.
|
24 |
|
53 |
Yes, using the following constants that can be placed in wp-config.php:
|
54 |
|
55 |
`
|
56 |
+
MAILGUN_USEAPI Type: boolean
|
|
|
|
|
57 |
MAILGUN_APIKEY Type: string
|
58 |
MAILGUN_DOMAIN Type: string
|
59 |
MAILGUN_USERNAME Type: string
|
60 |
MAILGUN_PASSWORD Type: string
|
61 |
+
MAILGUN_SECURE Type: boolean
|
62 |
MAILGUN_SECTYPE Type: string Choices: 'ssl' or 'tls'
|
63 |
MAILGUN_FROM_NAME Type: string
|
64 |
MAILGUN_FROM_ADDRESS Type: string
|
70 |
Mutates messages to use recipient variables syntax - see
|
71 |
https://documentation.mailgun.com/user_manual.html#batch-sending for more info.
|
72 |
|
73 |
+
Should accept a list of `To` addressses.
|
74 |
|
75 |
Should *only* return `true` or `false`.
|
76 |
|
95 |
Mutates messages to use recipient variables syntax - see
|
96 |
https://documentation.mailgun.com/user_manual.html#batch-sending for more info.
|
97 |
|
98 |
+
Should accept a list of `To` addressses.
|
99 |
|
100 |
Should *only* return `true` or `false`.
|
101 |
|
127 |
|
128 |
== Changelog ==
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
= 1.5.10 (2017-11-22): =
|
131 |
- Fix back to settings link on lists page (https://github.com/mailgun/wordpress-plugin/pull/65)
|
132 |
- Fix a bug causing `text/html` emails to send as both `text/plain` *and* `text/html` parts
|