diff --git a/lib/Queue/Daemon.php b/lib/Queue/Daemon.php index 5f6c0fb745..185a36594c 100644 --- a/lib/Queue/Daemon.php +++ b/lib/Queue/Daemon.php @@ -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; + } } \ No newline at end of file diff --git a/lib/Util/Helpers.php b/lib/Util/Helpers.php index 28a98a7c40..69afd86333 100644 --- a/lib/Util/Helpers.php +++ b/lib/Util/Helpers.php @@ -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); + } } \ No newline at end of file