Add linux cron option to settings

[MAILPOET-1538]
This commit is contained in:
Pavel Dohnal
2018-09-27 15:08:56 +02:00
parent 486c0ce4ee
commit fcd8509cef
4 changed files with 42 additions and 1 deletions

View File

@ -419,6 +419,7 @@ class Menu {
'pages' => Pages::getAll(),
'flags' => $flags,
'current_user' => wp_get_current_user(),
'linux_cron_path' => dirname(dirname(__DIR__)),
'hosts' => array(
'web' => Hosts::getWebHosts(),
'smtp' => Hosts::getSMTPHosts()

View File

@ -10,6 +10,7 @@ class CronTrigger {
public static $available_methods = array(
'mailpoet' => 'MailPoet',
'wordpress' => 'WordPress',
'linux_cron' => 'Linux Cron',
'none' => 'Disabled'
);
const DEFAULT_METHOD = 'WordPress';

View File

@ -166,6 +166,16 @@
toggleReCaptchaSettings();
$('#settings_re_captcha_tokens_error').hide();
function toggleLinuxCronSettings() {
if ($('input[name="cron_trigger[method]"]:checked').val() === '<%= cron_trigger.linux_cron %>') {
$('#settings_linux_cron').show();
} else {
$('#settings_linux_cron').hide();
}
}
$('input[name="cron_trigger[method]"]').on('click', toggleLinuxCronSettings);
toggleLinuxCronSettings();
// page preview
$('.mailpoet_page_preview').on('click', function() {
var selection = $(this).siblings('.mailpoet_page_selection');

View File

@ -65,6 +65,35 @@
%>
</label>
</p>
<p>
<label>
<input
type="radio"
name="cron_trigger[method]"
value="<%= cron_trigger.linux_cron %>"
<% if (settings.cron_trigger.method == cron_trigger.linux_cron) %>
checked="checked"
<% endif %>
/><%= __("Server side cron (Linux cron)")
%>
</label>
</p>
<div id="settings_linux_cron">
<p>
<%= __("To use this option please add this command to your crontab:") %><br>
<input
value="php <%= linux_cron_path %>/mailpoet-cron.php"
class="large-text"
readonly
/>
<p>
<%= __("With the frequency of running it every minute:") %><br>
<input
value="*/1 * * * *"
class="large-text"
readonly
/>
</div>
</td>
</tr>
<!-- roles and capabilities -->