Skip to content

Commit

Permalink
Merge pull request #76 from mailjet/development
Browse files Browse the repository at this point in the history
fix issue with widget subscription
  • Loading branch information
goshon authored Aug 22, 2017
2 parents a865060 + abfef00 commit 4602e0a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 49 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors: mailjet
Tags: email, marketing, signup, newsletter, widget, smtp, mailjet
Requires at least: 3.3.0
Tested up to: 4.8
Stable tag: 4.2.3
Stable tag: 4.2.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -90,6 +90,9 @@ Need help? Our multilingual support team is here to answer your questions in any

== Changelog ==

= 4.2.4 =
* Fix widget subscription issue

= 4.2.3 =
* Replace short array definition usage with long one for backward compatibility

Expand Down
2 changes: 1 addition & 1 deletion api/mailjet-api-v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function sendRequest($method = false, $params = array(), $request = 'GET'
curl_setopt($curl_handle, CURLOPT_USERPWD, $this->apiKey . ':' . $this->secretKey);
curl_setopt($curl_handle, CURLOPT_VERBOSE, true);
curl_setopt($curl_handle, CURLINFO_HEADER_OUT, true);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'wordpress-v1.4.2.3');
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'wordpress-v1.4.2.4');

$this->_request_post = false;
if ($request == 'POST')
Expand Down
2 changes: 1 addition & 1 deletion api/mailjet-api-v3.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ private function sendRequest($object, $params, $method)
curl_setopt($this->_curl_handle, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($this->_curl_handle, CURLOPT_USERPWD, $this->_apiKey.':'.$this->_secretKey);
curl_setopt($this->_curl_handle, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($this->_curl_handle, CURLOPT_USERAGENT, 'wordpress-4.2.3');
curl_setopt($this->_curl_handle, CURLOPT_USERAGENT, 'wordpress-4.2.4');

switch ($method) {
case 'GET' :
Expand Down
26 changes: 0 additions & 26 deletions mailjet-api-strategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ public function updateContactData($params)
*/
public function addContact($params)
{

// Check if the input data is OK
if (!is_numeric($params['ListID'])) {
return (object)array('Status' => 'ERROR');
Expand All @@ -479,31 +478,6 @@ public function addContact($params)
'action' => $params['action'],
'contacts' => $params['contacts']
));


// Add the contact
$result = $this->manycontacts(array(
'method' => 'POST',
'Action' => 'Add',
'Addresses' => array($params['Email']),
'ListID' => $params['ListID'],
));

// Check if any error
if (isset($result->Data['0']->Errors->Items)) {
if (strpos($result->Data['0']->Errors->Items[0]->ErrorMessage, 'duplicate') !== FALSE) {
return (object)array('Status' => 'DUPLICATE');
}
else {
return (object)array('Status' => 'ERROR');
}
}

$this->subContact($params);
return (object)array(
'Status' => 'OK',
'Response' => $result
);
}

public function findRecipient($params)
Expand Down
23 changes: 5 additions & 18 deletions mailjet-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ function subscribeUser()
// Add the contact to the contact list
$result = $this->api->addContact(array(
'action' => 'addforce',
'listId' => $_GET['list_id'],
'ListID' => $_GET['list_id'],
'contacts' => $contacts
));

Expand All @@ -551,23 +551,10 @@ function subscribeUser()
));
}

// Check what is the response and display proper message
if (isset($result->Status)) {
if ($result->Status == 'DUPLICATE') {
echo '<p class="error" listId="' . $_GET['list_id'] . '">';
echo sprintf(__("The contact %s is already subscribed", 'wp-mailjet-subscription-widget'), $email);
echo '</p>';
} else if ($result->Status == 'OK') {
echo '<p class="success" listId="' . $_GET['list_id'] . '">';
echo sprintf(__("Thanks for subscribing with %s", 'wp-mailjet-subscription-widget'), $email);
echo '</p>';
} else {
echo '<p class="error" listId="' . $_GET['list_id'] . '">';
echo sprintf(__("The contact %s is already subscribed", 'wp-mailjet-subscription-widget'), $email);
echo '</p>';
}
die();
}
echo '<p class="success" listId="' . $_GET['list_id'] . '">';
echo sprintf(__("Thanks for subscribing with %s", 'wp-mailjet-subscription-widget'), $email);
echo '</p>';
die();
}

function widget($args, $instance)
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors: mailjet
Tags: email, marketing, signup, newsletter, widget, smtp, mailjet
Requires at least: 3.3.0
Tested up to: 4.8
Stable tag: 4.2.3
Stable tag: 4.2.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -90,6 +90,9 @@ Need help? Our multilingual support team is here to answer your questions in any

== Changelog ==

= 4.2.4 =
* Fix widget subscription issue

= 4.2.3 =
* Replace short array definition usage with long one for backward compatibility

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

/*
Plugin Name: Mailjet for Wordpress
Version: 4.2.3
Version: 4.2.4
Plugin URI: https://www.mailjet.com/plugin/wordpress.htm
Description: Use mailjet SMTP to send email, manage lists and contacts within wordpress
Author: Mailjet SAS
Expand Down

0 comments on commit 4602e0a

Please sign in to comment.