- Adds a helper method to convert cameCase to under_score
- Removes unused method from Queue daemon
This commit is contained in:
@@ -78,29 +78,6 @@ class Daemon {
|
||||
$this->callSelf();
|
||||
}
|
||||
|
||||
function callSelf() {
|
||||
$payload = json_encode(array('token' => $this->refreshedToken));
|
||||
$args = array(
|
||||
'timeout' => 1,
|
||||
'user-agent' => 'MailPoet (www.mailpoet.com)'
|
||||
);
|
||||
wp_remote_get(
|
||||
Supervisor::getSiteUrl() .
|
||||
'/?mailpoet-api§ion=queue&action=run&payload=' . urlencode($payload),
|
||||
$args
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
function abortWithError($error) {
|
||||
wp_send_json(
|
||||
array(
|
||||
'result' => false,
|
||||
'error' => $error
|
||||
));
|
||||
exit;
|
||||
}
|
||||
|
||||
function getQueue() {
|
||||
$queue = Setting::where('name', 'queue')
|
||||
->findOne();
|
||||
@@ -109,14 +86,7 @@ class Daemon {
|
||||
($queue) ? unserialize($queue->value) : null
|
||||
);
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
if(!current_user_can('manage_options')) {
|
||||
header('HTTP/1.0 401 Not Authorized');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function refreshToken() {
|
||||
return Security::generateRandomString(5);
|
||||
}
|
||||
@@ -135,4 +105,27 @@ class Daemon {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function callSelf() {
|
||||
$payload = json_encode(array('token' => $this->refreshedToken));
|
||||
$args = array(
|
||||
'timeout' => 1,
|
||||
'user-agent' => 'MailPoet (www.mailpoet.com)'
|
||||
);
|
||||
wp_remote_get(
|
||||
Supervisor::getSiteUrl() .
|
||||
'/?mailpoet-api§ion=queue&action=run&payload=' . urlencode($payload),
|
||||
$args
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
function abortWithError($error) {
|
||||
wp_send_json(
|
||||
array(
|
||||
'result' => false,
|
||||
'error' => $error
|
||||
));
|
||||
exit;
|
||||
}
|
||||
}
|
@@ -178,4 +178,10 @@ class Helpers {
|
||||
$func = create_function('$c', 'return strtoupper($c[1]);');
|
||||
return preg_replace_callback('/_([a-z])/', $func, $str);
|
||||
}
|
||||
|
||||
static function camelCaseToUnderscore($str) {
|
||||
$str[0] = strtolower($str[0]);
|
||||
$func = create_function('$c', 'return "_" . strtolower($c[1]);');
|
||||
return preg_replace_callback('/([A-Z])/', $func, $str);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user