72048172 by Jeff Balicki

mandrill update

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent aef5a431
Showing 35 changed files with 589 additions and 459 deletions
1 ![Send Emails with Mandrill](https://ps.w.org/send-emails-with-mandrill/assets/banner-772x250.jpg)
2
3 # Send Emails with Mandrill
4 This is a fork of the official wpMandrill plugin for Wordpress, since it is no longer being actively supported. We encourage any developers to contribute to making this plugin better as we are actively maintaining this repository for the community's benefit.
5
6 Our plugin can be downloaded for free from the WordPress repository here:
7 https://wordpress.org/plugins/send-emails-with-mandrill/
8
9 Original wpMandrill plugin can be found here:
10 https://wordpress.org/plugins/wpmandrill/
11
12 Please help us gain visibility on this plugin by giving us a five-star rating on the WordPress plugin page here:
13 https://wordpress.org/support/plugin/send-emails-with-mandrill/reviews/#new-post .
14
15 # For developers contributing to this repository
16 For those of you forking this repository, please submit any pull requests to the `develop` branch. `develop` acts as the stable pre-release branch of the plugin. When new versions are released, `develop` will be merged into `master` where the code will then be tagged with the release's version number.
17
18 When submitting fixes to issues or new features/bug fixes, please make sure to branch and submit pull requests for each individually so we can effectively QA each one for accurately.
19
20 Also, thank you! We need developers like you to help us make this a great plugin for the whole WordPress community.
21
22 ---
23
24 ##### Miller Media offers maintenance, design and custom development for WordPress as a service. If you need help with your site, don't hestiate to visit the [Miller Media website](https://www.millermedia.io) or contact us at [support@miller-media.com](mailto:support@miller-media.com)
...@@ -64,5 +64,10 @@ ...@@ -64,5 +64,10 @@
64 max-width: 90% !important; 64 max-width: 90% !important;
65 margin-top:15px; 65 margin-top:15px;
66 } 66 }
67 .stuffbox h3 { cursor: default !important; padding: 3px 3px 3px 10px; } 67 .stuffbox h3, .stuffbox h2 { cursor: default !important; padding: 3px 3px 3px 10px; }
68 .stuffbox div.inside { padding-bottom: 10px;} 68 .stuffbox div.inside { padding-bottom: 10px;}
69
70 .stuffbox table.form-table { margin: 3px 3px 3px 10px; width: auto; }
71 .stuffbox h2 { text-decoration: underline; }
72
73 .stuffbox span.settings_sub_header {padding: 0px 10px; }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -18,8 +18,8 @@ JSON.stringify = JSON.stringify || function (obj) { ...@@ -18,8 +18,8 @@ JSON.stringify = JSON.stringify || function (obj) {
18 } 18 }
19 }; 19 };
20 20
21 jQuery(document).bind( 'ready', function() { 21 jQuery( function() {
22 jQuery('#filter,#display').bind('change keyup', function() { 22 jQuery('#filter,#display').on('change keyup', function() {
23 23
24 if ( jQuery("#filter option:selected").val() == 'none' ) { 24 if ( jQuery("#filter option:selected").val() == 'none' ) {
25 var display = 'block'; 25 var display = 'block';
...@@ -30,7 +30,7 @@ jQuery(document).bind( 'ready', function() { ...@@ -30,7 +30,7 @@ jQuery(document).bind( 'ready', function() {
30 jQuery('#all_time').css('display',display); 30 jQuery('#all_time').css('display',display);
31 showStats(); 31 showStats();
32 }); 32 });
33 jQuery('.columns-prefs, #collapse-button').bind('click', function () { 33 jQuery('.columns-prefs, #collapse-button').on('click', function () {
34 redrawDashboardWidget(); 34 redrawDashboardWidget();
35 }); 35 });
36 36
......
...@@ -259,14 +259,6 @@ msgstr "No tienes suficiente permisología para acceder a esta página." ...@@ -259,14 +259,6 @@ msgstr "No tienes suficiente permisología para acceder a esta página."
259 msgid "Send Test" 259 msgid "Send Test"
260 msgstr "Enviar Prueba" 260 msgstr "Enviar Prueba"
261 261
262 #: wpmandrill.php:313
263 msgid "Latest from Mandrill..."
264 msgstr "Lo último de Mandrill..."
265
266 #: wpmandrill.php:327
267 msgid "News from MailChimp..."
268 msgstr "Noticias de MailChimp"
269
270 #: wpmandrill.php:356 262 #: wpmandrill.php:356
271 msgid "Mandrill How-Tos" 263 msgid "Mandrill How-Tos"
272 msgstr "Mandrill: ¿Cómo hago?" 264 msgstr "Mandrill: ¿Cómo hago?"
......
...@@ -255,14 +255,6 @@ msgstr "" ...@@ -255,14 +255,6 @@ msgstr ""
255 msgid "Send Email" 255 msgid "Send Email"
256 msgstr "" 256 msgstr ""
257 257
258 #: wpmandrill.php:295
259 msgid "Latest from Mandrill..."
260 msgstr ""
261
262 #: wpmandrill.php:309
263 msgid "News from MailChimp..."
264 msgstr ""
265
266 #: wpmandrill.php:336 258 #: wpmandrill.php:336
267 msgid "Mandrill How-Tos" 259 msgid "Mandrill How-Tos"
268 msgstr "" 260 msgstr ""
......
...@@ -96,8 +96,17 @@ class Mandrill { ...@@ -96,8 +96,17 @@ class Mandrill {
96 if( 200 == $response_code ) { 96 if( 200 == $response_code ) {
97 return $body; 97 return $body;
98 } else { 98 } else {
99 error_log("wpMandrill Error: Error {$body['code']}: {$body['message']}"); 99 if( !is_array( $body ) ) {
100 throw new Mandrill_Exception( "wpMandrill Error: {$body['code']}: {$body['message']}", $response_code); 100 $code = 'Unknown';
101 $message = 'Unknown';
102 } else {
103 $code = 'Unknown' ? !array_key_exists('code', $body) : $body['code'];
104 $message = 'Unknown' ? !array_key_exists('message', $body) : $body['message'];
105 }
106
107 error_log("wpMandrill Error: Error {$code}: {$message}");
108 throw new Mandrill_Exception("wpMandrill Error: {$code}: {$message}", $response_code);
109
101 } 110 }
102 } 111 }
103 112
...@@ -292,36 +301,6 @@ class Mandrill { ...@@ -292,36 +301,6 @@ class Mandrill {
292 } 301 }
293 302
294 /** 303 /**
295 * @link https://mandrillapp.com/api/docs/urls.html#method=list
296 *
297 * @return array|Mandrill_Exception
298 */
299 function urls_list() {
300
301 return $this->request('urls/list');
302 }
303
304 /**
305 * @link https://mandrillapp.com/api/docs/urls.html#method=time-series
306 *
307 * @return array|Mandrill_Exception
308 */
309 function urls_time_series($name) {
310
311 return $this->request('urls/time-series', array('name' => $name) );
312 }
313
314 /**
315 * @link https://mandrillapp.com/api/docs/urls.html#method=search
316 *
317 * @return array|Mandrill_Exception
318 */
319 function urls_search($q) {
320
321 return $this->request('urls/search', array('q' => $q) );
322 }
323
324 /**
325 * @link https://mandrillapp.com/api/docs/webhooks.html#method=add 304 * @link https://mandrillapp.com/api/docs/webhooks.html#method=add
326 * 305 *
327 * @return array|Mandrill_Exception 306 * @return array|Mandrill_Exception
...@@ -428,9 +407,7 @@ class Mandrill { ...@@ -428,9 +407,7 @@ class Mandrill {
428 407
429 if( function_exists('curl_init') && function_exists('curl_exec') ) { 408 if( function_exists('curl_init') && function_exists('curl_exec') ) {
430 409
431 if( !ini_get('safe_mode') ){
432 set_time_limit(2 * 60); 410 set_time_limit(2 * 60);
433 }
434 411
435 $ch = curl_init(); 412 $ch = curl_init();
436 curl_setopt($ch, CURLOPT_URL, $url); 413 curl_setopt($ch, CURLOPT_URL, $url);
...@@ -508,7 +485,6 @@ class Mandrill { ...@@ -508,7 +485,6 @@ class Mandrill {
508 485
509 list($headers, $response) = explode("\r\n\r\n", $response, 2); 486 list($headers, $response) = explode("\r\n\r\n", $response, 2);
510 487
511 if(ini_get("magic_quotes_runtime")) $response = stripslashes($response);
512 $info = array('http_code' => 200); 488 $info = array('http_code' => 200);
513 } else { 489 } else {
514 ob_end_clean(); 490 ob_end_clean();
...@@ -539,17 +515,16 @@ class Mandrill { ...@@ -539,17 +515,16 @@ class Mandrill {
539 if ( !function_exists('set_magic_quotes') ) { 515 if ( !function_exists('set_magic_quotes') ) {
540 function set_magic_quotes($value) { return true;} 516 function set_magic_quotes($value) { return true;}
541 } 517 }
542 518 if ( !function_exists('get_magic_quotes_runtime') ) {
543 // if (strnatcmp(phpversion(),'6') >= 0) { 519 function get_magic_quotes_runtime() { return false; }
544 // $magic_quotes = get_magic_quotes_runtime(); 520 }
545 // set_magic_quotes_runtime(0); 521 if ( !function_exists('set_magic_quotes_runtime') ) {
546 // } 522 function set_magic_quotes_runtime($value) { return true; }
523 }
547 524
548 $file_buffer = file_get_contents($path); 525 $file_buffer = file_get_contents($path);
549 $file_buffer = chunk_split(base64_encode($file_buffer), 76, "\n"); 526 $file_buffer = chunk_split(base64_encode($file_buffer), 76, "\n");
550 527
551 // if (strnatcmp(phpversion(),'6') >= 0) set_magic_quotes_runtime($magic_quotes);
552
553 $mime_type = ''; 528 $mime_type = '';
554 if ( function_exists('finfo_open') && function_exists('finfo_file') ) { 529 if ( function_exists('finfo_open') && function_exists('finfo_file') ) {
555 $finfo = finfo_open(FILEINFO_MIME_TYPE); 530 $finfo = finfo_open(FILEINFO_MIME_TYPE);
......
1 <?php
2
3 class pluginActivation
4 {
5 function __construct()
6 {
7 add_action('admin_init', array($this, 'check_version'));
8
9 if (!self::compatible_version()) {
10 return;
11 }
12 }
13
14 static function activation_check()
15 {
16 if (!self::compatible_version()) {
17 deactivate_plugins(SEWM_BASE);
18 wp_die(__('Send Emails with Mandrill requires PHP 5.6 or higher. Please upgrade your version of PHP to activate.', 'send-emails-with-mandrill'));
19 }
20 }
21
22 function check_version()
23 {
24 if (!self::compatible_version()) {
25 if (is_plugin_active(SEWM_BASE)) {
26 deactivate_plugins(SEWM_BASE);
27 add_action('admin_notices', array($this, 'disabled_notice'));
28
29 if (isset($_GET['activate'])) {
30 unset($_GET['activate']);
31 }
32 }
33 }
34 }
35
36 function disabled_notice()
37 {
38 echo '<div class="notice notice-error is-dismissible"><p>' . esc_html__('Send Emails with Mandrill requires PHP 5.6 or higher. Please upgrade your version of PHP to activate.', 'send-emails-with-mandrill') . '</p></div>';
39 }
40
41 static function compatible_version()
42 {
43 if (version_compare(PHP_VERSION, '5.6', '<'))
44 return false;
45
46 // Add sanity checks for other version requirements here
47 return true;
48 }
49 }
50
51 global $pluginCheck;
52 $pluginCheck = new pluginActivation();
53
54 register_activation_hook(__FILE__, array('pluginActivation', 'activation_check'));
...\ No newline at end of file ...\ No newline at end of file
1 <?php 1 <?php
2 /* 2
3 Plugin Name: wpMandrill 3 /* Attach native mail function */
4 Description: wpMandrill sends emails, generated by WordPress using Mandrill. 4 add_action( 'wp_mail_native', array( 'wpMandrill', 'wp_mail_native' ), 10, 5 );
5 Author: Mandrill
6 Author URI: http://mandrillapp.com/
7 Plugin URI: http://connect.mailchimp.com/integrations/transactional-emails-from-wordpress
8 Version: 1.33
9 Text Domain: wpmandrill
10 */
11 /* Copyright 2012 MailChimp (email : will@mailchimp.com )
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation using version 2 of the License.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
26
27 */
28 wpMandrill::on_load();
29 5
30 class wpMandrill { 6 class wpMandrill {
31 const DEBUG = false; 7 const DEBUG = false;
...@@ -43,17 +19,16 @@ class wpMandrill { ...@@ -43,17 +19,16 @@ class wpMandrill {
43 add_action('admin_init', array(__CLASS__, 'adminInit')); 19 add_action('admin_init', array(__CLASS__, 'adminInit'));
44 add_action('admin_menu', array(__CLASS__, 'adminMenu')); 20 add_action('admin_menu', array(__CLASS__, 'adminMenu'));
45 21
46 add_filter('contextual_help', array(__CLASS__, 'showContextualHelp'), 10, 3);
47
48 add_action('admin_print_footer_scripts', array(__CLASS__,'openContextualHelp')); 22 add_action('admin_print_footer_scripts', array(__CLASS__,'openContextualHelp'));
49 add_action('wp_ajax_get_mandrill_stats', array(__CLASS__,'getAjaxStats')); 23 add_action('wp_ajax_get_mandrill_stats', array(__CLASS__,'getAjaxStats'));
50 add_action('wp_ajax_get_dashboard_widget_stats', array(__CLASS__,'showDashboardWidget')); 24 add_action('wp_ajax_get_dashboard_widget_stats', array(__CLASS__,'showDashboardWidget'));
51 25
26 add_action('admin_post_sewm_fetch_new', array(__CLASS__, 'fetchNewDashboardData') );
27
52 load_plugin_textdomain('wpmandrill', false, dirname( plugin_basename( __FILE__ ) ).'/lang'); 28 load_plugin_textdomain('wpmandrill', false, dirname( plugin_basename( __FILE__ ) ).'/lang');
53 29
54 if( function_exists('wp_mail') ) { 30 if( function_exists('wp_mail') ) {
55 self::$conflict = true; 31 self::$conflict = true;
56 add_action('admin_notices', array(__CLASS__, 'adminNotices'));
57 return; 32 return;
58 } 33 }
59 34
...@@ -62,18 +37,11 @@ class wpMandrill { ...@@ -62,18 +37,11 @@ class wpMandrill {
62 37
63 function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { 38 function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
64 try { 39 try {
65 $sent = wpMandrill::mail( $to, $subject, $message, $headers, $attachments ); 40 $response = wpMandrill::mail( $to, $subject, $message, $headers, $attachments );
66 41 return wpMandrill::evaluate_response( $response );
67 if ( is_wp_error($sent)
68 || !isset($sent[0]['status'])
69 || ($sent[0]['status'] != 'sent' && $sent[0]['status'] != 'queued') ) {
70
71 return wpMandrill::wp_mail_native( $to, $subject, $message, $headers, $attachments );
72 }
73
74 return true;
75 } catch ( Exception $e ) { 42 } catch ( Exception $e ) {
76 return wpMandrill::wp_mail_native( $to, $subject, $message, $headers, $attachments ); 43 error_log( 'Mandrill error: ' . $e->getMessage() );
44 do_action( 'wp_mail_native', $to, $subject, $message, $headers, $attachments );
77 } 45 }
78 } 46 }
79 } 47 }
...@@ -81,6 +49,31 @@ class wpMandrill { ...@@ -81,6 +49,31 @@ class wpMandrill {
81 } 49 }
82 50
83 /** 51 /**
52 * Evaluate response from Mandrill API.
53 *
54 * @param WP_Error|array
55 */
56 static function evaluate_response( $response ) {
57 if ( is_wp_error( $response ) )
58 throw new Exception( $response->get_error_message() );
59
60 if ( !isset( $response[0]['status'] ) )
61 throw new Exception( 'Email status was not provided in response.' );
62
63 if (
64 'rejected' === $response[0]['status']
65 && isset( $response[0]['reject_reason'] )
66 && 'hard-bounce' !== $response[0]['reject_reason'] # Exclude hard bounces (email address doesn't exist).
67 )
68 throw new Exception( 'Email was rejected due to the following reason: ' . $response[0]['reject_reason'] . '.' );
69
70 if ( !in_array( $response[0]['status'], array( 'sent', 'queued' ) ) )
71 throw new Exception( 'Email was not sent or queued. Response: ' . json_encode( $response ) );
72
73 return true;
74 }
75
76 /**
84 * Sets up options page and sections. 77 * Sets up options page and sections.
85 */ 78 */
86 static function adminInit() { 79 static function adminInit() {
...@@ -104,20 +97,24 @@ class wpMandrill { ...@@ -104,20 +97,24 @@ class wpMandrill {
104 add_settings_field('from-name', __('FROM Name', 'wpmandrill'), array(__CLASS__, 'askFromName'), 'wpmandrill', 'wpmandrill-addresses'); 97 add_settings_field('from-name', __('FROM Name', 'wpmandrill'), array(__CLASS__, 'askFromName'), 'wpmandrill', 'wpmandrill-addresses');
105 add_settings_field('from-email', __('FROM Email', 'wpmandrill'), array(__CLASS__, 'askFromEmail'), 'wpmandrill', 'wpmandrill-addresses'); 98 add_settings_field('from-email', __('FROM Email', 'wpmandrill'), array(__CLASS__, 'askFromEmail'), 'wpmandrill', 'wpmandrill-addresses');
106 add_settings_field('reply-to', __('Reply-To Email', 'wpmandrill'), array(__CLASS__, 'askReplyTo'), 'wpmandrill', 'wpmandrill-addresses'); 99 add_settings_field('reply-to', __('Reply-To Email', 'wpmandrill'), array(__CLASS__, 'askReplyTo'), 'wpmandrill', 'wpmandrill-addresses');
100 add_settings_field('subaccount', __('Sub Account', 'wpmandrill'), array(__CLASS__, 'askSubAccount'), 'wpmandrill', 'wpmandrill-addresses');
107 101
108 // Tracking 102 // Tracking
109 add_settings_section('wpmandrill-tracking', __('Tracking', 'wpmandrill'), '__return_false', 'wpmandrill'); 103 add_settings_section('wpmandrill-tracking', __('Tracking', 'wpmandrill'), '__return_false', 'wpmandrill');
110 add_settings_field('trackopens', __('Track opens', 'wpmandrill'), array(__CLASS__, 'askTrackOpens'), 'wpmandrill', 'wpmandrill-tracking'); 104 add_settings_field('trackopens', __('Track opens', 'wpmandrill'), array(__CLASS__, 'askTrackOpens'), 'wpmandrill', 'wpmandrill-tracking');
111 add_settings_field('trackclicks', __('Track clicks', 'wpmandrill'), array(__CLASS__, 'askTrackClicks'), 'wpmandrill', 'wpmandrill-tracking'); 105 add_settings_field('trackclicks', __('Track clicks', 'wpmandrill'), array(__CLASS__, 'askTrackClicks'), 'wpmandrill', 'wpmandrill-tracking');
112 106
113 // Template 107 // General Design
114 add_settings_section('wpmandrill-templates', __('General Design', 'wpmandrill'), '__return_false', 'wpmandrill'); 108 add_settings_section('wpmandrill-templates', __('General Design', 'wpmandrill'), '__return_false', 'wpmandrill');
115 add_settings_field('template', __('Template', 'wpmandrill'), array(__CLASS__, 'askTemplate'), 'wpmandrill', 'wpmandrill-templates'); 109 add_settings_field('template', __('Template', 'wpmandrill'), array(__CLASS__, 'askTemplate'), 'wpmandrill', 'wpmandrill-templates');
116 add_settings_field('nl2br', __('Content', 'wpmandrill'), array(__CLASS__, 'asknl2br'), 'wpmandrill', 'wpmandrill-templates'); 110 add_settings_field('nl2br', __('Content', 'wpmandrill'), array(__CLASS__, 'asknl2br'), 'wpmandrill', 'wpmandrill-templates');
117 111
112 if( self::isWooCommerceActive() )
113 add_settings_field('nl2br-woocommerce', __('WooCommerce Fix', 'wpmandrill'), array(__CLASS__, 'asknl2brWooCommerce'), 'wpmandrill', 'wpmandrill-templates');
114
118 // Tags 115 // Tags
119 add_settings_section('wpmandrill-tags', __('General Tags', 'wpmandrill'), '__return_false', 'wpmandrill'); 116 add_settings_section('wpmandrill-tags', __('General Tags', 'wpmandrill'), '__return_false', 'wpmandrill');
120 add_settings_field('tags', __('&nbsp;', 'wpmandrill'), array(__CLASS__, 'askTags'), 'wpmandrill', 'wpmandrill-tags'); 117 add_settings_field('tags', __('Tags', 'wpmandrill'), array(__CLASS__, 'askTags'), 'wpmandrill', 'wpmandrill-tags');
121 118
122 if ( self::isConfigured() ) { 119 if ( self::isConfigured() ) {
123 // Email Test 120 // Email Test
...@@ -129,6 +126,16 @@ class wpMandrill { ...@@ -129,6 +126,16 @@ class wpMandrill {
129 add_settings_field('email-message', __('Message', 'wpmandrill'), array(__CLASS__, 'askTestEmailMessage'), 'wpmandrill-test', 'mandrill-email-test'); 126 add_settings_field('email-message', __('Message', 'wpmandrill'), array(__CLASS__, 'askTestEmailMessage'), 'wpmandrill-test', 'mandrill-email-test');
130 } 127 }
131 128
129 // Misc. Plugin Settings
130 add_settings_section('wpmandrill-misc', __('Miscellaneous', 'wpmandrill'), function(){ echo "<span class='settings_sub_header'>Settings for WordPress plugin. Does not affect email delivery functionality or design.</span>"; }, 'wpmandrill');
131 add_settings_field('hide_dashboard_widget', __('Hide WP Dashboard Widget', 'wpmandrill'), array(__CLASS__, 'hideDashboardWidget'), 'wpmandrill', 'wpmandrill-misc');
132 }
133
134 // Fix for WooCommerce
135 if( self::getnl2brWooCommerce() ) {
136 add_action( 'woocommerce_email', function() {
137 add_filter( 'mandrill_nl2br', '__return_false' );
138 }, 10, 1 );
132 } 139 }
133 140
134 // Activate the cron job that will update the stats 141 // Activate the cron job that will update the stats
...@@ -157,8 +164,9 @@ class wpMandrill { ...@@ -157,8 +164,9 @@ class wpMandrill {
157 'wpmandrill', 164 'wpmandrill',
158 array(__CLASS__,'showOptionsPage') 165 array(__CLASS__,'showOptionsPage')
159 ); 166 );
167 add_action( 'load-'.self::$settings, array(__CLASS__,'showContextualHelp'));
160 168
161 if( self::isConfigured() ) { 169 if( self::isConfigured() && apply_filters( 'wpmandrill_enable_reports', true ) ) {
162 if (current_user_can('manage_options')) self::$report = add_dashboard_page( 170 if (current_user_can('manage_options')) self::$report = add_dashboard_page(
163 __('Mandrill Reports', 'wpmandrill'), 171 __('Mandrill Reports', 'wpmandrill'),
164 __('Mandrill Reports', 'wpmandrill'), 172 __('Mandrill Reports', 'wpmandrill'),
...@@ -167,9 +175,9 @@ class wpMandrill { ...@@ -167,9 +175,9 @@ class wpMandrill {
167 array(__CLASS__,'showReportPage') 175 array(__CLASS__,'showReportPage')
168 ); 176 );
169 if ( self::isPluginPage('-reports') ) { 177 if ( self::isPluginPage('-reports') ) {
170 wp_register_script('flot', plugins_url('/js/flot/jquery.flot.js', __FILE__), array('jquery'), null, true); 178 wp_register_script('flot', SEWM_URL . 'js/flot/jquery.flot.js', array('jquery'), SEWM_VERSION, true);
171 wp_register_script('flotstack', plugins_url('/js/flot/jquery.flot.stack.js', __FILE__), array('flot'), null, true); 179 wp_register_script('flotstack', SEWM_URL . 'js/flot/jquery.flot.stack.js', array('flot'), SEWM_VERSION, true);
172 wp_register_script('flotresize', plugins_url('/js/flot/jquery.flot.resize.js', __FILE__), array('flot'), null, true); 180 wp_register_script('flotresize', SEWM_URL . 'js/flot/jquery.flot.resize.js', array('flot'), SEWM_VERSION, true);
173 wp_enqueue_script('flot'); 181 wp_enqueue_script('flot');
174 wp_enqueue_script('flotstack'); 182 wp_enqueue_script('flotstack');
175 wp_enqueue_script('flotresize'); 183 wp_enqueue_script('flotresize');
...@@ -177,9 +185,9 @@ class wpMandrill { ...@@ -177,9 +185,9 @@ class wpMandrill {
177 } 185 }
178 } 186 }
179 187
180 wp_register_style( 'mandrill_stylesheet', plugins_url('/css/mandrill.css', __FILE__) ); 188 wp_register_style( 'mandrill_stylesheet', SEWM_URL . 'css/mandrill.css', array(), SEWM_VERSION );
181 wp_enqueue_style( 'mandrill_stylesheet' ); 189 wp_enqueue_style( 'mandrill_stylesheet' );
182 wp_register_script('mandrill', plugins_url('/js/mandrill.js', __FILE__), array(), null, true); 190 wp_register_script('mandrill', SEWM_URL . 'js/mandrill.js', array(), SEWM_VERSION, true);
183 wp_enqueue_script('mandrill'); 191 wp_enqueue_script('mandrill');
184 } 192 }
185 193
...@@ -205,7 +213,7 @@ class wpMandrill { ...@@ -205,7 +213,7 @@ class wpMandrill {
205 213
206 static function showAdminEnqueueScripts($hook_suffix) { 214 static function showAdminEnqueueScripts($hook_suffix) {
207 if( $hook_suffix == self::$report && self::isConnected() ) { 215 if( $hook_suffix == self::$report && self::isConnected() ) {
208 wp_register_script('mandrill-report-script', plugins_url("js/mandrill.js", __FILE__), array('flot'), null, true); 216 wp_register_script('mandrill-report-script', SEWM_URL . "js/mandrill.js", array('flot'), null, true);
209 wp_enqueue_script('mandrill-report-script'); 217 wp_enqueue_script('mandrill-report-script');
210 } 218 }
211 } 219 }
...@@ -213,8 +221,8 @@ class wpMandrill { ...@@ -213,8 +221,8 @@ class wpMandrill {
213 /** 221 /**
214 * Generates source of contextual help panel. 222 * Generates source of contextual help panel.
215 */ 223 */
216 static function showContextualHelp($contextual_help, $screen_id, $screen) { 224 static function showContextualHelp() {
217 if ($screen_id == self::$settings) { 225 $screen = get_current_screen();
218 self::getConnected(); 226 self::getConnected();
219 227
220 $ok = array(); 228 $ok = array();
...@@ -230,7 +238,7 @@ class wpMandrill { ...@@ -230,7 +238,7 @@ class wpMandrill {
230 . '</ol>'; 238 . '</ol>';
231 } 239 }
232 240
233 return $requirements 241 $requirements = $requirements
234 . '<p>' . __('Once you have properly configured the settings, the plugin will take care of all the emails sent through your WordPress installation.', 'wpmandrill').'</p>' 242 . '<p>' . __('Once you have properly configured the settings, the plugin will take care of all the emails sent through your WordPress installation.', 'wpmandrill').'</p>'
235 . '<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>' 243 . '<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>'
236 . '<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>' 244 . '<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>'
...@@ -239,26 +247,33 @@ class wpMandrill { ...@@ -239,26 +247,33 @@ class wpMandrill {
239 . '<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>' 247 . '<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>'
240 . '<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>' 248 . '<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>'
241 ; 249 ;
242 }
243 250
244 return $contextual_help; 251 $screen->add_help_tab( array(
252 'id' => 'tab1',
253 'title' => __('Setup'),
254 'content' => '<p>' . __( $requirements) . '</p>',
255 ) );
245 } 256 }
246 257
247 /** 258 /**
248 * Adds link to settings page in list of plugins 259 * Adds link to settings page in list of plugins
249 */ 260 */
250 static function showPluginActionLinks($actions, $plugin_file) { 261 static function showPluginActionLinks($actions, $plugin_file) {
251 static $plugin;
252 262
253 if (!isset($plugin)) 263 // The code below no longer returns the current filename; @todo to update this to non-hard coded values
254 $plugin = plugin_basename(__FILE__); 264 // static $plugin;
265 //
266 // if (!isset($plugin))
267 // $plugin = plugin_basename(__FILE__);
255 268
256 if ($plugin == $plugin_file) { 269 $plugin = 'send-emails-with-mandrill/wpmandrill.php';
257 270
258 $settings = array('settings' => '<a href="options-general.php?page=wpmandrill">' . __('Settings', 'wpmandrill') . '</a>'); 271 if ($plugin == $plugin_file) {
272 $settings = array('settings' => '<a href="'.admin_url("/options-general.php?page=wpmandrill").'">' . __('Settings', 'wpmandrill') . '</a>');
259 273
274 self::getConnected();
260 if ( self::isConnected() ) { 275 if ( self::isConnected() ) {
261 $report = array('report' => '<a href="index.php?page=wpmandrill-reports">' . __('Reports', 'wpmandrill') . '</a>'); 276 $report = array('report' => '<a href="'.self::getReportsDashboardURL().'">' . __('Reports', 'wpmandrill') . '</a>');
262 $actions = array_merge($settings, $actions, $report); 277 $actions = array_merge($settings, $actions, $report);
263 } else { 278 } else {
264 $actions = array_merge($settings, $actions); 279 $actions = array_merge($settings, $actions);
...@@ -284,8 +299,8 @@ class wpMandrill { ...@@ -284,8 +299,8 @@ class wpMandrill {
284 self::getConnected(); 299 self::getConnected();
285 300
286 ?> 301 ?>
287 <div class="wrap"> 302 <div class="wrap">
288 <div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div> 303 <div class="icon32" style="background: url('<?php echo SEWM_URL . 'images/mandrill-head-icon.png'; ?>');"><br /></div>
289 <h2><?php _e('Mandrill Settings', 'wpmandrill'); ?> <small><a href="options-general.php?page=<?php echo 'wpmandrill'; ?>&show=how-tos">view how-tos</a></small></h2> 304 <h2><?php _e('Mandrill Settings', 'wpmandrill'); ?> <small><a href="options-general.php?page=<?php echo 'wpmandrill'; ?>&show=how-tos">view how-tos</a></small></h2>
290 305
291 <div style="float: left;width: 70%;"> 306 <div style="float: left;width: 70%;">
...@@ -312,53 +327,7 @@ class wpMandrill { ...@@ -312,53 +327,7 @@ class wpMandrill {
312 <?php } ?> 327 <?php } ?>
313 328
314 </div> 329 </div>
315
316 <div style="float: left;width: 20%;">
317 <?php
318 $rss = fetch_feed('http://blog.mandrill.com/feeds/all.atom.xml');
319 $maxitems = 0;
320 if (!is_wp_error( $rss ) ) {
321 $maxitems = $rss->get_item_quantity(5);
322 $rss_items = $rss->get_items(0, $maxitems);
323 }
324
325 if ( $maxitems > 0 ) {
326 ?>
327 <div class="mcnews mandrill">
328 <h3 class="mcnews_header"><?php _e('Latest from Mandrill...', 'wpmandrill'); ?></h3>
329 <ul>
330 <?php
331 foreach ( $rss_items as $item ) { ?>
332 <li>
333 <a href='<?php echo esc_url( $item->get_permalink() ); ?>'
334 title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
335 <?php echo esc_html( $item->get_title() ); ?></a>
336 </li>
337 <?php } ?>
338 </ul>
339 </div>
340 <?php } ?>
341 <div class="mcnews">
342 <h3 class="mcnews_header"><?php _e('News from MailChimp...', 'wpmandrill'); ?></h3><?php
343 $rss = fetch_feed('http://mailchimp.com/blog/feed');
344 if (!is_wp_error( $rss ) ) {
345 $maxitems = $rss->get_item_quantity(5);
346 $rss_items = $rss->get_items(0, $maxitems);
347 } ?>
348 <ul>
349 <?php if ($maxitems == 0) echo '<li>No news!</li>';
350 else
351 foreach ( $rss_items as $item ) { ?>
352 <li>
353 <a href='<?php echo esc_url( $item->get_permalink() ); ?>'
354 title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
355 <?php echo esc_html( $item->get_title() ); ?></a>
356 </li>
357 <?php } ?>
358 </ul>
359 </div>
360 </div> 330 </div>
361 </div>
362 <?php 331 <?php
363 } 332 }
364 333
...@@ -366,11 +335,11 @@ class wpMandrill { ...@@ -366,11 +335,11 @@ class wpMandrill {
366 self::getConnected(); 335 self::getConnected();
367 336
368 ?> 337 ?>
369 <div class="wrap"> 338 <div class="wrap">
370 <div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div> 339 <div class="icon32" style="background: url('<?php echo SEWM_URL . 'images/mandrill-head-icon.png'; ?>');"><br /></div>
371 <h2><?php _e('Mandrill How-Tos', 'wpmandrill'); ?> <small><a href="options-general.php?page=<?php echo 'wpmandrill'; ?>">back to settings</a></small></h2> 340 <h2><?php _e('Mandrill How-Tos', 'wpmandrill'); ?> <small><a href="options-general.php?page=<?php echo 'wpmandrill'; ?>">back to settings</a></small></h2>
372 <?php 341 <?php
373 require plugin_dir_path( __FILE__ ) . '/how-tos.php'; 342 require SEWM_PATH . '/how-tos.php';
374 343
375 echo wpMandrill_HowTos::show('intro'); 344 echo wpMandrill_HowTos::show('intro');
376 echo wpMandrill_HowTos::show('auto'); 345 echo wpMandrill_HowTos::show('auto');
...@@ -385,7 +354,22 @@ class wpMandrill { ...@@ -385,7 +354,22 @@ class wpMandrill {
385 } 354 }
386 355
387 static function showReportPage() { 356 static function showReportPage() {
388 require plugin_dir_path( __FILE__ ) . '/stats.php'; 357 require SEWM_PATH . '/stats.php';
358 }
359
360 static function getReportsDashboardURL($args=[]){
361 $get_params = !empty($args) ? '&'.http_build_query( $args ) : '';
362 return admin_url('/index.php?page=wpmandrill-reports'.$get_params);
363 }
364
365 static function fetchNewDashboardData() {
366 wp_redirect(
367 self::getReportsDashboardURL(
368 array(
369 'fetch_new' => 'asap'
370 )
371 )
372 );
389 } 373 }
390 374
391 /** 375 /**
...@@ -422,17 +406,17 @@ class wpMandrill { ...@@ -422,17 +406,17 @@ class wpMandrill {
422 return; 406 return;
423 407
424 ?> 408 ?>
425 <script type="text/javascript"> 409 <script type="text/javascript">
426 jQuery(document).bind( 'ready', function() { 410 jQuery(document).on( 'ready', function() {
427 jQuery('a#contextual-help-link').trigger('click'); 411 jQuery('a#contextual-help-link').trigger('click');
428 }); 412 });
429 </script> 413 </script>
430 <?php 414 <?php
431 } 415 }
432 416
433 /****************************************************************** 417 /******************************************************************
434 ** Helper functions 418 ** Helper functions
435 *******************************************************************/ 419 *******************************************************************/
436 420
437 /** 421 /**
438 * @return mixed 422 * @return mixed
...@@ -457,7 +441,7 @@ jQuery(document).bind( 'ready', function() { ...@@ -457,7 +441,7 @@ jQuery(document).bind( 'ready', function() {
457 static function getConnected() { 441 static function getConnected() {
458 if ( !isset(self::$mandrill) ) { 442 if ( !isset(self::$mandrill) ) {
459 try { 443 try {
460 require_once( plugin_dir_path( __FILE__ ) . '/lib/mandrill.class.php'); 444 require_once( SEWM_PATH . '/lib/mandrill.class.php');
461 self::$mandrill = new Mandrill( self::getAPIKey() ); 445 self::$mandrill = new Mandrill( self::getAPIKey() );
462 } catch ( Exception $e ) {} 446 } catch ( Exception $e ) {}
463 } 447 }
...@@ -488,6 +472,9 @@ jQuery(document).bind( 'ready', function() { ...@@ -488,6 +472,9 @@ jQuery(document).bind( 'ready', function() {
488 * @return string|boolean 472 * @return string|boolean
489 */ 473 */
490 static function getAPIKey() { 474 static function getAPIKey() {
475 if( defined('SEWM_API_KEY') ){
476 return SEWM_API_KEY;
477 }
491 478
492 return self::getOption('api_key'); 479 return self::getOption('api_key');
493 } 480 }
...@@ -532,6 +519,14 @@ jQuery(document).bind( 'ready', function() { ...@@ -532,6 +519,14 @@ jQuery(document).bind( 'ready', function() {
532 /** 519 /**
533 * @return string|boolean 520 * @return string|boolean
534 */ 521 */
522 static function getSubAccount() {
523
524 return self::getOption('subaccount');
525 }
526
527 /**
528 * @return string|boolean
529 */
535 static function getTemplate() { 530 static function getTemplate() {
536 531
537 return self::getOption('template'); 532 return self::getOption('template');
...@@ -548,6 +543,36 @@ jQuery(document).bind( 'ready', function() { ...@@ -548,6 +543,36 @@ jQuery(document).bind( 'ready', function() {
548 /** 543 /**
549 * @return string|boolean 544 * @return string|boolean
550 */ 545 */
546 static function isWooCommerceActive() {
547 // If WooCommerce is not active, we can ignore
548 if ( !class_exists( 'WooCommerce' ) ) {
549 return false;
550 }
551
552 return true;
553 }
554
555 /**
556 * @return string|boolean
557 */
558 static function getnl2brWooCommerce() {
559
560 if( !self::isWooCommerceActive() )
561 return false;
562
563 return self::getOption('nl2br_woocommerce');
564 }
565
566 /**
567 * @return string|boolean
568 */
569 static function gethideDashboardWidget() {
570 return self::getOption('hide_dashboard_widget');
571 }
572
573 /**
574 * @return string|boolean
575 */
551 static function getTrackOpens() { 576 static function getTrackOpens() {
552 577
553 return self::getOption('trackopens'); 578 return self::getOption('trackopens');
...@@ -625,7 +650,7 @@ jQuery(document).bind( 'ready', function() { ...@@ -625,7 +650,7 @@ jQuery(document).bind( 'ready', function() {
625 650
626 $templates = self::$mandrill->templates_list(); 651 $templates = self::$mandrill->templates_list();
627 foreach ( $templates as $curtemplate ) { 652 foreach ( $templates as $curtemplate ) {
628 if ( $curtemplate['name'] == $template ) { 653 if ( $curtemplate['name'] == $template || $curtemplate['slug'] == $template) {
629 return true; 654 return true;
630 } 655 }
631 } 656 }
...@@ -680,8 +705,13 @@ jQuery(document).bind( 'ready', function() { ...@@ -680,8 +705,13 @@ jQuery(document).bind( 'ready', function() {
680 static function askAPIKey() { 705 static function askAPIKey() {
681 echo '<div class="inside">'; 706 echo '<div class="inside">';
682 707
683 $api_key = self::getOption('api_key'); 708 $api_key = self::getAPIKey();
709
710 if( defined('SEWM_API_KEY') ) {
711 ?>API Key globally defined.<?php
712 } else {
684 ?><input id='api_key' name='wpmandrill[api_key]' size='45' type='text' value="<?php esc_attr_e( $api_key ); ?>" /><?php 713 ?><input id='api_key' name='wpmandrill[api_key]' size='45' type='text' value="<?php esc_attr_e( $api_key ); ?>" /><?php
714 }
685 715
686 if ( empty($api_key) ) { 716 if ( empty($api_key) ) {
687 ?><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 717 ?><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
...@@ -731,7 +761,19 @@ jQuery(document).bind( 'ready', function() { ...@@ -731,7 +761,19 @@ jQuery(document).bind( 'ready', function() {
731 761
732 ?><?php _e('This address will be used as the recipient where replies from the users will be sent to:', 'wpmandrill'); ?><br /> 762 ?><?php _e('This address will be used as the recipient where replies from the users will be sent to:', 'wpmandrill'); ?><br />
733 <input id="reply_to" name="wpmandrill[reply_to]" type="text" value="<?php esc_attr_e($reply_to);?>"><br/> 763 <input id="reply_to" name="wpmandrill[reply_to]" type="text" value="<?php esc_attr_e($reply_to);?>"><br/>
734 <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 764 <span class="setting-description"><br /><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
765
766 echo '</div>';
767 }
768
769 static function askSubAccount() {
770 echo '<div class="inside">';
771
772 $subaccount = self::getSubAccount();
773
774 ?><?php _e('Name of the sub account you wish to use (optional):', 'wpmandrill'); ?><br />
775 <input id="subaccount" name="wpmandrill[subaccount]" type="text" value="<?php esc_attr_e($subaccount); ?>">
776 <?php
735 777
736 echo '</div>'; 778 echo '</div>';
737 } 779 }
...@@ -767,7 +809,7 @@ jQuery(document).bind( 'ready', function() { ...@@ -767,7 +809,7 @@ jQuery(document).bind( 'ready', function() {
767 foreach( $templates as $curtemplate ) { 809 foreach( $templates as $curtemplate ) {
768 ?><option value="<?php esc_attr_e($curtemplate['name']); ?>" <?php selected($curtemplate['name'], $template); ?>><?php esc_html_e($curtemplate['name']); ?></option><?php 810 ?><option value="<?php esc_attr_e($curtemplate['name']); ?>" <?php selected($curtemplate['name'], $template); ?>><?php esc_html_e($curtemplate['name']); ?></option><?php
769 } 811 }
770 ?></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 812 ?></select><br/><span class="setting-description"><em><?php _e('<br /><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
771 813
772 echo '</div>'; 814 echo '</div>';
773 } 815 }
...@@ -799,8 +841,21 @@ jQuery(document).bind( 'ready', function() { ...@@ -799,8 +841,21 @@ jQuery(document).bind( 'ready', function() {
799 <input id="nl2br" name="wpmandrill[nl2br]" type="checkbox" <?php echo checked($nl2br,1); ?> value='1' /><br/> 841 <input id="nl2br" name="wpmandrill[nl2br]" type="checkbox" <?php echo checked($nl2br,1); ?> value='1' /><br/>
800 <span class="setting-description"> 842 <span class="setting-description">
801 <em> 843 <em>
802 <?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'); ?><br/> 844 <?php _e('<br /><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'); ?><br/>
803 <?php _e('<small>You can change the value of this setting on the fly by using the <strong><a href="#" onclick="jQuery(\'a#contextual-help-link\').trigger(\'click\');return false;">wpmandrill_nl2br</a></strong> filter.</small>', 'wpmandrill'); ?> 845 <?php _e('<small>You can change the value of this setting on the fly by using the <strong><a href="#" onclick="jQuery(\'a#contextual-help-link\').trigger(\'click\');return false;">mandrill_nl2br</a></strong> filter.</small>', 'wpmandrill'); ?>
846 </em></span>
847 </div><?php
848 }
849
850 static function asknl2brWooCommerce() {
851 $nl2br_woocommerce = self::getnl2brWooCommerce();
852 if ( $nl2br_woocommerce == '' ) $nl2br_woocommerce = 0;
853 ?>
854 <div class="inside">
855 <input id="nl2br_woocommere" name="wpmandrill[nl2br_woocommerce]" type="checkbox" <?php echo checked($nl2br_woocommerce,1); ?> value='1' /><br/>
856 <span class="setting-description">
857 <em>
858 <?php _e('<br /><small>Check this if your WooCommerce emails are spaced incorrectly after enabling the <br/> setting above.</small>', 'wpmandrill'); ?>
804 </em></span> 859 </em></span>
805 </div><?php 860 </div><?php
806 } 861 }
...@@ -810,14 +865,23 @@ jQuery(document).bind( 'ready', function() { ...@@ -810,14 +865,23 @@ jQuery(document).bind( 'ready', function() {
810 865
811 $tags = self::getTags(); 866 $tags = self::getTags();
812 867
813 ?><?php _e('If there are tags that you want appended to every call, list them here, one per line:', 'wpmandrill'); ?><br /> 868 ?><?php _e('If there are tags that you want appended to every call, list them here, one per line:<br />', 'wpmandrill'); ?><br />
814 <textarea id="tags" name="wpmandrill[tags]" cols="25" rows="3"><?php echo $tags; ?></textarea><br/> 869 <textarea id="tags" name="wpmandrill[tags]" cols="25" rows="3"><?php echo $tags; ?></textarea><br/>
815 <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> 870 <span class="setting-description"><br /><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>
816 <?php 871 <?php
817 872
818 echo '</div>'; 873 echo '</div>';
819 } 874 }
820 875
876 static function hideDashboardWidget() {
877 $hideDashboardWidget = self::getHideDashboardWidget();
878 if ( $hideDashboardWidget == '' ) $hideDashboardWidget = 0;
879 ?>
880 <div class="inside">
881 <input id="hide_dashboard_widget" name="wpmandrill[hide_dashboard_widget]" type="checkbox" <?php echo checked($hideDashboardWidget,1); ?> value='1' /><br/>
882 <?php
883 }
884
821 static function askTestEmailTo() { 885 static function askTestEmailTo() {
822 echo '<div class="inside">'; 886 echo '<div class="inside">';
823 ?><input id='email_to' name='wpmandrill-test[email_to]' size='45' type='text' value="<?php esc_attr_e( self::getTestEmailOption('email_to') ); ?>"/><?php 887 ?><input id='email_to' name='wpmandrill-test[email_to]' size='45' type='text' value="<?php esc_attr_e( self::getTestEmailOption('email_to') ); ?>"/><?php
...@@ -851,9 +915,9 @@ jQuery(document).bind( 'ready', function() { ...@@ -851,9 +915,9 @@ jQuery(document).bind( 'ready', function() {
851 } 915 }
852 916
853 917
854 /****************************************************************** 918 /******************************************************************
855 ** Stats-related functions 919 ** Stats-related functions
856 *******************************************************************/ 920 *******************************************************************/
857 921
858 /** 922 /**
859 * @return array 923 * @return array
...@@ -891,11 +955,7 @@ jQuery(document).bind( 'ready', function() { ...@@ -891,11 +955,7 @@ jQuery(document).bind( 'ready', function() {
891 } 955 }
892 $stats['senders'] = $data; 956 $stats['senders'] = $data;
893 957
894 $stats['urls'] = self::$mandrill->urls_list();
895
896
897 $final['general'] = $stats['user']; 958 $final['general'] = $stats['user'];
898 $final['urls'] = $stats['urls'];
899 959
900 $final['stats'] = array(); 960 $final['stats'] = array();
901 $final['stats']['hourly']['senders'] = array();; 961 $final['stats']['hourly']['senders'] = array();;
...@@ -1010,9 +1070,15 @@ jQuery(document).bind( 'ready', function() { ...@@ -1010,9 +1070,15 @@ jQuery(document).bind( 'ready', function() {
1010 1070
1011 /** 1071 /**
1012 * Try to get the current stats from cache. First, using a transient, if it has expired, it returns the latest 1072 * Try to get the current stats from cache. First, using a transient, if it has expired, it returns the latest
1013 * saved stats if found... and if there's none saved, it creates it diretly from Mandrill. 1073 * saved stats if found... and if there's none saved, it creates it directly from Mandrill.
1014 */ 1074 */
1015 static function getCurrentStats() { 1075 static function getCurrentStats() {
1076 if( is_array($_GET) ){
1077 if( array_key_exists('fetch_new', $_GET) && $_GET['fetch_new']=='asap'){
1078 $stats = self::saveProcessedStats();
1079 return $stats;
1080 }
1081 }
1016 1082
1017 $stats = get_transient('wpmandrill-stats'); 1083 $stats = get_transient('wpmandrill-stats');
1018 if ( empty($stats) ) { 1084 if ( empty($stats) ) {
...@@ -1037,7 +1103,7 @@ jQuery(document).bind( 'ready', function() { ...@@ -1037,7 +1103,7 @@ jQuery(document).bind( 'ready', function() {
1037 $stats = self::GetProcessedStats(); 1103 $stats = self::GetProcessedStats();
1038 if ( !empty($stats) ) { 1104 if ( !empty($stats) ) {
1039 set_transient('wpmandrill-stats', $stats, 60 * 60); 1105 set_transient('wpmandrill-stats', $stats, 60 * 60);
1040 update_option('wpmandrill-stats', $stats); 1106 update_option('wpmandrill-stats', $stats, false);
1041 } else { 1107 } else {
1042 error_log( date('Y-m-d H:i:s') . " wpMandrill::saveProcessedStats (Empty Response from ::GetProcessedStats)\n" ); 1108 error_log( date('Y-m-d H:i:s') . " wpMandrill::saveProcessedStats (Empty Response from ::GetProcessedStats)\n" );
1043 } 1109 }
...@@ -1046,10 +1112,10 @@ jQuery(document).bind( 'ready', function() { ...@@ -1046,10 +1112,10 @@ jQuery(document).bind( 'ready', function() {
1046 } 1112 }
1047 1113
1048 static function addDashboardWidgets() { 1114 static function addDashboardWidgets() {
1049 if (!current_user_can('manage_options')) return; 1115 if (!current_user_can('manage_options') || self::getOption('hide_dashboard_widget')) return;
1050 1116
1051 self::getConnected(); 1117 self::getConnected();
1052 if ( !self::isConnected() ) return; 1118 if ( !self::isConnected() || !apply_filters( 'wpmandrill_enable_widgets', true ) ) return;
1053 1119
1054 $widget_id = 'mandrill_widget'; 1120 $widget_id = 'mandrill_widget';
1055 1121
...@@ -1203,16 +1269,16 @@ jQuery(document).bind( 'ready', function() { ...@@ -1203,16 +1269,16 @@ jQuery(document).bind( 'ready', function() {
1203 $js = ''; 1269 $js = '';
1204 if ( !$isAjaxCall ) { 1270 if ( !$isAjaxCall ) {
1205 $js .= ' 1271 $js .= '
1206 <script type="text/javascript" src="'.plugins_url('/js/flot/jquery.flot.js', __FILE__).'"></script> 1272 <script type="text/javascript" src="'.SEWM_URL . 'js/flot/jquery.flot.js"></script>
1207 <script type="text/javascript" src="'.plugins_url('/js/flot/jquery.flot.stack.js', __FILE__).'"></script> 1273 <script type="text/javascript" src="'.SEWM_URL . 'js/flot/jquery.flot.stack.js"></script>
1208 <script type="text/javascript" src="'.plugins_url('/js/flot/jquery.flot.resize.js', __FILE__).'"></script>'; 1274 <script type="text/javascript" src="'.SEWM_URL . 'js/flot/jquery.flot.resize.js"></script>';
1209 1275
1210 $js .= ' 1276 $js .= '
1211 <div style="height:400px;"> 1277 <div style="height:400px;">
1212 <div id="filtered_recent" style="height:400px;">Loading...</div> 1278 <div id="filtered_recent" style="height:400px;">Loading...</div>
1213 </div> 1279 </div>
1214 <script type="text/javascript"> 1280 <script type="text/javascript">
1215 jQuery(document).bind( \'ready\', function() { 1281 jQuery(document).on( \'ready\', function() {
1216 '; 1282 ';
1217 } 1283 }
1218 $js .= <<<JS 1284 $js .= <<<JS
...@@ -1235,7 +1301,7 @@ jQuery(document).bind( \'ready\', function() { ...@@ -1235,7 +1301,7 @@ jQuery(document).bind( \'ready\', function() {
1235 }).appendTo("body").fadeIn(200); 1301 }).appendTo("body").fadeIn(200);
1236 } 1302 }
1237 var previousPoint = null; 1303 var previousPoint = null;
1238 jQuery("#filtered_recent").bind("plothover", function (event, pos, item) { 1304 jQuery("#filtered_recent").on("plothover", function (event, pos, item) {
1239 if (item) { 1305 if (item) {
1240 if (previousPoint != item.dataIndex) { 1306 if (previousPoint != item.dataIndex) {
1241 previousPoint = item.dataIndex; 1307 previousPoint = item.dataIndex;
...@@ -1257,11 +1323,16 @@ jQuery(document).bind( \'ready\', function() { ...@@ -1257,11 +1323,16 @@ jQuery(document).bind( \'ready\', function() {
1257 previousPoint = null; 1323 previousPoint = null;
1258 } 1324 }
1259 }); 1325 });
1326
1260 jQuery(function () { 1327 jQuery(function () {
1261 var hbounces= [{$bounces['recent']}]; 1328 var hbounces= [{$bounces['recent']}];
1262 var hopens = [{$opens['recent']}]; 1329 var hopens = [{$opens['recent']}];
1263 var huopens = [{$unopens['recent']}]; 1330 var huopens = [{$unopens['recent']}];
1264 1331
1332 if ( ! jQuery("#mandrill_widget").is(":visible") ) {
1333 return;
1334 }
1335
1265 jQuery.plot(jQuery("#filtered_recent"), 1336 jQuery.plot(jQuery("#filtered_recent"),
1266 [ { data: hbounces, label: "{$lit['bounced']}" }, 1337 [ { data: hbounces, label: "{$lit['bounced']}" },
1267 { data: hopens, label: "{$lit['opened']}" }, 1338 { data: hopens, label: "{$lit['opened']}" },
...@@ -1468,7 +1539,7 @@ var ounopened = [{$ounopened}] ...@@ -1468,7 +1539,7 @@ var ounopened = [{$ounopened}]
1468 1539
1469 jQuery(function () { 1540 jQuery(function () {
1470 var previousPoint = null; 1541 var previousPoint = null;
1471 jQuery("#filtered_recent").bind("plothover", function (event, pos, item) { 1542 jQuery("#filtered_recent").on("plothover", function (event, pos, item) {
1472 if (item) { 1543 if (item) {
1473 if (previousPoint != item.dataIndex) { 1544 if (previousPoint != item.dataIndex) {
1474 previousPoint = item.dataIndex; 1545 previousPoint = item.dataIndex;
...@@ -1490,7 +1561,7 @@ jQuery(function () { ...@@ -1490,7 +1561,7 @@ jQuery(function () {
1490 previousPoint = null; 1561 previousPoint = null;
1491 } 1562 }
1492 }); 1563 });
1493 jQuery("#filtered_oldest").bind("plothover", function (event, pos, item) { 1564 jQuery("#filtered_oldest").on("plothover", function (event, pos, item) {
1494 if (item) { 1565 if (item) {
1495 if (previousPoint != item.dataIndex) { 1566 if (previousPoint != item.dataIndex) {
1496 previousPoint = item.dataIndex; 1567 previousPoint = item.dataIndex;
...@@ -1576,9 +1647,9 @@ JS; ...@@ -1576,9 +1647,9 @@ JS;
1576 } 1647 }
1577 1648
1578 1649
1579 /****************************************************************** 1650 /******************************************************************
1580 ** Function to actually send the emails 1651 ** Function to actually send the emails
1581 ******************************************************************* 1652 *******************************************************************
1582 /** 1653 /**
1583 * @param string|array $to recipients, array or comma-separated string 1654 * @param string|array $to recipients, array or comma-separated string
1584 * @param string $subject email subject 1655 * @param string $subject email subject
...@@ -1676,9 +1747,7 @@ JS; ...@@ -1676,9 +1747,7 @@ JS;
1676 * @return boolean 1747 * @return boolean
1677 */ 1748 */
1678 static function wp_mail_native( $to, $subject, $message, $headers = '', $attachments = array() ) { 1749 static function wp_mail_native( $to, $subject, $message, $headers = '', $attachments = array() ) {
1679 error_log( "\nwpMandrill::wp_mail_native: $to ($subject)\n" ); 1750 require SEWM_PATH . '/legacy/function.wp_mail.php';
1680
1681 require plugin_dir_path( __FILE__ ) . '/legacy/function.wp_mail.php';
1682 } 1751 }
1683 1752
1684 /** 1753 /**
...@@ -1749,7 +1818,7 @@ JS; ...@@ -1749,7 +1818,7 @@ JS;
1749 1818
1750 case 'bcc': 1819 case 'bcc':
1751 // TODO: Mandrill's API only accept one BCC address. Other addresses will be silently discarded 1820 // TODO: Mandrill's API only accept one BCC address. Other addresses will be silently discarded
1752 $bcc = array_merge( (array) $bcc, explode( ',', $content ) ); 1821 $bcc = explode( ',', $content );
1753 1822
1754 $message['bcc_address'] = $bcc[0]; 1823 $message['bcc_address'] = $bcc[0];
1755 break; 1824 break;
...@@ -1786,7 +1855,7 @@ JS; ...@@ -1786,7 +1855,7 @@ JS;
1786 if ( is_array($email) ) { 1855 if ( is_array($email) ) {
1787 $processed_to[] = $email; 1856 $processed_to[] = $email;
1788 } else { 1857 } else {
1789 $processed_to[] = array( 'email' => $email ); 1858 $processed_to[] = self::ensureEmailFormatting( $email );
1790 } 1859 }
1791 } 1860 }
1792 $message['to'] = $processed_to; 1861 $message['to'] = $processed_to;
...@@ -1856,6 +1925,9 @@ JS; ...@@ -1856,6 +1925,9 @@ JS;
1856 } 1925 }
1857 } 1926 }
1858 1927
1928 // Add subaccount if specified in settings
1929 if ( !empty(self::getSubAccount()) ) $message['subaccount'] = self::getSubAccount();
1930
1859 // Letting user to filter/change the message payload 1931 // Letting user to filter/change the message payload
1860 $message['from_email'] = apply_filters('wp_mail_from', $message['from_email']); 1932 $message['from_email'] = apply_filters('wp_mail_from', $message['from_email']);
1861 $message['from_name'] = apply_filters('wp_mail_from_name', $message['from_name']); 1933 $message['from_name'] = apply_filters('wp_mail_from_name', $message['from_name']);
...@@ -1908,8 +1980,8 @@ JS; ...@@ -1908,8 +1980,8 @@ JS;
1908 global $wp_version; 1980 global $wp_version;
1909 1981
1910 if ( ! function_exists( 'get_plugins' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 1982 if ( ! function_exists( 'get_plugins' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1911 $plugin_folder = get_plugins( '/' . plugin_basename( dirname( __FILE__ ) ) ); 1983 $plugin_folder = get_plugins( '/' . dirname( SEWM_BASE ) );
1912 $plugin_file = basename( ( __FILE__ ) ); 1984 $plugin_file = basename( SEWM_BASE );
1913 1985
1914 $me = $plugin_folder[$plugin_file]['Version']; 1986 $me = $plugin_folder[$plugin_file]['Version'];
1915 $php = phpversion(); 1987 $php = phpversion();
...@@ -1917,13 +1989,34 @@ JS; ...@@ -1917,13 +1989,34 @@ JS;
1917 1989
1918 return "wpMandrill/$me (PHP/$php; WP/$wp)"; 1990 return "wpMandrill/$me (PHP/$php; WP/$wp)";
1919 } 1991 }
1992
1993 /**
1994 * Ensures the email field sent to Mandrill is formatted accordingly for emails with the name formatting
1995 *
1996 * @param $email
1997 * @param string $type
1998 * @return array
1999 */
2000 static function ensureEmailFormatting( $email, $type = 'to' ) {
2001 if( preg_match( '/(.*)<(.+)>/', $email, $matches ) ) {
2002 if ( count( $matches ) == 3 ) {
2003 return array(
2004 'email' => $matches[2],
2005 'name' => $matches[1],
2006 'type' => $type
2007 );
2008 }
2009 }
2010
2011 return array( 'email' => $email );
2012 }
1920 } 2013 }
1921 2014
1922 function wpMandrill_transformJSArray(&$value, $key, $params = 0) { 2015 function wpMandrill_transformJSArray(&$value, $key, $params = 0) {
1923 if ( is_array($params) ) { 2016 if ( is_array($params) ) {
1924 $format = isset($params[0]) ? $params[0] : 0; 2017 $format = isset($params[0]) ? $params[0] : 0;
1925 $day_keys = isset($params[1]) ? $params[1] : array(); 2018 $day_keys = isset($params[1]) ? $params[1] : array();
1926 } 2019
1927 switch ( $format ) { 2020 switch ( $format ) {
1928 case 0: 2021 case 0:
1929 $value = "[$key,$value]"; 2022 $value = "[$key,$value]";
...@@ -1933,6 +2026,5 @@ function wpMandrill_transformJSArray(&$value, $key, $params = 0) { ...@@ -1933,6 +2026,5 @@ function wpMandrill_transformJSArray(&$value, $key, $params = 0) {
1933 $value = "[$key,$value]"; 2026 $value = "[$key,$value]";
1934 break; 2027 break;
1935 } 2028 }
2029 }
1936 } 2030 }
1937
1938 ?>
...\ No newline at end of file ...\ No newline at end of file
......
1 === Send Emails with Mandrill ===
2 Contributors: MillerMediaNow, mikemm01, MC_Will, MC_Amanda, cornelraiu-1, crstauf, bizmatebiz, andrewhilson, anthonywnz, srumery, ronald2020, ilanio, sanderteirlynck
3 Tags: mandrill, mailchimp, transactional email, email, email reliability, smtp, wp_mail, email templates
4 Requires PHP: 5.6
5 Requires at least: 3.0
6 Tested up to: 6.1.1
7 Stable tag: 1.3.1
8 License: GPLv2
9
10 The Send Emails with Mandrill plugin sends emails that are generated by WordPress through Mandrill, a transactional email service powered by MailChimp.
11
12 == Description ==
13
14 **Did you find this plugin helpful?** Please consider [leaving a 5-star review](https://wordpress.org/support/view/plugin-reviews/send-emails-with-mandrill/).
15
16 Note: This is a forked version of the now unsupported <a href="https://wordpress.org/plugins/wpmandrill/">wpMandrill</a> plugin. The notes below are copied over from the original plugin and will be updated as relevant updates become available. Please help by contributing to the GitHub repository [Send Emails With Mandrill on GitHub](https://github.com/Miller-Media/send-emails-with-mandrill)
17
18 This plugin uses [Mandrill API](http://mandrillapp.com/api/docs/) to send outgoing emails, with or without attachments, from your Wordpress installation. It replaces the wp_mail function included with WordPress.
19
20 Emails are tracked and automatically tagged for statistics within the Mandrill Dashboard. You can also add general tags to every email sent, as well as particular tags based on selected emails defined by your requirements.
21
22 You can also use your own templates that have been added to your MailChimp account and shared with your Mandrill account.
23
24 There are a few levels of integrations between your WordPress installation and this plugin:
25
26 1. The simplest option: Install it, configure it, and Send Emails with Mandrill will start sending your emails through Mandrill.
27 1. If you need to fine tune certain emails, you can change any email by creating a filter for the **mandrill_payload** hook.
28 1. For further customization, we've exposed a function that allows you to send emails from within your plugins, instead of the regular wp_mail function: **wpMandrill::mail**
29
30 Enable the connection by entering a valid API key in the settings page or adding the line `define('SEWM_API_KEY', '{YOUR_API_KEY}')` your site's wp-config.php file.
31
32 Spanish translation available.
33
34 == Installation ==
35
36 1. Upload `Send Emails with Mandrill` to the `/wp-content/plugins/` directory
37 1. Activate the plugin through the _Plugins_ menu in WordPress
38 1. Configure plugin in _Settings > Mandrill_
39
40 == Frequently Asked Questions ==
41
42 = Why do I need a Mandrill API key? =
43
44 In order to use this plugin, you have to provide one of your Mandrill API keys. That's currently the only way we can get access to your Mandrill account.
45
46 = Do I need a MailChimp account? =
47
48 Yes. If you aren't currently on a MailChimp Monthly Plan, you'll first need to upgrade or switch to a Monthly Plan. Once you have upgraded you can follow the steps [here](https://mailchimp.com/help/add-or-remove-mandrill/) to add Mandrill to your account.
49
50 = Are all emails routed through Mandrill? =
51
52 Yes. We try to send every single email sent through your WordPress installation. We also try to process your headers and attachments.
53
54 If the sending fails for any reason, the plugin will try to send it again using the WordPress wp_mail function.
55
56 = What if I need to send some of my emails using the native wp_mail() function?
57
58 Use the mandrill_payload filter and add a new parameter called 'force_native' to the $message variable, and set it to true:
59
60 $message['force_native'] = true;
61
62 = My emails are broken and show weird CSS code =
63
64 In version 1.09, we added a setting that allows you to tell the plugin if you want to replace your line feeds by <br/>. Try playing with that switch.
65
66 If it works for certain emails but doesn't work for others, you might want to modify this setting using the **mandrill_nl2br** filter. For example, if you don't want to use this filter for the "forgot password" emails, add something like this to your theme's functions.php file:
67
68 function my_function($nl2br, $message) {
69 if ( in_array('wp_retrieve_password', $message['tags']['automatic']) ) {
70 $nl2br = false;
71 }
72 return $nl2br;
73 }
74 add_filter('mandrill_nl2br', 'my_function');
75
76
77 = Is there any way to check what's going on? =
78
79 If we couldn't send your email through Mandrill, we'll try to leave the Mandrill response in your server's log so that's your first stop.
80
81 Additionally, 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.
82
83 = I am getting an Invalid API Key message and I'm sure my API is valid!
84
85 Please verify the following:
86
87 1. That your API key is active (this can be viewed on the SMTP & API Credentials page in your Mandrill account);
88 2. 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);
89 3. That the domain name you're using above is listed in the Sending Domains for your Mandrill account.
90
91 == Request ==
92
93 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](https://wordpress.org/support/plugin/send-emails-with-mandrill/) so we can make it better. Our [mind-reading device](http://www.youtube.com/watch?v=cCTlonSwePs) still needs some tweaking.
94
95 == Localizations ==
96 Send Emails with Mandrill is currently localized in the following languages:
97
98 * Spanish (es_ES)
99
100 == Known Issues ==
101
102 * Daily statistics will show data for the first 20 senders (emails) registered.
103 * Daily statistics will show data for the first 40 tags registered.
104
105 If your account has more than 20 senders registered or more than 40 tags used, the detailed daily statisticas might show incompleted data.
106
107 == Screenshots ==
108
109 1. Settings screen
110 2. Statistics
111 3. Dashboard widget
112 4. Dashboard widget Settings
113
114 == Changelog ==
115 = 1.3.1 =
116 * Check for error messages parameters before processing (was throwing an error)
117
118 = 1.3 =
119 * Added setting to turn off Dashboard Widget
120 * Added ability to manually fetch new data from Reports screen
121 * Added ability to define API key as SEWM_API_KEY in wp-config.php file
122 * Minor error handling adjustments
123
124 = 1.2.13 =
125 * Setting to disable <br /> setting for WooCommerce emails due to layout issues from recent WooCommerce updates
126
127 = 1.2.12 =
128 * Updates to deprecated jQuery functions
129
130 = 1.2.9 =
131 * Removed deprecated contextual_help() function and added add_help_tab()
132
133 = 1.2.8 =
134 * Add wpmandrill_enable_reports and wpmandrill_enable_widgets filters to programmatically disable the reports dashboard and widget if desired.
135
136 = 1.2.7 =
137 * Removed code added for previous Mandrill outage
138
139 = 1.2.6 =
140 * Updated messaging on how to handle the upcoming Mandrill outage
141 * Bug fix for memcache overload when loading Mandrill reports page on high traffic sites
142
143 = 1.2.5 =
144 * Updated plugin screenshots for WordPress repository
145 * Added support/setting for Mandrill subaccount
146 * Removed discontinued Mandrill API endpoint support (URL tracking)
147
148 = 1.2.4 =
149 * Removed RSS Feeds due to WordPress core bugs (SimplePie library)
150 * CSS adjustments
151 * Fixed false negatives when used in conjunction with Contact Form 7 and other mail sending programs
152
153 = 1.2.3 =
154 * Fixed WooCommerce checkout issue (class scope bug)
155
156 = 1.2.2 =
157 * More detailed error logging for failed e-mails
158 * Added email formatting to include 'name'
159
160 = 1.2.1 =
161 * PHP warning fix
162
163 = 1.2 =
164 * Added ability to override wp_mail_native function with a WordPress action
165 * 404 console fixes
166 * Various undefined variable fixes
167
168 = 1.1 =
169 * Added support for PHP 7.2
170 * Removed support for PHP < 5.6
171 * Added plugin activation compatibility checks
172
173 = 1.0 =
174 * Initial release
175
...@@ -36,7 +36,13 @@ $lit['clickrate'] = __('Click Rate','wpmandrill'); ...@@ -36,7 +36,13 @@ $lit['clickrate'] = __('Click Rate','wpmandrill');
36 ?> 36 ?>
37 <div id="alltime_report"> 37 <div id="alltime_report">
38 <h3><?php echo sprintf(__('All-time statistics since %s: ', 'wpmandrill'),date('m/d/Y',strtotime($stats['general']['created_at']))); ?></h3> 38 <h3><?php echo sprintf(__('All-time statistics since %s: ', 'wpmandrill'),date('m/d/Y',strtotime($stats['general']['created_at']))); ?></h3>
39 39 <hr />
40 <form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="POST">
41 <input name="action" value="sewm_fetch_new" type="hidden" />
42 <?php submit_button('Fetch new data'); ?>
43 <h5 style="margin-top:0px;">Note: Fetching new data can take a long time</h5>
44 </form>
45 <hr />
40 <div id="alltime_report_canvas"> 46 <div id="alltime_report_canvas">
41 <div class="stat_box"><?php _e('Reputation:', 'wpmandrill'); ?><br/><span><?php echo $stats['general']['reputation']?>%</span></div> 47 <div class="stat_box"><?php _e('Reputation:', 'wpmandrill'); ?><br/><span><?php echo $stats['general']['reputation']?>%</span></div>
42 <div class="stat_box"><?php _e('Quota:', 'wpmandrill'); ?><br/><span><?php echo $stats['general']['hourly_quota']?> <?php _e('sends/hour', 'wpmandrill'); ?></span></div> 48 <div class="stat_box"><?php _e('Quota:', 'wpmandrill'); ?><br/><span><?php echo $stats['general']['hourly_quota']?> <?php _e('sends/hour', 'wpmandrill'); ?></span></div>
...@@ -152,7 +158,7 @@ var dclickrates = [<?php echo implode(',',$dcrate);?>] ...@@ -152,7 +158,7 @@ var dclickrates = [<?php echo implode(',',$dcrate);?>]
152 var dticks = [<?php echo implode(',',array_keys($stats['graph']['daily']['delivered']));?>] 158 var dticks = [<?php echo implode(',',array_keys($stats['graph']['daily']['delivered']));?>]
153 jQuery(function () { 159 jQuery(function () {
154 var previousPoint = null; 160 var previousPoint = null;
155 jQuery("#hourly_report_canvas").bind("plothover", function (event, pos, item) { 161 jQuery("#hourly_report_canvas").on("plothover", function (event, pos, item) {
156 if (item) { 162 if (item) {
157 if (previousPoint != item.dataIndex) { 163 if (previousPoint != item.dataIndex) {
158 previousPoint = item.dataIndex; 164 previousPoint = item.dataIndex;
...@@ -174,7 +180,7 @@ jQuery(function () { ...@@ -174,7 +180,7 @@ jQuery(function () {
174 previousPoint = null; 180 previousPoint = null;
175 } 181 }
176 }); 182 });
177 jQuery("#daily_report_canvas").bind("plothover", function (event, pos, item) { 183 jQuery("#daily_report_canvas").on("plothover", function (event, pos, item) {
178 if (item) { 184 if (item) {
179 if (previousPoint != item.dataIndex) { 185 if (previousPoint != item.dataIndex) {
180 previousPoint = item.dataIndex; 186 previousPoint = item.dataIndex;
......
1 <?php
2 /*
3 Plugin Name: Send E-mails with Mandrill
4 Description: Send e-mails using Mandrill. This is a forked version of the now unsupported plugin <a href="https://wordpress.org/plugins/wpmandrill/">wpMandrill</a>.
5 Author: Miller Media ( Matt Miller )
6 Author URI: http://www.millermedia.io
7 Version: 1.3.1
8 Requires PHP: 5.6
9 Text Domain: send-emails-with-mandrill
10 */
11
12 /* Copyright 2012 MailChimp (email : will@mailchimp.com )
13 Copyright 2018 Miller Media (email : support@miller-media.com )
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation using version 2 of the License.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
28
29 */
30
31 if ( ! defined( 'ABSPATH' ) ) exit;
32
33 // Define plugin constants
34 if ( !defined('SEWM_VERSION'))
35 define( 'SEWM_VERSION', '1.3.1' );
36
37 if ( !defined( 'SEWM_BASE' ) )
38 define( 'SEWM_BASE', plugin_basename( __FILE__ ) );
39
40 if ( !defined( 'SEWM_URL' ) )
41 define( 'SEWM_URL', plugin_dir_url( __FILE__ ) );
42
43 if ( !defined( 'SEWM_PATH' ) )
44 define( 'SEWM_PATH', plugin_dir_path( __FILE__ ) );
45
46 include( plugin_dir_path( __FILE__ ) . 'lib/pluginActivation.class.php');
47 include( plugin_dir_path( __FILE__ ) . 'lib/wpMandrill.class.php');
48
49 wpMandrill::on_load();
1 === wpMandrill ===
2 Contributors: MC_Will
3 Tags: mandrill, mailchimp, transactional email, email, email reliability, smtp, wp_mail, email templates
4 Requires at least: 3.0
5 Tested up to: 3.8
6 Stable tag: trunk
7 License: GPLv2
8
9 The wpMandrill plugin sends emails that are generated by WordPress through Mandrill, a transactional email service powered by MailChimp.
10
11 == Description ==
12
13 This plugin uses [Mandrill API](http://mandrillapp.com/api/docs/) to send outgoing emails, with or without attachments, from your Wordpress installation. It replaces the wp_mail function included with WordPress.
14
15 Emails are tracked and automatically tagged for statistics within the Mandrill Dashboard. You can also add general tags to every email sent, as well as particular tags based on selected emails defined by your requirements.
16
17 You can also use your own templates that have been added to your MailChimp account and shared with your Mandrill account.
18
19 There are a few levels of integrations between your WordPress installation and this plugin:
20
21 1. The simplest option: Install it, configure it, and wpMandrill will start sending your emails through Mandrill.
22 1. If you need to fine tune certain emails, you can change any email by creating a filter for the **mandrill_payload** hook.
23 1. For further customization, we've exposed a function that allows you to send emails from within your plugins, instead of the regular wp_mail function: **wpMandrill::mail**
24
25 This plugin is currently released as **beta** for early adopter evaluation and finalizing of the initial feature set.
26
27 Spanish translation available.
28
29 == Installation ==
30
31 1. Upload `wpMandrill` to the `/wp-content/plugins/` directory
32 1. Activate the plugin through the _Plugins_ menu in WordPress
33 1. Configure plugin in _Settings > Mandrill_
34
35 == Frequently Asked Questions ==
36
37 = Why do I need a Mandrill API key? =
38
39 In order to use this plugin, you have to provide one of your Mandrill API keys. That's currently the only way we can get access to your Mandrill account.
40
41 = Do I need a MailChimp account? =
42
43 Nop.
44
45 = Are all emails routed through Mandrill? =
46
47 Yes. We try to send every single email sent through your WordPress installation. We also try to process your headers and attachments.
48
49 If the sending fails for any reason, the plugin will try to send it again using the WordPress wp_mail function.
50
51 = What if I need to send some of my emails using the native wp_mail() function?
52
53 Use the mandrill_payload filter and add a new parameter called 'force_native' to the $message variable, and set it to true:
54
55 $message['force_native'] = true;
56
57 = My emails are broken and show weird CSS code =
58
59 In version 1.09, we added a setting that allows you to tell the plugin if you want to replace your line feeds by <br/>. Try playing with that switch.
60
61 If it works for certain emails but doesn't work for others, you might want to modify this setting using the **mandrill_nl2br** filter. For example, if you don't want to use this filter for the "forgot password" emails, add something like this to your theme's functions.php file:
62
63 function my_function($nl2br, $message) {
64 if ( in_array('wp_retrieve_password', $message['tags']['automatic']) ) {
65 $nl2br = false;
66 }
67 return $nl2br;
68 }
69 add_filter('mandrill_nl2br', 'my_function');
70
71
72 = Is there any way to check what's going on? =
73
74 If we couldn't send your email through Mandrill, we'll try to leave the Mandrill response in your server's log so that's your first stop.
75
76 Additionaly, 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.
77
78 = I am getting an Invalid API Key message and I'm sure my API is valid!
79
80 Please verify the following:
81
82 1. That your API key is active (this can be viewed on the SMTP & API Credentials page in your Mandrill account);
83 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);
84 1. That the domain name you're using above is listed in the Sending Domains for your Mandrill account.
85
86 == Request ==
87
88 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.
89
90 == Localizations ==
91 wpMandrill is currently localized in the following languages:
92
93 * Spanish (es_ES)
94
95 == Known Issues ==
96
97 * Daily statistics will show data for the first 20 senders (emails) registered.
98 * Daily statistics will show data for the first 40 tags registered.
99
100 If your account has more than 20 senders registered or more than 40 tags used, the detailed daily statisticas might show incompleted data.
101
102 == Screenshots ==
103
104 1. Settings screen
105 2. Statistics
106 3. Dashboard widget
107 4. Dashboard widget Settings
108
109 == Changelog ==
110 = 1.33 =
111 * ADDED: Logging messages to trace a bug where the stats are not getting updated
112 * FIXED: Order of preference for tags.
113 * ADDED: Support for css inlining, recipient preservation, whether or not to have the view content link in your Mandrill dashboard, tracking, signing, and return-path domains, using subaccounts, per recipient metadata, pool of ips, email scheduling, and asynchronous sending in wpMandrill::mail().
114 * REMOVED: The concept of 'verified domains' was completely removed from the plugin.
115 * ADDED: Tracking options in the settings page
116 * ADDED: New filter, mandrill_nl2br, that can be used to modify the value of the "Replace Line Feeds by <br>" setting, for specific messages. Check the How-To to see how it works.
117 * FIXED: Removing wrongly formatted attachments from the payload
118
119 = 1.32 =
120 * FIXED: Reordering constructors of Mandrill class to prevent the "Redefining already defined constructor" message
121 * UPDATE: Favoring self:: instead of wpMandrill::
122
123 = 1.31 =
124 * FIXED: Some PHP 5.3 installations don't have the finfo_open available so we're now checking for the function instead of the PHP version
125
126 = 1.30 =
127 * FIXED: Multiples To: recipients where not being handling correctly.
128
129 = 1.29 =
130 * ADDED: wp_mail, wp_mail_from, and wp_mail_from_name filters. ** Thanks Mike Little! **
131 * ADDED: Support for "important" emails.
132 * UPDATED: Wordpress wp_mail function code.
133 * ADDED: wpMandrill User-Agent
134
135 = 1.28 =
136 * ADDED: If you want to fall back some of your emails to the native wp_mail function, now you can do it by using the mandrill_payload filter and setting a parameter called 'force_native' to true.
137 * REMOVED: Mime type checking on attachments.
138 * ADDED: Sending MIME TYPE of attachments to Mandrill only when wpMandrill is able to find it.
139
140 = 1.27 =
141 * FIXED: Removing php short tags. ** Thanks Kailey Lampert! **
142
143 = 1.26 =
144 * UPDATED: Now Mandrill accepts any content type and so does wpMandrill.
145 * FIXED: Queued messages were triggering the native wp_mail function. ** Thanks Scott Connerly! **
146
147 = 1.25 =
148 * FIXED: Undefined WPDOMAIN constant in stats.php
149
150 = 1.24 =
151 * UPDATED: Dashboard widget shown only to those capable of manage_options
152 * ADDED: CURL calls doesn't verify SSL certificates anymore. ** Thanks Bruno Braga! **
153 * ADDED: Adding support for editable regions. ** Thanks dennissmolek **
154 * FIXED: Using a literal as the textdomain instead of a constant. ** Thanks Joost! **
155 * FIXED: Cleaning some unused variables. ** Thanks Joost! **
156 * FIXED: Removed checking of sender domain at send time.
157
158 = 1.23 =
159 * FIXED: JS Alerts in wrong places...
160
161 = 1.22 =
162 * UPDATED: Replacing Highcharts in favor of Flot
163 * ADD: Cron job to fetch stats
164
165 = 1.21 =
166 * FIXED: Logging wrong error messages when sending emails with no attachments
167 * FIXED: Attachments that Mandrill doesn't support were discarded instead of sending the email (with attachment) through the native wp_mail function.
168 * ADDED: Added support Audio and Video file attachments.
169 * FIXED: Valid Domains matching is NOT case-sensitive now.
170 * FIXED: Better error reporting on Dashboard widgets.
171 * FIXED: Validating FROM: email address after mandrill_payload has been processed.
172
173 = 1.20 =
174 * ADDED: Mandrill's Privacy Policy and Terms of Use
175 * FIXED: Sending more than one attachment was failing
176 * FIXED: Doing a Ping call only when displaying the API Key on the settings page
177 * ADDED: Support for Global Merge Vars, Per-Recipient Merge Vars, Google Analytics, and Meta Data in wpMandrill::mail()
178 * FIXED: Logging error messages even if WP_DEBUG is false.
179
180 = 1.12 =
181 * FIXED: Issue with the CSS declaration of the RSS icon displayed on the settings page. ** Thanks Nicholas Ciske! **
182 * FIXED: Highcharts' Exporting module not loaded for dashboard widget
183 * FIXED: Removing unnecessary pings to MandrillApp.com and instanciating the API client on demand ** Thanks Per Wiklander! **
184
185 = 1.11 =
186 * ADDED: screenshot-4.jpg
187 * FIXED: Emails delivered % in Mandrill stats
188 * ADDED: Limiting the numbers of senders that the Mandrill stats reports.
189 * FIXED: Limiting the numbers of days to 30 in Daily Sending Volume graph in Mandrill stats reports.
190 * ADDED: Visual notification in the dashboard widget while loading.
191 * ADDED: Support for sockets when CURL is not present.
192
193 = 1.10 =
194 * ADDED: Blank .po file for other translations :)
195 * ADDED: Some debugging messages just in case need arises.
196 * ADDED: Adding GNU license
197 * ADDED: Mandrill's blog RSS
198
199 = 1.09 =
200 * ADDED: Reply-To Setting
201 * ADDED: Replacing line feed by <br> setting.
202
203 = 1.08 =
204 * FIXED: Wrong references to self:: in wp_mail introduce in 1.04 :(
205
206 = 1.07 =
207 * FIXED: Removing notices in the dashboard widget when there's no open or click data in the last 7 days.
208 * FIXED: No having general tags defined were causing a validation error. ** Thanks Max Rice! **
209 * FIXED: Daily stats showing some hourly stats.
210 * UPDATED: Spanish translation updated.
211 * FIXED: Speeding dashboard widget results.
212
213 = 1.06 =
214 * FIXED: Some installations were reporting valid API keys as invalid due to a restrictive server configuration regarding Time-Out.
215
216 = 1.05 =
217 * FIXED: Contextual help tab getting open in all admin pages when plugin was not configured correctly.
218 * FIXED: Some references to verified domains. All domains are now verified in Mandrill.
219 * FIXED: Mandrill Class was returning Exceptions in two places (not throwing them).
220
221 = 1.03 =
222 * FIXED: Test email were using an old function.
223 * FIXED: Some data type checking to avoid PHP warnings.
224
225 = 1.02 =
226 * FIXED: Dashboard widget title was displaying incorrectly when a filter was defined.
227
228 = 1.01 =
229 * REMOVED: How-To Plugin
230 * ADDED: How-To page
231
232 = 1.0 =
233 * Public release
234