Skip to content

Commit

Permalink
Merge pull request #94 from Miller-Media/1.4
Browse files Browse the repository at this point in the history
Version 1.4
  • Loading branch information
MillerMedia authored Aug 28, 2024
2 parents 4f1d739 + ebc9d85 commit 817e8d7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
38 changes: 21 additions & 17 deletions js/mandrill.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,32 @@ jQuery( function() {
function showStats() {
var filter = jQuery("#filter option:selected").val();
var display = jQuery("#display option:selected").val();
var mandrillNonce = wpMandrillData.nonce;

jQuery('#loading_data').css('display','block');

jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'get_mandrill_stats',
filter: filter,
display: display
},
success: function(data, textStatus, XMLHttpRequest){
jQuery('#loading_data').css('display','none');
eval(data);
},
error: function(MLHttpRequest, textStatus, errorThrown){
jQuery('#loading_data').css('display','none');
}
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'get_mandrill_stats',
filter: filter,
display: display,
_wpnonce: mandrillNonce
},
success: function(data, textStatus, XMLHttpRequest){
jQuery('#loading_data').css('display','none');
eval(data);
},
error: function(MLHttpRequest, textStatus, errorThrown){
jQuery('#loading_data').css('display','none');
}
});
return false;

return false;
}


function redrawDashboardWidget() {
jQuery('#mandrill_widget div#filtered_recent').html('<div id="ajax-icon-container"><span id="loading_data"></span></div>');
jQuery.ajax({
Expand Down
12 changes: 12 additions & 0 deletions lib/wpMandrill.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ static function evaluate_response( $response ) {

if ( !isset( $response[0]['status'] ) )
throw new Exception( 'Email status was not provided in response.' );

do_action( 'mandrill_response_received', $response );

if (
'rejected' === $response[0]['status']
Expand Down Expand Up @@ -189,6 +191,11 @@ static function adminMenu() {
wp_enqueue_style( 'mandrill_stylesheet' );
wp_register_script('mandrill', SEWM_URL . 'js/mandrill.js', array(), SEWM_VERSION, true);
wp_enqueue_script('mandrill');

// Pass nonce to JavaScript
wp_localize_script('mandrill', 'wpMandrillData', array(
'nonce' => wp_create_nonce('get_mandrill_stats_nonce')
));
}

static function network_connect_notice() {
Expand Down Expand Up @@ -1434,6 +1441,11 @@ static function showDashboardWidgetOptions() {
}

static function getAjaxStats() {
if ( !isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'get_mandrill_stats_nonce') ) {
wp_send_json_error('Invalid nonce');
exit();
}

$stats = self::getCurrentStats();
if ( empty($stats) ) {
exit();
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: MillerMediaNow, mikemm01, MC_Will, MC_Amanda, cornelraiu-1, crstau
Tags: mandrill, mailchimp, transactional email, email, email reliability, smtp, wp_mail, email templates
Requires PHP: 5.6
Requires at least: 3.0
Tested up to: 6.1.1
Stable tag: 1.3.1
Tested up to: 6.6.1
Stable tag: 1.4
License: GPLv2

The Send Emails with Mandrill plugin sends emails that are generated by WordPress through Mandrill, a transactional email service powered by MailChimp.
Expand Down Expand Up @@ -112,6 +112,10 @@ If your account has more than 20 senders registered or more than 40 tags used, t
4. Dashboard widget Settings

== Changelog ==
= 1.4 =
* Added action hook for monitoring Mandrill API response
* Added nonce to stats AJAX call

= 1.3.1 =
* Check for error messages parameters before processing (was throwing an error)

Expand Down
2 changes: 1 addition & 1 deletion wpmandrill.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

// Define plugin constants
if ( !defined('SEWM_VERSION'))
define( 'SEWM_VERSION', '1.3.1' );
define( 'SEWM_VERSION', '1.4' );

if ( !defined( 'SEWM_BASE' ) )
define( 'SEWM_BASE', plugin_basename( __FILE__ ) );
Expand Down

0 comments on commit 817e8d7

Please sign in to comment.