diff --git a/css/mandrill.css b/css/mandrill.css index 4e063bb..465dbbf 100644 --- a/css/mandrill.css +++ b/css/mandrill.css @@ -68,4 +68,6 @@ .stuffbox div.inside { padding-bottom: 10px;} .stuffbox table.form-table { margin: 3px 3px 3px 10px; width: auto; } -.stuffbox h2 { text-decoration: underline; } \ No newline at end of file +.stuffbox h2 { text-decoration: underline; } + +.stuffbox span.settings_sub_header {padding: 0px 10px; } \ No newline at end of file diff --git a/lib/mandrill.class.php b/lib/mandrill.class.php index 690c667..c8335a3 100644 --- a/lib/mandrill.class.php +++ b/lib/mandrill.class.php @@ -96,8 +96,17 @@ function request($method, $args = array(), $http = 'POST', $output = 'json') { if( 200 == $response_code ) { return $body; } else { - error_log("wpMandrill Error: Error {$body['code']}: {$body['message']}"); - throw new Mandrill_Exception( "wpMandrill Error: {$body['code']}: {$body['message']}", $response_code); + if( !is_array( $body ) ) { + $code = 'Unknown'; + $message = 'Unknown'; + } else { + $code = 'Unknown' ? !array_key_exists('code', $body) : $body['code']; + $message = 'Unknown' ? !array_key_exists('message', $body) : $body['message']; + } + + error_log("wpMandrill Error: Error {$code}: {$message}"); + throw new Mandrill_Exception("wpMandrill Error: {$code}: {$message}", $response_code); + } } diff --git a/lib/wpMandrill.class.php b/lib/wpMandrill.class.php index 31f5b3f..4d5a391 100644 --- a/lib/wpMandrill.class.php +++ b/lib/wpMandrill.class.php @@ -23,6 +23,8 @@ static function on_load() { add_action('wp_ajax_get_mandrill_stats', array(__CLASS__,'getAjaxStats')); add_action('wp_ajax_get_dashboard_widget_stats', array(__CLASS__,'showDashboardWidget')); + add_action('admin_post_sewm_fetch_new', array(__CLASS__, 'fetchNewDashboardData') ); + load_plugin_textdomain('wpmandrill', false, dirname( plugin_basename( __FILE__ ) ).'/lang'); if( function_exists('wp_mail') ) { @@ -102,13 +104,13 @@ static function adminInit() { add_settings_field('trackopens', __('Track opens', 'wpmandrill'), array(__CLASS__, 'askTrackOpens'), 'wpmandrill', 'wpmandrill-tracking'); add_settings_field('trackclicks', __('Track clicks', 'wpmandrill'), array(__CLASS__, 'askTrackClicks'), 'wpmandrill', 'wpmandrill-tracking'); - // Template + // General Design add_settings_section('wpmandrill-templates', __('General Design', 'wpmandrill'), '__return_false', 'wpmandrill'); add_settings_field('template', __('Template', 'wpmandrill'), array(__CLASS__, 'askTemplate'), 'wpmandrill', 'wpmandrill-templates'); add_settings_field('nl2br', __('Content', 'wpmandrill'), array(__CLASS__, 'asknl2br'), 'wpmandrill', 'wpmandrill-templates'); if( self::isWooCommerceActive() ) - add_settings_field('nl2br-woocommerce', __('WooCommerce', 'wpmandrill'), array(__CLASS__, 'asknl2brWooCommerce'), 'wpmandrill', 'wpmandrill-templates'); + add_settings_field('nl2br-woocommerce', __('WooCommerce Fix', 'wpmandrill'), array(__CLASS__, 'asknl2brWooCommerce'), 'wpmandrill', 'wpmandrill-templates'); // Tags add_settings_section('wpmandrill-tags', __('General Tags', 'wpmandrill'), '__return_false', 'wpmandrill'); @@ -124,6 +126,9 @@ static function adminInit() { add_settings_field('email-message', __('Message', 'wpmandrill'), array(__CLASS__, 'askTestEmailMessage'), 'wpmandrill-test', 'mandrill-email-test'); } + // Misc. Plugin Settings + add_settings_section('wpmandrill-misc', __('Miscellaneous', 'wpmandrill'), function(){ echo "Settings for WordPress plugin. Does not affect email delivery functionality or design."; }, 'wpmandrill'); + add_settings_field('hide_dashboard_widget', __('Hide WP Dashboard Widget', 'wpmandrill'), array(__CLASS__, 'hideDashboardWidget'), 'wpmandrill', 'wpmandrill-misc'); } // Fix for WooCommerce @@ -254,17 +259,21 @@ static function showContextualHelp() { * Adds link to settings page in list of plugins */ static function showPluginActionLinks($actions, $plugin_file) { - static $plugin; - if (!isset($plugin)) - $plugin = plugin_basename(__FILE__); + // The code below no longer returns the current filename; @todo to update this to non-hard coded values + // static $plugin; + // + // if (!isset($plugin)) + // $plugin = plugin_basename(__FILE__); - if ($plugin == $plugin_file) { + $plugin = 'send-emails-with-mandrill/wpmandrill.php'; - $settings = array('settings' => '' . __('Settings', 'wpmandrill') . ''); + if ($plugin == $plugin_file) { + $settings = array('settings' => '' . __('Settings', 'wpmandrill') . ''); + self::getConnected(); if ( self::isConnected() ) { - $report = array('report' => '' . __('Reports', 'wpmandrill') . ''); + $report = array('report' => '' . __('Reports', 'wpmandrill') . ''); $actions = array_merge($settings, $actions, $report); } else { $actions = array_merge($settings, $actions); @@ -348,6 +357,21 @@ static function showReportPage() { require SEWM_PATH . '/stats.php'; } + static function getReportsDashboardURL($args=[]){ + $get_params = !empty($args) ? '&'.http_build_query( $args ) : ''; + return admin_url('/index.php?page=wpmandrill-reports'.$get_params); + } + + static function fetchNewDashboardData() { + wp_redirect( + self::getReportsDashboardURL( + array( + 'fetch_new' => 'asap' + ) + ) + ); + } + /** * Processes submitted settings from. */ @@ -448,6 +472,9 @@ static function setOption( $name, $value ) { * @return string|boolean */ static function getAPIKey() { + if( defined('SEWM_API_KEY') ){ + return SEWM_API_KEY; + } return self::getOption('api_key'); } @@ -536,6 +563,13 @@ static function getnl2brWooCommerce() { return self::getOption('nl2br_woocommerce'); } + /** + * @return string|boolean + */ + static function gethideDashboardWidget() { + return self::getOption('hide_dashboard_widget'); + } + /** * @return string|boolean */ @@ -671,8 +705,13 @@ static function sendTestEmail($input) { static function askAPIKey() { echo '
'; - $api_key = self::getOption('api_key'); + $api_key = self::getAPIKey(); + + if( defined('SEWM_API_KEY') ) { + ?>API Key globally defined.
Mandrill Settings', 'wpmandrill'); ?>
- value='1' />
@@ -835,6 +873,15 @@ static function askTags() { echo '
'; } + static function hideDashboardWidget() { + $hideDashboardWidget = self::getHideDashboardWidget(); + if ( $hideDashboardWidget == '' ) $hideDashboardWidget = 0; + ?> +
+ value='1' />
+ '; ?> setting for WooCommerce emails due to layout issues from recent WooCommerce updates + = 1.2.12 = * Updates to deprecated jQuery functions diff --git a/screenshot-1.jpg b/screenshot-1.jpg index 063f1de..b3d8fa0 100644 Binary files a/screenshot-1.jpg and b/screenshot-1.jpg differ diff --git a/stats.php b/stats.php index 69b71c4..88ea9dc 100644 --- a/stats.php +++ b/stats.php @@ -36,7 +36,13 @@ ?>

- +
+
+ + +
Note: Fetching new data can take a long time
+
+

%

diff --git a/wpmandrill.php b/wpmandrill.php index 80c5c61..dbf8453 100644 --- a/wpmandrill.php +++ b/wpmandrill.php @@ -4,7 +4,7 @@ Description: Send e-mails using Mandrill. This is a forked version of the now unsupported plugin wpMandrill. Author: Miller Media ( Matt Miller ) Author URI: http://www.millermedia.io -Version: 1.2.12 +Version: 1.3.1 Requires PHP: 5.6 Text Domain: send-emails-with-mandrill */ @@ -32,7 +32,7 @@ // Define plugin constants if ( !defined('SEWM_VERSION')) - define( 'SEWM_VERSION', '1.2.11' ); + define( 'SEWM_VERSION', '1.3.1' ); if ( !defined( 'SEWM_BASE' ) ) define( 'SEWM_BASE', plugin_basename( __FILE__ ) ); @@ -46,4 +46,4 @@ include( plugin_dir_path( __FILE__ ) . 'lib/pluginActivation.class.php'); include( plugin_dir_path( __FILE__ ) . 'lib/wpMandrill.class.php'); -wpMandrill::on_load(); \ No newline at end of file +wpMandrill::on_load();