72048172 by Jeff Balicki

mandrill update

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent aef5a431
Showing 35 changed files with 337 additions and 65 deletions
![Send Emails with Mandrill](https://ps.w.org/send-emails-with-mandrill/assets/banner-772x250.jpg)
# Send Emails with Mandrill
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.
Our plugin can be downloaded for free from the WordPress repository here:
https://wordpress.org/plugins/send-emails-with-mandrill/
Original wpMandrill plugin can be found here:
https://wordpress.org/plugins/wpmandrill/
Please help us gain visibility on this plugin by giving us a five-star rating on the WordPress plugin page here:
https://wordpress.org/support/plugin/send-emails-with-mandrill/reviews/#new-post .
# For developers contributing to this repository
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.
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.
Also, thank you! We need developers like you to help us make this a great plugin for the whole WordPress community.
---
##### 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 @@
max-width: 90% !important;
margin-top:15px;
}
.stuffbox h3 { cursor: default !important; padding: 3px 3px 3px 10px; }
.stuffbox h3, .stuffbox h2 { cursor: default !important; padding: 3px 3px 3px 10px; }
.stuffbox div.inside { padding-bottom: 10px;}
.stuffbox table.form-table { margin: 3px 3px 3px 10px; width: auto; }
.stuffbox h2 { text-decoration: underline; }
.stuffbox span.settings_sub_header {padding: 0px 10px; }
\ No newline at end of file
......
......@@ -18,8 +18,8 @@ JSON.stringify = JSON.stringify || function (obj) {
}
};
jQuery(document).bind( 'ready', function() {
jQuery('#filter,#display').bind('change keyup', function() {
jQuery( function() {
jQuery('#filter,#display').on('change keyup', function() {
if ( jQuery("#filter option:selected").val() == 'none' ) {
var display = 'block';
......@@ -30,7 +30,7 @@ jQuery(document).bind( 'ready', function() {
jQuery('#all_time').css('display',display);
showStats();
});
jQuery('.columns-prefs, #collapse-button').bind('click', function () {
jQuery('.columns-prefs, #collapse-button').on('click', function () {
redrawDashboardWidget();
});
......
......@@ -259,14 +259,6 @@ msgstr "No tienes suficiente permisología para acceder a esta página."
msgid "Send Test"
msgstr "Enviar Prueba"
#: wpmandrill.php:313
msgid "Latest from Mandrill..."
msgstr "Lo último de Mandrill..."
#: wpmandrill.php:327
msgid "News from MailChimp..."
msgstr "Noticias de MailChimp"
#: wpmandrill.php:356
msgid "Mandrill How-Tos"
msgstr "Mandrill: ¿Cómo hago?"
......
......@@ -255,14 +255,6 @@ msgstr ""
msgid "Send Email"
msgstr ""
#: wpmandrill.php:295
msgid "Latest from Mandrill..."
msgstr ""
#: wpmandrill.php:309
msgid "News from MailChimp..."
msgstr ""
#: wpmandrill.php:336
msgid "Mandrill How-Tos"
msgstr ""
......
......@@ -96,8 +96,17 @@ class Mandrill {
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);
}
}
......@@ -292,36 +301,6 @@ class Mandrill {
}
/**
* @link https://mandrillapp.com/api/docs/urls.html#method=list
*
* @return array|Mandrill_Exception
*/
function urls_list() {
return $this->request('urls/list');
}
/**
* @link https://mandrillapp.com/api/docs/urls.html#method=time-series
*
* @return array|Mandrill_Exception
*/
function urls_time_series($name) {
return $this->request('urls/time-series', array('name' => $name) );
}
/**
* @link https://mandrillapp.com/api/docs/urls.html#method=search
*
* @return array|Mandrill_Exception
*/
function urls_search($q) {
return $this->request('urls/search', array('q' => $q) );
}
/**
* @link https://mandrillapp.com/api/docs/webhooks.html#method=add
*
* @return array|Mandrill_Exception
......@@ -428,9 +407,7 @@ class Mandrill {
if( function_exists('curl_init') && function_exists('curl_exec') ) {
if( !ini_get('safe_mode') ){
set_time_limit(2 * 60);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
......@@ -508,7 +485,6 @@ class Mandrill {
list($headers, $response) = explode("\r\n\r\n", $response, 2);
if(ini_get("magic_quotes_runtime")) $response = stripslashes($response);
$info = array('http_code' => 200);
} else {
ob_end_clean();
......@@ -539,17 +515,16 @@ class Mandrill {
if ( !function_exists('set_magic_quotes') ) {
function set_magic_quotes($value) { return true;}
}
// if (strnatcmp(phpversion(),'6') >= 0) {
// $magic_quotes = get_magic_quotes_runtime();
// set_magic_quotes_runtime(0);
// }
if ( !function_exists('get_magic_quotes_runtime') ) {
function get_magic_quotes_runtime() { return false; }
}
if ( !function_exists('set_magic_quotes_runtime') ) {
function set_magic_quotes_runtime($value) { return true; }
}
$file_buffer = file_get_contents($path);
$file_buffer = chunk_split(base64_encode($file_buffer), 76, "\n");
// if (strnatcmp(phpversion(),'6') >= 0) set_magic_quotes_runtime($magic_quotes);
$mime_type = '';
if ( function_exists('finfo_open') && function_exists('finfo_file') ) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
......
<?php
class pluginActivation
{
function __construct()
{
add_action('admin_init', array($this, 'check_version'));
if (!self::compatible_version()) {
return;
}
}
static function activation_check()
{
if (!self::compatible_version()) {
deactivate_plugins(SEWM_BASE);
wp_die(__('Send Emails with Mandrill requires PHP 5.6 or higher. Please upgrade your version of PHP to activate.', 'send-emails-with-mandrill'));
}
}
function check_version()
{
if (!self::compatible_version()) {
if (is_plugin_active(SEWM_BASE)) {
deactivate_plugins(SEWM_BASE);
add_action('admin_notices', array($this, 'disabled_notice'));
if (isset($_GET['activate'])) {
unset($_GET['activate']);
}
}
}
}
function disabled_notice()
{
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>';
}
static function compatible_version()
{
if (version_compare(PHP_VERSION, '5.6', '<'))
return false;
// Add sanity checks for other version requirements here
return true;
}
}
global $pluginCheck;
$pluginCheck = new pluginActivation();
register_activation_hook(__FILE__, array('pluginActivation', 'activation_check'));
\ No newline at end of file
=== Send Emails with Mandrill ===
Contributors: MillerMediaNow, mikemm01, MC_Will, MC_Amanda, cornelraiu-1, crstauf, bizmatebiz, andrewhilson, anthonywnz, srumery, ronald2020, ilanio, sanderteirlynck
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
License: GPLv2
The Send Emails with Mandrill plugin sends emails that are generated by WordPress through Mandrill, a transactional email service powered by MailChimp.
== Description ==
**Did you find this plugin helpful?** Please consider [leaving a 5-star review](https://wordpress.org/support/view/plugin-reviews/send-emails-with-mandrill/).
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)
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.
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.
You can also use your own templates that have been added to your MailChimp account and shared with your Mandrill account.
There are a few levels of integrations between your WordPress installation and this plugin:
1. The simplest option: Install it, configure it, and Send Emails with Mandrill will start sending your emails through Mandrill.
1. If you need to fine tune certain emails, you can change any email by creating a filter for the **mandrill_payload** hook.
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**
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.
Spanish translation available.
== Installation ==
1. Upload `Send Emails with Mandrill` to the `/wp-content/plugins/` directory
1. Activate the plugin through the _Plugins_ menu in WordPress
1. Configure plugin in _Settings > Mandrill_
== Frequently Asked Questions ==
= Why do I need a Mandrill API key? =
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.
= Do I need a MailChimp account? =
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.
= Are all emails routed through Mandrill? =
Yes. We try to send every single email sent through your WordPress installation. We also try to process your headers and attachments.
If the sending fails for any reason, the plugin will try to send it again using the WordPress wp_mail function.
= What if I need to send some of my emails using the native wp_mail() function?
Use the mandrill_payload filter and add a new parameter called 'force_native' to the $message variable, and set it to true:
$message['force_native'] = true;
= My emails are broken and show weird CSS code =
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.
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:
function my_function($nl2br, $message) {
if ( in_array('wp_retrieve_password', $message['tags']['automatic']) ) {
$nl2br = false;
}
return $nl2br;
}
add_filter('mandrill_nl2br', 'my_function');
= Is there any way to check what's going on? =
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.
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.
= I am getting an Invalid API Key message and I'm sure my API is valid!
Please verify the following:
1. That your API key is active (this can be viewed on the SMTP & API Credentials page in your Mandrill account);
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);
3. That the domain name you're using above is listed in the Sending Domains for your Mandrill account.
== Request ==
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.
== Localizations ==
Send Emails with Mandrill is currently localized in the following languages:
* Spanish (es_ES)
== Known Issues ==
* Daily statistics will show data for the first 20 senders (emails) registered.
* Daily statistics will show data for the first 40 tags registered.
If your account has more than 20 senders registered or more than 40 tags used, the detailed daily statisticas might show incompleted data.
== Screenshots ==
1. Settings screen
2. Statistics
3. Dashboard widget
4. Dashboard widget Settings
== Changelog ==
= 1.3.1 =
* Check for error messages parameters before processing (was throwing an error)
= 1.3 =
* Added setting to turn off Dashboard Widget
* Added ability to manually fetch new data from Reports screen
* Added ability to define API key as SEWM_API_KEY in wp-config.php file
* Minor error handling adjustments
= 1.2.13 =
* Setting to disable <br /> setting for WooCommerce emails due to layout issues from recent WooCommerce updates
= 1.2.12 =
* Updates to deprecated jQuery functions
= 1.2.9 =
* Removed deprecated contextual_help() function and added add_help_tab()
= 1.2.8 =
* Add wpmandrill_enable_reports and wpmandrill_enable_widgets filters to programmatically disable the reports dashboard and widget if desired.
= 1.2.7 =
* Removed code added for previous Mandrill outage
= 1.2.6 =
* Updated messaging on how to handle the upcoming Mandrill outage
* Bug fix for memcache overload when loading Mandrill reports page on high traffic sites
= 1.2.5 =
* Updated plugin screenshots for WordPress repository
* Added support/setting for Mandrill subaccount
* Removed discontinued Mandrill API endpoint support (URL tracking)
= 1.2.4 =
* Removed RSS Feeds due to WordPress core bugs (SimplePie library)
* CSS adjustments
* Fixed false negatives when used in conjunction with Contact Form 7 and other mail sending programs
= 1.2.3 =
* Fixed WooCommerce checkout issue (class scope bug)
= 1.2.2 =
* More detailed error logging for failed e-mails
* Added email formatting to include 'name'
= 1.2.1 =
* PHP warning fix
= 1.2 =
* Added ability to override wp_mail_native function with a WordPress action
* 404 console fixes
* Various undefined variable fixes
= 1.1 =
* Added support for PHP 7.2
* Removed support for PHP < 5.6
* Added plugin activation compatibility checks
= 1.0 =
* Initial release
......@@ -36,7 +36,13 @@ $lit['clickrate'] = __('Click Rate','wpmandrill');
?>
<div id="alltime_report">
<h3><?php echo sprintf(__('All-time statistics since %s: ', 'wpmandrill'),date('m/d/Y',strtotime($stats['general']['created_at']))); ?></h3>
<hr />
<form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="POST">
<input name="action" value="sewm_fetch_new" type="hidden" />
<?php submit_button('Fetch new data'); ?>
<h5 style="margin-top:0px;">Note: Fetching new data can take a long time</h5>
</form>
<hr />
<div id="alltime_report_canvas">
<div class="stat_box"><?php _e('Reputation:', 'wpmandrill'); ?><br/><span><?php echo $stats['general']['reputation']?>%</span></div>
<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);?>]
var dticks = [<?php echo implode(',',array_keys($stats['graph']['daily']['delivered']));?>]
jQuery(function () {
var previousPoint = null;
jQuery("#hourly_report_canvas").bind("plothover", function (event, pos, item) {
jQuery("#hourly_report_canvas").on("plothover", function (event, pos, item) {
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
......@@ -174,7 +180,7 @@ jQuery(function () {
previousPoint = null;
}
});
jQuery("#daily_report_canvas").bind("plothover", function (event, pos, item) {
jQuery("#daily_report_canvas").on("plothover", function (event, pos, item) {
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
......
<?php
/*
Plugin Name: Send E-mails with Mandrill
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>.
Author: Miller Media ( Matt Miller )
Author URI: http://www.millermedia.io
Version: 1.3.1
Requires PHP: 5.6
Text Domain: send-emails-with-mandrill
*/
/* Copyright 2012 MailChimp (email : will@mailchimp.com )
Copyright 2018 Miller Media (email : support@miller-media.com )
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation using version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if ( ! defined( 'ABSPATH' ) ) exit;
// Define plugin constants
if ( !defined('SEWM_VERSION'))
define( 'SEWM_VERSION', '1.3.1' );
if ( !defined( 'SEWM_BASE' ) )
define( 'SEWM_BASE', plugin_basename( __FILE__ ) );
if ( !defined( 'SEWM_URL' ) )
define( 'SEWM_URL', plugin_dir_url( __FILE__ ) );
if ( !defined( 'SEWM_PATH' ) )
define( 'SEWM_PATH', plugin_dir_path( __FILE__ ) );
include( plugin_dir_path( __FILE__ ) . 'lib/pluginActivation.class.php');
include( plugin_dir_path( __FILE__ ) . 'lib/wpMandrill.class.php');
wpMandrill::on_load();