Add space between if and ‘(‘
[MAILPOET-1791]
This commit is contained in:
@@ -5,7 +5,7 @@ use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\AmazonSESMapper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class AmazonSES {
|
||||
public $aws_access_key;
|
||||
@@ -46,7 +46,7 @@ class AmazonSES {
|
||||
$this->aws_access_key = $access_key;
|
||||
$this->aws_secret_key = $secret_key;
|
||||
$this->aws_region = (in_array($region, $this->available_regions)) ? $region : false;
|
||||
if(!$this->aws_region) {
|
||||
if (!$this->aws_region) {
|
||||
throw new \Exception(__('Unsupported Amazon SES region', 'mailpoet'));
|
||||
}
|
||||
$this->aws_endpoint = sprintf('email.%s.amazonaws.com', $this->aws_region);
|
||||
@@ -76,11 +76,11 @@ class AmazonSES {
|
||||
$error = $this->error_mapper->getErrorFromException($e, $subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
if(is_wp_error($result)) {
|
||||
if (is_wp_error($result)) {
|
||||
$error = $this->error_mapper->getConnectionError($result->get_error_message());
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
if($this->wp->wpRemoteRetrieveResponseCode($result) !== 200) {
|
||||
if ($this->wp->wpRemoteRetrieveResponseCode($result) !== 200) {
|
||||
$response = simplexml_load_string($this->wp->wpRemoteRetrieveBody($result));
|
||||
$error = $this->error_mapper->getErrorFromResponse($response, $subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
@@ -111,14 +111,14 @@ class AmazonSES {
|
||||
))
|
||||
->setReturnPath($this->return_path)
|
||||
->setSubject($newsletter['subject']);
|
||||
if(!empty($extra_params['unsubscribe_url'])) {
|
||||
if (!empty($extra_params['unsubscribe_url'])) {
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addTextHeader('List-Unsubscribe', '<' . $extra_params['unsubscribe_url'] . '>');
|
||||
}
|
||||
if(!empty($newsletter['body']['html'])) {
|
||||
if (!empty($newsletter['body']['html'])) {
|
||||
$message = $message->setBody($newsletter['body']['html'], 'text/html');
|
||||
}
|
||||
if(!empty($newsletter['body']['text'])) {
|
||||
if (!empty($newsletter['body']['text'])) {
|
||||
$message = $message->addPart($newsletter['body']['text'], 'text/plain');
|
||||
}
|
||||
return $message;
|
||||
@@ -130,7 +130,7 @@ class AmazonSES {
|
||||
|
||||
function processSubscriber($subscriber) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriber_data);
|
||||
if(!isset($subscriber_data['email'])) {
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
$subscriber_data = array(
|
||||
'email' => $subscriber,
|
||||
);
|
||||
|
@@ -10,7 +10,7 @@ class AmazonSESMapper {
|
||||
|
||||
function getErrorFromException(\Exception $e, $subscriber) {
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if($e instanceof \Swift_RfcComplianceException) {
|
||||
if ($e instanceof \Swift_RfcComplianceException) {
|
||||
$level = MailerError::LEVEL_SOFT;
|
||||
}
|
||||
$subscriber_errors = [new SubscriberError($subscriber, null)];
|
||||
@@ -27,7 +27,7 @@ class AmazonSESMapper {
|
||||
sprintf(__('%s has returned an unknown error.', 'mailpoet'), Mailer::METHOD_AMAZONSES);
|
||||
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if($response && $response->Error->Code->__toString() === 'MessageRejected') {
|
||||
if ($response && $response->Error->Code->__toString() === 'MessageRejected') {
|
||||
$level = MailerError::LEVEL_SOFT;
|
||||
}
|
||||
$subscriber_errors = [new SubscriberError($subscriber, null)];
|
||||
|
@@ -7,7 +7,7 @@ use MailPoet\Services\Bridge\API;
|
||||
use InvalidArgumentException;
|
||||
use MailPoet\Util\Helpers;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class MailPoetMapper {
|
||||
use ConnectionErrorMapperTrait;
|
||||
@@ -35,7 +35,7 @@ class MailPoetMapper {
|
||||
case API::RESPONSE_CODE_PAYLOAD_ERROR:
|
||||
$result_parsed = json_decode($result['message'], true);
|
||||
$message = __('Error while sending.', 'mailpoet');
|
||||
if(!is_array($result_parsed)) {
|
||||
if (!is_array($result_parsed)) {
|
||||
$message .= ' ' . $result['message'];
|
||||
break;
|
||||
}
|
||||
@@ -68,11 +68,11 @@ class MailPoetMapper {
|
||||
private function getSubscribersErrors($result_parsed, $subscribers) {
|
||||
$errors = [];
|
||||
foreach ($result_parsed as $result_error) {
|
||||
if(!is_array($result_error) || !isset($result_error['index']) || !isset($subscribers[$result_error['index']])) {
|
||||
if (!is_array($result_error) || !isset($result_error['index']) || !isset($subscribers[$result_error['index']])) {
|
||||
throw new InvalidArgumentException( __('Invalid MSS response format.', 'mailpoet'));
|
||||
}
|
||||
$subscriber_errors = [];
|
||||
if(isset($result_error['errors']) && is_array($result_error['errors'])) {
|
||||
if (isset($result_error['errors']) && is_array($result_error['errors'])) {
|
||||
array_walk_recursive($result_error['errors'], function($item) use (&$subscriber_errors) {
|
||||
$subscriber_errors[] = $item;
|
||||
});
|
||||
|
@@ -10,7 +10,7 @@ class PHPMailMapper {
|
||||
|
||||
function getErrorFromException(\Exception $e, $subscriber) {
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if(strpos($e->getMessage(), 'Invalid address') === 0) {
|
||||
if (strpos($e->getMessage(), 'Invalid address') === 0) {
|
||||
$level = MailerError::LEVEL_SOFT;
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class SMTPMapper {
|
||||
$message = explode(PHP_EOL, $e->getMessage());
|
||||
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if($e instanceof \Swift_RfcComplianceException) {
|
||||
if ($e instanceof \Swift_RfcComplianceException) {
|
||||
$level = MailerError::LEVEL_SOFT;
|
||||
}
|
||||
$subscriber_errors = [new SubscriberError($subscriber, null)];
|
||||
@@ -27,7 +27,7 @@ class SMTPMapper {
|
||||
function getErrorFromLog($log, $subscriber) {
|
||||
// extract error message from log
|
||||
preg_match('/!! (.*?)>>/ism', $log, $message);
|
||||
if(!empty($message[1])) {
|
||||
if (!empty($message[1])) {
|
||||
$message = $message[1];
|
||||
// remove line breaks from the message due to how logger's dump() method works
|
||||
$message = preg_replace('/\r|\n/', '', $message);
|
||||
|
@@ -14,7 +14,7 @@ class SendGridMapper {
|
||||
sprintf(__('%s has returned an unknown error.', 'mailpoet'), Mailer::METHOD_SENDGRID);
|
||||
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if(strpos($response, 'Invalid email address') === 0) {
|
||||
if (strpos($response, 'Invalid email address') === 0) {
|
||||
$level = MailerError::LEVEL_SOFT;
|
||||
}
|
||||
$subscriber_errors = [new SubscriberError($subscriber, null)];
|
||||
|
@@ -7,7 +7,7 @@ use MailPoet\Mailer\Methods\ErrorMappers\MailPoetMapper;
|
||||
use MailPoet\Services\Bridge;
|
||||
use MailPoet\Services\Bridge\API;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class MailPoet {
|
||||
public $api;
|
||||
@@ -27,7 +27,7 @@ class MailPoet {
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = array()) {
|
||||
if($this->services_checker->isMailPoetAPIKeyValid() === false) {
|
||||
if ($this->services_checker->isMailPoetAPIKeyValid() === false) {
|
||||
return Mailer::formatMailerErrorResult($this->error_mapper->getInvalidApiKeyError());
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class MailPoet {
|
||||
}
|
||||
|
||||
function processSendError($result, $subscriber) {
|
||||
if(!empty($result['code']) && $result['code'] === API::RESPONSE_CODE_KEY_INVALID) {
|
||||
if (!empty($result['code']) && $result['code'] === API::RESPONSE_CODE_KEY_INVALID) {
|
||||
Bridge::invalidateKey();
|
||||
}
|
||||
return $this->error_mapper->getErrorForResult($result, $subscriber);
|
||||
@@ -56,7 +56,7 @@ class MailPoet {
|
||||
|
||||
function processSubscriber($subscriber) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriber_data);
|
||||
if(!isset($subscriber_data['email'])) {
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
$subscriber_data = array(
|
||||
'email' => $subscriber,
|
||||
);
|
||||
@@ -85,18 +85,18 @@ class MailPoet {
|
||||
)),
|
||||
'subject' => $newsletter['subject']
|
||||
);
|
||||
if(!empty($newsletter['body']['html'])) {
|
||||
if (!empty($newsletter['body']['html'])) {
|
||||
$body['html'] = $newsletter['body']['html'];
|
||||
}
|
||||
if(!empty($newsletter['body']['text'])) {
|
||||
if (!empty($newsletter['body']['text'])) {
|
||||
$body['text'] = $newsletter['body']['text'];
|
||||
}
|
||||
if($unsubscribe_url) {
|
||||
if ($unsubscribe_url) {
|
||||
$body['list_unsubscribe'] = $unsubscribe_url;
|
||||
}
|
||||
return $body;
|
||||
};
|
||||
if(is_array($newsletter) && is_array($subscriber)) {
|
||||
if (is_array($newsletter) && is_array($subscriber)) {
|
||||
$body = array();
|
||||
for ($record = 0; $record < count($newsletter); $record++) {
|
||||
$body[] = $composeBody(
|
||||
|
@@ -5,7 +5,7 @@ namespace MailPoet\Mailer\Methods;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\PHPMailMapper;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
require_once ABSPATH . WPINC . '/class-phpmailer.php';
|
||||
|
||||
@@ -35,7 +35,7 @@ class PHPMail {
|
||||
} catch (\Exception $e) {
|
||||
return Mailer::formatMailerErrorResult($this->error_mapper->getErrorFromException($e, $subscriber));
|
||||
}
|
||||
if($result === true) {
|
||||
if ($result === true) {
|
||||
return Mailer::formatMailerSendSuccessResult();
|
||||
} else {
|
||||
$error = $this->error_mapper->getErrorForSubscriber($subscriber);
|
||||
@@ -64,7 +64,7 @@ class PHPMail {
|
||||
$mailer->Body = (!empty($newsletter['body']['html'])) ? $newsletter['body']['html'] : '';
|
||||
$mailer->AltBody = (!empty($newsletter['body']['text'])) ? $newsletter['body']['text'] : '';
|
||||
$mailer->Sender = $this->return_path;
|
||||
if(!empty($extra_params['unsubscribe_url'])) {
|
||||
if (!empty($extra_params['unsubscribe_url'])) {
|
||||
$this->mailer->addCustomHeader('List-Unsubscribe', $extra_params['unsubscribe_url']);
|
||||
}
|
||||
return $mailer;
|
||||
@@ -72,7 +72,7 @@ class PHPMail {
|
||||
|
||||
function processSubscriber($subscriber) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriber_data);
|
||||
if(!isset($subscriber_data['email'])) {
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
$subscriber_data = array(
|
||||
'email' => $subscriber,
|
||||
);
|
||||
|
@@ -5,7 +5,7 @@ use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\SMTPMapper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class SMTP {
|
||||
public $host;
|
||||
@@ -56,7 +56,7 @@ class SMTP {
|
||||
$this->error_mapper->getErrorFromException($e, $subscriber)
|
||||
);
|
||||
}
|
||||
if($result === 1) {
|
||||
if ($result === 1) {
|
||||
return Mailer::formatMailerSendSuccessResult();
|
||||
} else {
|
||||
$error = $this->error_mapper->getErrorFromLog($this->mailer_logger->dump(), $subscriber);
|
||||
@@ -69,7 +69,7 @@ class SMTP {
|
||||
$this->host, $this->port, $this->encryption);
|
||||
$connection_timeout = $this->wp->applyFilters('mailpoet_mailer_smtp_connection_timeout', self::SMTP_CONNECTION_TIMEOUT);
|
||||
$transport->setTimeout($connection_timeout);
|
||||
if($this->authentication) {
|
||||
if ($this->authentication) {
|
||||
$transport
|
||||
->setUsername($this->login)
|
||||
->setPassword($this->password);
|
||||
@@ -94,14 +94,14 @@ class SMTP {
|
||||
)
|
||||
->setReturnPath($this->return_path)
|
||||
->setSubject($newsletter['subject']);
|
||||
if(!empty($extra_params['unsubscribe_url'])) {
|
||||
if (!empty($extra_params['unsubscribe_url'])) {
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addTextHeader('List-Unsubscribe', '<' . $extra_params['unsubscribe_url'] . '>');
|
||||
}
|
||||
if(!empty($newsletter['body']['html'])) {
|
||||
if (!empty($newsletter['body']['html'])) {
|
||||
$message = $message->setBody($newsletter['body']['html'], 'text/html');
|
||||
}
|
||||
if(!empty($newsletter['body']['text'])) {
|
||||
if (!empty($newsletter['body']['text'])) {
|
||||
$message = $message->addPart($newsletter['body']['text'], 'text/plain');
|
||||
}
|
||||
return $message;
|
||||
@@ -109,7 +109,7 @@ class SMTP {
|
||||
|
||||
function processSubscriber($subscriber) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriber_data);
|
||||
if(!isset($subscriber_data['email'])) {
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
$subscriber_data = array(
|
||||
'email' => $subscriber,
|
||||
);
|
||||
|
@@ -6,7 +6,7 @@ use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\SendGridMapper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class SendGrid {
|
||||
public $url = 'https://api.sendgrid.com/api/mail.send.json';
|
||||
@@ -32,11 +32,11 @@ class SendGrid {
|
||||
$this->url,
|
||||
$this->request($newsletter, $subscriber, $extra_params)
|
||||
);
|
||||
if(is_wp_error($result)) {
|
||||
if (is_wp_error($result)) {
|
||||
$error = $this->error_mapper->getConnectionError($result->get_error_message());
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
if($this->wp->wpRemoteRetrieveResponseCode($result) !== 200) {
|
||||
if ($this->wp->wpRemoteRetrieveResponseCode($result) !== 200) {
|
||||
$response = json_decode($result['body'], true);
|
||||
$error = $this->error_mapper->getErrorFromResponse($response, $subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
@@ -53,16 +53,16 @@ class SendGrid {
|
||||
'subject' => $newsletter['subject']
|
||||
);
|
||||
$headers = array();
|
||||
if(!empty($extra_params['unsubscribe_url'])) {
|
||||
if (!empty($extra_params['unsubscribe_url'])) {
|
||||
$headers['List-Unsubscribe'] = '<' . $extra_params['unsubscribe_url'] . '>';
|
||||
}
|
||||
if($headers) {
|
||||
if ($headers) {
|
||||
$body['headers'] = json_encode($headers);
|
||||
}
|
||||
if(!empty($newsletter['body']['html'])) {
|
||||
if (!empty($newsletter['body']['html'])) {
|
||||
$body['html'] = $newsletter['body']['html'];
|
||||
}
|
||||
if(!empty($newsletter['body']['text'])) {
|
||||
if (!empty($newsletter['body']['text'])) {
|
||||
$body['text'] = $newsletter['body']['text'];
|
||||
}
|
||||
return $body;
|
||||
|
Reference in New Issue
Block a user