Version Description
- FIXED: Issue with the CSS declaration of the RSS icon displayed on the settings page. ** Thanks Nicholas Ciske! **
- FIXED: Highcharts' Exporting module not loaded for dashboard widget
- FIXED: Removing unnecessary pings to MandrillApp.com and instanciating the API client on demand ** Thanks Per Wiklander! **
Download this release
Release Info
Developer | MC_Will |
Plugin | wpMandrill |
Version | 1.12 |
Comparing to | |
See all releases |
Code changes from version 1.11 to 1.12
- css/mandrill.css +3 -3
- readme.txt +6 -1
- stats.php +1 -0
- wpmandrill.php +61 -39
css/mandrill.css
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
.wrap h2 small {
|
2 |
font-size: 10px;
|
3 |
}
|
4 |
-
.
|
5 |
background: url("../images/rss_icon.gif") no-repeat scroll 0 0 transparent;
|
6 |
padding-left: 30px;
|
7 |
line-height: 20px;
|
8 |
}
|
9 |
-
.
|
10 |
background: url("../images/FreddieHead.png") no-repeat bottom right #FFFFCC;
|
11 |
border: 1px solid yellow;
|
12 |
float: right;
|
@@ -18,7 +18,7 @@
|
|
18 |
.mandrill {
|
19 |
background: url("../images/MandrillHead.png") no-repeat bottom right #FFFFCC;
|
20 |
}
|
21 |
-
.
|
22 |
color: #000;
|
23 |
}
|
24 |
|
1 |
.wrap h2 small {
|
2 |
font-size: 10px;
|
3 |
}
|
4 |
+
.mcnews_header {
|
5 |
background: url("../images/rss_icon.gif") no-repeat scroll 0 0 transparent;
|
6 |
padding-left: 30px;
|
7 |
line-height: 20px;
|
8 |
}
|
9 |
+
.mcnews {
|
10 |
background: url("../images/FreddieHead.png") no-repeat bottom right #FFFFCC;
|
11 |
border: 1px solid yellow;
|
12 |
float: right;
|
18 |
.mandrill {
|
19 |
background: url("../images/MandrillHead.png") no-repeat bottom right #FFFFCC;
|
20 |
}
|
21 |
+
.mcnews ul li a {
|
22 |
color: #000;
|
23 |
}
|
24 |
|
readme.txt
CHANGED
@@ -83,6 +83,11 @@ If your account has more than 20 senders registered or more than 40 tags used, t
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
|
|
86 |
= 1.11 =
|
87 |
* ADDED: screenshot-4.jpg
|
88 |
* FIXED: Emails delivered % in Mandrill stats
|
@@ -106,7 +111,7 @@ If your account has more than 20 senders registered or more than 40 tags used, t
|
|
106 |
|
107 |
= 1.07 =
|
108 |
* FIXED: Removing notices in the dashboard widget when there's no open or click data in the last 7 days.
|
109 |
-
* FIXED: No having general tags defined were causing a validation error. ** Thanks Max! **
|
110 |
* FIXED: Daily stats showing some hourly stats.
|
111 |
* UPDATED: Spanish translation updated.
|
112 |
* FIXED: Speeding dashboard widget results.
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 1.12 =
|
87 |
+
* FIXED: Issue with the CSS declaration of the RSS icon displayed on the settings page. ** Thanks Nicholas Ciske! **
|
88 |
+
* FIXED: Highcharts' Exporting module not loaded for dashboard widget
|
89 |
+
* FIXED: Removing unnecessary pings to MandrillApp.com and instanciating the API client on demand ** Thanks Per Wiklander! **
|
90 |
+
|
91 |
= 1.11 =
|
92 |
* ADDED: screenshot-4.jpg
|
93 |
* FIXED: Emails delivered % in Mandrill stats
|
111 |
|
112 |
= 1.07 =
|
113 |
* FIXED: Removing notices in the dashboard widget when there's no open or click data in the last 7 days.
|
114 |
+
* FIXED: No having general tags defined were causing a validation error. ** Thanks Max Rice! **
|
115 |
* FIXED: Daily stats showing some hourly stats.
|
116 |
* UPDATED: Spanish translation updated.
|
117 |
* FIXED: Speeding dashboard widget results.
|
stats.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php if (!current_user_can('manage_options')) wp_die( __('You do not have sufficient permissions to access this page.') ); ?>
|
|
|
2 |
<div class="wrap">
|
3 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
4 |
<h2><?php _e('Mandrill Service Report', wpMandrill::WPDOMAIN); ?></h2><?php
|
1 |
<?php if (!current_user_can('manage_options')) wp_die( __('You do not have sufficient permissions to access this page.') ); ?>
|
2 |
+
<?php wpMandrill::getConnected(); ?>
|
3 |
<div class="wrap">
|
4 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
5 |
<h2><?php _e('Mandrill Service Report', wpMandrill::WPDOMAIN); ?></h2><?php
|
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 )
|
@@ -40,10 +40,6 @@ class wpMandrill {
|
|
40 |
|
41 |
static function on_load() {
|
42 |
|
43 |
-
if ( !self::DEBUG ) {
|
44 |
-
ini_set( "display_errors", 0);
|
45 |
-
}
|
46 |
-
|
47 |
define('WPMANDRILL_API_VERSION', '1.0');
|
48 |
|
49 |
add_action('admin_init', array(__CLASS__, 'adminInit'));
|
@@ -57,14 +53,6 @@ class wpMandrill {
|
|
57 |
|
58 |
load_plugin_textdomain(self::WPDOMAIN, false, dirname( plugin_basename( __FILE__ ) ).'/lang');
|
59 |
|
60 |
-
try {
|
61 |
-
|
62 |
-
require_once( plugin_dir_path( __FILE__ ) . '/lib/mandrill.class.php');
|
63 |
-
$api_key = self::getAPIKey();
|
64 |
-
if ( $api_key && !isset(self::$mandrill) ) self::$mandrill = new Mandrill($api_key);
|
65 |
-
|
66 |
-
} catch ( Exception $e ) {}
|
67 |
-
|
68 |
if( function_exists('wp_mail') ) {
|
69 |
self::$conflict = true;
|
70 |
add_action('admin_notices', array(__CLASS__, 'adminNotices'));
|
@@ -72,12 +60,10 @@ class wpMandrill {
|
|
72 |
}
|
73 |
|
74 |
self::$conflict = false;
|
75 |
-
if( self::
|
76 |
|
77 |
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
|
78 |
-
|
79 |
try {
|
80 |
-
|
81 |
$sent = wpMandrill::mail( $to, $subject, $message, $headers, $attachments );
|
82 |
|
83 |
if ( is_wp_error($sent)
|
@@ -112,7 +98,7 @@ class wpMandrill {
|
|
112 |
add_settings_section('wpmandrill-api', __('API Settings', self::WPDOMAIN), '__return_false', self::WPDOMAIN);
|
113 |
add_settings_field('api-key', __('API Key', self::WPDOMAIN), array(__CLASS__, 'askAPIKey'), self::WPDOMAIN, 'wpmandrill-api');
|
114 |
|
115 |
-
if( self::
|
116 |
add_action('wp_dashboard_setup', array( __CLASS__,'addDashboardWidgets') );
|
117 |
|
118 |
// Verified Addresses
|
@@ -130,7 +116,7 @@ class wpMandrill {
|
|
130 |
add_settings_section('wpmandrill-tags', __('General Tags', self::WPDOMAIN), '__return_false', self::WPDOMAIN);
|
131 |
add_settings_field('tags', __(' ', self::WPDOMAIN), array(__CLASS__, 'askTags'), self::WPDOMAIN, 'wpmandrill-tags');
|
132 |
|
133 |
-
if ( self::
|
134 |
// Email Test
|
135 |
register_setting('wpmandrill-test', 'wpmandrill-test', array(__CLASS__, 'sendTestEmail'));
|
136 |
|
@@ -156,7 +142,7 @@ class wpMandrill {
|
|
156 |
array(__CLASS__,'showOptionsPage')
|
157 |
);
|
158 |
|
159 |
-
if( self::
|
160 |
self::$report = add_dashboard_page(
|
161 |
__('Mandrill Reports', self::WPDOMAIN),
|
162 |
__('Mandrill Reports', self::WPDOMAIN),
|
@@ -210,12 +196,14 @@ class wpMandrill {
|
|
210 |
*/
|
211 |
static function showContextualHelp($contextual_help, $screen_id, $screen) {
|
212 |
if ($screen_id == self::$settings) {
|
|
|
|
|
213 |
$dir = dirname( plugin_basename( __FILE__ ) ).'/images';
|
214 |
|
215 |
$ok = array();
|
216 |
-
$ok['account'] = ( !
|
217 |
-
$ok['domains'] = ( !self::ListVerifiedDomains() ) ? ' class="missing"' : '';
|
218 |
-
$ok['email'] = ( !self::getFromEmail() ) ? ' class="missing"' : '';
|
219 |
|
220 |
$requirements = '';
|
221 |
if ($ok['account'] . $ok['domains'] . $ok['email'] != '' ) {
|
@@ -277,6 +265,9 @@ class wpMandrill {
|
|
277 |
self::showHowTos();
|
278 |
return;
|
279 |
}
|
|
|
|
|
|
|
280 |
?>
|
281 |
<div class="wrap">
|
282 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
@@ -294,7 +285,7 @@ class wpMandrill {
|
|
294 |
</form>
|
295 |
|
296 |
|
297 |
-
<?php if( self::
|
298 |
<form method="post" action="options.php">
|
299 |
<div class="stuffbox" style="max-width: 90% !important;">
|
300 |
<?php settings_fields('wpmandrill-test'); ?>
|
@@ -318,8 +309,8 @@ class wpMandrill {
|
|
318 |
|
319 |
if ( $maxitems > 0 ) {
|
320 |
?>
|
321 |
-
<div class="
|
322 |
-
<h3 class="
|
323 |
<ul>
|
324 |
<?php
|
325 |
foreach ( $rss_items as $item ) { ?>
|
@@ -332,8 +323,8 @@ class wpMandrill {
|
|
332 |
</ul>
|
333 |
</div>
|
334 |
<?php } ?>
|
335 |
-
<div class="
|
336 |
-
<h3 class="
|
337 |
$rss = fetch_feed('http://mailchimp.com/blog/feed');
|
338 |
if (!is_wp_error( $rss ) ) {
|
339 |
$maxitems = $rss->get_item_quantity(5);
|
@@ -356,7 +347,9 @@ class wpMandrill {
|
|
356 |
<?php
|
357 |
}
|
358 |
|
359 |
-
static function showHowTos() {
|
|
|
|
|
360 |
?>
|
361 |
<div class="wrap">
|
362 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
@@ -375,7 +368,7 @@ class wpMandrill {
|
|
375 |
<?php
|
376 |
}
|
377 |
|
378 |
-
static function showReportPage() {
|
379 |
require plugin_dir_path( __FILE__ ) . '/stats.php';
|
380 |
}
|
381 |
|
@@ -383,6 +376,8 @@ class wpMandrill {
|
|
383 |
* Processes submitted settings from.
|
384 |
*/
|
385 |
static function formValidate($input) {
|
|
|
|
|
386 |
if ( !empty($input['from_domain']) && ( empty($input['from_username']) || !self::isDomainEnabled($input['from_domain']) ) ) {
|
387 |
add_settings_error(
|
388 |
self::WPDOMAIN,
|
@@ -408,7 +403,7 @@ class wpMandrill {
|
|
408 |
* Opens contextual help section.
|
409 |
*/
|
410 |
static function openContextualHelp() {
|
411 |
-
if ( !
|
412 |
return;
|
413 |
|
414 |
?>
|
@@ -442,7 +437,7 @@ jQuery(document).bind( 'ready', function() {
|
|
442 |
* @return boolean
|
443 |
*/
|
444 |
static function isReady() {
|
445 |
-
return
|
446 |
}
|
447 |
|
448 |
/**
|
@@ -451,14 +446,23 @@ jQuery(document).bind( 'ready', function() {
|
|
451 |
static function isConnected() {
|
452 |
$result = false;
|
453 |
|
454 |
-
if (
|
455 |
try {
|
456 |
$result = ( self::$mandrill->users_ping() == 'PONG!' );
|
457 |
-
} catch ( Exception $e) {}
|
458 |
}
|
459 |
return $result;
|
460 |
}
|
461 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
462 |
/**
|
463 |
* @return boolean
|
464 |
*/
|
@@ -605,6 +609,8 @@ jQuery(document).bind( 'ready', function() {
|
|
605 |
* @return array|bool
|
606 |
*/
|
607 |
static function listVerifiedDomains() {
|
|
|
|
|
608 |
if ( !self::isConnected() ) return array();
|
609 |
|
610 |
$domains = self::$mandrill->senders_domains();
|
@@ -640,6 +646,8 @@ jQuery(document).bind( 'ready', function() {
|
|
640 |
* @return boolean
|
641 |
*/
|
642 |
static function isTemplateValid($template) {
|
|
|
|
|
643 |
if ( empty($template) || !self::isConnected() ) return false;
|
644 |
|
645 |
$templates = self::$mandrill->templates_list();
|
@@ -667,7 +675,7 @@ jQuery(document).bind( 'ready', function() {
|
|
667 |
|
668 |
if (is_wp_error($test)) {
|
669 |
|
670 |
-
add_settings_error('email-to', 'email-to', __('Test
|
671 |
|
672 |
return array_map('wp_strip_all_tags', $input);
|
673 |
|
@@ -694,16 +702,17 @@ jQuery(document).bind( 'ready', function() {
|
|
694 |
// Following methods generate parts of settings and test forms.
|
695 |
static function askAPIKey() {
|
696 |
echo '<div class="inside">';
|
697 |
-
|
698 |
$api_key = self::getOption('api_key');
|
699 |
?><input id='api_key' name='wpmandrill[api_key]' size='45' type='text' value="<?php esc_attr_e( $api_key ); ?>" /><?php
|
700 |
|
701 |
if ( empty($api_key) ) {
|
702 |
?><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>', self::WPDOMAIN); ?></em></small></span><?php
|
703 |
-
} elseif ( self::isConnected() ) {
|
704 |
-
?><br/><span class="setting-description"><small><em><?php _e('We are connected to your Mandrill Account.', self::WPDOMAIN); ?></em></small></span><?php
|
705 |
} else {
|
706 |
-
|
|
|
|
|
|
|
707 |
}
|
708 |
|
709 |
echo '</div>';
|
@@ -769,6 +778,8 @@ jQuery(document).bind( 'ready', function() {
|
|
769 |
static function askTemplate() {
|
770 |
echo '<div class="inside">';
|
771 |
|
|
|
|
|
772 |
if ( !self::isConnected() ) {
|
773 |
_e('No templates found.', self::WPDOMAIN);
|
774 |
|
@@ -864,6 +875,8 @@ jQuery(document).bind( 'ready', function() {
|
|
864 |
* @return array
|
865 |
*/
|
866 |
static function GetRawStatistics() {
|
|
|
|
|
867 |
if ( !self::isConnected() ) return array();
|
868 |
|
869 |
$stats = array();
|
@@ -1015,6 +1028,9 @@ jQuery(document).bind( 'ready', function() {
|
|
1015 |
}
|
1016 |
|
1017 |
static function addDashboardWidgets() {
|
|
|
|
|
|
|
1018 |
$widget_id = 'mandrill_widget';
|
1019 |
|
1020 |
$widget_options = get_option('dashboard_widget_options');
|
@@ -1056,6 +1072,8 @@ jQuery(document).bind( 'ready', function() {
|
|
1056 |
}
|
1057 |
|
1058 |
static function showDashboardWidget() {
|
|
|
|
|
1059 |
$isAjaxCall = isset($_POST['ajax']) && $_POST['ajax'] ? true : false;
|
1060 |
|
1061 |
$widget_id = 'mandrill_widget';
|
@@ -1161,7 +1179,6 @@ jQuery(document).bind( 'ready', function() {
|
|
1161 |
$js = '';
|
1162 |
if ( !$isAjaxCall ) {
|
1163 |
$js .= '<script type="text/javascript" src="'.plugins_url('/js/highcharts.js', __FILE__).'"></script>';
|
1164 |
-
$js .= '<script type="text/javascript" src="'.plugins_url('/js/modules/exporting.js', __FILE__).'"></script>';
|
1165 |
|
1166 |
$js .= '
|
1167 |
<div style="height:400px;">
|
@@ -1175,6 +1192,9 @@ jQuery(document).bind( \'ready\', function() {
|
|
1175 |
jQuery(function () {
|
1176 |
var chart;
|
1177 |
chart = new Highcharts.Chart({
|
|
|
|
|
|
|
1178 |
chart: {
|
1179 |
renderTo: 'filtered_recent',
|
1180 |
zoomType: 'xy',
|
@@ -1680,6 +1700,8 @@ JS;
|
|
1680 |
|
1681 |
try {
|
1682 |
// Checking if we are connected to Mandrill
|
|
|
|
|
1683 |
if ( !self::isConnected() ) throw new Exception('Invalid API Key');
|
1684 |
|
1685 |
/************
|
5 |
Author: Mandrill
|
6 |
Author URI: http://mandrillapp.com/
|
7 |
Plugin URI: http://connect.mailchimp.com/integrations/wpmandrill
|
8 |
+
Version: 1.12
|
9 |
Text Domain: wpmandrill
|
10 |
*/
|
11 |
/* Copyright 2012 MailChimp (email : will@mailchimp.com )
|
40 |
|
41 |
static function on_load() {
|
42 |
|
|
|
|
|
|
|
|
|
43 |
define('WPMANDRILL_API_VERSION', '1.0');
|
44 |
|
45 |
add_action('admin_init', array(__CLASS__, 'adminInit'));
|
53 |
|
54 |
load_plugin_textdomain(self::WPDOMAIN, false, dirname( plugin_basename( __FILE__ ) ).'/lang');
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
if( function_exists('wp_mail') ) {
|
57 |
self::$conflict = true;
|
58 |
add_action('admin_notices', array(__CLASS__, 'adminNotices'));
|
60 |
}
|
61 |
|
62 |
self::$conflict = false;
|
63 |
+
if( self::isConfigured() ) {
|
64 |
|
65 |
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
|
|
|
66 |
try {
|
|
|
67 |
$sent = wpMandrill::mail( $to, $subject, $message, $headers, $attachments );
|
68 |
|
69 |
if ( is_wp_error($sent)
|
98 |
add_settings_section('wpmandrill-api', __('API Settings', self::WPDOMAIN), '__return_false', self::WPDOMAIN);
|
99 |
add_settings_field('api-key', __('API Key', self::WPDOMAIN), array(__CLASS__, 'askAPIKey'), self::WPDOMAIN, 'wpmandrill-api');
|
100 |
|
101 |
+
if( self::getAPIKey() ) {
|
102 |
add_action('wp_dashboard_setup', array( __CLASS__,'addDashboardWidgets') );
|
103 |
|
104 |
// Verified Addresses
|
116 |
add_settings_section('wpmandrill-tags', __('General Tags', self::WPDOMAIN), '__return_false', self::WPDOMAIN);
|
117 |
add_settings_field('tags', __(' ', self::WPDOMAIN), array(__CLASS__, 'askTags'), self::WPDOMAIN, 'wpmandrill-tags');
|
118 |
|
119 |
+
if ( self::isConfigured() ) {
|
120 |
// Email Test
|
121 |
register_setting('wpmandrill-test', 'wpmandrill-test', array(__CLASS__, 'sendTestEmail'));
|
122 |
|
142 |
array(__CLASS__,'showOptionsPage')
|
143 |
);
|
144 |
|
145 |
+
if( self::isConfigured() ) {
|
146 |
self::$report = add_dashboard_page(
|
147 |
__('Mandrill Reports', self::WPDOMAIN),
|
148 |
__('Mandrill Reports', self::WPDOMAIN),
|
196 |
*/
|
197 |
static function showContextualHelp($contextual_help, $screen_id, $screen) {
|
198 |
if ($screen_id == self::$settings) {
|
199 |
+
wpMandrill::getConnected();
|
200 |
+
|
201 |
$dir = dirname( plugin_basename( __FILE__ ) ).'/images';
|
202 |
|
203 |
$ok = array();
|
204 |
+
$ok['account'] = ( !wpMandrill::isConnected() ) ? ' class="missing"' : '';
|
205 |
+
$ok['domains'] = ( $ok['account'] != '' || !self::ListVerifiedDomains() ) ? ' class="missing"' : '';
|
206 |
+
$ok['email'] = ( $ok['account'] != '' || !self::getFromEmail() ) ? ' class="missing"' : '';
|
207 |
|
208 |
$requirements = '';
|
209 |
if ($ok['account'] . $ok['domains'] . $ok['email'] != '' ) {
|
265 |
self::showHowTos();
|
266 |
return;
|
267 |
}
|
268 |
+
|
269 |
+
wpMandrill::getConnected();
|
270 |
+
|
271 |
?>
|
272 |
<div class="wrap">
|
273 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
285 |
</form>
|
286 |
|
287 |
|
288 |
+
<?php if( self::isConnected() ) { ?>
|
289 |
<form method="post" action="options.php">
|
290 |
<div class="stuffbox" style="max-width: 90% !important;">
|
291 |
<?php settings_fields('wpmandrill-test'); ?>
|
309 |
|
310 |
if ( $maxitems > 0 ) {
|
311 |
?>
|
312 |
+
<div class="mcnews mandrill">
|
313 |
+
<h3 class="mcnews_header"><?php _e('Latest from Mandrill...', self::WPDOMAIN); ?></h3>
|
314 |
<ul>
|
315 |
<?php
|
316 |
foreach ( $rss_items as $item ) { ?>
|
323 |
</ul>
|
324 |
</div>
|
325 |
<?php } ?>
|
326 |
+
<div class="mcnews">
|
327 |
+
<h3 class="mcnews_header"><?php _e('News from MailChimp...', self::WPDOMAIN); ?></h3><?php
|
328 |
$rss = fetch_feed('http://mailchimp.com/blog/feed');
|
329 |
if (!is_wp_error( $rss ) ) {
|
330 |
$maxitems = $rss->get_item_quantity(5);
|
347 |
<?php
|
348 |
}
|
349 |
|
350 |
+
static function showHowTos() {
|
351 |
+
wpMandrill::getConnected();
|
352 |
+
|
353 |
?>
|
354 |
<div class="wrap">
|
355 |
<div class="icon32" style="background: url('<?php echo plugins_url('images/mandrill-head-icon.png',__FILE__); ?>');"><br /></div>
|
368 |
<?php
|
369 |
}
|
370 |
|
371 |
+
static function showReportPage() {
|
372 |
require plugin_dir_path( __FILE__ ) . '/stats.php';
|
373 |
}
|
374 |
|
376 |
* Processes submitted settings from.
|
377 |
*/
|
378 |
static function formValidate($input) {
|
379 |
+
wpMandrill::getConnected();
|
380 |
+
|
381 |
if ( !empty($input['from_domain']) && ( empty($input['from_username']) || !self::isDomainEnabled($input['from_domain']) ) ) {
|
382 |
add_settings_error(
|
383 |
self::WPDOMAIN,
|
403 |
* Opens contextual help section.
|
404 |
*/
|
405 |
static function openContextualHelp() {
|
406 |
+
if ( !wpMandrill::isPluginPage() || ( wpMandrill::isConnected() && self::getFromEmail() ) )
|
407 |
return;
|
408 |
|
409 |
?>
|
437 |
* @return boolean
|
438 |
*/
|
439 |
static function isReady() {
|
440 |
+
return isset(self::$mandrill);
|
441 |
}
|
442 |
|
443 |
/**
|
446 |
static function isConnected() {
|
447 |
$result = false;
|
448 |
|
449 |
+
if ( self::isReady() ) {
|
450 |
try {
|
451 |
$result = ( self::$mandrill->users_ping() == 'PONG!' );
|
452 |
+
} catch ( Exception $e ) {}
|
453 |
}
|
454 |
return $result;
|
455 |
}
|
456 |
|
457 |
+
static function getConnected() {
|
458 |
+
if ( !isset(self::$mandrill) ) {
|
459 |
+
try {
|
460 |
+
require_once( plugin_dir_path( __FILE__ ) . '/lib/mandrill.class.php');
|
461 |
+
wpMandrill::$mandrill = new Mandrill( self::getAPIKey() );
|
462 |
+
} catch ( Exception $e ) {}
|
463 |
+
}
|
464 |
+
}
|
465 |
+
|
466 |
/**
|
467 |
* @return boolean
|
468 |
*/
|
609 |
* @return array|bool
|
610 |
*/
|
611 |
static function listVerifiedDomains() {
|
612 |
+
self::getConnected();
|
613 |
+
|
614 |
if ( !self::isConnected() ) return array();
|
615 |
|
616 |
$domains = self::$mandrill->senders_domains();
|
646 |
* @return boolean
|
647 |
*/
|
648 |
static function isTemplateValid($template) {
|
649 |
+
self::getConnected();
|
650 |
+
|
651 |
if ( empty($template) || !self::isConnected() ) return false;
|
652 |
|
653 |
$templates = self::$mandrill->templates_list();
|
675 |
|
676 |
if (is_wp_error($test)) {
|
677 |
|
678 |
+
add_settings_error('email-to', 'email-to', __('Test failed. ', self::WPDOMAIN) . $test->get_error_message());
|
679 |
|
680 |
return array_map('wp_strip_all_tags', $input);
|
681 |
|
702 |
// Following methods generate parts of settings and test forms.
|
703 |
static function askAPIKey() {
|
704 |
echo '<div class="inside">';
|
705 |
+
|
706 |
$api_key = self::getOption('api_key');
|
707 |
?><input id='api_key' name='wpmandrill[api_key]' size='45' type='text' value="<?php esc_attr_e( $api_key ); ?>" /><?php
|
708 |
|
709 |
if ( empty($api_key) ) {
|
710 |
?><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>', self::WPDOMAIN); ?></em></small></span><?php
|
|
|
|
|
711 |
} else {
|
712 |
+
wpMandrill::getConnected();
|
713 |
+
if ( !wpMandrill::isConnected() ) {
|
714 |
+
?><br/><span class="setting-description"><small><em><?php _e('Sorry. Invalid API key.', self::WPDOMAIN); ?></em></small></span><?php
|
715 |
+
}
|
716 |
}
|
717 |
|
718 |
echo '</div>';
|
778 |
static function askTemplate() {
|
779 |
echo '<div class="inside">';
|
780 |
|
781 |
+
self::getConnected();
|
782 |
+
|
783 |
if ( !self::isConnected() ) {
|
784 |
_e('No templates found.', self::WPDOMAIN);
|
785 |
|
875 |
* @return array
|
876 |
*/
|
877 |
static function GetRawStatistics() {
|
878 |
+
self::getConnected();
|
879 |
+
|
880 |
if ( !self::isConnected() ) return array();
|
881 |
|
882 |
$stats = array();
|
1028 |
}
|
1029 |
|
1030 |
static function addDashboardWidgets() {
|
1031 |
+
self::getConnected();
|
1032 |
+
if ( !self::isConnected() ) return;
|
1033 |
+
|
1034 |
$widget_id = 'mandrill_widget';
|
1035 |
|
1036 |
$widget_options = get_option('dashboard_widget_options');
|
1072 |
}
|
1073 |
|
1074 |
static function showDashboardWidget() {
|
1075 |
+
wpMandrill::getConnected();
|
1076 |
+
|
1077 |
$isAjaxCall = isset($_POST['ajax']) && $_POST['ajax'] ? true : false;
|
1078 |
|
1079 |
$widget_id = 'mandrill_widget';
|
1179 |
$js = '';
|
1180 |
if ( !$isAjaxCall ) {
|
1181 |
$js .= '<script type="text/javascript" src="'.plugins_url('/js/highcharts.js', __FILE__).'"></script>';
|
|
|
1182 |
|
1183 |
$js .= '
|
1184 |
<div style="height:400px;">
|
1192 |
jQuery(function () {
|
1193 |
var chart;
|
1194 |
chart = new Highcharts.Chart({
|
1195 |
+
exporting: {
|
1196 |
+
enabled: false,
|
1197 |
+
},
|
1198 |
chart: {
|
1199 |
renderTo: 'filtered_recent',
|
1200 |
zoomType: 'xy',
|
1700 |
|
1701 |
try {
|
1702 |
// Checking if we are connected to Mandrill
|
1703 |
+
wpMandrill::getConnected();
|
1704 |
+
|
1705 |
if ( !self::isConnected() ) throw new Exception('Invalid API Key');
|
1706 |
|
1707 |
/************
|