- Removes Cron status from MailPoet's WP admin panel
This commit is contained in:
@ -1,72 +0,0 @@
|
|||||||
define(
|
|
||||||
[
|
|
||||||
'react',
|
|
||||||
'react-dom',
|
|
||||||
'mailpoet'
|
|
||||||
],
|
|
||||||
function(
|
|
||||||
React,
|
|
||||||
ReactDOM,
|
|
||||||
MailPoet
|
|
||||||
) {
|
|
||||||
var CronControl = React.createClass({
|
|
||||||
getInitialState: function() {
|
|
||||||
return {
|
|
||||||
status: 'loading'
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getCronData: function() {
|
|
||||||
MailPoet.Ajax.post({
|
|
||||||
endpoint: 'cron',
|
|
||||||
action: 'getStatus'
|
|
||||||
}).done((response) => {
|
|
||||||
this.setState({
|
|
||||||
status: response.data.status
|
|
||||||
});
|
|
||||||
}).fail((response) => {
|
|
||||||
this.setState({
|
|
||||||
status: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
componentDidMount: function() {
|
|
||||||
if(this.isMounted()) {
|
|
||||||
this.getCronData();
|
|
||||||
setInterval(this.getCronData, 5000);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
render: function() {
|
|
||||||
let status;
|
|
||||||
|
|
||||||
switch(this.state.status) {
|
|
||||||
case false:
|
|
||||||
case 'stopping':
|
|
||||||
case 'stopped':
|
|
||||||
status = MailPoet.I18n.t('cronDaemonIsNotRunning');
|
|
||||||
break;
|
|
||||||
case 'starting':
|
|
||||||
case 'started':
|
|
||||||
status = MailPoet.I18n.t('cronDaemonIsRunning');
|
|
||||||
break;
|
|
||||||
case 'loading':
|
|
||||||
status = MailPoet.I18n.t('loadingDaemonStatus');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{ status }
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const container = document.getElementById('cron_container');
|
|
||||||
|
|
||||||
if(container) {
|
|
||||||
ReactDOM.render(
|
|
||||||
<CronControl />,
|
|
||||||
container
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace MailPoet\API\Endpoints;
|
|
||||||
use \MailPoet\API\Endpoint as APIEndpoint;
|
|
||||||
use \MailPoet\API\Error as APIError;
|
|
||||||
|
|
||||||
use MailPoet\Cron\CronHelper;
|
|
||||||
use MailPoet\Models\Setting;
|
|
||||||
|
|
||||||
if(!defined('ABSPATH')) exit;
|
|
||||||
|
|
||||||
class Cron extends APIEndpoint {
|
|
||||||
function getStatus() {
|
|
||||||
$daemon = Setting::getValue(CronHelper::DAEMON_SETTING, false);
|
|
||||||
|
|
||||||
if($daemon === false) {
|
|
||||||
return $this->errorResponse(array(
|
|
||||||
APIError::NOT_FOUND => __('Cron daemon is not running.')
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
return $this->successResponse($daemon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -186,15 +186,6 @@ class Menu {
|
|||||||
'mailpoet-newsletter-editor',
|
'mailpoet-newsletter-editor',
|
||||||
array($this, 'newletterEditor')
|
array($this, 'newletterEditor')
|
||||||
);
|
);
|
||||||
|
|
||||||
add_submenu_page(
|
|
||||||
$main_page_slug,
|
|
||||||
$this->setPageTitle(__('Cron')),
|
|
||||||
__('Cron'),
|
|
||||||
'manage_options',
|
|
||||||
'mailpoet-cron',
|
|
||||||
array($this, 'cron')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function welcome() {
|
function welcome() {
|
||||||
@ -418,10 +409,6 @@ class Menu {
|
|||||||
echo $this->renderer->render('form/editor.html', $data);
|
echo $this->renderer->render('form/editor.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cron() {
|
|
||||||
echo $this->renderer->render('cron.html');
|
|
||||||
}
|
|
||||||
|
|
||||||
function setPageTitle($title) {
|
function setPageTitle($title) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s - %s',
|
'%s - %s',
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace MailPoet\Cron;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use MailPoet\Models\Setting;
|
|
||||||
|
|
||||||
class BootStrapMenu {
|
|
||||||
function __construct() {
|
|
||||||
$this->daemon = Setting::where('name', 'cron_daemon')
|
|
||||||
->findOne();
|
|
||||||
}
|
|
||||||
|
|
||||||
function bootStrap() {
|
|
||||||
return ($this->daemon) ?
|
|
||||||
array_merge(
|
|
||||||
array(
|
|
||||||
'timeSinceStart' => Carbon::createFromFormat(
|
|
||||||
'Y-m-d H:i:s',
|
|
||||||
$this->daemon->created_at,
|
|
||||||
'UTC'
|
|
||||||
)->diffForHumans(),
|
|
||||||
'timeSinceUpdate' => Carbon::createFromFormat(
|
|
||||||
'Y-m-d H:i:s',
|
|
||||||
$this->daemon->updated_at,
|
|
||||||
'UTC'
|
|
||||||
)->diffForHumans()
|
|
||||||
),
|
|
||||||
json_decode($this->daemon->value, true)
|
|
||||||
) :
|
|
||||||
"false";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<% extends 'layout.html' %>
|
|
||||||
|
|
||||||
<% block content %>
|
|
||||||
<div id="cron_container"></div>
|
|
||||||
<% endblock %>
|
|
||||||
|
|
||||||
<% block translations %>
|
|
||||||
<%= localize({
|
|
||||||
'loadingDaemonStatus': __('Loading daemon status...'),
|
|
||||||
'cronDaemonIsRunning': __('Cron daemon is running'),
|
|
||||||
'cronDaemonIsNotRunning': __('Cron daemon is not running')
|
|
||||||
}) %>
|
|
||||||
<% endblock %>
|
|
Reference in New Issue
Block a user