Add task scheduler field
[MAILPOET-2680]
This commit is contained in:
committed by
Veljko V
parent
103a2e7423
commit
903314669a
@@ -1,10 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import BounceAddress from './bounce_address';
|
import BounceAddress from './bounce_address';
|
||||||
|
import TaskScheduler from './task_scheduler';
|
||||||
|
|
||||||
export default function Advanced() {
|
export default function Advanced() {
|
||||||
return (
|
return (
|
||||||
<div className="mailpoet-settings-grid">
|
<div className="mailpoet-settings-grid">
|
||||||
<BounceAddress />
|
<BounceAddress />
|
||||||
|
<TaskScheduler />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
101
assets/js/src/settings/pages/advanced/task_scheduler.tsx
Normal file
101
assets/js/src/settings/pages/advanced/task_scheduler.tsx
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactStringReplace from 'react-string-replace';
|
||||||
|
|
||||||
|
import { t, onChange } from 'common/functions';
|
||||||
|
import { useSetting, useSelector } from 'settings/store/hooks';
|
||||||
|
import { Label, Inputs } from 'settings/components';
|
||||||
|
|
||||||
|
export default function TaskScheduler() {
|
||||||
|
const [method, setMethod] = useSetting('cron_trigger', 'method');
|
||||||
|
const paths = useSelector('getPaths')();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Label
|
||||||
|
title={t('taskCron')}
|
||||||
|
description={(
|
||||||
|
<>
|
||||||
|
{t('taskCronDescription')}
|
||||||
|
{' '}
|
||||||
|
<a
|
||||||
|
href="https://kb.mailpoet.com/article/129-what-is-the-newsletter-task-scheduler"
|
||||||
|
data-beacon-article="57ce0a7a903360649f6e5703"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
{t('readMore')}
|
||||||
|
</a>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
htmlFor="cron_trigger-method"
|
||||||
|
/>
|
||||||
|
<Inputs>
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
id="cron_trigger-method-wordpress"
|
||||||
|
value="WordPress"
|
||||||
|
checked={method === 'WordPress'}
|
||||||
|
onChange={onChange(setMethod)}
|
||||||
|
/>
|
||||||
|
<label htmlFor="cron_trigger-method-wordpress">
|
||||||
|
{t('websiteVisitors')}
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
id="cron_trigger-method-mailpoet"
|
||||||
|
value="MailPoet"
|
||||||
|
checked={method === 'MailPoet'}
|
||||||
|
onChange={onChange(setMethod)}
|
||||||
|
/>
|
||||||
|
<label htmlFor="cron_trigger-method-mailpoet">
|
||||||
|
{ReactStringReplace(t('mailpoetScript'),
|
||||||
|
/\[link\](.*?)\[\/link\]/,
|
||||||
|
(text) => (
|
||||||
|
<a
|
||||||
|
key={text}
|
||||||
|
href="https://kb.mailpoet.com/article/131-hosts-which-mailpoet-task-scheduler-wont-work"
|
||||||
|
data-beacon-article="57ce0b05c6979108399a0456"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
{text}
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
id="cron_trigger-method-cron"
|
||||||
|
value="Linux Cron"
|
||||||
|
checked={method === 'Linux Cron'}
|
||||||
|
onChange={onChange(setMethod)}
|
||||||
|
/>
|
||||||
|
<label htmlFor="cron_trigger-method-cron">
|
||||||
|
{t('serverCron')}
|
||||||
|
</label>
|
||||||
|
{method === 'Linux Cron' && (
|
||||||
|
<>
|
||||||
|
<br />
|
||||||
|
{t('addCommandToCrontab')}
|
||||||
|
<br />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
readOnly
|
||||||
|
className="large-text"
|
||||||
|
value={`php ${paths.plugin}/mailpoet-cron.php ${paths.root}`}
|
||||||
|
/>
|
||||||
|
<br />
|
||||||
|
{t('withFrequency')}
|
||||||
|
<br />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
readOnly
|
||||||
|
value="*/1 * * * *"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Inputs>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@@ -4,6 +4,7 @@ import normalizeSettings from './normalize_settings';
|
|||||||
|
|
||||||
export default function makeDefaultState(window: any): State {
|
export default function makeDefaultState(window: any): State {
|
||||||
const pages = window.mailpoet_pages;
|
const pages = window.mailpoet_pages;
|
||||||
|
const paths = window.mailpoet_paths;
|
||||||
const segments = window.mailpoet_segments;
|
const segments = window.mailpoet_segments;
|
||||||
const save = { inProgress: false, error: null };
|
const save = { inProgress: false, error: null };
|
||||||
const data = normalizeSettings(window.mailpoet_settings);
|
const data = normalizeSettings(window.mailpoet_settings);
|
||||||
@@ -32,7 +33,7 @@ export default function makeDefaultState(window: any): State {
|
|||||||
key: data.premium.premium_key || data.mta.mailpoet_api_key,
|
key: data.premium.premium_key || data.mta.mailpoet_api_key,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
data, flags, save, keyActivation, segments, pages,
|
data, flags, save, keyActivation, segments, pages, paths,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,3 +48,7 @@ export function getPages(state: State) {
|
|||||||
export function getKeyActivationState(state: State) {
|
export function getKeyActivationState(state: State) {
|
||||||
return state.keyActivation;
|
return state.keyActivation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPaths(state: State) {
|
||||||
|
return state.paths;
|
||||||
|
}
|
||||||
|
@@ -226,6 +226,10 @@ export type State = {
|
|||||||
data: Settings
|
data: Settings
|
||||||
segments: Segment[]
|
segments: Segment[]
|
||||||
pages: Page[]
|
pages: Page[]
|
||||||
|
paths: {
|
||||||
|
root: string
|
||||||
|
plugin: string
|
||||||
|
}
|
||||||
flags: {
|
flags: {
|
||||||
woocommerce: boolean
|
woocommerce: boolean
|
||||||
newUser: boolean
|
newUser: boolean
|
||||||
|
@@ -78,13 +78,15 @@ class Settings {
|
|||||||
'members_plugin_active' => $this->wp->isPluginActive('members/members.php'),
|
'members_plugin_active' => $this->wp->isPluginActive('members/members.php'),
|
||||||
'pages' => Pages::getAll(),
|
'pages' => Pages::getAll(),
|
||||||
'current_user' => $this->wp->wpGetCurrentUser(),
|
'current_user' => $this->wp->wpGetCurrentUser(),
|
||||||
'linux_cron_path' => dirname(dirname(dirname(__DIR__))),
|
|
||||||
'is_woocommerce_active' => $this->woocommerceHelper->isWooCommerceActive(),
|
'is_woocommerce_active' => $this->woocommerceHelper->isWooCommerceActive(),
|
||||||
'ABSPATH' => ABSPATH,
|
|
||||||
'hosts' => [
|
'hosts' => [
|
||||||
'web' => Hosts::getWebHosts(),
|
'web' => Hosts::getWebHosts(),
|
||||||
'smtp' => Hosts::getSMTPHosts(),
|
'smtp' => Hosts::getSMTPHosts(),
|
||||||
],
|
],
|
||||||
|
'paths' => [
|
||||||
|
'root' => ABSPATH,
|
||||||
|
'plugin' => dirname(dirname(dirname(__DIR__))),
|
||||||
|
],
|
||||||
'built_in_captcha_supported' => $this->captcha->isSupported(),
|
'built_in_captcha_supported' => $this->captcha->isSupported(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
var mailpoet_mss_key_valid = <%= json_encode(mss_key_valid) %>;
|
var mailpoet_mss_key_valid = <%= json_encode(mss_key_valid) %>;
|
||||||
var mailpoet_premium_key_valid = <%= json_encode(premium_key_valid) %>;
|
var mailpoet_premium_key_valid = <%= json_encode(premium_key_valid) %>;
|
||||||
var mailpoet_premium_plugin_installed = <%= json_encode(premium_plugin_installed) %>;
|
var mailpoet_premium_plugin_installed = <%= json_encode(premium_plugin_installed) %>;
|
||||||
|
var mailpoet_paths = <%= json_encode(paths) %>;
|
||||||
<% endautoescape %>
|
<% endautoescape %>
|
||||||
var mailpoet_beacon_articles = [
|
var mailpoet_beacon_articles = [
|
||||||
'57f71d49c697911f2d323486',
|
'57f71d49c697911f2d323486',
|
||||||
@@ -109,7 +110,7 @@
|
|||||||
'taskCron': __('Newsletter task scheduler (cron)'),
|
'taskCron': __('Newsletter task scheduler (cron)'),
|
||||||
'taskCronDescription': __('Select what will activate your newsletter queue.'),
|
'taskCronDescription': __('Select what will activate your newsletter queue.'),
|
||||||
'websiteVisitors': __('Visitors to your website (recommended)'),
|
'websiteVisitors': __('Visitors to your website (recommended)'),
|
||||||
'mailPoetScript': __("MailPoet's own script. Doesn't work with [link]these hosts[/link]."),
|
'mailpoetScript': __("MailPoet's own script. Doesn't work with [link]these hosts[/link]."),
|
||||||
'serverCron': __("Server side cron (Linux cron)"),
|
'serverCron': __("Server side cron (Linux cron)"),
|
||||||
'addCommandToCrontab': __("To use this option please add this command to your crontab:"),
|
'addCommandToCrontab': __("To use this option please add this command to your crontab:"),
|
||||||
'withFrequency': __("With the frequency of running it every minute:"),
|
'withFrequency': __("With the frequency of running it every minute:"),
|
||||||
|
Reference in New Issue
Block a user