Version Description
- UPDATED: Dashboard widget shown only to those capable of manage_options
- ADDED: CURL calls doesn't verify SSL certificates anymore. ** Thanks Bruno Braga! **
- ADDED: Adding support for editable regions. ** Thanks dennissmolek **
- FIXED: Using a literal as the textdomain instead of a constant. ** Thanks Joost! **
- FIXED: Cleaning some unused variables. ** Thanks Joost! **
- FIXED: Removed checking of sender domain at send time.
Download this release
Release Info
Developer | MC_Will |
Plugin | wpMandrill |
Version | 1.24 |
Comparing to | |
See all releases |
Code changes from version 1.23 to 1.24
- how-tos.php +14 -1
- lib/mandrill.class.php +3 -0
- readme.txt +18 -2
- wpmandrill.php +166 -160
how-tos.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
class wpMandrill_HowTos {
|
4 |
static function show($section) {
|
5 |
$section = strtolower($section);
|
6 |
-
if ( !in_array($section, array('intro','auto','regular','filter','direct') ) ) $section = 'auto';
|
7 |
|
8 |
$title = '';
|
9 |
|
@@ -22,6 +22,9 @@ class wpMandrill_HowTos {
|
|
22 |
case 'direct':
|
23 |
$title = __('Mandrill: How to send emails from within your plugins.', 'wpmandrill');
|
24 |
break;
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
$method = 'showSection' . ucwords($section);
|
@@ -73,6 +76,16 @@ HTML;
|
|
73 |
';
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
static function showSectionFilter() {
|
77 |
return '
|
78 |
<span class="setting-description">
|
3 |
class wpMandrill_HowTos {
|
4 |
static function show($section) {
|
5 |
$section = strtolower($section);
|
6 |
+
if ( !in_array($section, array('intro','auto','regular','filter','direct','regions') ) ) $section = 'auto';
|
7 |
|
8 |
$title = '';
|
9 |
|
22 |
case 'direct':
|
23 |
$title = __('Mandrill: How to send emails from within your plugins.', 'wpmandrill');
|
24 |
break;
|
25 |
+
case 'regions':
|
26 |
+
$title = __('Mandrill: How to use multiple editable regions in your template.', 'wpmandrill');
|
27 |
+
break;
|
28 |
}
|
29 |
|
30 |
$method = 'showSection' . ucwords($section);
|
76 |
';
|
77 |
}
|
78 |
|
79 |
+
static function showSectionRegions() {
|
80 |
+
return '
|
81 |
+
<span class="setting-description">
|
82 |
+
<p>'.__('By default, wpMandrill uses only one editable section of your templates: <em>main</em> so its use is transparent for the you.', 'wpmandrill').'</p>
|
83 |
+
<p>'.__('If you need to use more than one, <em>main</em> included, you need to provided an array with the content to use for each editable region involved. This array should be supply in the field "html" of the payload.', 'wpmandrill').'</p>
|
84 |
+
<p>'.__('This array has the same structure of the parameter <em>template_content</em> of the API call <a href="https://mandrillapp.com/api/docs/messages.html#method=send-template" target="_blank">send-template</a>:', 'wpmandrill').'</p>
|
85 |
+
<p>'.__('$message["html"] = array( array("name" => region_name_1", "content" => "My awesome content for Region 1"), ... , array( "name" => region_name_2", "content" => "My awesome content for Region 2") )', 'wpmandrill').'</p>
|
86 |
+
';
|
87 |
+
}
|
88 |
+
|
89 |
static function showSectionFilter() {
|
90 |
return '
|
91 |
<span class="setting-description">
|
lib/mandrill.class.php
CHANGED
@@ -428,6 +428,9 @@ class Mandrill {
|
|
428 |
|
429 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
|
430 |
|
|
|
|
|
|
|
431 |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
|
432 |
curl_setopt($ch, CURLOPT_HEADER, false);
|
433 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
428 |
|
429 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
|
430 |
|
431 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // @Bruno Braga:
|
432 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Thanks for the hack!
|
433 |
+
|
434 |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
|
435 |
curl_setopt($ch, CURLOPT_HEADER, false);
|
436 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
readme.txt
CHANGED
@@ -43,7 +43,7 @@ In order to use this plugin, you have to provide one of your Mandrill API keys.
|
|
43 |
|
44 |
= Do I need a MailChimp account? =
|
45 |
|
46 |
-
Not anymore!
|
47 |
|
48 |
= Is all email routed through Mandrill? =
|
49 |
|
@@ -59,6 +59,14 @@ In version 1.09, we added a setting that allows you to tell the plugin if you wa
|
|
59 |
|
60 |
If you set the WP_DEBUG constant (defined in your wp-config.php file) to true, you'll see some messages added by the plugin in key parts of the process.
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
== Request ==
|
63 |
|
64 |
If you find that a part of this plugin isn't working, please don't simply click the Wordpress "It's broken" button. Let us know what's broken in [its support forum](http://wordpress.org/tags/wpmandrill?forum_id=10) so we can make it better. Our [mind-reading device](http://www.youtube.com/watch?v=cCTlonSwePs) still needs some tweaking.
|
@@ -84,8 +92,16 @@ If your account has more than 20 senders registered or more than 40 tags used, t
|
|
84 |
|
85 |
== Changelog ==
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
= 1.23 =
|
88 |
-
* FIXED: JS Alerts
|
89 |
|
90 |
= 1.22 =
|
91 |
* UPDATED: Replacing Highcharts in favor of Flot
|
43 |
|
44 |
= Do I need a MailChimp account? =
|
45 |
|
46 |
+
Not anymore!
|
47 |
|
48 |
= Is all email routed through Mandrill? =
|
49 |
|
59 |
|
60 |
If you set the WP_DEBUG constant (defined in your wp-config.php file) to true, you'll see some messages added by the plugin in key parts of the process.
|
61 |
|
62 |
+
= I am getting an Invalid API Key message and I'm sure my API is valid!
|
63 |
+
|
64 |
+
Please verify the following:
|
65 |
+
|
66 |
+
1. That your API key is active (this can be viewed on the SMTP & API Credentials page in your Mandrill account);
|
67 |
+
1. That your web server has either cURL installed or is able to use fsock*() functions (if you don't know what this means, you may want to check with your hosting provider for more details);
|
68 |
+
1. That the domain name you're using above is listed in the Sending Domains for your Mandrill account.
|
69 |
+
|
70 |
== Request ==
|
71 |
|
72 |
If you find that a part of this plugin isn't working, please don't simply click the Wordpress "It's broken" button. Let us know what's broken in [its support forum](http://wordpress.org/tags/wpmandrill?forum_id=10) so we can make it better. Our [mind-reading device](http://www.youtube.com/watch?v=cCTlonSwePs) still needs some tweaking.
|
92 |
|
93 |
== Changelog ==
|
94 |
|
95 |
+
= 1.24 =
|
96 |
+
* UPDATED: Dashboard widget shown only to those capable of manage_options
|
97 |
+
* ADDED: CURL calls doesn't verify SSL certificates anymore. ** Thanks Bruno Braga! **
|
98 |
+
* ADDED: Adding support for editable regions. ** Thanks dennissmolek **
|
99 |
+
* FIXED: Using a literal as the textdomain instead of a constant. ** Thanks Joost! **
|
100 |
+
* FIXED: Cleaning some unused variables. ** Thanks Joost! **
|
101 |
+
* FIXED: Removed checking of sender domain at send time.
|
102 |
+
|
103 |
= 1.23 =
|
104 |
+
* FIXED: JS Alerts in wrong places...
|
105 |
|
106 |
= 1.22 =
|
107 |
* UPDATED: Replacing Highcharts in favor of Flot
|
wpmandrill.php
CHANGED
@@ -5,7 +5,7 @@ Description: wpMandrill sends emails, generated by WordPress using Mandrill.
|
|
5 |
Author: Mandrill
|
6 |
Author URI: http://mandrillapp.com/
|
7 |
Plugin URI: http://connect.mailchimp.com/integrations/wpmandrill
|
8 |
-
Version: 1.
|
9 |
Text Domain: wpmandrill
|
10 |
*/
|
11 |
/* Copyright 2012 MailChimp (email : will@mailchimp.com )
|
@@ -28,7 +28,6 @@ Text Domain: wpmandrill
|
|
28 |
wpMandrill::on_load();
|
29 |
|
30 |
class wpMandrill {
|
31 |
-
const WPDOMAIN = 'wpmandrill';
|
32 |
const DEBUG = false;
|
33 |
|
34 |
static $settings;
|
@@ -51,7 +50,7 @@ class wpMandrill {
|
|
51 |
add_action('wp_ajax_get_mandrill_stats', array(__CLASS__,'getAjaxStats'));
|
52 |
add_action('wp_ajax_get_dashboard_widget_stats', array(__CLASS__,'showDashboardWidget'));
|
53 |
|
54 |
-
load_plugin_textdomain(
|
55 |
|
56 |
if( function_exists('wp_mail') ) {
|
57 |
self::$conflict = true;
|
@@ -90,40 +89,40 @@ class wpMandrill {
|
|
90 |
add_filter('plugin_action_links',array(__CLASS__,'showPluginActionLinks'), 10,5);
|
91 |
add_action('admin_enqueue_scripts', array(__CLASS__,'showAdminEnqueueScripts'));
|
92 |
|
93 |
-
register_setting(
|
94 |
|
95 |
add_action( 'network_admin_notices', array( __CLASS__, 'network_connect_notice' ) );
|
96 |
|
97 |
// SMTP Settings
|
98 |
-
add_settings_section('wpmandrill-api', __('API Settings',
|
99 |
-
add_settings_field('api-key', __('API Key',
|
100 |
|
101 |
if( self::getAPIKey() ) {
|
102 |
-
add_action('wp_dashboard_setup', array( __CLASS__,'addDashboardWidgets') );
|
103 |
|
104 |
// Verified Addresses
|
105 |
-
add_settings_section('wpmandrill-addresses', __('Sender Settings',
|
106 |
-
add_settings_field('from-name', __('FROM Name',
|
107 |
-
add_settings_field('from-email', __('FROM Email',
|
108 |
-
add_settings_field('reply-to', __('Reply-To Email',
|
109 |
|
110 |
// Template
|
111 |
-
add_settings_section('wpmandrill-templates', __('General Design',
|
112 |
-
add_settings_field('template', __('Template',
|
113 |
-
add_settings_field('nl2br', __('Content',
|
114 |
|
115 |
// Tags
|
116 |
-
add_settings_section('wpmandrill-tags', __('General Tags',
|
117 |
-
add_settings_field('tags', __(' ',
|
118 |
|
119 |
if ( self::isConfigured() ) {
|
120 |
// Email Test
|
121 |
register_setting('wpmandrill-test', 'wpmandrill-test', array(__CLASS__, 'sendTestEmail'));
|
122 |
|
123 |
-
add_settings_section('mandrill-email-test', __('Send a test email using these settings',
|
124 |
-
add_settings_field('email-to', __('Send to',
|
125 |
-
add_settings_field('email-subject', __('Subject',
|
126 |
-
add_settings_field('email-message', __('Message',
|
127 |
}
|
128 |
|
129 |
}
|
@@ -148,19 +147,19 @@ class wpMandrill {
|
|
148 |
static function adminMenu() {
|
149 |
|
150 |
self::$settings = add_options_page(
|
151 |
-
__('Mandrill Settings',
|
152 |
-
__('Mandrill',
|
153 |
'manage_options',
|
154 |
-
|
155 |
array(__CLASS__,'showOptionsPage')
|
156 |
);
|
157 |
|
158 |
if( self::isConfigured() ) {
|
159 |
-
self::$report = add_dashboard_page(
|
160 |
-
__('Mandrill Reports',
|
161 |
-
__('Mandrill Reports',
|
162 |
'manage_options',
|
163 |
-
|
164 |
array(__CLASS__,'showReportPage')
|
165 |
);
|
166 |
if ( self::isPluginPage('-reports') ) {
|
@@ -186,7 +185,7 @@ class wpMandrill {
|
|
186 |
?>
|
187 |
<div id="message" class="updated wpmandrill-message">
|
188 |
<div class="squeezer">
|
189 |
-
<h4><?php _e( '<strong>wpMandrill is activated!</strong> Each site on your network must be connected individually by an admin on that site.',
|
190 |
</div>
|
191 |
</div>
|
192 |
<?php
|
@@ -196,7 +195,7 @@ class wpMandrill {
|
|
196 |
|
197 |
static function adminNotices() {
|
198 |
if ( self::$conflict ) {
|
199 |
-
echo '<div class="error"><p>'.__('Mandrill: wp_mail has been declared by another process or plugin, so you won\'t be able to use Mandrill until the problem is solved.',
|
200 |
}
|
201 |
}
|
202 |
|
@@ -214,8 +213,6 @@ class wpMandrill {
|
|
214 |
if ($screen_id == self::$settings) {
|
215 |
wpMandrill::getConnected();
|
216 |
|
217 |
-
$dir = dirname( plugin_basename( __FILE__ ) ).'/images';
|
218 |
-
|
219 |
$ok = array();
|
220 |
$ok['account'] = ( !wpMandrill::isConnected() ) ? ' class="missing"' : '';
|
221 |
$ok['domains'] = ( $ok['account'] != '' || !count(self::ListVerifiedDomains()) ) ? ' class="missing"' : '';
|
@@ -223,22 +220,22 @@ class wpMandrill {
|
|
223 |
|
224 |
$requirements = '';
|
225 |
if ($ok['account'] . $ok['domains'] . $ok['email'] != '' ) {
|
226 |
-
$requirements = '<p>' . __('To use this plugin you will need:',
|
227 |
. '<ol>'
|
228 |
-
. '<li'.$ok['account'].'>'. __('Your Mandrill account.',
|
229 |
-
. '<li'.$ok['domains'].'>' . __('At least one domain defined in your Mandrill account.',
|
230 |
-
. '<li'.$ok['email'].'>' . __('A valid sender email address.',
|
231 |
. '</ol>';
|
232 |
}
|
233 |
|
234 |
return $requirements
|
235 |
-
. '<p>' . __('Once you have properly configured the settings, the plugin will take care of all the emails sent through your WordPress installation.',
|
236 |
-
. '<p>' . __('However, if you need to customize any part of the email before sending, you can do so by using the WordPress filter <strong>mandrill_payload</strong>.',
|
237 |
-
. '<p>' . __('This filter has the same structure as Mandrill\'s API call <a href="http://mandrillapp.com/api/docs/messages.html#method=send" target="_blank">/messages/send</a>, except that it can have one additional parameter when the email is based on a template. The parameter is called "<em>template</em>", which is an associative array of two elements (the first element, a string whose key is "<em>template_name</em>", and a second parameter whose key is "<em>template_content</em>". Its value is an array with the same structure of the parameter "<em>template_content</em>" in the call <a href="http://mandrillapp.com/api/docs/messages.html#method=send-template" target="_blank">/messages/send-template</a>.)',
|
238 |
-
. '<p>' . __('Note that if you\'re sending additional headers in your emails, the only valid headers are <em>From:</em>, <em>Reply-To:</em>, and <em>X-*:</em>. <em>Bcc:</em> is also valid, but Mandrill will send the blind carbon copy to only the first address, and the remaining will be silently discarted.',
|
239 |
-
. '<p>' . __('Also note that if any error occurs while sending the email, the plugin will try to send the message again using the native WordPress mailing capabilities.',
|
240 |
-
. '<p>' . __('Confirm that any change you made to the payload is in line with the <a href="http://mandrillapp.com/api/docs/" target="_blank">Mandrill\'s API\'s documentation</a>. Also, the <em>X-*:</em> headers, must be in line with the <a href="http://help.mandrill.com/forums/20689696-smtp-integration" target="_blank">SMTP API documentation</a>. By using this plugin, you agree that you and your website will adhere to <a href="http://www.mandrill.com/terms/" target="_blank">Mandrill\'s Terms of Use</a> and <a href="http://mandrill.com/privacy/" target="_blank">Privacy Policy</a>.',
|
241 |
-
. '<p>' . __('if you have any question about Mandrill or this plugin, visit the <a href="http://help.mandrill.com/" target="_blank">Mandrill\'s Support Center</a>.',
|
242 |
;
|
243 |
}
|
244 |
|
@@ -256,10 +253,10 @@ class wpMandrill {
|
|
256 |
|
257 |
if ($plugin == $plugin_file) {
|
258 |
|
259 |
-
$settings = array('settings' => '<a href="options-general.php?page=wpmandrill">' . __('Settings',
|
260 |
|
261 |
if ( self::isConnected() ) {
|
262 |
-
$report = array('report' => '<a href="index.php?page=wpmandrill-reports">' . __('Reports',
|
263 |
$actions = array_merge($settings, $actions, $report);
|
264 |
} else {
|
265 |
$actions = array_merge($settings, $actions);
|
@@ -287,14 +284,14 @@ class wpMandrill {
|
|
287 |
?>
|
288 |
<div class="wrap">
|
289 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
290 |
-
<h2><?php _e('Mandrill Settings',
|
291 |
|
292 |
<div style="float: left;width: 70%;">
|
293 |
<form method="post" action="options.php">
|
294 |
|
295 |
<div class="stuffbox">
|
296 |
-
<?php settings_fields(
|
297 |
-
<?php do_settings_sections(
|
298 |
</div>
|
299 |
|
300 |
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /></p>
|
@@ -308,7 +305,7 @@ class wpMandrill {
|
|
308 |
<?php do_settings_sections('wpmandrill-test'); ?>
|
309 |
</div>
|
310 |
|
311 |
-
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e('Send Test',
|
312 |
</form>
|
313 |
<?php } ?>
|
314 |
|
@@ -326,7 +323,7 @@ class wpMandrill {
|
|
326 |
if ( $maxitems > 0 ) {
|
327 |
?>
|
328 |
<div class="mcnews mandrill">
|
329 |
-
<h3 class="mcnews_header"><?php _e('Latest from Mandrill...',
|
330 |
<ul>
|
331 |
<?php
|
332 |
foreach ( $rss_items as $item ) { ?>
|
@@ -340,7 +337,7 @@ class wpMandrill {
|
|
340 |
</div>
|
341 |
<?php } ?>
|
342 |
<div class="mcnews">
|
343 |
-
<h3 class="mcnews_header"><?php _e('News from MailChimp...',
|
344 |
$rss = fetch_feed('http://mailchimp.com/blog/feed');
|
345 |
if (!is_wp_error( $rss ) ) {
|
346 |
$maxitems = $rss->get_item_quantity(5);
|
@@ -369,7 +366,7 @@ class wpMandrill {
|
|
369 |
?>
|
370 |
<div class="wrap">
|
371 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
372 |
-
<h2><?php _e('Mandrill How-Tos',
|
373 |
<?php
|
374 |
require plugin_dir_path( __FILE__ ) . '/how-tos.php';
|
375 |
|
@@ -396,9 +393,9 @@ class wpMandrill {
|
|
396 |
|
397 |
if ( !empty($input['from_domain']) && ( empty($input['from_username']) || !self::isDomainEnabled($input['from_domain']) ) ) {
|
398 |
add_settings_error(
|
399 |
-
|
400 |
'from-email',
|
401 |
-
__('You must define a valid sender email.',
|
402 |
'error'
|
403 |
);
|
404 |
|
@@ -441,7 +438,7 @@ jQuery(document).bind( 'ready', function() {
|
|
441 |
*/
|
442 |
static function getOption( $name, $default = false ) {
|
443 |
|
444 |
-
$options = get_option(
|
445 |
|
446 |
if( isset( $options[$name] ) )
|
447 |
return $options[$name];
|
@@ -477,11 +474,11 @@ jQuery(document).bind( 'ready', function() {
|
|
477 |
*/
|
478 |
static function setOption( $name, $value ) {
|
479 |
|
480 |
-
$options = get_option(
|
481 |
|
482 |
$options[$name] = $value;
|
483 |
|
484 |
-
$result = update_option(
|
485 |
|
486 |
return $result;
|
487 |
}
|
@@ -602,7 +599,7 @@ jQuery(document).bind( 'ready', function() {
|
|
602 |
*/
|
603 |
static function isPluginPage($sufix = '') {
|
604 |
|
605 |
-
return ( isset( $_GET['page'] ) && $_GET['page'] ==
|
606 |
}
|
607 |
|
608 |
/**
|
@@ -674,7 +671,12 @@ jQuery(document).bind( 'ready', function() {
|
|
674 |
|
675 |
if (is_wp_error($test)) {
|
676 |
|
677 |
-
add_settings_error('email-to', 'email-to', __('Test failed.
|
|
|
|
|
|
|
|
|
|
|
678 |
|
679 |
return array_map('wp_strip_all_tags', $input);
|
680 |
|
@@ -691,7 +693,7 @@ jQuery(document).bind( 'ready', function() {
|
|
691 |
}
|
692 |
|
693 |
|
694 |
-
add_settings_error('email-to', 'email-to', sprintf(__('Test executed: %d emails sent, %d emails queued and %d emails rejected',
|
695 |
}
|
696 |
}
|
697 |
|
@@ -706,7 +708,7 @@ jQuery(document).bind( 'ready', function() {
|
|
706 |
?><input id='api_key' name='wpmandrill[api_key]' size='45' type='text' value="<?php esc_attr_e( $api_key ); ?>" /><?php
|
707 |
|
708 |
if ( empty($api_key) ) {
|
709 |
-
?><br/><span class="setting-description"><small><em><?php _e('To get your API key, please visit your <a href="http://mandrillapp.com/settings/index" target="_blank">Mandrill Settings</a>',
|
710 |
} else {
|
711 |
$api_is_valid = false;
|
712 |
|
@@ -714,7 +716,7 @@ jQuery(document).bind( 'ready', function() {
|
|
714 |
if ( wpMandrill::isConnected() ) $api_is_valid = ( wpMandrill::$mandrill->users_ping() == 'PONG!' );
|
715 |
|
716 |
if ( !$api_is_valid ) {
|
717 |
-
?><br/><span class="setting-description"><small><em><?php _e('Sorry. Invalid API key.',
|
718 |
}
|
719 |
}
|
720 |
|
@@ -731,7 +733,7 @@ jQuery(document).bind( 'ready', function() {
|
|
731 |
$domains = self::ListVerifiedDomains();
|
732 |
if ( !count($domains) ) {
|
733 |
|
734 |
-
_e('No domains found.',
|
735 |
|
736 |
if ( $from_email ) {
|
737 |
self::setOption('from_username', false);
|
@@ -743,13 +745,13 @@ jQuery(document).bind( 'ready', function() {
|
|
743 |
return;
|
744 |
}
|
745 |
|
746 |
-
?><?php _e('This address will be used as the sender of the outgoing emails:',
|
747 |
<input id="from_username" name="wpmandrill[from_username]" type="text" value="<?php esc_attr_e($from_username);?>" style="text-align:right;width:100px">@
|
748 |
<select id="from_domain" name="wpmandrill[from_domain]"><?php
|
749 |
foreach( $domains as $curdomain ) {
|
750 |
?><option value="<?php esc_attr_e($curdomain['domain']); ?>" <?php selected($curdomain['domain'], $from_domain); ?>><?php esc_html_e($curdomain['domain']); ?></option><?php
|
751 |
}
|
752 |
-
?></select><br/><span class="setting-description"><small><em><?php _e('If you need to add a new domain, please visit your <a href="https://mandrillapp.com/settings/sending-domains" target="_blank">Mandrill Settings</a>',
|
753 |
|
754 |
echo '</div>';
|
755 |
}
|
@@ -759,7 +761,7 @@ jQuery(document).bind( 'ready', function() {
|
|
759 |
|
760 |
$from_name = self::getFromName();
|
761 |
|
762 |
-
?><?php _e('Name the recipients will see in their email clients:',
|
763 |
<input name="wpmandrill[from_name]" type="text" value="<?php esc_attr_e($from_name); ?>">
|
764 |
<?php
|
765 |
|
@@ -771,9 +773,9 @@ jQuery(document).bind( 'ready', function() {
|
|
771 |
|
772 |
$reply_to = self::getReplyTo();
|
773 |
|
774 |
-
?><?php _e('This address will be used as the recipient where replies from the users will be sent to:',
|
775 |
<input id="reply_to" name="wpmandrill[reply_to]" type="text" value="<?php esc_attr_e($reply_to);?>"><br/>
|
776 |
-
<span class="setting-description"><small><em><?php _e('Leave blank to use the FROM Email. If you want to override this setting, you must use the <em><a href="#" onclick="jQuery(\'a#contextual-help-link\').trigger(\'click\');return false;">mandrill_payload</a></em> WordPress filter.',
|
777 |
|
778 |
echo '</div>';
|
779 |
}
|
@@ -784,7 +786,7 @@ jQuery(document).bind( 'ready', function() {
|
|
784 |
self::getConnected();
|
785 |
|
786 |
if ( !self::isConnected() ) {
|
787 |
-
_e('No templates found.',
|
788 |
|
789 |
echo '</div>';
|
790 |
return;
|
@@ -794,7 +796,7 @@ jQuery(document).bind( 'ready', function() {
|
|
794 |
$templates = self::$mandrill->templates_list();
|
795 |
if( is_wp_error($templates) || empty($templates)) {
|
796 |
|
797 |
-
_e('No templates found.',
|
798 |
|
799 |
if( $templates )
|
800 |
self::setOption('templates', false);
|
@@ -803,13 +805,13 @@ jQuery(document).bind( 'ready', function() {
|
|
803 |
return;
|
804 |
}
|
805 |
|
806 |
-
?><?php _e('Select the template to use:',
|
807 |
<select name="wpmandrill[template]">
|
808 |
<option value="">-None-</option><?php
|
809 |
foreach( $templates as $curtemplate ) {
|
810 |
?><option value="<?php esc_attr_e($curtemplate['name']); ?>" <?php selected($curtemplate['name'], $template); ?>><?php esc_html_e($curtemplate['name']); ?></option><?php
|
811 |
}
|
812 |
-
?></select><br/><span class="setting-description"><em><?php _e('<small>The selected template must have a <strong><em>mc:edit="main"</em></strong> placeholder defined. The message will be shown there.</small>',
|
813 |
|
814 |
echo '</div>';
|
815 |
}
|
@@ -818,9 +820,9 @@ jQuery(document).bind( 'ready', function() {
|
|
818 |
if ( $nl2br == '' ) $nl2br = 0;
|
819 |
?>
|
820 |
<div class="inside">
|
821 |
-
<?php _e('Replace all line feeds ("\n") by <br/> in the message body?',
|
822 |
<input name="wpmandrill[nl2br]" type="checkbox" <?=checked($nl2br,1); ?> value='1' /><br/>
|
823 |
-
<span class="setting-description"><em><?php _e('<small>If you are sending HTML emails already keep this setting deactivated.<br/>But if you are sending text only emails (WordPress default) this option might help your emails look better.</small>',
|
824 |
</div><?php
|
825 |
}
|
826 |
|
@@ -829,9 +831,9 @@ jQuery(document).bind( 'ready', function() {
|
|
829 |
|
830 |
$tags = self::getTags();
|
831 |
|
832 |
-
?><?php _e('If there are tags that you want appended to every call, list them here, one per line:',
|
833 |
<textarea name="wpmandrill[tags]" cols="25" rows="3"><?php echo $tags; ?></textarea><br/>
|
834 |
-
<span class="setting-description"><small><em><?php _e('Also keep in mind that you can add or remove tags using the <em><a href="#" onclick="jQuery(\'a#contextual-help-link\').trigger(\'click\');return false;">mandrill_payload</a></em> WordPress filter.',
|
835 |
<?php
|
836 |
|
837 |
echo '</div>';
|
@@ -861,7 +863,7 @@ jQuery(document).bind( 'ready', function() {
|
|
861 |
*/
|
862 |
static function getTestEmailOption($field) {
|
863 |
|
864 |
-
$email = get_option(
|
865 |
|
866 |
if( isset( $email[$field] ) )
|
867 |
return $email[$field];
|
@@ -1023,9 +1025,9 @@ jQuery(document).bind( 'ready', function() {
|
|
1023 |
*/
|
1024 |
static function getCurrentStats() {
|
1025 |
|
1026 |
-
$stats = get_transient(
|
1027 |
if ( empty($stats) ) {
|
1028 |
-
$stats = get_option(
|
1029 |
|
1030 |
if ( empty($stats) ) $stats = self::saveProcessedStats();
|
1031 |
|
@@ -1042,14 +1044,16 @@ jQuery(document).bind( 'ready', function() {
|
|
1042 |
static function saveProcessedStats() {
|
1043 |
$stats = self::GetProcessedStats();
|
1044 |
if ( !empty($stats) ) {
|
1045 |
-
set_transient(
|
1046 |
-
update_option(
|
1047 |
}
|
1048 |
|
1049 |
return $stats;
|
1050 |
}
|
1051 |
|
1052 |
static function addDashboardWidgets() {
|
|
|
|
|
1053 |
self::getConnected();
|
1054 |
if ( !self::isConnected() ) return;
|
1055 |
|
@@ -1059,11 +1063,8 @@ jQuery(document).bind( 'ready', function() {
|
|
1059 |
|
1060 |
if ( !$widget_options || !isset($widget_options[$widget_id])) {
|
1061 |
$filter = 'none';
|
1062 |
-
$display = 'volume';
|
1063 |
} else {
|
1064 |
-
|
1065 |
$filter = $widget_options[$widget_id]['filter'];
|
1066 |
-
$display = $widget_options[$widget_id]['display'];
|
1067 |
}
|
1068 |
|
1069 |
if ( $filter == 'none' ) {
|
@@ -1076,7 +1077,7 @@ jQuery(document).bind( 'ready', function() {
|
|
1076 |
}
|
1077 |
|
1078 |
wp_add_dashboard_widget( "mandrill_widget",
|
1079 |
-
__("Mandrill Recent Statistics",
|
1080 |
array(__CLASS__, 'showDashboardWidget'),
|
1081 |
array(__CLASS__, 'showDashboardWidgetOptions')
|
1082 |
);
|
@@ -1094,6 +1095,8 @@ jQuery(document).bind( 'ready', function() {
|
|
1094 |
}
|
1095 |
|
1096 |
static function showDashboardWidget() {
|
|
|
|
|
1097 |
wpMandrill::getConnected();
|
1098 |
|
1099 |
$isAjaxCall = isset($_POST['ajax']) && $_POST['ajax'] ? true : false;
|
@@ -1114,7 +1117,6 @@ jQuery(document).bind( 'ready', function() {
|
|
1114 |
$stats = array();
|
1115 |
if ( $filter == 'none' ) {
|
1116 |
$filter_type = 'account';
|
1117 |
-
$filter_used = '';
|
1118 |
|
1119 |
$data = self::$mandrill->users_info();
|
1120 |
$stats['stats']['periods']['account']['today'] = $data['stats']['today'];
|
@@ -1123,14 +1125,12 @@ jQuery(document).bind( 'ready', function() {
|
|
1123 |
} elseif ( substr($filter,0,2) == 's:' ) {
|
1124 |
$filter_type = 'senders';
|
1125 |
$filter = substr($filter,2);
|
1126 |
-
$filter_used = 'Filtering by sender: '.$filter;
|
1127 |
|
1128 |
$data = self::$mandrill->senders_info($filter);
|
1129 |
$stats['stats']['periods']['senders']['today'][$filter] = $data['stats']['today'];
|
1130 |
$stats['stats']['periods']['senders']['last_7_days'][$filter] = $data['stats']['last_7_days'];
|
1131 |
} else {
|
1132 |
$filter_type = 'tags';
|
1133 |
-
$filter_used = 'Filtering by tag: '.$filter;
|
1134 |
|
1135 |
$data = self::$mandrill->tags_info($filter);
|
1136 |
$stats['stats']['periods']['tags']['today'][$filter] = $data['stats']['today'];
|
@@ -1169,30 +1169,29 @@ jQuery(document).bind( 'ready', function() {
|
|
1169 |
|
1170 |
$lit = array();
|
1171 |
|
1172 |
-
$lit['title'] = __('Sending Volume',
|
1173 |
-
$lit['label_suffix'] = __(' emails',
|
1174 |
-
$lit['Ylabel'] = __('Total Volume per Day',
|
1175 |
|
1176 |
-
$lit['last_few_days'] = __('in the last few days',
|
1177 |
-
$lit['last_few_months']= __('in the last few months',
|
1178 |
-
$lit['today'] = __('Today',
|
1179 |
-
$lit['last7days'] = __('Last 7 Days',
|
1180 |
-
$lit['last30days'] = __('Last 30 Days',
|
1181 |
-
$lit['last60days'] = __('Last 60 Days',
|
1182 |
-
$lit['last90days'] = __('Last 90 Days',
|
1183 |
-
$lit['periods'] = __('Periods',
|
1184 |
-
$lit['volume'] = __('Volume',
|
1185 |
-
$lit['total'] = __('Total:',
|
1186 |
-
$lit['unopened'] = __('Unopened',
|
1187 |
-
$lit['bounced'] = __('Bounced or Rejected',
|
1188 |
-
$lit['opened'] = __('Opened',
|
1189 |
|
1190 |
$tickFormatter = 'emailFormatter';
|
1191 |
-
$format_sufix = ' email(s)';
|
1192 |
if ( $display == 'average' ) {
|
1193 |
-
$lit['title'] = __('Average Sending Volume',
|
1194 |
-
$lit['label_suffix'] .= __('/day',
|
1195 |
-
$lit['Ylabel'] = __('Average Volume per Day',
|
1196 |
|
1197 |
foreach ( array(1 => 'today', 7 => 'last_7_days') as $days => $period ) {
|
1198 |
$data['opens'][$period] = number_format($data['opens'][$period] / $days,2);
|
@@ -1200,7 +1199,6 @@ jQuery(document).bind( 'ready', function() {
|
|
1200 |
$data['unopens'][$period] = number_format($data['unopens'][$period] / $days,2);
|
1201 |
}
|
1202 |
$tickFormatter = 'percentageFormatter';
|
1203 |
-
$format_sufix = '%';
|
1204 |
}
|
1205 |
// Filling arrays for recent stats
|
1206 |
$unopens['recent'] = '[0,' . $data['unopens']['today'] . '],[1,' . $data['unopens']['last_7_days'] . ']';
|
@@ -1316,7 +1314,7 @@ JS;
|
|
1316 |
static function showDashboardWidgetOptions() {
|
1317 |
$stats = self::getCurrentStats();
|
1318 |
if ( empty($stats) ) {
|
1319 |
-
echo '<p>' . __('There was a problem retrieving statistics.',
|
1320 |
return;
|
1321 |
}
|
1322 |
|
@@ -1345,17 +1343,17 @@ JS;
|
|
1345 |
$filter = isset( $widget_options[$widget_id]['filter'] ) ? $widget_options[$widget_id]['filter'] : '';
|
1346 |
$display = isset( $widget_options[$widget_id]['display'] ) ? $widget_options[$widget_id]['display'] : '';
|
1347 |
?>
|
1348 |
-
<label for="filter"><?php _e('Filter by:',
|
1349 |
<select id="filter" name="filter">
|
1350 |
-
<option value="none" <?=selected($filter, 'none');?>><?php _e('No filter',
|
1351 |
-
<optgroup label="<?php _e('Sender:',
|
1352 |
<?php
|
1353 |
foreach ( array_keys($stats['stats']['hourly']['senders']) as $sender) {
|
1354 |
echo '<option value="s:'.$sender.'" '.selected($filter, 's:'.$sender).'>'.$sender.'</option>';
|
1355 |
}
|
1356 |
?>
|
1357 |
</optgroup>
|
1358 |
-
<optgroup label="<?php _e('Tag:',
|
1359 |
<?php
|
1360 |
foreach ( array_keys($stats['stats']['hourly']['tags']['detailed_stats']) as $tag) {
|
1361 |
echo '<option value="'.$tag.'" '.selected($filter, $tag).'>'.$tag.'</option>';
|
@@ -1363,10 +1361,10 @@ JS;
|
|
1363 |
?>
|
1364 |
</optgroup>
|
1365 |
</select>
|
1366 |
-
<label for="display"><?php _e('Display:',
|
1367 |
<select id="display" name="display">
|
1368 |
-
<option value="volume" <?=selected($display, 'volume');?>><?php _e('Total Volume per Period',
|
1369 |
-
<option value="average" <?=selected($display, 'average');?>><?php _e('Average Volume per Period',
|
1370 |
</select><?php
|
1371 |
}
|
1372 |
|
@@ -1413,30 +1411,29 @@ JS;
|
|
1413 |
|
1414 |
$lit = array();
|
1415 |
|
1416 |
-
$lit['title'] = __('Sending Volume',
|
1417 |
-
$lit['label_suffix'] = __(' emails',
|
1418 |
-
$lit['Ylabel'] = __('Total Volume per Day',
|
1419 |
|
1420 |
-
$lit['last_few_days'] = __('in the last few days',
|
1421 |
-
$lit['last_few_months']= __('in the last few months',
|
1422 |
-
$lit['today'] = __('Today',
|
1423 |
-
$lit['last7days'] = __('Last 7 Days',
|
1424 |
-
$lit['last30days'] = __('Last 30 Days',
|
1425 |
-
$lit['last60days'] = __('Last 60 Days',
|
1426 |
-
$lit['last90days'] = __('Last 90 Days',
|
1427 |
-
$lit['periods'] = __('Periods',
|
1428 |
-
$lit['volume'] = __('Volume',
|
1429 |
-
$lit['total'] = __('Total:',
|
1430 |
-
$lit['unopened'] = __('Unopened',
|
1431 |
-
$lit['bounced'] = __('Bounced or Rejected',
|
1432 |
-
$lit['opened'] = __('Opened',
|
1433 |
|
1434 |
$tickFormatter = 'emailFormatter';
|
1435 |
-
$format_sufix = ' email(s)';
|
1436 |
if ( $display == 'average' ) {
|
1437 |
-
$lit['title'] = __('Average Sending Volume',
|
1438 |
-
$lit['label_suffix'] .= __('/day',
|
1439 |
-
$lit['Ylabel'] = __('Average Volume per Day',
|
1440 |
|
1441 |
foreach ( array(1 => 'today', 7 => 'last_7_days', 30 => 'last_30_days', 60 => 'last_60_days', 90 => 'last_90_days') as $days => $period ) {
|
1442 |
$data['opens'][$period] = number_format($data['opens'][$period] / $days,2);
|
@@ -1444,7 +1441,6 @@ JS;
|
|
1444 |
$data['unopens'][$period] = number_format($data['unopens'][$period] / $days,2);
|
1445 |
}
|
1446 |
$tickFormatter = 'percentageFormatter';
|
1447 |
-
$format_sufix = '%';
|
1448 |
}
|
1449 |
|
1450 |
// Filling arrays for recent stats
|
@@ -1741,7 +1737,7 @@ JS;
|
|
1741 |
|
1742 |
// Adding a Reply-To header if needed.
|
1743 |
$reply_to = self::getReplyTo();
|
1744 |
-
if ( !empty($reply_to) && !in_array( '
|
1745 |
$message['headers']['Reply-To'] = trim(self::getReplyTo());
|
1746 |
}
|
1747 |
|
@@ -1773,11 +1769,21 @@ JS;
|
|
1773 |
$message['track_opens'] = $track_opens;
|
1774 |
$message['track_clicks']= $track_clicks;
|
1775 |
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1781 |
$template = '';
|
1782 |
// If user specified a given template, check if it is valid for this Mandrill account
|
1783 |
if ( !empty($template_name) && self::isTemplateValid($template_name) ) {
|
@@ -1786,28 +1792,28 @@ JS;
|
|
1786 |
$template = self::getTemplate(); // If no template was specified or the specified was invalid, use the general one.
|
1787 |
}
|
1788 |
|
|
|
1789 |
if ( $template ) {
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1795 |
}
|
1796 |
|
1797 |
// Letting the user filter/change the message payload
|
1798 |
-
if ( defined('WP_DEBUG') && WP_DEBUG !== false ) {
|
1799 |
-
error_log( "\nwpMandrill::sendEmail: Before mandrill_payload ".print_r(array_replace($message,array('html' => '', 'text' => '', 'template' => '')),true)."\n" );
|
1800 |
-
}
|
1801 |
$message = apply_filters('mandrill_payload', $message);
|
1802 |
-
if ( defined('WP_DEBUG') && WP_DEBUG !== false ) {
|
1803 |
-
error_log( "\nwpMandrill::sendEmail: After mandrill_payload ".print_r(array_replace($message,array('html' => '', 'text' => '', 'template' => '')),true)."\n" );
|
1804 |
-
}
|
1805 |
|
1806 |
-
// Checking that the final From: email address is valid
|
1807 |
-
list($dummy,$domain) = explode('@', $message['from_email']);
|
1808 |
-
if ( !self::isDomainEnabled( $domain ) )
|
1809 |
-
throw new Exception('The domain of the email you provided ('.$domain.') has not been added to Mandrill yet.');
|
1810 |
-
|
1811 |
// Setting the tags property correctly to be received by the Mandrill's API
|
1812 |
if ( !is_array($message['tags']['user']) ) $message['tags']['user'] = array();
|
1813 |
if ( !is_array($message['tags']['general']) ) $message['tags']['general'] = array();
|
@@ -1827,7 +1833,7 @@ JS;
|
|
1827 |
}
|
1828 |
|
1829 |
} catch ( Exception $e) {
|
1830 |
-
error_log( "
|
1831 |
return new WP_Error( $e->getMessage() );
|
1832 |
}
|
1833 |
}
|
5 |
Author: Mandrill
|
6 |
Author URI: http://mandrillapp.com/
|
7 |
Plugin URI: http://connect.mailchimp.com/integrations/wpmandrill
|
8 |
+
Version: 1.24
|
9 |
Text Domain: wpmandrill
|
10 |
*/
|
11 |
/* Copyright 2012 MailChimp (email : will@mailchimp.com )
|
28 |
wpMandrill::on_load();
|
29 |
|
30 |
class wpMandrill {
|
|
|
31 |
const DEBUG = false;
|
32 |
|
33 |
static $settings;
|
50 |
add_action('wp_ajax_get_mandrill_stats', array(__CLASS__,'getAjaxStats'));
|
51 |
add_action('wp_ajax_get_dashboard_widget_stats', array(__CLASS__,'showDashboardWidget'));
|
52 |
|
53 |
+
load_plugin_textdomain('wpmandrill', false, dirname( plugin_basename( __FILE__ ) ).'/lang');
|
54 |
|
55 |
if( function_exists('wp_mail') ) {
|
56 |
self::$conflict = true;
|
89 |
add_filter('plugin_action_links',array(__CLASS__,'showPluginActionLinks'), 10,5);
|
90 |
add_action('admin_enqueue_scripts', array(__CLASS__,'showAdminEnqueueScripts'));
|
91 |
|
92 |
+
register_setting('wpmandrill', 'wpmandrill', array(__CLASS__,'formValidate'));
|
93 |
|
94 |
add_action( 'network_admin_notices', array( __CLASS__, 'network_connect_notice' ) );
|
95 |
|
96 |
// SMTP Settings
|
97 |
+
add_settings_section('wpmandrill-api', __('API Settings', 'wpmandrill'), '__return_false', 'wpmandrill');
|
98 |
+
add_settings_field('api-key', __('API Key', 'wpmandrill'), array(__CLASS__, 'askAPIKey'), 'wpmandrill', 'wpmandrill-api');
|
99 |
|
100 |
if( self::getAPIKey() ) {
|
101 |
+
if (current_user_can('manage_options')) add_action('wp_dashboard_setup', array( __CLASS__,'addDashboardWidgets') );
|
102 |
|
103 |
// Verified Addresses
|
104 |
+
add_settings_section('wpmandrill-addresses', __('Sender Settings', 'wpmandrill'), '__return_false', 'wpmandrill');
|
105 |
+
add_settings_field('from-name', __('FROM Name', 'wpmandrill'), array(__CLASS__, 'askFromName'), 'wpmandrill', 'wpmandrill-addresses');
|
106 |
+
add_settings_field('from-email', __('FROM Email', 'wpmandrill'), array(__CLASS__, 'askFromEmail'), 'wpmandrill', 'wpmandrill-addresses');
|
107 |
+
add_settings_field('reply-to', __('Reply-To Email', 'wpmandrill'), array(__CLASS__, 'askReplyTo'), 'wpmandrill', 'wpmandrill-addresses');
|
108 |
|
109 |
// Template
|
110 |
+
add_settings_section('wpmandrill-templates', __('General Design', 'wpmandrill'), '__return_false', 'wpmandrill');
|
111 |
+
add_settings_field('template', __('Template', 'wpmandrill'), array(__CLASS__, 'askTemplate'), 'wpmandrill', 'wpmandrill-templates');
|
112 |
+
add_settings_field('nl2br', __('Content', 'wpmandrill'), array(__CLASS__, 'asknl2br'), 'wpmandrill', 'wpmandrill-templates');
|
113 |
|
114 |
// Tags
|
115 |
+
add_settings_section('wpmandrill-tags', __('General Tags', 'wpmandrill'), '__return_false', 'wpmandrill');
|
116 |
+
add_settings_field('tags', __(' ', 'wpmandrill'), array(__CLASS__, 'askTags'), 'wpmandrill', 'wpmandrill-tags');
|
117 |
|
118 |
if ( self::isConfigured() ) {
|
119 |
// Email Test
|
120 |
register_setting('wpmandrill-test', 'wpmandrill-test', array(__CLASS__, 'sendTestEmail'));
|
121 |
|
122 |
+
add_settings_section('mandrill-email-test', __('Send a test email using these settings', 'wpmandrill'), '__return_false', 'wpmandrill-test');
|
123 |
+
add_settings_field('email-to', __('Send to', 'wpmandrill'), array(__CLASS__, 'askTestEmailTo'), 'wpmandrill-test', 'mandrill-email-test');
|
124 |
+
add_settings_field('email-subject', __('Subject', 'wpmandrill'), array(__CLASS__, 'askTestEmailSubject'), 'wpmandrill-test', 'mandrill-email-test');
|
125 |
+
add_settings_field('email-message', __('Message', 'wpmandrill'), array(__CLASS__, 'askTestEmailMessage'), 'wpmandrill-test', 'mandrill-email-test');
|
126 |
}
|
127 |
|
128 |
}
|
147 |
static function adminMenu() {
|
148 |
|
149 |
self::$settings = add_options_page(
|
150 |
+
__('Mandrill Settings', 'wpmandrill'),
|
151 |
+
__('Mandrill', 'wpmandrill'),
|
152 |
'manage_options',
|
153 |
+
'wpmandrill',
|
154 |
array(__CLASS__,'showOptionsPage')
|
155 |
);
|
156 |
|
157 |
if( self::isConfigured() ) {
|
158 |
+
if (current_user_can('manage_options')) self::$report = add_dashboard_page(
|
159 |
+
__('Mandrill Reports', 'wpmandrill'),
|
160 |
+
__('Mandrill Reports', 'wpmandrill'),
|
161 |
'manage_options',
|
162 |
+
'wpmandrill'.'-reports',
|
163 |
array(__CLASS__,'showReportPage')
|
164 |
);
|
165 |
if ( self::isPluginPage('-reports') ) {
|
185 |
?>
|
186 |
<div id="message" class="updated wpmandrill-message">
|
187 |
<div class="squeezer">
|
188 |
+
<h4><?php _e( '<strong>wpMandrill is activated!</strong> Each site on your network must be connected individually by an admin on that site.', 'wpmandrill' ) ?></h4>
|
189 |
</div>
|
190 |
</div>
|
191 |
<?php
|
195 |
|
196 |
static function adminNotices() {
|
197 |
if ( self::$conflict ) {
|
198 |
+
echo '<div class="error"><p>'.__('Mandrill: wp_mail has been declared by another process or plugin, so you won\'t be able to use Mandrill until the problem is solved.', 'wpmandrill') . '</p></div>';
|
199 |
}
|
200 |
}
|
201 |
|
213 |
if ($screen_id == self::$settings) {
|
214 |
wpMandrill::getConnected();
|
215 |
|
|
|
|
|
216 |
$ok = array();
|
217 |
$ok['account'] = ( !wpMandrill::isConnected() ) ? ' class="missing"' : '';
|
218 |
$ok['domains'] = ( $ok['account'] != '' || !count(self::ListVerifiedDomains()) ) ? ' class="missing"' : '';
|
220 |
|
221 |
$requirements = '';
|
222 |
if ($ok['account'] . $ok['domains'] . $ok['email'] != '' ) {
|
223 |
+
$requirements = '<p>' . __('To use this plugin you will need:', 'wpmandrill') . '</p>'
|
224 |
. '<ol>'
|
225 |
+
. '<li'.$ok['account'].'>'. __('Your Mandrill account.', 'wpmandrill') . '</li>'
|
226 |
+
. '<li'.$ok['domains'].'>' . __('At least one domain defined in your Mandrill account.', 'wpmandrill') . '</li>'
|
227 |
+
. '<li'.$ok['email'].'>' . __('A valid sender email address.', 'wpmandrill') . '</li>'
|
228 |
. '</ol>';
|
229 |
}
|
230 |
|
231 |
return $requirements
|
232 |
+
. '<p>' . __('Once you have properly configured the settings, the plugin will take care of all the emails sent through your WordPress installation.', 'wpmandrill').'</p>'
|
233 |
+
. '<p>' . __('However, if you need to customize any part of the email before sending, you can do so by using the WordPress filter <strong>mandrill_payload</strong>.', 'wpmandrill').'</p>'
|
234 |
+
. '<p>' . __('This filter has the same structure as Mandrill\'s API call <a href="http://mandrillapp.com/api/docs/messages.html#method=send" target="_blank">/messages/send</a>, except that it can have one additional parameter when the email is based on a template. The parameter is called "<em>template</em>", which is an associative array of two elements (the first element, a string whose key is "<em>template_name</em>", and a second parameter whose key is "<em>template_content</em>". Its value is an array with the same structure of the parameter "<em>template_content</em>" in the call <a href="http://mandrillapp.com/api/docs/messages.html#method=send-template" target="_blank">/messages/send-template</a>.)', 'wpmandrill').'</p>'
|
235 |
+
. '<p>' . __('Note that if you\'re sending additional headers in your emails, the only valid headers are <em>From:</em>, <em>Reply-To:</em>, and <em>X-*:</em>. <em>Bcc:</em> is also valid, but Mandrill will send the blind carbon copy to only the first address, and the remaining will be silently discarted.', 'wpmandrill').'</p>'
|
236 |
+
. '<p>' . __('Also note that if any error occurs while sending the email, the plugin will try to send the message again using the native WordPress mailing capabilities.', 'wpmandrill').'</p>'
|
237 |
+
. '<p>' . __('Confirm that any change you made to the payload is in line with the <a href="http://mandrillapp.com/api/docs/" target="_blank">Mandrill\'s API\'s documentation</a>. Also, the <em>X-*:</em> headers, must be in line with the <a href="http://help.mandrill.com/forums/20689696-smtp-integration" target="_blank">SMTP API documentation</a>. By using this plugin, you agree that you and your website will adhere to <a href="http://www.mandrill.com/terms/" target="_blank">Mandrill\'s Terms of Use</a> and <a href="http://mandrill.com/privacy/" target="_blank">Privacy Policy</a>.', 'wpmandrill').'</p>'
|
238 |
+
. '<p>' . __('if you have any question about Mandrill or this plugin, visit the <a href="http://help.mandrill.com/" target="_blank">Mandrill\'s Support Center</a>.', 'wpmandrill').'</p>'
|
239 |
;
|
240 |
}
|
241 |
|
253 |
|
254 |
if ($plugin == $plugin_file) {
|
255 |
|
256 |
+
$settings = array('settings' => '<a href="options-general.php?page=wpmandrill">' . __('Settings', 'wpmandrill') . '</a>');
|
257 |
|
258 |
if ( self::isConnected() ) {
|
259 |
+
$report = array('report' => '<a href="index.php?page=wpmandrill-reports">' . __('Reports', 'wpmandrill') . '</a>');
|
260 |
$actions = array_merge($settings, $actions, $report);
|
261 |
} else {
|
262 |
$actions = array_merge($settings, $actions);
|
284 |
?>
|
285 |
<div class="wrap">
|
286 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
287 |
+
<h2><?php _e('Mandrill Settings', 'wpmandrill'); ?> <small><a href="options-general.php?page=<?='wpmandrill'; ?>&show=how-tos">view how-tos</a></small></h2>
|
288 |
|
289 |
<div style="float: left;width: 70%;">
|
290 |
<form method="post" action="options.php">
|
291 |
|
292 |
<div class="stuffbox">
|
293 |
+
<?php settings_fields('wpmandrill'); ?>
|
294 |
+
<?php do_settings_sections('wpmandrill'); ?>
|
295 |
</div>
|
296 |
|
297 |
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /></p>
|
305 |
<?php do_settings_sections('wpmandrill-test'); ?>
|
306 |
</div>
|
307 |
|
308 |
+
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e('Send Test', 'wpmandrill') ?>" /></p>
|
309 |
</form>
|
310 |
<?php } ?>
|
311 |
|
323 |
if ( $maxitems > 0 ) {
|
324 |
?>
|
325 |
<div class="mcnews mandrill">
|
326 |
+
<h3 class="mcnews_header"><?php _e('Latest from Mandrill...', 'wpmandrill'); ?></h3>
|
327 |
<ul>
|
328 |
<?php
|
329 |
foreach ( $rss_items as $item ) { ?>
|
337 |
</div>
|
338 |
<?php } ?>
|
339 |
<div class="mcnews">
|
340 |
+
<h3 class="mcnews_header"><?php _e('News from MailChimp...', 'wpmandrill'); ?></h3><?php
|
341 |
$rss = fetch_feed('http://mailchimp.com/blog/feed');
|
342 |
if (!is_wp_error( $rss ) ) {
|
343 |
$maxitems = $rss->get_item_quantity(5);
|
366 |
?>
|
367 |
<div class="wrap">
|
368 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
369 |
+
<h2><?php _e('Mandrill How-Tos', 'wpmandrill'); ?> <small><a href="options-general.php?page=<?='wpmandrill'; ?>">back to settings</a></small></h2>
|
370 |
<?php
|
371 |
require plugin_dir_path( __FILE__ ) . '/how-tos.php';
|
372 |
|
393 |
|
394 |
if ( !empty($input['from_domain']) && ( empty($input['from_username']) || !self::isDomainEnabled($input['from_domain']) ) ) {
|
395 |
add_settings_error(
|
396 |
+
'wpmandrill',
|
397 |
'from-email',
|
398 |
+
__('You must define a valid sender email.', 'wpmandrill'),
|
399 |
'error'
|
400 |
);
|
401 |
|
438 |
*/
|
439 |
static function getOption( $name, $default = false ) {
|
440 |
|
441 |
+
$options = get_option('wpmandrill');
|
442 |
|
443 |
if( isset( $options[$name] ) )
|
444 |
return $options[$name];
|
474 |
*/
|
475 |
static function setOption( $name, $value ) {
|
476 |
|
477 |
+
$options = get_option('wpmandrill');
|
478 |
|
479 |
$options[$name] = $value;
|
480 |
|
481 |
+
$result = update_option('wpmandrill', $options);
|
482 |
|
483 |
return $result;
|
484 |
}
|
599 |
*/
|
600 |
static function isPluginPage($sufix = '') {
|
601 |
|
602 |
+
return ( isset( $_GET['page'] ) && $_GET['page'] == 'wpmandrill' . $sufix);
|
603 |
}
|
604 |
|
605 |
/**
|
671 |
|
672 |
if (is_wp_error($test)) {
|
673 |
|
674 |
+
add_settings_error('email-to', 'email-to', __('Test failed. Please verify the following:
|
675 |
+
<ol>
|
676 |
+
<li>That your web server has either cURL installed or is able to use fsock*() functions (if you don\'t know what this means, you may want to check with your hosting provider for more details);</li>
|
677 |
+
<li>That your API key is active (this can be viewed on the <a href="https://mandrillapp.com/settings/index" target="_blank">SMTP & API Credentials</a> page in your Mandrill account);</li>
|
678 |
+
<li>That the domain name you\'re using above is listed in the <a href="https://mandrillapp.com/settings/sending-domains" target="_blank">Sending Domains</a> for your Mandrill account.</li>
|
679 |
+
</ol>', 'wpmandrill') . $test->get_error_message());
|
680 |
|
681 |
return array_map('wp_strip_all_tags', $input);
|
682 |
|
693 |
}
|
694 |
|
695 |
|
696 |
+
add_settings_error('email-to', 'email-to', sprintf(__('Test executed: %d emails sent, %d emails queued and %d emails rejected', 'wpmandrill'), $result['sent'],$result['queue'],$result['rejected']), $result['sent'] ? 'updated' : 'error' );
|
697 |
}
|
698 |
}
|
699 |
|
708 |
?><input id='api_key' name='wpmandrill[api_key]' size='45' type='text' value="<?php esc_attr_e( $api_key ); ?>" /><?php
|
709 |
|
710 |
if ( empty($api_key) ) {
|
711 |
+
?><br/><span class="setting-description"><small><em><?php _e('To get your API key, please visit your <a href="http://mandrillapp.com/settings/index" target="_blank">Mandrill Settings</a>', 'wpmandrill'); ?></em></small></span><?php
|
712 |
} else {
|
713 |
$api_is_valid = false;
|
714 |
|
716 |
if ( wpMandrill::isConnected() ) $api_is_valid = ( wpMandrill::$mandrill->users_ping() == 'PONG!' );
|
717 |
|
718 |
if ( !$api_is_valid ) {
|
719 |
+
?><br/><span class="setting-description"><small><em><?php _e('Sorry. Invalid API key.', 'wpmandrill'); ?></em></small></span><?php
|
720 |
}
|
721 |
}
|
722 |
|
733 |
$domains = self::ListVerifiedDomains();
|
734 |
if ( !count($domains) ) {
|
735 |
|
736 |
+
_e('No domains found.', 'wpmandrill');
|
737 |
|
738 |
if ( $from_email ) {
|
739 |
self::setOption('from_username', false);
|
745 |
return;
|
746 |
}
|
747 |
|
748 |
+
?><?php _e('This address will be used as the sender of the outgoing emails:', 'wpmandrill'); ?><br />
|
749 |
<input id="from_username" name="wpmandrill[from_username]" type="text" value="<?php esc_attr_e($from_username);?>" style="text-align:right;width:100px">@
|
750 |
<select id="from_domain" name="wpmandrill[from_domain]"><?php
|
751 |
foreach( $domains as $curdomain ) {
|
752 |
?><option value="<?php esc_attr_e($curdomain['domain']); ?>" <?php selected($curdomain['domain'], $from_domain); ?>><?php esc_html_e($curdomain['domain']); ?></option><?php
|
753 |
}
|
754 |
+
?></select><br/><span class="setting-description"><small><em><?php _e('If you need to add a new domain, please visit your <a href="https://mandrillapp.com/settings/sending-domains" target="_blank">Mandrill Settings</a>', 'wpmandrill'); ?></em></small></span><?php
|
755 |
|
756 |
echo '</div>';
|
757 |
}
|
761 |
|
762 |
$from_name = self::getFromName();
|
763 |
|
764 |
+
?><?php _e('Name the recipients will see in their email clients:', 'wpmandrill'); ?><br />
|
765 |
<input name="wpmandrill[from_name]" type="text" value="<?php esc_attr_e($from_name); ?>">
|
766 |
<?php
|
767 |
|
773 |
|
774 |
$reply_to = self::getReplyTo();
|
775 |
|
776 |
+
?><?php _e('This address will be used as the recipient where replies from the users will be sent to:', 'wpmandrill'); ?><br />
|
777 |
<input id="reply_to" name="wpmandrill[reply_to]" type="text" value="<?php esc_attr_e($reply_to);?>"><br/>
|
778 |
+
<span class="setting-description"><small><em><?php _e('Leave blank to use the FROM Email. If you want to override this setting, you must use the <em><a href="#" onclick="jQuery(\'a#contextual-help-link\').trigger(\'click\');return false;">mandrill_payload</a></em> WordPress filter.', 'wpmandrill'); ?></em></small></span><?php
|
779 |
|
780 |
echo '</div>';
|
781 |
}
|
786 |
self::getConnected();
|
787 |
|
788 |
if ( !self::isConnected() ) {
|
789 |
+
_e('No templates found.', 'wpmandrill');
|
790 |
|
791 |
echo '</div>';
|
792 |
return;
|
796 |
$templates = self::$mandrill->templates_list();
|
797 |
if( is_wp_error($templates) || empty($templates)) {
|
798 |
|
799 |
+
_e('No templates found.', 'wpmandrill');
|
800 |
|
801 |
if( $templates )
|
802 |
self::setOption('templates', false);
|
805 |
return;
|
806 |
}
|
807 |
|
808 |
+
?><?php _e('Select the template to use:', 'wpmandrill'); ?><br />
|
809 |
<select name="wpmandrill[template]">
|
810 |
<option value="">-None-</option><?php
|
811 |
foreach( $templates as $curtemplate ) {
|
812 |
?><option value="<?php esc_attr_e($curtemplate['name']); ?>" <?php selected($curtemplate['name'], $template); ?>><?php esc_html_e($curtemplate['name']); ?></option><?php
|
813 |
}
|
814 |
+
?></select><br/><span class="setting-description"><em><?php _e('<small>The selected template must have a <strong><em>mc:edit="main"</em></strong> placeholder defined. The message will be shown there.</small>', 'wpmandrill'); ?></em></span><?php
|
815 |
|
816 |
echo '</div>';
|
817 |
}
|
820 |
if ( $nl2br == '' ) $nl2br = 0;
|
821 |
?>
|
822 |
<div class="inside">
|
823 |
+
<?php _e('Replace all line feeds ("\n") by <br/> in the message body?', 'wpmandrill'); ?>
|
824 |
<input name="wpmandrill[nl2br]" type="checkbox" <?=checked($nl2br,1); ?> value='1' /><br/>
|
825 |
+
<span class="setting-description"><em><?php _e('<small>If you are sending HTML emails already keep this setting deactivated.<br/>But if you are sending text only emails (WordPress default) this option might help your emails look better.</small>', 'wpmandrill'); ?></em></span>
|
826 |
</div><?php
|
827 |
}
|
828 |
|
831 |
|
832 |
$tags = self::getTags();
|
833 |
|
834 |
+
?><?php _e('If there are tags that you want appended to every call, list them here, one per line:', 'wpmandrill'); ?><br />
|
835 |
<textarea name="wpmandrill[tags]" cols="25" rows="3"><?php echo $tags; ?></textarea><br/>
|
836 |
+
<span class="setting-description"><small><em><?php _e('Also keep in mind that you can add or remove tags using the <em><a href="#" onclick="jQuery(\'a#contextual-help-link\').trigger(\'click\');return false;">mandrill_payload</a></em> WordPress filter.', 'wpmandrill'); ?></em></small></span>
|
837 |
<?php
|
838 |
|
839 |
echo '</div>';
|
863 |
*/
|
864 |
static function getTestEmailOption($field) {
|
865 |
|
866 |
+
$email = get_option('wpmandrill' . '-test');
|
867 |
|
868 |
if( isset( $email[$field] ) )
|
869 |
return $email[$field];
|
1025 |
*/
|
1026 |
static function getCurrentStats() {
|
1027 |
|
1028 |
+
$stats = get_transient('wpmandrill'.'-stats');
|
1029 |
if ( empty($stats) ) {
|
1030 |
+
$stats = get_option('wpmandrill'.'-stats');
|
1031 |
|
1032 |
if ( empty($stats) ) $stats = self::saveProcessedStats();
|
1033 |
|
1044 |
static function saveProcessedStats() {
|
1045 |
$stats = self::GetProcessedStats();
|
1046 |
if ( !empty($stats) ) {
|
1047 |
+
set_transient('wpmandrill'.'-stats', $stats, 60 * 60);
|
1048 |
+
update_option('wpmandrill'.'-stats', $stats);
|
1049 |
}
|
1050 |
|
1051 |
return $stats;
|
1052 |
}
|
1053 |
|
1054 |
static function addDashboardWidgets() {
|
1055 |
+
if (!current_user_can('manage_options')) return;
|
1056 |
+
|
1057 |
self::getConnected();
|
1058 |
if ( !self::isConnected() ) return;
|
1059 |
|
1063 |
|
1064 |
if ( !$widget_options || !isset($widget_options[$widget_id])) {
|
1065 |
$filter = 'none';
|
|
|
1066 |
} else {
|
|
|
1067 |
$filter = $widget_options[$widget_id]['filter'];
|
|
|
1068 |
}
|
1069 |
|
1070 |
if ( $filter == 'none' ) {
|
1077 |
}
|
1078 |
|
1079 |
wp_add_dashboard_widget( "mandrill_widget",
|
1080 |
+
__("Mandrill Recent Statistics", 'wpmandrill') . (!empty($filter_used) ? ' » ' . $filter_used : ''),
|
1081 |
array(__CLASS__, 'showDashboardWidget'),
|
1082 |
array(__CLASS__, 'showDashboardWidgetOptions')
|
1083 |
);
|
1095 |
}
|
1096 |
|
1097 |
static function showDashboardWidget() {
|
1098 |
+
if ( !current_user_can('manage_options') ) return;
|
1099 |
+
|
1100 |
wpMandrill::getConnected();
|
1101 |
|
1102 |
$isAjaxCall = isset($_POST['ajax']) && $_POST['ajax'] ? true : false;
|
1117 |
$stats = array();
|
1118 |
if ( $filter == 'none' ) {
|
1119 |
$filter_type = 'account';
|
|
|
1120 |
|
1121 |
$data = self::$mandrill->users_info();
|
1122 |
$stats['stats']['periods']['account']['today'] = $data['stats']['today'];
|
1125 |
} elseif ( substr($filter,0,2) == 's:' ) {
|
1126 |
$filter_type = 'senders';
|
1127 |
$filter = substr($filter,2);
|
|
|
1128 |
|
1129 |
$data = self::$mandrill->senders_info($filter);
|
1130 |
$stats['stats']['periods']['senders']['today'][$filter] = $data['stats']['today'];
|
1131 |
$stats['stats']['periods']['senders']['last_7_days'][$filter] = $data['stats']['last_7_days'];
|
1132 |
} else {
|
1133 |
$filter_type = 'tags';
|
|
|
1134 |
|
1135 |
$data = self::$mandrill->tags_info($filter);
|
1136 |
$stats['stats']['periods']['tags']['today'][$filter] = $data['stats']['today'];
|
1169 |
|
1170 |
$lit = array();
|
1171 |
|
1172 |
+
$lit['title'] = __('Sending Volume', 'wpmandrill');
|
1173 |
+
$lit['label_suffix'] = __(' emails', 'wpmandrill');
|
1174 |
+
$lit['Ylabel'] = __('Total Volume per Day', 'wpmandrill');
|
1175 |
|
1176 |
+
$lit['last_few_days'] = __('in the last few days', 'wpmandrill');
|
1177 |
+
$lit['last_few_months']= __('in the last few months', 'wpmandrill');
|
1178 |
+
$lit['today'] = __('Today', 'wpmandrill');
|
1179 |
+
$lit['last7days'] = __('Last 7 Days', 'wpmandrill');
|
1180 |
+
$lit['last30days'] = __('Last 30 Days', 'wpmandrill');
|
1181 |
+
$lit['last60days'] = __('Last 60 Days', 'wpmandrill');
|
1182 |
+
$lit['last90days'] = __('Last 90 Days', 'wpmandrill');
|
1183 |
+
$lit['periods'] = __('Periods', 'wpmandrill');
|
1184 |
+
$lit['volume'] = __('Volume', 'wpmandrill');
|
1185 |
+
$lit['total'] = __('Total:', 'wpmandrill');
|
1186 |
+
$lit['unopened'] = __('Unopened', 'wpmandrill');
|
1187 |
+
$lit['bounced'] = __('Bounced or Rejected', 'wpmandrill');
|
1188 |
+
$lit['opened'] = __('Opened', 'wpmandrill');
|
1189 |
|
1190 |
$tickFormatter = 'emailFormatter';
|
|
|
1191 |
if ( $display == 'average' ) {
|
1192 |
+
$lit['title'] = __('Average Sending Volume', 'wpmandrill');
|
1193 |
+
$lit['label_suffix'] .= __('/day', 'wpmandrill');
|
1194 |
+
$lit['Ylabel'] = __('Average Volume per Day', 'wpmandrill');
|
1195 |
|
1196 |
foreach ( array(1 => 'today', 7 => 'last_7_days') as $days => $period ) {
|
1197 |
$data['opens'][$period] = number_format($data['opens'][$period] / $days,2);
|
1199 |
$data['unopens'][$period] = number_format($data['unopens'][$period] / $days,2);
|
1200 |
}
|
1201 |
$tickFormatter = 'percentageFormatter';
|
|
|
1202 |
}
|
1203 |
// Filling arrays for recent stats
|
1204 |
$unopens['recent'] = '[0,' . $data['unopens']['today'] . '],[1,' . $data['unopens']['last_7_days'] . ']';
|
1314 |
static function showDashboardWidgetOptions() {
|
1315 |
$stats = self::getCurrentStats();
|
1316 |
if ( empty($stats) ) {
|
1317 |
+
echo '<p>' . __('There was a problem retrieving statistics.', 'wpmandrill') . '</p>';
|
1318 |
return;
|
1319 |
}
|
1320 |
|
1343 |
$filter = isset( $widget_options[$widget_id]['filter'] ) ? $widget_options[$widget_id]['filter'] : '';
|
1344 |
$display = isset( $widget_options[$widget_id]['display'] ) ? $widget_options[$widget_id]['display'] : '';
|
1345 |
?>
|
1346 |
+
<label for="filter"><?php _e('Filter by:', 'wpmandrill'); ?> </label>
|
1347 |
<select id="filter" name="filter">
|
1348 |
+
<option value="none" <?=selected($filter, 'none');?>><?php _e('No filter', 'wpmandrill'); ?></option>
|
1349 |
+
<optgroup label="<?php _e('Sender:', 'wpmandrill'); ?>">
|
1350 |
<?php
|
1351 |
foreach ( array_keys($stats['stats']['hourly']['senders']) as $sender) {
|
1352 |
echo '<option value="s:'.$sender.'" '.selected($filter, 's:'.$sender).'>'.$sender.'</option>';
|
1353 |
}
|
1354 |
?>
|
1355 |
</optgroup>
|
1356 |
+
<optgroup label="<?php _e('Tag:', 'wpmandrill'); ?>">
|
1357 |
<?php
|
1358 |
foreach ( array_keys($stats['stats']['hourly']['tags']['detailed_stats']) as $tag) {
|
1359 |
echo '<option value="'.$tag.'" '.selected($filter, $tag).'>'.$tag.'</option>';
|
1361 |
?>
|
1362 |
</optgroup>
|
1363 |
</select>
|
1364 |
+
<label for="display"><?php _e('Display:', 'wpmandrill'); ?> </label>
|
1365 |
<select id="display" name="display">
|
1366 |
+
<option value="volume" <?=selected($display, 'volume');?>><?php _e('Total Volume per Period', 'wpmandrill'); ?></option>
|
1367 |
+
<option value="average" <?=selected($display, 'average');?>><?php _e('Average Volume per Period', 'wpmandrill'); ?></option>
|
1368 |
</select><?php
|
1369 |
}
|
1370 |
|
1411 |
|
1412 |
$lit = array();
|
1413 |
|
1414 |
+
$lit['title'] = __('Sending Volume', 'wpmandrill');
|
1415 |
+
$lit['label_suffix'] = __(' emails', 'wpmandrill');
|
1416 |
+
$lit['Ylabel'] = __('Total Volume per Day', 'wpmandrill');
|
1417 |
|
1418 |
+
$lit['last_few_days'] = __('in the last few days', 'wpmandrill');
|
1419 |
+
$lit['last_few_months']= __('in the last few months', 'wpmandrill');
|
1420 |
+
$lit['today'] = __('Today', 'wpmandrill');
|
1421 |
+
$lit['last7days'] = __('Last 7 Days', 'wpmandrill');
|
1422 |
+
$lit['last30days'] = __('Last 30 Days', 'wpmandrill');
|
1423 |
+
$lit['last60days'] = __('Last 60 Days', 'wpmandrill');
|
1424 |
+
$lit['last90days'] = __('Last 90 Days', 'wpmandrill');
|
1425 |
+
$lit['periods'] = __('Periods', 'wpmandrill');
|
1426 |
+
$lit['volume'] = __('Volume', 'wpmandrill');
|
1427 |
+
$lit['total'] = __('Total:', 'wpmandrill');
|
1428 |
+
$lit['unopened'] = __('Unopened', 'wpmandrill');
|
1429 |
+
$lit['bounced'] = __('Bounced or Rejected', 'wpmandrill');
|
1430 |
+
$lit['opened'] = __('Opened', 'wpmandrill');
|
1431 |
|
1432 |
$tickFormatter = 'emailFormatter';
|
|
|
1433 |
if ( $display == 'average' ) {
|
1434 |
+
$lit['title'] = __('Average Sending Volume', 'wpmandrill');
|
1435 |
+
$lit['label_suffix'] .= __('/day', 'wpmandrill');
|
1436 |
+
$lit['Ylabel'] = __('Average Volume per Day', 'wpmandrill');
|
1437 |
|
1438 |
foreach ( array(1 => 'today', 7 => 'last_7_days', 30 => 'last_30_days', 60 => 'last_60_days', 90 => 'last_90_days') as $days => $period ) {
|
1439 |
$data['opens'][$period] = number_format($data['opens'][$period] / $days,2);
|
1441 |
$data['unopens'][$period] = number_format($data['unopens'][$period] / $days,2);
|
1442 |
}
|
1443 |
$tickFormatter = 'percentageFormatter';
|
|
|
1444 |
}
|
1445 |
|
1446 |
// Filling arrays for recent stats
|
1737 |
|
1738 |
// Adding a Reply-To header if needed.
|
1739 |
$reply_to = self::getReplyTo();
|
1740 |
+
if ( !empty($reply_to) && !in_array( 'reply-to', array_map( 'strtolower', array_keys($message['headers']) ) ) ) {
|
1741 |
$message['headers']['Reply-To'] = trim(self::getReplyTo());
|
1742 |
}
|
1743 |
|
1769 |
$message['track_opens'] = $track_opens;
|
1770 |
$message['track_clicks']= $track_clicks;
|
1771 |
|
1772 |
+
// Supporting editable sections: Common transformations for the HTML part
|
1773 |
+
if ( self::getnl2br() == 1 ) {
|
1774 |
+
if ( is_array($message['html']) ) {
|
1775 |
+
foreach ($message['html'] as &$value){
|
1776 |
+
$value['content'] = preg_replace('#<(https?://[^*]+)>#', '$1', $value['content']);
|
1777 |
+
$value['content'] = nl2br($value['content']);
|
1778 |
+
}
|
1779 |
+
|
1780 |
+
} else {
|
1781 |
+
$message['html'] = preg_replace('#<(https?://[^*]+)>#', '$1', $message['html']);
|
1782 |
+
$message['html'] = nl2br($message['html']);
|
1783 |
+
}
|
1784 |
+
}
|
1785 |
+
|
1786 |
+
// Defining template to use
|
1787 |
$template = '';
|
1788 |
// If user specified a given template, check if it is valid for this Mandrill account
|
1789 |
if ( !empty($template_name) && self::isTemplateValid($template_name) ) {
|
1792 |
$template = self::getTemplate(); // If no template was specified or the specified was invalid, use the general one.
|
1793 |
}
|
1794 |
|
1795 |
+
// Filling template regions if supply by using an array of regions in the 'html' field of the payload
|
1796 |
if ( $template ) {
|
1797 |
+
if ( is_array($message['html']) ) {
|
1798 |
+
|
1799 |
+
$message['template']['name'] = $template;
|
1800 |
+
foreach ($message['html'] as $region) {
|
1801 |
+
$message['template']['content'][] = $region;
|
1802 |
+
}
|
1803 |
+
|
1804 |
+
$message['html'] = '';
|
1805 |
+
|
1806 |
+
} else {
|
1807 |
+
// Default region if no array was supplied
|
1808 |
+
$message['template']['name'] = $template;
|
1809 |
+
$message['template']['content'] = array( array('name' => 'main', 'content' => $message['html']) );
|
1810 |
+
$message['html'] = '';
|
1811 |
+
}
|
1812 |
}
|
1813 |
|
1814 |
// Letting the user filter/change the message payload
|
|
|
|
|
|
|
1815 |
$message = apply_filters('mandrill_payload', $message);
|
|
|
|
|
|
|
1816 |
|
|
|
|
|
|
|
|
|
|
|
1817 |
// Setting the tags property correctly to be received by the Mandrill's API
|
1818 |
if ( !is_array($message['tags']['user']) ) $message['tags']['user'] = array();
|
1819 |
if ( !is_array($message['tags']['general']) ) $message['tags']['general'] = array();
|
1833 |
}
|
1834 |
|
1835 |
} catch ( Exception $e) {
|
1836 |
+
error_log( date('Y-m-d H:i:s') . " wpMandrill::sendEmail: Exception Caught => ".$e->getMessage()."\n" );
|
1837 |
return new WP_Error( $e->getMessage() );
|
1838 |
}
|
1839 |
}
|