Replaced "contains" by "indexOf" (chrome issue)
- added public ajax routing (not checking permissions) - exception handling in form subscription
This commit is contained in:
@ -120,13 +120,13 @@ define('date',
|
|||||||
let outputFormat = '';
|
let outputFormat = '';
|
||||||
|
|
||||||
Object.keys(replacements).forEach(function(key) {
|
Object.keys(replacements).forEach(function(key) {
|
||||||
if (format.contains(key)) {
|
if (format.indexOf(key) !== -1) {
|
||||||
format = format.replace(key, '%'+key);
|
format = format.replace(key, '%'+key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
outputFormat = format;
|
outputFormat = format;
|
||||||
Object.keys(replacements).forEach(function(key) {
|
Object.keys(replacements).forEach(function(key) {
|
||||||
if (outputFormat.contains('%'+key)) {
|
if (outputFormat.indexOf('%'+key) !== -1) {
|
||||||
outputFormat = outputFormat.replace('%'+key, replacements[key]);
|
outputFormat = outputFormat.replace('%'+key, replacements[key]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -33,7 +33,6 @@ class Initializer {
|
|||||||
$this->setupRenderer();
|
$this->setupRenderer();
|
||||||
$this->setupLocalizer();
|
$this->setupLocalizer();
|
||||||
$this->setupMenu();
|
$this->setupMenu();
|
||||||
$this->setupRouter();
|
|
||||||
$this->setupPermissions();
|
$this->setupPermissions();
|
||||||
$this->setupPublicAPI();
|
$this->setupPublicAPI();
|
||||||
$this->setupAnalytics();
|
$this->setupAnalytics();
|
||||||
@ -49,6 +48,7 @@ class Initializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onInit() {
|
function onInit() {
|
||||||
|
$this->setupRouter();
|
||||||
$this->setupPages();
|
$this->setupPages();
|
||||||
$this->runQueueSupervisor();
|
$this->runQueueSupervisor();
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class Subscriber extends Model {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// convert subsdriber to array
|
// convert subscriber to array
|
||||||
$subscriber = $this->asArray();
|
$subscriber = $this->asArray();
|
||||||
|
|
||||||
// set from
|
// set from
|
||||||
@ -163,14 +163,13 @@ class Subscriber extends Model {
|
|||||||
) ? $signup_confirmation['reply_to']
|
) ? $signup_confirmation['reply_to']
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
|
||||||
// send email
|
// send email
|
||||||
$mailer = new Mailer(
|
try {
|
||||||
false,
|
$mailer = new Mailer(false, $from, $reply_to);
|
||||||
$from,
|
|
||||||
$reply_to
|
|
||||||
);
|
|
||||||
return $mailer->send($email, $subscriber);
|
return $mailer->send($email, $subscriber);
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,26 @@ class Router {
|
|||||||
);
|
);
|
||||||
add_action(
|
add_action(
|
||||||
'wp_ajax_mailpoet',
|
'wp_ajax_mailpoet',
|
||||||
array($this, 'setup')
|
array($this, 'setupAdmin')
|
||||||
|
);
|
||||||
|
add_action(
|
||||||
|
'wp_ajax_nopriv_mailpoet',
|
||||||
|
array($this, 'setupPublic')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup() {
|
function setupAdmin() {
|
||||||
$this->securityCheck();
|
$this->verifyToken();
|
||||||
|
$this->checkPermissions();
|
||||||
|
return $this->processRoute();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupPublic() {
|
||||||
|
$this->verifyToken();
|
||||||
|
return $this->processRoute();
|
||||||
|
}
|
||||||
|
|
||||||
|
function processRoute() {
|
||||||
$class = ucfirst($_POST['endpoint']);
|
$class = ucfirst($_POST['endpoint']);
|
||||||
$endpoint = __NAMESPACE__ . "\\" . $class;
|
$endpoint = __NAMESPACE__ . "\\" . $class;
|
||||||
$method = $_POST['method'];
|
$method = $_POST['method'];
|
||||||
@ -43,8 +57,11 @@ class Router {
|
|||||||
echo $global;
|
echo $global;
|
||||||
}
|
}
|
||||||
|
|
||||||
function securityCheck() {
|
function checkPermissions() {
|
||||||
if(!current_user_can('manage_options')) { die(); }
|
if(!current_user_can('manage_options')) { die(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
function verifyToken() {
|
||||||
if(!wp_verify_nonce($_POST['token'], 'mailpoet_token')) { die(); }
|
if(!wp_verify_nonce($_POST['token'], 'mailpoet_token')) { die(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user