Compare commits
139 Commits
Author | SHA1 | Date | |
---|---|---|---|
12a3931b7b | |||
25a55dbb67 | |||
6758f60a81 | |||
5e9e53ec41 | |||
1285252a8c | |||
98f95f72ad | |||
09ca788371 | |||
b48cc5a959 | |||
812d138c4e | |||
07bc35d4cd | |||
90b95a2c25 | |||
78c50c41e3 | |||
7eee7def63 | |||
9ba6e9806f | |||
8c28dc3d8a | |||
9197e39fb4 | |||
37f59814e5 | |||
bf894fc26f | |||
0b2b42cf4d | |||
542015a4f6 | |||
f5a8323f5d | |||
55942cd88b | |||
f26a2cbd26 | |||
4402f826c3 | |||
b9745b555a | |||
f923a8063b | |||
f4367b9146 | |||
a3395e41c9 | |||
be61135daf | |||
21b4187a11 | |||
1c3c1e35e7 | |||
ded373557e | |||
280c4762bb | |||
bbd02260be | |||
1b1e9abd68 | |||
b0ab9e0408 | |||
d32abff78d | |||
7fbf84db1f | |||
8c5aebc7d6 | |||
42202f676a | |||
ba6198f956 | |||
120af4170b | |||
1faa53b978 | |||
e565a7a234 | |||
90b6b57a8d | |||
548253d68e | |||
e1c5f609ff | |||
226befdef6 | |||
a9d57654b4 | |||
ed00ae0516 | |||
48d738e8c4 | |||
132b4ed2e8 | |||
9a513cb27b | |||
5d692c0395 | |||
991ab67fff | |||
dd00640119 | |||
fa04173cfb | |||
a328d3b48a | |||
d5cff4f0d3 | |||
52bf24b6db | |||
50e134d696 | |||
ea5c73721b | |||
4799882b80 | |||
2e4c5ca39a | |||
13ed3aa3b9 | |||
6091751a4b | |||
c4d9e85dff | |||
1a85914c1b | |||
0ba48234de | |||
1c2a532949 | |||
9087be6ee8 | |||
5b2ede8b83 | |||
2fa5e5ead2 | |||
d5107be65e | |||
379dfb5f6e | |||
8360377992 | |||
4538cab6c8 | |||
1bf0988297 | |||
e1caf49ea5 | |||
0dfae97b32 | |||
ef2187c175 | |||
6157d17c5b | |||
8e879047c2 | |||
bff6aecd0d | |||
a121583c2d | |||
e11fd66fec | |||
b37e85eeb5 | |||
f88dabffe8 | |||
8c436180d9 | |||
b834a6af4d | |||
1bd8aed192 | |||
cfdf72867e | |||
5888620fc1 | |||
55ba605eb0 | |||
7a73ca7d1a | |||
1918894c5c | |||
0c5589a3e3 | |||
d6eaa4ac8a | |||
b0571b97f5 | |||
6d51ca8011 | |||
d3289dfb84 | |||
bfffdd7274 | |||
c5b8b2aef0 | |||
d7bcf1b817 | |||
f30ed153ce | |||
f436088a16 | |||
db8cb7499d | |||
49c4adc754 | |||
405e743171 | |||
3508ac36b4 | |||
f17c8228cd | |||
3dd5ac0536 | |||
4ebdff49e0 | |||
4a72995bf4 | |||
ef27ac0b84 | |||
2b4adef6c2 | |||
f650455a90 | |||
afbe25e215 | |||
d93249f077 | |||
6223ef77d9 | |||
a423123b66 | |||
1b3d3082b0 | |||
fa117cc7dd | |||
acd407c1f1 | |||
9baf4b068f | |||
18d852e147 | |||
b8dc306741 | |||
6ea056c042 | |||
bcf1b37c6a | |||
2986cdba85 | |||
53a8ae74e2 | |||
8bab01506c | |||
c664045444 | |||
6b8149210d | |||
f31d30b318 | |||
d9fbbdc02d | |||
8136ee2d9b | |||
f7cf6e2131 | |||
f2d1787bd5 |
15
.circle_ci/apache/mailpoet.loc.conf
Normal file
@ -0,0 +1,15 @@
|
||||
Listen 8080
|
||||
|
||||
<VirtualHost *:8080>
|
||||
UseCanonicalName Off
|
||||
ServerName mailpoet.loc
|
||||
DocumentRoot /home/ubuntu/mailpoet/wordpress
|
||||
DirectoryIndex index.php
|
||||
LogLevel notice
|
||||
|
||||
<Directory /home/ubuntu/mailpoet/wordpress>
|
||||
AllowOverride All
|
||||
Allow from All
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
|
1
.gitignore
vendored
@ -17,3 +17,4 @@ tests/javascript/testBundles
|
||||
assets/css/*.css
|
||||
assets/js/*.js
|
||||
.vagrant
|
||||
lang
|
@ -60,15 +60,20 @@
|
||||
.mailpoet_boxes .mailpoet_description
|
||||
float:left
|
||||
width: 245px
|
||||
max-height: calc(110px - 2em)
|
||||
max-height: calc(115px - 2em)
|
||||
padding-bottom: 2em
|
||||
overflow: hidden
|
||||
|
||||
.mailpoet_boxes .mailpoet_description h3
|
||||
margin: 0 0 0.7em 0
|
||||
overflow: hidden
|
||||
max-width: 210px
|
||||
line-height: 1.4em
|
||||
h3
|
||||
margin: 0 0 0.7em 0
|
||||
overflow: hidden
|
||||
max-width: 210px
|
||||
line-height: 1.4em
|
||||
|
||||
p
|
||||
font-size: 13px
|
||||
line-height: 1.5
|
||||
margin: 1em 0
|
||||
|
||||
.mailpoet_boxes .mailpoet_actions
|
||||
position: absolute
|
||||
|
@ -1,6 +1,6 @@
|
||||
$tool-inactive-color = #bbbbbb
|
||||
$tool-inactive-color = #333333
|
||||
$tool-inactive-secondary-color = #ffffff
|
||||
$tool-hover-color = #333333
|
||||
$tool-hover-color = #bbbbbb
|
||||
$tool-hover-secondary-color = #ffffff
|
||||
$tool-active-color = #d2d2d4
|
||||
$tool-active-secondary-color = #ffffff
|
||||
@ -12,21 +12,42 @@ $master-column-tool-width = 24px
|
||||
position: absolute
|
||||
top: 0
|
||||
right: 0
|
||||
display: none
|
||||
z-index: 20
|
||||
padding: 2px
|
||||
text-align: right
|
||||
overflow: hidden
|
||||
|
||||
.mailpoet_tool_slider
|
||||
position: relative
|
||||
right: -100%
|
||||
transition: all 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000)
|
||||
opacity: 0
|
||||
|
||||
&.mailpoet_display_tools
|
||||
.mailpoet_tool_slider
|
||||
right: 0
|
||||
opacity: 1
|
||||
|
||||
a
|
||||
vertical-align: top
|
||||
|
||||
.mailpoet_container_horizontal + &
|
||||
left: 100%
|
||||
right: initial
|
||||
padding-left: 5px
|
||||
|
||||
.mailpoet_tool_slider
|
||||
left: -100%
|
||||
right: initial
|
||||
|
||||
&.mailpoet_display_tools
|
||||
.mailpoet_tool_slider
|
||||
left: 0
|
||||
|
||||
.mailpoet_tool
|
||||
width: $master-column-tool-width
|
||||
height: $master-column-tool-width
|
||||
display: block
|
||||
|
||||
.mailpoet_tool_icon
|
||||
width: $master-column-tool-width
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
.mailpoet_input_title,
|
||||
.mailpoet_input_preheader
|
||||
width: 400px
|
||||
width: 500px
|
||||
padding: 3px
|
||||
line-height: normal
|
||||
|
||||
|
@ -5,8 +5,8 @@ $active-social-icon-set-border-color = #adadad
|
||||
$active-social-icon-set-background-color = #daebf2
|
||||
$social-icon-set-hover-border-color = $primary-active-color
|
||||
|
||||
$tool-inactive-color = #bbbbbb
|
||||
$tool-hover-color = #333333
|
||||
$tool-inactive-color = #333333
|
||||
$tool-hover-color = #bbbbbb
|
||||
$tool-active-color = #d2d2d4
|
||||
|
||||
$tool-width = 16px
|
||||
|
@ -1,12 +1,12 @@
|
||||
animation-slide-open-downwards()
|
||||
animation-slide-open-downwards($max-height = 2000px)
|
||||
transition: all 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000) /* ease-in-out */
|
||||
max-height: 2000px
|
||||
max-height: $max-height
|
||||
opacity: 1
|
||||
overflow-y: hidden
|
||||
|
||||
&.mailpoet_closed
|
||||
max-height: 0
|
||||
max-height: 0px
|
||||
opacity: 0
|
||||
overflow-y: hidden
|
||||
|
||||
animation-background-color()
|
||||
transition: background 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000) /* ease-in-out */
|
||||
|
Before Width: | Height: | Size: 178 KiB After Width: | Height: | Size: 178 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
BIN
assets/img/sample_templates/discount/bicycle-header2.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
assets/img/sample_templates/discount/bicycle-header3.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
assets/img/sample_templates/discount/orange-bicycle.jpg
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
assets/img/sample_templates/discount/red-icycle.jpg
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
assets/img/sample_templates/restaurant/boyga-1329911-639x852.jpg
Normal file
After Width: | Height: | Size: 303 KiB |
BIN
assets/img/sample_templates/restaurant/burger.jpg
Normal file
After Width: | Height: | Size: 289 KiB |
BIN
assets/img/sample_templates/restaurant/header.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 498 KiB |
BIN
assets/img/sample_templates/travel/gallery1.jpg
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
assets/img/sample_templates/travel/gallery2.jpg
Normal file
After Width: | Height: | Size: 106 KiB |
BIN
assets/img/sample_templates/travel/gallery3.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
assets/img/sample_templates/travel/gallery4.jpg
Normal file
After Width: | Height: | Size: 156 KiB |
BIN
assets/img/sample_templates/travel/glow-worms.jpg
Normal file
After Width: | Height: | Size: 145 KiB |
BIN
assets/img/sample_templates/travel/header.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
assets/img/sample_templates/travel/holiday-park.jpg
Normal file
After Width: | Height: | Size: 136 KiB |
BIN
assets/img/sample_templates/travel/luge.jpg
Normal file
After Width: | Height: | Size: 77 KiB |
BIN
assets/img/welcome_template/beacon.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 4.8 KiB |
BIN
assets/img/welcome_template/mailpoet-logo.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
@ -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
|
||||
);
|
||||
}
|
||||
});
|
@ -89,10 +89,17 @@ function(
|
||||
if(this.props.field['selected'] !== undefined) {
|
||||
return this.props.field['selected'](this.props.item);
|
||||
} else if(this.props.item !== undefined && this.props.field.name !== undefined) {
|
||||
return this.props.item[this.props.field.name];
|
||||
} else {
|
||||
return null;
|
||||
if (this.allowMultipleValues()) {
|
||||
if (Array.isArray(this.props.item[this.props.field.name])) {
|
||||
return this.props.item[this.props.field.name].map(function(item) {
|
||||
return item.id;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return this.props.item[this.props.field.name];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
loadCachedItems: function() {
|
||||
if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
|
||||
|
@ -66,22 +66,22 @@ define(
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'get',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
if(response === false) {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {}
|
||||
}, function() {
|
||||
this.context.router.push('/new');
|
||||
}.bind(this));
|
||||
} else {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response
|
||||
});
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}.bind(this));
|
||||
}).done((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response.data
|
||||
});
|
||||
}).fail((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {}
|
||||
}, function() {
|
||||
this.context.router.push('/new');
|
||||
});
|
||||
});
|
||||
},
|
||||
handleSubmit: function(e) {
|
||||
e.preventDefault();
|
||||
@ -115,29 +115,25 @@ define(
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'save',
|
||||
data: item
|
||||
}).done(function(response) {
|
||||
}).always(() => {
|
||||
this.setState({ loading: false });
|
||||
|
||||
if(response.result === true) {
|
||||
if(this.props.onSuccess !== undefined) {
|
||||
this.props.onSuccess();
|
||||
} else {
|
||||
this.context.router.push('/');
|
||||
}
|
||||
|
||||
if(this.props.params.id !== undefined) {
|
||||
this.props.messages.onUpdate();
|
||||
} else {
|
||||
this.props.messages.onCreate();
|
||||
}
|
||||
}).done((response) => {
|
||||
if(this.props.onSuccess !== undefined) {
|
||||
this.props.onSuccess();
|
||||
} else {
|
||||
if(response.result === false) {
|
||||
if(response.errors.length > 0) {
|
||||
this.setState({ errors: response.errors });
|
||||
}
|
||||
}
|
||||
this.context.router.push('/');
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
if(this.props.params.id !== undefined) {
|
||||
this.props.messages.onUpdate();
|
||||
} else {
|
||||
this.props.messages.onCreate();
|
||||
}
|
||||
}).fail((response) => {
|
||||
if(response.errors.length > 0) {
|
||||
this.setState({ errors: response.errors });
|
||||
}
|
||||
});
|
||||
},
|
||||
handleValueChange: function(e) {
|
||||
if (this.props.onChange) {
|
||||
@ -159,7 +155,7 @@ define(
|
||||
var errors = this.getErrors().map(function(error, index) {
|
||||
return (
|
||||
<p key={ 'error-'+index } className="mailpoet_error">
|
||||
{ error }
|
||||
{ error.message }
|
||||
</p>
|
||||
);
|
||||
});
|
||||
|
@ -27,48 +27,48 @@ const columns = [
|
||||
];
|
||||
|
||||
const messages = {
|
||||
onTrash: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormTrashed')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormDeleted')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormRestored')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -99,14 +99,21 @@ const item_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'forms',
|
||||
action: 'duplicate',
|
||||
data: item.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response['name'] !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.name)
|
||||
data: {
|
||||
id: item.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.data.name)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -120,9 +127,14 @@ const FormList = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'forms',
|
||||
action: 'create'
|
||||
}).done(function(response) {
|
||||
if(response.result && response.form_id) {
|
||||
window.location = mailpoet_form_edit_url + response.form_id;
|
||||
}).done((response) => {
|
||||
window.location = mailpoet_form_edit_url + response.data.id;
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -139,6 +151,10 @@ const FormList = React.createClass({
|
||||
return segment.name;
|
||||
}).join(', ');
|
||||
|
||||
if (form.settings.segments_selected_by === 'user') {
|
||||
segments = MailPoet.I18n.t('userChoice') + ' ' + segments;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<td className={ row_classes }>
|
||||
|
@ -53,7 +53,10 @@ function(
|
||||
}
|
||||
|
||||
if(data.action) {
|
||||
this.props.onBulkAction(selected_ids, data).then(onSuccess);
|
||||
const promise = this.props.onBulkAction(selected_ids, data);
|
||||
if (promise !== false) {
|
||||
promise.then(onSuccess);
|
||||
};
|
||||
}
|
||||
|
||||
this.setState({
|
||||
|
@ -456,22 +456,29 @@ const Listing = React.createClass({
|
||||
sort_by: this.state.sort_by,
|
||||
sort_order: this.state.sort_order
|
||||
}
|
||||
}).done(function(response) {
|
||||
}).always(() => {
|
||||
this.setState({ loading: false });
|
||||
}).done((response) => {
|
||||
this.setState({
|
||||
items: response.items || [],
|
||||
filters: response.filters || {},
|
||||
groups: response.groups || [],
|
||||
count: response.count || 0,
|
||||
loading: false
|
||||
}, function() {
|
||||
if (this.props['onGetItems'] !== undefined) {
|
||||
const count = (response.groups[0] !== undefined)
|
||||
? ~~(response.groups[0].count)
|
||||
: 0;
|
||||
this.props.onGetItems(count);
|
||||
items: response.data || [],
|
||||
filters: response.meta.filters || {},
|
||||
groups: response.meta.groups || [],
|
||||
count: response.meta.count || 0
|
||||
}, () => {
|
||||
// if viewing an empty trash
|
||||
if (this.state.group === 'trash' && response.meta.count === 0) {
|
||||
// redirect to default group
|
||||
this.handleGroup('all');
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
});
|
||||
}).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
handleRestoreItem: function(id) {
|
||||
@ -483,8 +490,10 @@ const Listing = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'restore',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).done((response) => {
|
||||
if (
|
||||
this.props.messages !== undefined
|
||||
&& this.props.messages['onRestore'] !== undefined
|
||||
@ -492,7 +501,12 @@ const Listing = React.createClass({
|
||||
this.props.messages.onRestore(response);
|
||||
}
|
||||
this.getItems();
|
||||
}.bind(this));
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
handleTrashItem: function(id) {
|
||||
this.setState({
|
||||
@ -503,8 +517,10 @@ const Listing = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'trash',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).done((response) => {
|
||||
if (
|
||||
this.props.messages !== undefined
|
||||
&& this.props.messages['onTrash'] !== undefined
|
||||
@ -512,7 +528,12 @@ const Listing = React.createClass({
|
||||
this.props.messages.onTrash(response);
|
||||
}
|
||||
this.getItems();
|
||||
}.bind(this));
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
handleDeleteItem: function(id) {
|
||||
this.setState({
|
||||
@ -523,8 +544,10 @@ const Listing = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'delete',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).done((response) => {
|
||||
if (
|
||||
this.props.messages !== undefined
|
||||
&& this.props.messages['onDelete'] !== undefined
|
||||
@ -532,22 +555,29 @@ const Listing = React.createClass({
|
||||
this.props.messages.onDelete(response);
|
||||
}
|
||||
this.getItems();
|
||||
}.bind(this));
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
handleEmptyTrash: function() {
|
||||
return this.handleBulkAction('all', {
|
||||
action: 'delete',
|
||||
group: 'trash'
|
||||
}).then(function(response) {
|
||||
if (~~(response) > 0) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response)
|
||||
);
|
||||
}
|
||||
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response.meta.count)
|
||||
);
|
||||
// redirect to default group
|
||||
this.handleGroup('all');
|
||||
}.bind(this));
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
handleBulkAction: function(selected_ids, params) {
|
||||
if (
|
||||
@ -555,7 +585,7 @@ const Listing = React.createClass({
|
||||
&& this.state.selected_ids.length === 0
|
||||
&& selected_ids !== 'all'
|
||||
) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
this.setState({ loading: true });
|
||||
@ -594,7 +624,7 @@ const Listing = React.createClass({
|
||||
handleSort: function(sort_by, sort_order = 'asc') {
|
||||
this.setState({
|
||||
sort_by: sort_by,
|
||||
sort_order: sort_order,
|
||||
sort_order: (sort_order === 'asc') ? 'asc' : 'desc',
|
||||
}, function() {
|
||||
this.setParams();
|
||||
}.bind(this));
|
||||
|
@ -99,12 +99,12 @@ define([
|
||||
},
|
||||
showTools: function(_event) {
|
||||
if (!this.showingToolsDisabled) {
|
||||
this.$('> .mailpoet_tools').show();
|
||||
this.$('> .mailpoet_tools').addClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('showTools');
|
||||
}
|
||||
},
|
||||
hideTools: function(e) {
|
||||
this.$('> .mailpoet_tools').hide();
|
||||
this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('hideTools');
|
||||
},
|
||||
enableShowingTools: function() {
|
||||
|
@ -186,13 +186,13 @@ define([
|
||||
},
|
||||
showTools: function() {
|
||||
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
||||
this.$(this.ui.tools).show();
|
||||
this.$(this.ui.tools).addClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('showTools');
|
||||
}
|
||||
},
|
||||
hideTools: function() {
|
||||
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
||||
this.$(this.ui.tools).hide();
|
||||
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('hideTools');
|
||||
}
|
||||
},
|
||||
|
@ -71,11 +71,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -84,6 +90,12 @@ define([
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'),
|
||||
});
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.FooterBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -71,11 +71,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -84,6 +90,12 @@ define([
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'),
|
||||
});
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.HeaderBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -171,11 +171,11 @@ define([
|
||||
this.regionManager.destroy();
|
||||
},
|
||||
showTools: function(_event) {
|
||||
this.$(this.ui.tools).show();
|
||||
this.$(this.ui.tools).addClass('mailpoet_display_tools');
|
||||
_event.stopPropagation();
|
||||
},
|
||||
hideTools: function(_event) {
|
||||
this.$(this.ui.tools).hide();
|
||||
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
|
||||
_event.stopPropagation();
|
||||
},
|
||||
showSettings: function(options) {
|
||||
|
@ -69,11 +69,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -83,6 +89,12 @@ define([
|
||||
});
|
||||
}
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.TextBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -11,7 +11,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'automatedLatestContent',
|
||||
action: args.action,
|
||||
data: args.options || {},
|
||||
data: args.options || {}
|
||||
});
|
||||
};
|
||||
Module._cachedQuery = _.memoize(Module._query, JSON.stringify);
|
||||
@ -19,14 +19,14 @@ define([
|
||||
Module.getNewsletter = function(options) {
|
||||
return Module._query({
|
||||
action: 'get',
|
||||
options: options,
|
||||
options: options
|
||||
});
|
||||
};
|
||||
|
||||
Module.getPostTypes = function() {
|
||||
return Module._cachedQuery({
|
||||
action: 'getPostTypes',
|
||||
options: {},
|
||||
options: {}
|
||||
}).then(function(response) {
|
||||
return _.values(response.data);
|
||||
});
|
||||
@ -83,7 +83,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'save',
|
||||
data: options || {},
|
||||
data: options || {}
|
||||
});
|
||||
};
|
||||
|
||||
@ -91,7 +91,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'sendPreview',
|
||||
data: options || {},
|
||||
data: options || {}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -252,32 +252,31 @@ define([
|
||||
endpoint: 'newsletters',
|
||||
action: 'showPreview',
|
||||
data: json,
|
||||
}).done(function(response) {
|
||||
if (response.result === true) {
|
||||
this.previewView = new Module.NewsletterPreviewView({
|
||||
previewUrl: response.data.url
|
||||
});
|
||||
|
||||
var view = this.previewView.render();
|
||||
|
||||
MailPoet.Modal.popup({
|
||||
template: '',
|
||||
element: this.previewView.$el,
|
||||
title: MailPoet.I18n.t('newsletterPreview'),
|
||||
onCancel: function() {
|
||||
this.previewView.destroy();
|
||||
this.previewView = null;
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
MailPoet.Notice.error(response.errors);
|
||||
}
|
||||
}.bind(this)).fail(function(error) {
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('newsletterPreviewFailed')
|
||||
);
|
||||
}).always(function() {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function(response) {
|
||||
this.previewView = new Module.NewsletterPreviewView({
|
||||
previewUrl: response.meta.preview_url
|
||||
});
|
||||
|
||||
var view = this.previewView.render();
|
||||
|
||||
MailPoet.Modal.popup({
|
||||
template: '',
|
||||
element: this.previewView.$el,
|
||||
title: MailPoet.I18n.t('newsletterPreview'),
|
||||
onCancel: function() {
|
||||
this.previewView.destroy();
|
||||
this.previewView = null;
|
||||
}.bind(this)
|
||||
});
|
||||
}.bind(this)).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
sendPreview: function() {
|
||||
@ -302,28 +301,19 @@ define([
|
||||
// send test email
|
||||
MailPoet.Modal.loading(true);
|
||||
|
||||
CommunicationComponent.previewNewsletter(data).done(function(response) {
|
||||
if(response.result !== undefined && response.result === true) {
|
||||
MailPoet.Notice.success(MailPoet.I18n.t('newsletterPreviewSent'), { scroll: true });
|
||||
} else {
|
||||
if (_.isArray(response.errors)) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error, { scroll: true });
|
||||
});
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('newsletterPreviewFailedToSend'),
|
||||
{
|
||||
scroll: true,
|
||||
static: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
CommunicationComponent.previewNewsletter(data).always(function() {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterPreviewSent'),
|
||||
{ scroll: true });
|
||||
}).fail(function(response) {
|
||||
// an error occurred
|
||||
MailPoet.Modal.loading(false);
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true, static: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
@ -17,8 +17,8 @@ import {
|
||||
} from 'newsletters/scheduling/common.jsx'
|
||||
|
||||
const messages = {
|
||||
onTrash(response) {
|
||||
const count = ~~response;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -28,12 +28,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete(response) {
|
||||
const count = ~~response;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -43,12 +43,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore(response) {
|
||||
const count = ~~response;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -58,7 +58,7 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -127,16 +127,23 @@ const newsletter_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'duplicate',
|
||||
data: newsletter.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response.subject !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.subject
|
||||
)
|
||||
data: {
|
||||
id: newsletter.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.data.subject
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -12,8 +12,8 @@ import { QueueMixin, StatisticsMixin } from 'newsletters/listings/mixins.jsx'
|
||||
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
|
||||
|
||||
const messages = {
|
||||
onTrash(response) {
|
||||
const count = ~~response;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -23,12 +23,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete(response) {
|
||||
const count = ~~response;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -38,12 +38,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore(response) {
|
||||
const count = ~~response;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -53,7 +53,7 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -122,16 +122,23 @@ const newsletter_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'duplicate',
|
||||
data: newsletter.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response.subject !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.subject
|
||||
)
|
||||
data: {
|
||||
id: newsletter.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.data.subject
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -15,8 +15,8 @@ const mailpoet_segments = window.mailpoet_segments || {};
|
||||
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
|
||||
|
||||
const messages = {
|
||||
onTrash(response) {
|
||||
const count = ~~response;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -26,12 +26,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete(response) {
|
||||
const count = ~~response;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -41,12 +41,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore(response) {
|
||||
const count = ~~response;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -56,7 +56,7 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -125,16 +125,23 @@ const newsletter_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'duplicate',
|
||||
data: newsletter.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response.subject !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.subject
|
||||
)
|
||||
data: {
|
||||
id: newsletter.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.data.subject
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -66,22 +66,22 @@ define(
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'get',
|
||||
data: id
|
||||
}).done((response) => {
|
||||
if(response === false) {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {},
|
||||
}, function() {
|
||||
this.context.router.push('/new');
|
||||
}.bind(this));
|
||||
} else {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response,
|
||||
fields: this.getFieldsByNewsletter(response),
|
||||
});
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).done((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response.data,
|
||||
fields: this.getFieldsByNewsletter(response.data)
|
||||
});
|
||||
}).fail((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {}
|
||||
}, () => {
|
||||
this.context.router.push('/new');
|
||||
});
|
||||
});
|
||||
},
|
||||
handleSend: function(e) {
|
||||
|
@ -40,11 +40,7 @@ define(
|
||||
return !!(!segment.deleted_at);
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
var name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
return name;
|
||||
return segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
},
|
||||
validation: {
|
||||
'data-parsley-required': true,
|
||||
|
@ -346,11 +346,7 @@ define(
|
||||
return !!(!segment.deleted_at);
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
var name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
return name;
|
||||
return segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
},
|
||||
validation: {
|
||||
'data-parsley-required': true,
|
||||
|
@ -28,17 +28,16 @@ define(
|
||||
type: type,
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.context.router.push(`/template/${response.newsletter.id}`);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.context.router.push(`/template/${response.data.id}`);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
|
@ -50,17 +50,16 @@ define(
|
||||
type: 'notification',
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}),
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${newsletterId}`);
|
||||
|
@ -25,19 +25,18 @@ define(
|
||||
endpoint: 'newsletters',
|
||||
action: 'create',
|
||||
data: {
|
||||
type: 'standard',
|
||||
type: 'standard'
|
||||
}
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
|
@ -27,10 +27,7 @@ const events = {
|
||||
const availableSegmentValues = _.object(_.map(
|
||||
availableSegments,
|
||||
function(segment) {
|
||||
let name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
let name = segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
return [segment.id, name];
|
||||
}
|
||||
));
|
||||
@ -113,17 +110,16 @@ const WelcomeScheduling = React.createClass({
|
||||
type: 'welcome',
|
||||
options: this.state
|
||||
}
|
||||
}).done(function(response) {
|
||||
if (response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${ newsletterId }`);
|
||||
|
@ -57,18 +57,17 @@ define(
|
||||
data: _.extend({}, this.state, {
|
||||
type: 'welcome',
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}),
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
})
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${newsletterId}`);
|
||||
|
@ -44,29 +44,36 @@ function(
|
||||
endpoint: 'subscribers',
|
||||
action: 'subscribe',
|
||||
data: data
|
||||
}).fail(function(response) {
|
||||
form.find('.mailpoet_validate_error').html(
|
||||
response.errors.map(function(error) {
|
||||
return error.message;
|
||||
}).join('<br />')
|
||||
).show();
|
||||
}).done(function(response) {
|
||||
if(response.result === false) {
|
||||
form.find('.mailpoet_validate_error').html(
|
||||
response.errors.join('<br />')
|
||||
).show();
|
||||
// successfully subscribed
|
||||
if (
|
||||
response.meta !== undefined
|
||||
&& response.meta.redirect_url !== undefined
|
||||
) {
|
||||
// go to page
|
||||
window.location.href = response.meta.redirect_url;
|
||||
} else {
|
||||
// successfully subscribed
|
||||
if(response.page !== undefined) {
|
||||
// go to page
|
||||
window.location.href = response.page;
|
||||
} else {
|
||||
// display success message
|
||||
form.find('.mailpoet_validate_success').show();
|
||||
}
|
||||
|
||||
// reset form
|
||||
form.trigger('reset');
|
||||
// reset validation
|
||||
parsley.reset();
|
||||
// display success message
|
||||
form.find('.mailpoet_validate_success').show();
|
||||
}
|
||||
|
||||
// reset form
|
||||
form.trigger('reset');
|
||||
// reset validation
|
||||
parsley.reset();
|
||||
|
||||
// resize iframe
|
||||
if(window.frameElement !== null) {
|
||||
if (
|
||||
window.frameElement !== null
|
||||
&& MailPoet !== undefined
|
||||
&& MailPoet['Iframe']
|
||||
) {
|
||||
MailPoet.Iframe.autoSize(window.frameElement);
|
||||
}
|
||||
});
|
||||
|
@ -36,48 +36,48 @@ var columns = [
|
||||
];
|
||||
|
||||
const messages = {
|
||||
onTrash: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentTrashed')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentDeleted')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentRestored')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -106,16 +106,23 @@ const item_actions = [
|
||||
{
|
||||
name: 'duplicate_segment',
|
||||
label: MailPoet.I18n.t('duplicate'),
|
||||
onClick: function(item, refresh) {
|
||||
onClick: (item, refresh) => {
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'segments',
|
||||
action: 'duplicate',
|
||||
data: item.id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: item.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('listDuplicated')).replace('%$1s', response.name)
|
||||
MailPoet.I18n.t('listDuplicated').replace('%$1s', response.data.name)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
display: function(segment) {
|
||||
@ -127,7 +134,7 @@ const item_actions = [
|
||||
link: function(item) {
|
||||
return (
|
||||
<a
|
||||
href="https://www.mailpoet.com/#TODO"
|
||||
href="http://docs.mailpoet.com/article/133-the-wordpress-users-list"
|
||||
target="_blank"
|
||||
>{MailPoet.I18n.t('readMore')}</a>
|
||||
);
|
||||
|
@ -75,6 +75,9 @@ define(
|
||||
filter: function(segment) {
|
||||
return !!(!segment.deleted_at && segment.type === 'default');
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
return segment.name + ' ('+ segment.subscribers +')';
|
||||
},
|
||||
getSearchLabel: function(segment, subscriber) {
|
||||
let label = '';
|
||||
|
||||
|
@ -7,7 +7,6 @@ define(
|
||||
'handlebars',
|
||||
'papaparse',
|
||||
'asyncqueue',
|
||||
'xss',
|
||||
'moment',
|
||||
'select2'
|
||||
],
|
||||
@ -19,7 +18,6 @@ define(
|
||||
Handlebars,
|
||||
Papa,
|
||||
AsyncQueue,
|
||||
xss,
|
||||
Moment
|
||||
) {
|
||||
if (!jQuery('#mailpoet_subscribers_import').length) {
|
||||
@ -337,9 +335,9 @@ define(
|
||||
complete: function (CSV) {
|
||||
for (var rowCount in CSV.data) {
|
||||
var rowData = CSV.data[rowCount].map(function (el) {
|
||||
return filterXSS(el.trim());
|
||||
}),
|
||||
rowColumnCount = rowData.length;
|
||||
return el.trim();
|
||||
});
|
||||
var rowColumnCount = rowData.length;
|
||||
// set the number of row elements based on the first non-empty row
|
||||
if (columnCount === null) {
|
||||
columnCount = rowColumnCount;
|
||||
@ -530,15 +528,11 @@ define(
|
||||
width: '20em',
|
||||
templateResult: function (item) {
|
||||
item.subscriberCount = parseInt(item.subscriberCount);
|
||||
return (item.subscriberCount > 0)
|
||||
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
|
||||
: item.name;
|
||||
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
item.subscriberCount = parseInt(item.subscriberCount);
|
||||
return (item.subscriberCount > 0)
|
||||
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
|
||||
: item.name;
|
||||
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
|
||||
}
|
||||
})
|
||||
.change(function () {
|
||||
@ -586,7 +580,8 @@ define(
|
||||
}).done(function(response) {
|
||||
mailpoetSegments.push({
|
||||
'id': response.data.id,
|
||||
'name': response.data.name
|
||||
'name': response.data.name,
|
||||
'subscriberCount': 0
|
||||
});
|
||||
|
||||
var selected_values = segmentSelectElement.val();
|
||||
@ -673,8 +668,15 @@ define(
|
||||
return options.fn(displayedColumns);
|
||||
});
|
||||
|
||||
// sanitize unsafe data
|
||||
Handlebars.registerHelper('sanitize_data', function(data) {
|
||||
return (data instanceof Handlebars.SafeString) ?
|
||||
data :
|
||||
new Handlebars.SafeString(Handlebars.Utils.escapeExpression(data));
|
||||
});
|
||||
|
||||
// start array index from 1
|
||||
Handlebars.registerHelper('show_real_index', function (index) {
|
||||
Handlebars.registerHelper('calculate_index', function (index) {
|
||||
var index = parseInt(index);
|
||||
// display filler data (e.g., ellipsis) if we've reached the maximum number of rows and
|
||||
// subscribers count is greater than the maximum number of rows we're displaying
|
||||
@ -883,7 +885,9 @@ define(
|
||||
jQuery(matchedColumn.element).data('validation-rule', validationRule);
|
||||
break;
|
||||
}
|
||||
if (validationRule === 'datetime') validationRule = Moment.ISO_8601;
|
||||
if (validationRule === 'datetime') {
|
||||
validationRule = Moment.ISO_8601;
|
||||
}
|
||||
}
|
||||
}
|
||||
jQuery.map(subscribersClone.subscribers, function (data, index) {
|
||||
@ -892,18 +896,22 @@ define(
|
||||
var date = Moment(rowData, testedFormat, true);
|
||||
// validate date
|
||||
if (date.isValid()) {
|
||||
data[matchedColumn.index] +=
|
||||
'<span class="mailpoet_data_match" title="'
|
||||
+ MailPoet.I18n.t('verifyDateMatch') + '">'
|
||||
+ MailPoet.Date.format(date)
|
||||
+ '</span>';
|
||||
data[matchedColumn.index] = new Handlebars.SafeString(
|
||||
Handlebars.Utils.escapeExpression(data[matchedColumn.index])
|
||||
+ '<span class="mailpoet_data_match" title="'
|
||||
+ MailPoet.I18n.t('verifyDateMatch') + '">'
|
||||
+ MailPoet.Date.format(date)
|
||||
+ '</span>'
|
||||
);
|
||||
}
|
||||
else {
|
||||
data[matchedColumn.index] +=
|
||||
'<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
data[matchedColumn.index] = new Handlebars.SafeString(
|
||||
Handlebars.Utils.escapeExpression(data[matchedColumn.index])
|
||||
+ '<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
|
||||
+ MailPoet.I18n.t('dateMatchError')
|
||||
+ '</span>';
|
||||
+ (new Handlebars.SafeString(MailPoet.I18n.t('dateMatchError')))
|
||||
+ '</span>'
|
||||
);
|
||||
preventNextStep = true;
|
||||
};
|
||||
});
|
||||
|
@ -37,59 +37,50 @@ const columns = [
|
||||
];
|
||||
|
||||
const messages = {
|
||||
onTrash: function(response) {
|
||||
if (response) {
|
||||
var message = null;
|
||||
if (~~response === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberTrashed')
|
||||
);
|
||||
} else if (~~response > 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersTrashed')
|
||||
).replace('%$1d', (~~response).toLocaleString());
|
||||
}
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (message !== null) {
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberTrashed')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersTrashed')
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete: function(response) {
|
||||
if (response) {
|
||||
var message = null;
|
||||
if (~~response === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberDeleted')
|
||||
);
|
||||
} else if (~~response > 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersDeleted')
|
||||
).replace('%$1d', ~~response);
|
||||
}
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (message !== null) {
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberDeleted')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersDeleted')
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore: function(response) {
|
||||
if (response) {
|
||||
var message = null;
|
||||
if (~~response === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberRestored')
|
||||
);
|
||||
} else if (~~response > 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersRestored')
|
||||
).replace('%$1d', (~~response).toLocaleString());
|
||||
}
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (message !== null) {
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberRestored')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersRestored')
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
};
|
||||
|
||||
@ -120,8 +111,8 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleSubscribersMovedToList')
|
||||
.replace('%$1d', (~~(response.subscribers)).toLocaleString())
|
||||
.replace('%$2s', response.segment)
|
||||
.replace('%$1d', (~~(response.meta.count)).toLocaleString())
|
||||
.replace('%$2s', response.meta.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -151,8 +142,8 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleSubscribersAddedToList')
|
||||
.replace('%$1d', (~~response.subscribers).toLocaleString())
|
||||
.replace('%$2s', response.segment)
|
||||
.replace('%$1d', (~~response.meta.count).toLocaleString())
|
||||
.replace('%$2s', response.meta.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -182,8 +173,8 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleSubscribersRemovedFromList')
|
||||
.replace('%$1d', (~~response.subscribers).toLocaleString())
|
||||
.replace('%$2s', response.segment)
|
||||
.replace('%$1d', (~~response.meta.count).toLocaleString())
|
||||
.replace('%$2s', response.meta.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -193,7 +184,7 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleSubscribersRemovedFromAllLists')
|
||||
.replace('%$1d', (~~response).toLocaleString())
|
||||
.replace('%$1d', (~~response.meta.count).toLocaleString())
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -203,7 +194,7 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleConfirmationEmailsSent')
|
||||
.replace('%$1d', (~~response).toLocaleString())
|
||||
.replace('%$1d', (~~response.meta.count).toLocaleString())
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -330,16 +321,23 @@ const SubscriberList = React.createClass({
|
||||
</div>
|
||||
);
|
||||
},
|
||||
onGetItems: function(count) {
|
||||
jQuery('#mailpoet_export_button')[(count > 0) ? 'show' : 'hide']();
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="title">
|
||||
{MailPoet.I18n.t('pageTitle')} <Link className="page-title-action" to="/new">{MailPoet.I18n.t('new')}</Link>
|
||||
<a className="page-title-action" href="?page=mailpoet-import#step1">{MailPoet.I18n.t('import')}</a>
|
||||
<a id="mailpoet_export_button" className="page-title-action" href="?page=mailpoet-export">{MailPoet.I18n.t('export')}</a>
|
||||
{MailPoet.I18n.t('pageTitle')} <Link
|
||||
className="page-title-action"
|
||||
to="/new"
|
||||
>{MailPoet.I18n.t('new')}</Link>
|
||||
<a
|
||||
className="page-title-action"
|
||||
href="?page=mailpoet-import#step1"
|
||||
>{MailPoet.I18n.t('import')}</a>
|
||||
<a
|
||||
id="mailpoet_export_button"
|
||||
className="page-title-action"
|
||||
href="?page=mailpoet-export"
|
||||
>{MailPoet.I18n.t('export')}</a>
|
||||
</h1>
|
||||
|
||||
<Listing
|
||||
@ -352,7 +350,6 @@ const SubscriberList = React.createClass({
|
||||
bulk_actions={ bulk_actions }
|
||||
item_actions={ item_actions }
|
||||
messages={ messages }
|
||||
onGetItems={ this.onGetItems }
|
||||
sort_by={ 'created_at' }
|
||||
sort_order={ 'desc' }
|
||||
/>
|
||||
|
23
build.sh
@ -1,5 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Translations (npm install & composer install need to be run before)
|
||||
./do makepot
|
||||
|
||||
plugin_name='mailpoet'
|
||||
|
||||
# Remove previous build.
|
||||
@ -14,10 +17,7 @@ npm install
|
||||
./do compile:all
|
||||
|
||||
# Production libraries.
|
||||
./composer.phar install --no-dev
|
||||
|
||||
# Translations
|
||||
./do makepot
|
||||
./composer.phar install --no-dev --prefer-dist --optimize-autoloader
|
||||
|
||||
# Copy release folders.
|
||||
cp -Rf lang $plugin_name
|
||||
@ -28,6 +28,21 @@ cp -Rf views $plugin_name
|
||||
rm -Rf $plugin_name/assets/css/src
|
||||
rm -Rf $plugin_name/assets/js/src
|
||||
|
||||
# Remove extra files (docs, examples,...) from 3rd party extensions
|
||||
find $plugin_name/vendor -type f -regextype posix-egrep -iregex ".*\/*\.(markdown|md|txt)" -print0 | xargs -0 rm -f
|
||||
find $plugin_name/vendor -type f -regextype posix-egrep -iregex ".*\/(readme|license|version|changes|changelog)" -print0 | xargs -0 rm -f
|
||||
find $plugin_name/vendor -type d -regextype posix-egrep -iregex ".*\/(docs?|examples?|\.git)" -print0 | xargs -0 rm -rf
|
||||
|
||||
# Remove unit tests from 3rd party extensions
|
||||
rm $plugin_name/vendor/j4mie/idiorm/demo.php
|
||||
rm -rf $plugin_name/vendor/twig/twig/test
|
||||
rm -rf $plugin_name/vendor/symfony/translation/Tests
|
||||
rm -rf $plugin_name/vendor/phpmailer/phpmailer/test
|
||||
rm -rf $plugin_name/vendor/soundasleep/html2text/tests
|
||||
rm -rf $plugin_name/vendor/mtdowling/cron-expression/tests
|
||||
rm -rf $plugin_name/vendor/swiftmailer/swiftmailer/tests
|
||||
rm -rf $plugin_name/vendor/cerdic/css-tidy/testing
|
||||
|
||||
# Copy release files.
|
||||
cp LICENSE $plugin_name
|
||||
cp index.php $plugin_name
|
||||
|
10
circle.yml
@ -8,9 +8,17 @@ machine:
|
||||
## Customize dependencies
|
||||
dependencies:
|
||||
pre:
|
||||
# install PHP dependencies for WordPress
|
||||
- sudo apt-get update
|
||||
- sudo apt-get --assume-yes install php5-mysql
|
||||
# configure Apache
|
||||
- sudo cp ./.circle_ci/apache/mailpoet.loc.conf /etc/apache2/sites-available
|
||||
- sudo a2ensite mailpoet.loc
|
||||
- sudo a2enmod rewrite
|
||||
- sudo service apache2 restart
|
||||
# install Phoenix dependencies
|
||||
- composer install
|
||||
- ./do install
|
||||
|
||||
# Set up Wordpress
|
||||
# No password is required for the MySQL user `ubuntu`
|
||||
- mysql -u ubuntu -e "create database wordpress"
|
||||
|
4160
lang/mailpoet.pot
@ -1,14 +1,10 @@
|
||||
<?php
|
||||
namespace MailPoet\API;
|
||||
|
||||
use \MailPoet\Util\Security;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class API {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function init() {
|
||||
// security token
|
||||
add_action(
|
||||
@ -27,32 +23,29 @@ class API {
|
||||
'wp_ajax_nopriv_mailpoet',
|
||||
array($this, 'setupPublic')
|
||||
);
|
||||
// Public API (Post)
|
||||
add_action(
|
||||
'admin_post_nopriv_mailpoet',
|
||||
array($this, 'setupPublic')
|
||||
);
|
||||
}
|
||||
|
||||
function setupAdmin() {
|
||||
if($this->checkToken() === false) {
|
||||
(new ErrorResponse(
|
||||
$error_response = new ErrorResponse(
|
||||
array(
|
||||
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
|
||||
Error::UNAUTHORIZED => __('You need to specify a valid API token.', 'mailpoet')
|
||||
),
|
||||
array(),
|
||||
Response::STATUS_UNAUTHORIZED
|
||||
))->send();
|
||||
);
|
||||
$error_response->send();
|
||||
}
|
||||
|
||||
if($this->checkPermissions() === false) {
|
||||
(new ErrorResponse(
|
||||
$error_response = new ErrorResponse(
|
||||
array(
|
||||
Error::FORBIDDEN => __('You do not have the required permissions.')
|
||||
Error::FORBIDDEN => __('You do not have the required permissions.', 'mailpoet')
|
||||
),
|
||||
array(),
|
||||
Response::STATUS_FORBIDDEN
|
||||
))->send();
|
||||
);
|
||||
$error_response->send();
|
||||
}
|
||||
|
||||
$this->processRoute();
|
||||
@ -60,13 +53,14 @@ class API {
|
||||
|
||||
function setupPublic() {
|
||||
if($this->checkToken() === false) {
|
||||
(new ErrorResponse(
|
||||
$error_response = new ErrorResponse(
|
||||
array(
|
||||
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
|
||||
Error::UNAUTHORIZED => __('You need to specify a valid API token.', 'mailpoet')
|
||||
),
|
||||
array(),
|
||||
Response::STATUS_UNAUTHORIZED
|
||||
))->send();
|
||||
);
|
||||
$error_response->send();
|
||||
}
|
||||
|
||||
$this->processRoute();
|
||||
@ -76,14 +70,7 @@ class API {
|
||||
$class = ucfirst($_POST['endpoint']);
|
||||
$endpoint = __NAMESPACE__ . "\\Endpoints\\" . $class;
|
||||
$method = $_POST['method'];
|
||||
|
||||
$doing_ajax = (bool)(defined('DOING_AJAX') && DOING_AJAX);
|
||||
|
||||
if($doing_ajax) {
|
||||
$data = isset($_POST['data']) ? stripslashes_deep($_POST['data']) : array();
|
||||
} else {
|
||||
$data = $_POST;
|
||||
}
|
||||
$data = isset($_POST['data']) ? stripslashes_deep($_POST['data']) : array();
|
||||
|
||||
if(is_array($data) && !empty($data)) {
|
||||
// filter out reserved keywords from data
|
||||
@ -99,18 +86,12 @@ class API {
|
||||
try {
|
||||
$endpoint = new $endpoint();
|
||||
$response = $endpoint->$method($data);
|
||||
|
||||
// TODO: remove this condition once the API unification is complete
|
||||
if(is_object($response)) {
|
||||
$response->send();
|
||||
} else {
|
||||
// LEGACY API
|
||||
wp_send_json($response);
|
||||
}
|
||||
$response->send();
|
||||
} catch(\Exception $e) {
|
||||
(new ErrorResponse(
|
||||
$error_response = new ErrorResponse(
|
||||
array($e->getCode() => $e->getMessage())
|
||||
))->send();
|
||||
);
|
||||
$error_response->send();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ abstract class Endpoint {
|
||||
) {
|
||||
if(empty($errors)) {
|
||||
$errors = array(
|
||||
Error::UNKNOWN => __('An unknown error occurred.')
|
||||
Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet')
|
||||
);
|
||||
}
|
||||
return new ErrorResponse($errors, $meta, $status);
|
||||
@ -25,7 +25,7 @@ abstract class Endpoint {
|
||||
function badRequest($errors = array(), $meta = array()) {
|
||||
if(empty($errors)) {
|
||||
$errors = array(
|
||||
Error::BAD_REQUEST => __('Invalid request parameters.')
|
||||
Error::BAD_REQUEST => __('Invalid request parameters.', 'mailpoet')
|
||||
);
|
||||
}
|
||||
return new ErrorResponse($errors, $meta, Response::STATUS_BAD_REQUEST);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ if(!defined('ABSPATH')) exit;
|
||||
|
||||
class CustomFields extends APIEndpoint {
|
||||
function getAll() {
|
||||
$collection = CustomField::findMany();
|
||||
$collection = CustomField::orderByAsc('created_at')->findMany();
|
||||
$custom_fields = array_map(function($custom_field) {
|
||||
return $custom_field->asArray();
|
||||
}, $collection);
|
||||
@ -21,7 +21,7 @@ class CustomFields extends APIEndpoint {
|
||||
$custom_field = CustomField::findOne($id);
|
||||
if($custom_field === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This custom field does not exist.')
|
||||
APIError::NOT_FOUND => __('This custom field does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$custom_field->delete();
|
||||
@ -48,7 +48,7 @@ class CustomFields extends APIEndpoint {
|
||||
$custom_field = CustomField::findOne($id);
|
||||
if($custom_field === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This custom field does not exist.')
|
||||
APIError::NOT_FOUND => __('This custom field does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse($custom_field->asArray());
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
use MailPoet\API\Endpoint as APIEndpoint;
|
||||
use MailPoet\API\Error as APIError;
|
||||
|
||||
use \MailPoet\Models\Form;
|
||||
use \MailPoet\Models\StatisticsForms;
|
||||
@ -9,16 +11,17 @@ use \MailPoet\Form\Util;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Forms {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function get($id = false) {
|
||||
class Forms extends APIEndpoint {
|
||||
function get($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
$form = $form->asArray();
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse($form->asArray());
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
function listing($data = array()) {
|
||||
@ -29,8 +32,8 @@ class Forms {
|
||||
|
||||
$listing_data = $listing->get();
|
||||
|
||||
// fetch segments relations for each returned item
|
||||
foreach($listing_data['items'] as $key => $form) {
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $form) {
|
||||
$form = $form->asArray();
|
||||
|
||||
$form['signups'] = StatisticsForms::getTotalSignups($form['id']);
|
||||
@ -40,40 +43,45 @@ class Forms {
|
||||
? $form['settings']['segments']
|
||||
: array()
|
||||
);
|
||||
$listing_data['items'][$key] = $form;
|
||||
|
||||
$data[] = $form;
|
||||
}
|
||||
|
||||
return $listing_data;
|
||||
return $this->successResponse($data, array(
|
||||
'count' => $listing_data['count'],
|
||||
'filters' => $listing_data['filters'],
|
||||
'groups' => $listing_data['groups']
|
||||
));
|
||||
}
|
||||
|
||||
function create() {
|
||||
// create new form
|
||||
$form_data = array(
|
||||
'name' => __('New form'),
|
||||
'name' => __('New form', 'mailpoet'),
|
||||
'body' => array(
|
||||
array(
|
||||
'id' => 'email',
|
||||
'name' => __('Email'),
|
||||
'name' => __('Email', 'mailpoet'),
|
||||
'type' => 'text',
|
||||
'static' => true,
|
||||
'params' => array(
|
||||
'label' => __('Email'),
|
||||
'label' => __('Email', 'mailpoet'),
|
||||
'required' => true
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'submit',
|
||||
'name' => __('Submit'),
|
||||
'name' => __('Submit', 'mailpoet'),
|
||||
'type' => 'submit',
|
||||
'static' => true,
|
||||
'params' => array(
|
||||
'label' => __('Subscribe!')
|
||||
'label' => __('Subscribe!', 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
'settings' => array(
|
||||
'on_success' => 'message',
|
||||
'success_message' => __('Check your inbox or spam folder to confirm your subscription.'),
|
||||
'success_message' => __('Check your inbox or spam folder to confirm your subscription.', 'mailpoet'),
|
||||
'segments' => null,
|
||||
'segments_selected_by' => 'admin'
|
||||
)
|
||||
@ -87,14 +95,10 @@ class Forms {
|
||||
$errors = $form->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $errors
|
||||
);
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
return array(
|
||||
'result' => true,
|
||||
'form_id' => $form->id()
|
||||
return $this->successResponse(
|
||||
Form::findOne($form->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -109,76 +113,74 @@ class Forms {
|
||||
// styles
|
||||
$css = new Util\Styles(FormRenderer::getStyles($data));
|
||||
|
||||
return array(
|
||||
return $this->successResponse(array(
|
||||
'html' => $html,
|
||||
'css' => $css->render()
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
function exportsEditor($id) {
|
||||
$exports = false;
|
||||
|
||||
function exportsEditor($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
|
||||
if($form !== false) {
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$exports = Util\Export::getAll($form->asArray());
|
||||
return $this->successResponse($exports);
|
||||
}
|
||||
|
||||
return $exports;
|
||||
}
|
||||
|
||||
function saveEditor($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
|
||||
$form_id = (isset($data['id']) ? (int)$data['id'] : 0);
|
||||
$name = (isset($data['name']) ? $data['name'] : __('New form'));
|
||||
$name = (isset($data['name']) ? $data['name'] : __('New form', 'mailpoet'));
|
||||
$body = (isset($data['body']) ? $data['body'] : array());
|
||||
$settings = (isset($data['settings']) ? $data['settings'] : array());
|
||||
$styles = (isset($data['styles']) ? $data['styles'] : '');
|
||||
|
||||
if(empty($body) || empty($settings)) {
|
||||
// error
|
||||
return false;
|
||||
} else {
|
||||
// check if the form is used as a widget
|
||||
$is_widget = false;
|
||||
$widgets = get_option('widget_mailpoet_form');
|
||||
if(!empty($widgets)) {
|
||||
foreach($widgets as $widget) {
|
||||
if(isset($widget['form']) && (int)$widget['form'] === $form_id) {
|
||||
$is_widget = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if the user gets to pick his own lists
|
||||
// or if it's selected by the admin
|
||||
$has_segment_selection = false;
|
||||
|
||||
foreach($body as $i => $block) {
|
||||
if($block['type'] === 'segment') {
|
||||
$has_segment_selection = true;
|
||||
if(!empty($block['params']['values'])) {
|
||||
$list_selection = array_filter(
|
||||
array_map(function($segment) {
|
||||
return (isset($segment['id'])
|
||||
? (int)$segment['id']
|
||||
: null
|
||||
);
|
||||
}, $block['params']['values'])
|
||||
);
|
||||
}
|
||||
// check if the form is used as a widget
|
||||
$is_widget = false;
|
||||
$widgets = get_option('widget_mailpoet_form');
|
||||
if(!empty($widgets)) {
|
||||
foreach($widgets as $widget) {
|
||||
if(isset($widget['form']) && (int)$widget['form'] === $form_id) {
|
||||
$is_widget = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check list selection
|
||||
if($has_segment_selection === true) {
|
||||
$settings['segments_selected_by'] = 'user';
|
||||
} else {
|
||||
$settings['segments_selected_by'] = 'admin';
|
||||
// check if the user gets to pick his own lists
|
||||
// or if it's selected by the admin
|
||||
$has_segment_selection = false;
|
||||
foreach($body as $i => $block) {
|
||||
if($block['type'] === 'segment') {
|
||||
$has_segment_selection = true;
|
||||
if(!empty($block['params']['values'])) {
|
||||
$list_selection = array_filter(
|
||||
array_map(function($segment) {
|
||||
return (isset($segment['id'])
|
||||
? $segment['id']
|
||||
: null
|
||||
);
|
||||
}, $block['params']['values'])
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// check list selection
|
||||
if($has_segment_selection === true) {
|
||||
$settings['segments_selected_by'] = 'user';
|
||||
$settings['segments'] = $list_selection;
|
||||
} else {
|
||||
$settings['segments_selected_by'] = 'admin';
|
||||
}
|
||||
|
||||
$form = Form::createOrUpdate(array(
|
||||
'id' => $form_id,
|
||||
'name' => $name,
|
||||
@ -187,64 +189,101 @@ class Forms {
|
||||
'styles' => $styles
|
||||
));
|
||||
|
||||
if($form->getErrors() === false) {
|
||||
return array(
|
||||
'result' => true,
|
||||
'is_widget' => $is_widget
|
||||
);
|
||||
$errors = $form->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $form->getErrors()
|
||||
return $this->successResponse(
|
||||
Form::findOne($form->id)->asArray(),
|
||||
array('is_widget' => $is_widget)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($id) {
|
||||
function restore($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$form->restore();
|
||||
}
|
||||
return ($form->getErrors() === false);
|
||||
}
|
||||
|
||||
function trash($id) {
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
$form->trash();
|
||||
}
|
||||
return ($form->getErrors() === false);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
$form->delete();
|
||||
return 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function duplicate($id) {
|
||||
$result = false;
|
||||
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
$data = array(
|
||||
'name' => sprintf(__('Copy of %s'), $form->name)
|
||||
return $this->successResponse(
|
||||
Form::findOne($form->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
$result = $form->duplicate($data)->asArray();
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
function trash($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$form->trash();
|
||||
return $this->successResponse(
|
||||
Form::findOne($form->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function delete($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$form->delete();
|
||||
return $this->successResponse(null, array('count' => 1));
|
||||
}
|
||||
}
|
||||
|
||||
function duplicate($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$data = array(
|
||||
'name' => sprintf(__('Copy of %s', 'mailpoet'), $form->name)
|
||||
);
|
||||
$duplicate = $form->duplicate($data);
|
||||
$errors = $duplicate->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->errorResponse($errors);
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
Form::findOne($duplicate->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bulkAction($data = array()) {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Form',
|
||||
$data
|
||||
);
|
||||
|
||||
return $bulk_action->apply();
|
||||
try {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Form',
|
||||
$data
|
||||
);
|
||||
$meta = $bulk_action->apply();
|
||||
return $this->successResponse(null, $meta);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class Mailer extends APIEndpoint {
|
||||
|
||||
if($result === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::BAD_REQUEST => __("The email could not be sent. Please check your settings.")
|
||||
APIError::BAD_REQUEST => __("The email could not be sent. Please check your settings.", 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse(null);
|
||||
|
@ -13,7 +13,7 @@ class NewsletterTemplates extends APIEndpoint {
|
||||
$template = NewsletterTemplate::findOne($id);
|
||||
if($template === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This template does not exist.')
|
||||
APIError::NOT_FOUND => __('This template does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
@ -49,7 +49,7 @@ class NewsletterTemplates extends APIEndpoint {
|
||||
$template = NewsletterTemplate::findOne($id);
|
||||
if($template === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This template does not exist.')
|
||||
APIError::NOT_FOUND => __('This template does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$template->delete();
|
||||
|
@ -22,19 +22,20 @@ if(!defined('ABSPATH')) exit;
|
||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
class Newsletters extends APIEndpoint {
|
||||
function get($id = false) {
|
||||
function get($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
if($newsletter === false) {
|
||||
return false;
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$segments = $newsletter->segments()->findArray();
|
||||
$options = $newsletter->options()->findArray();
|
||||
$newsletter = $newsletter->asArray();
|
||||
$newsletter['segments'] = array_map(function($segment) {
|
||||
return $segment['id'];
|
||||
}, $segments);
|
||||
$newsletter['options'] = Helpers::arrayColumn($options, 'value', 'name');
|
||||
return $newsletter;
|
||||
return $this->successResponse(
|
||||
$newsletter
|
||||
->withSegments()
|
||||
->withOptions()
|
||||
->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,19 +97,20 @@ class Newsletters extends APIEndpoint {
|
||||
}
|
||||
|
||||
function setStatus($data = array()) {
|
||||
$id = (isset($data['id'])) ? (int)$data['id'] : false;
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
$status = (isset($data['status']) ? $data['status'] : null);
|
||||
|
||||
if(!$status) {
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST => __('You need to specify a status.')
|
||||
APIError::BAD_REQUEST => __('You need to specify a status.', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
$id = (isset($data['id'])) ? (int)$data['id'] : false;
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.')
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
@ -119,143 +121,178 @@ class Newsletters extends APIEndpoint {
|
||||
return $this->errorResponse($errors);
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
$newsletter->asArray()
|
||||
Newsletter::findOne($newsletter->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($id) {
|
||||
function restore($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
if($newsletter !== false) {
|
||||
$newsletter->restore();
|
||||
}
|
||||
return ($newsletter->getErrors() === false);
|
||||
}
|
||||
|
||||
function trash($id) {
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
if($newsletter !== false) {
|
||||
$newsletter->trash();
|
||||
}
|
||||
return ($newsletter->getErrors() === false);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
if($newsletter !== false) {
|
||||
$newsletter->delete();
|
||||
return 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function duplicate($id = false) {
|
||||
$result = false;
|
||||
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
if($newsletter !== false) {
|
||||
$duplicate = $newsletter->duplicate(array(
|
||||
'subject' => sprintf(__('Copy of %s'), $newsletter->subject)
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$newsletter->restore();
|
||||
return $this->successResponse(
|
||||
Newsletter::findOne($newsletter->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if($duplicate !== false && $duplicate->getErrors() === false) {
|
||||
$result = $duplicate->asArray();
|
||||
function trash($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$newsletter->trash();
|
||||
return $this->successResponse(
|
||||
Newsletter::findOne($newsletter->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function delete($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$newsletter->delete();
|
||||
return $this->successResponse(null, array('count' => 1));
|
||||
}
|
||||
}
|
||||
|
||||
function duplicate($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$data = array(
|
||||
'subject' => sprintf(__('Copy of %s', 'mailpoet'), $newsletter->subject)
|
||||
);
|
||||
$duplicate = $newsletter->duplicate($data);
|
||||
$errors = $duplicate->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->errorResponse($errors);
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
Newsletter::findOne($duplicate->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function showPreview($data = array()) {
|
||||
if(!isset($data['body'])) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => array(__('Newsletter data is missing'))
|
||||
);
|
||||
if(empty($data['body'])) {
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST => __('Newsletter data is missing.', 'mailpoet')
|
||||
));
|
||||
}
|
||||
$newsletter_id = (isset($data['id'])) ? (int)$data['id'] : null;
|
||||
$newsletter = Newsletter::findOne($newsletter_id);
|
||||
if(!$newsletter) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => array(__('Newsletter could not be read'))
|
||||
);
|
||||
}
|
||||
$newsletter->body = $data['body'];
|
||||
$newsletter->save();
|
||||
$subscriber = Subscriber::getCurrentWPUser();
|
||||
$preview_url = NewsletterUrl::getViewInBrowserUrl(
|
||||
$data, $subscriber, $queue = false, $preview = true
|
||||
);
|
||||
return array(
|
||||
'result' => true,
|
||||
'data' => array('url' => $preview_url)
|
||||
);
|
||||
}
|
||||
|
||||
function sendPreview($data = array()) {
|
||||
$id = (isset($data['id'])) ? (int)$data['id'] : false;
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
|
||||
if($newsletter === false) {
|
||||
return array(
|
||||
'result' => false
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$newsletter->body = $data['body'];
|
||||
$newsletter->save();
|
||||
$subscriber = Subscriber::getCurrentWPUser();
|
||||
$preview_url = NewsletterUrl::getViewInBrowserUrl(
|
||||
$data, $subscriber, $queue = false, $preview = true
|
||||
);
|
||||
}
|
||||
if(empty($data['subscriber'])) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => array(__('Please specify receiver information.'))
|
||||
);
|
||||
}
|
||||
|
||||
$newsletter = $newsletter->asArray();
|
||||
|
||||
$renderer = new Renderer($newsletter, $preview = true);
|
||||
$rendered_newsletter = $renderer->render();
|
||||
$divider = '***MailPoet***';
|
||||
$data_for_shortcodes =
|
||||
array_merge(array($newsletter['subject']), $rendered_newsletter);
|
||||
$body = implode($divider, $data_for_shortcodes);
|
||||
|
||||
$subscriber = Subscriber::getCurrentWPUser();
|
||||
$subscriber = ($subscriber) ? $subscriber->asArray() : false;
|
||||
|
||||
$shortcodes = new \MailPoet\Newsletter\Shortcodes\Shortcodes(
|
||||
$newsletter,
|
||||
$subscriber
|
||||
);
|
||||
list($newsletter['subject'],
|
||||
$newsletter['body']['html'],
|
||||
$newsletter['body']['text']
|
||||
) = explode($divider, $shortcodes->replace($body));
|
||||
|
||||
try {
|
||||
$mailer = new \MailPoet\Mailer\Mailer(
|
||||
$mailer = false,
|
||||
$sender = false,
|
||||
$reply_to = false
|
||||
);
|
||||
$result = $mailer->send($newsletter, $data['subscriber']);
|
||||
|
||||
return array('result' => $result);
|
||||
} catch(\Exception $e) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => array($e->getMessage()),
|
||||
return $this->successResponse(
|
||||
Newsletter::findOne($newsletter->id)->asArray(),
|
||||
array('preview_url' => $preview_url)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function listing($data = array()) {
|
||||
function sendPreview($data = array()) {
|
||||
if(empty($data['subscriber'])) {
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST => __('Please specify receiver information.', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
$id = (isset($data['id'])) ? (int)$data['id'] : false;
|
||||
$newsletter = Newsletter::findOne($id);
|
||||
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$newsletter = $newsletter->asArray();
|
||||
|
||||
$renderer = new Renderer($newsletter, $preview = true);
|
||||
$rendered_newsletter = $renderer->render();
|
||||
$divider = '***MailPoet***';
|
||||
$data_for_shortcodes = array_merge(
|
||||
array($newsletter['subject']),
|
||||
$rendered_newsletter
|
||||
);
|
||||
|
||||
$body = implode($divider, $data_for_shortcodes);
|
||||
|
||||
$subscriber = Subscriber::getCurrentWPUser();
|
||||
$subscriber = ($subscriber) ? $subscriber->asArray() : false;
|
||||
|
||||
$shortcodes = new \MailPoet\Newsletter\Shortcodes\Shortcodes(
|
||||
$newsletter,
|
||||
$subscriber
|
||||
);
|
||||
list(
|
||||
$newsletter['subject'],
|
||||
$newsletter['body']['html'],
|
||||
$newsletter['body']['text']
|
||||
) = explode($divider, $shortcodes->replace($body));
|
||||
|
||||
try {
|
||||
$mailer = new \MailPoet\Mailer\Mailer(
|
||||
$mailer = false,
|
||||
$sender = false,
|
||||
$reply_to = false
|
||||
);
|
||||
$mailer->send($newsletter, $data['subscriber']);
|
||||
return $this->successResponse(
|
||||
Newsletter::findOne($id)->asArray()
|
||||
);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function listing($data = array()) {
|
||||
$listing = new Listing\Handler(
|
||||
'\MailPoet\Models\Newsletter',
|
||||
$data
|
||||
);
|
||||
$listing_data = $listing->get();
|
||||
$subscriber = Subscriber::getCurrentWPUser();
|
||||
|
||||
foreach($listing_data['items'] as $key => $newsletter) {
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $newsletter) {
|
||||
$queue = false;
|
||||
|
||||
if($newsletter->type === Newsletter::TYPE_STANDARD) {
|
||||
@ -287,22 +324,33 @@ class Newsletters extends APIEndpoint {
|
||||
}
|
||||
|
||||
// get preview url
|
||||
$subscriber = Subscriber::getCurrentWPUser();
|
||||
$newsletter->preview_url = NewsletterUrl::getViewInBrowserUrl(
|
||||
$newsletter, $subscriber, $queue, $preview = true);
|
||||
|
||||
// convert object to array
|
||||
$listing_data['items'][$key] = $newsletter->asArray();
|
||||
$data[] = $newsletter->asArray();
|
||||
}
|
||||
|
||||
return $listing_data;
|
||||
return $this->successResponse($data, array(
|
||||
'count' => $listing_data['count'],
|
||||
'filters' => $listing_data['filters'],
|
||||
'groups' => $listing_data['groups']
|
||||
));
|
||||
}
|
||||
|
||||
function bulkAction($data = array()) {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Newsletter',
|
||||
$data
|
||||
);
|
||||
return $bulk_action->apply();
|
||||
try {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Newsletter',
|
||||
$data
|
||||
);
|
||||
$meta = $bulk_action->apply();
|
||||
return $this->successResponse(null, $meta);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function create($data = array()) {
|
||||
@ -313,23 +361,25 @@ class Newsletters extends APIEndpoint {
|
||||
}
|
||||
|
||||
$newsletter = Newsletter::createOrUpdate($data);
|
||||
$errors = $newsletter->getErrors();
|
||||
|
||||
// try to load template data
|
||||
$template_id = (!empty($data['template']) ? (int)$data['template'] : false);
|
||||
$template = NewsletterTemplate::findOne($template_id);
|
||||
if($template !== false) {
|
||||
$newsletter->body = $template->body;
|
||||
if(!empty($errors)) {
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
$newsletter->body = array();
|
||||
// try to load template data
|
||||
$template_id = (isset($data['template']) ? (int)$data['template'] : false);
|
||||
$template = NewsletterTemplate::findOne($template_id);
|
||||
if($template === false) {
|
||||
$newsletter->body = array();
|
||||
} else {
|
||||
$newsletter->body = $template->body;
|
||||
}
|
||||
}
|
||||
|
||||
$newsletter->save();
|
||||
$errors = $newsletter->getErrors();
|
||||
if(!empty($errors)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' =>$errors
|
||||
);
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
if(!empty($options)) {
|
||||
$option_fields = NewsletterOptionField::where(
|
||||
@ -346,15 +396,20 @@ class Newsletters extends APIEndpoint {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isset($data['id']) &&
|
||||
isset($data['type']) &&
|
||||
$data['type'] === 'notification'
|
||||
|
||||
if(
|
||||
empty($data['id'])
|
||||
&&
|
||||
isset($data['type'])
|
||||
&&
|
||||
$data['type'] === Newsletter::TYPE_NOTIFICATION
|
||||
) {
|
||||
Scheduler::processPostNotificationSchedule($newsletter->id);
|
||||
$newsletter = Newsletter::filter('filterWithOptions')->findOne($newsletter->id);
|
||||
Scheduler::processPostNotificationSchedule($newsletter);
|
||||
}
|
||||
return array(
|
||||
'result' => true,
|
||||
'newsletter' => $newsletter->asArray()
|
||||
|
||||
return $this->successResponse(
|
||||
Newsletter::findOne($newsletter->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
use \MailPoet\API\Endpoint as APIEndpoint;
|
||||
use \MailPoet\API\Error as APIError;
|
||||
|
||||
use \MailPoet\Models\Segment;
|
||||
use \MailPoet\Models\SubscriberSegment;
|
||||
@ -9,16 +11,16 @@ use \MailPoet\Segments\WP;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Segments {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function get($id = false) {
|
||||
class Segments extends APIEndpoint {
|
||||
function get($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment === false) {
|
||||
return false;
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $segment->asArray();
|
||||
return $this->successResponse($segment->asArray());
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,18 +32,22 @@ class Segments {
|
||||
|
||||
$listing_data = $listing->get();
|
||||
|
||||
// fetch segments relations for each returned item
|
||||
foreach($listing_data['items'] as $key => $segment) {
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $segment) {
|
||||
$segment->subscribers_url = admin_url(
|
||||
'admin.php?page=mailpoet-subscribers#/filter[segment='.$segment->id.']'
|
||||
);
|
||||
|
||||
$listing_data['items'][$key] = $segment
|
||||
$data[] = $segment
|
||||
->withSubscribersCount()
|
||||
->asArray();
|
||||
}
|
||||
|
||||
return $listing_data;
|
||||
return $this->successResponse($data, array(
|
||||
'count' => $listing_data['count'],
|
||||
'filters' => $listing_data['filters'],
|
||||
'groups' => $listing_data['groups']
|
||||
));
|
||||
}
|
||||
|
||||
function save($data = array()) {
|
||||
@ -49,68 +55,109 @@ class Segments {
|
||||
$errors = $segment->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $errors
|
||||
);
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
return array(
|
||||
'result' => true
|
||||
return $this->successResponse(
|
||||
Segment::findOne($segment->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($id) {
|
||||
function restore($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment !== false) {
|
||||
if($segment === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$segment->restore();
|
||||
}
|
||||
return ($segment->getErrors() === false);
|
||||
}
|
||||
|
||||
function trash($id) {
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment !== false) {
|
||||
$segment->trash();
|
||||
}
|
||||
return ($segment->getErrors() === false);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment !== false) {
|
||||
$segment->delete();
|
||||
return 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function duplicate($id) {
|
||||
$result = false;
|
||||
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment !== false) {
|
||||
$data = array(
|
||||
'name' => sprintf(__('Copy of %s'), $segment->name)
|
||||
return $this->successResponse(
|
||||
Segment::findOne($segment->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
$result = $segment->duplicate($data)->asArray();
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
function trash($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$segment->trash();
|
||||
return $this->successResponse(
|
||||
Segment::findOne($segment->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function delete($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$segment->delete();
|
||||
return $this->successResponse(null, array('count' => 1));
|
||||
}
|
||||
}
|
||||
|
||||
function duplicate($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
|
||||
if($segment === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$data = array(
|
||||
'name' => sprintf(__('Copy of %s', 'mailpoet'), $segment->name)
|
||||
);
|
||||
$duplicate = $segment->duplicate($data);
|
||||
$errors = $duplicate->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->errorResponse($errors);
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
Segment::findOne($duplicate->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function synchronize() {
|
||||
$result = WP::synchronizeUsers();
|
||||
try {
|
||||
WP::synchronizeUsers();
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->successResponse(null);
|
||||
}
|
||||
|
||||
function bulkAction($data = array()) {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Segment',
|
||||
$data
|
||||
);
|
||||
|
||||
return $bulk_action->apply();
|
||||
try {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Segment',
|
||||
$data
|
||||
);
|
||||
$meta = $bulk_action->apply();
|
||||
return $this->successResponse(null, $meta);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class SendingQueue extends APIEndpoint {
|
||||
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.')
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ class SendingQueue extends APIEndpoint {
|
||||
|
||||
if(!empty($queue)) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter is already being sent.')
|
||||
APIError::NOT_FOUND => __('This newsletter is already being sent.', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class SendingQueue extends APIEndpoint {
|
||||
|
||||
// set queue status
|
||||
$queue->status = SendingQueueModel::STATUS_SCHEDULED;
|
||||
$queue->scheduled_at = Scheduler::scheduleFromTimestamp(
|
||||
$queue->scheduled_at = Scheduler::formatDatetimeString(
|
||||
$newsletter->scheduledAt
|
||||
);
|
||||
$queue->subscribers = null;
|
||||
@ -83,7 +83,7 @@ class SendingQueue extends APIEndpoint {
|
||||
$subscribers = array_unique($subscribers);
|
||||
if(!count($subscribers)) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::UNKNOWN => __('There are no subscribers in that list!')
|
||||
APIError::UNKNOWN => __('There are no subscribers in that list!', 'mailpoet')
|
||||
));
|
||||
}
|
||||
$queue->status = null;
|
||||
@ -119,14 +119,14 @@ class SendingQueue extends APIEndpoint {
|
||||
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.')
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$queue = $newsletter->getQueue();
|
||||
|
||||
if($queue === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::UNKNOWN => __('This newsletter has not been sent yet.')
|
||||
APIError::UNKNOWN => __('This newsletter has not been sent yet.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$queue->pause();
|
||||
@ -145,14 +145,14 @@ class SendingQueue extends APIEndpoint {
|
||||
$newsletter = Newsletter::findOne($newsletter_id);
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.')
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$queue = $newsletter->getQueue();
|
||||
|
||||
if($queue === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::UNKNOWN => __('This newsletter has not been sent yet.')
|
||||
APIError::UNKNOWN => __('This newsletter has not been sent yet.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$queue->resume();
|
||||
|
@ -15,7 +15,7 @@ class Settings extends APIEndpoint {
|
||||
if(empty($settings)) {
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST =>
|
||||
__("You have not specified any settings to be saved.")
|
||||
__("You have not specified any settings to be saved.", 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
use \MailPoet\API\Endpoint as APIEndpoint;
|
||||
use \MailPoet\API\Error as APIError;
|
||||
|
||||
use MailPoet\Listing;
|
||||
use MailPoet\Models\Subscriber;
|
||||
@ -9,23 +11,25 @@ use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Models\Form;
|
||||
use MailPoet\Models\StatisticsForms;
|
||||
use MailPoet\Util\Url;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Subscribers {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function get($id = null) {
|
||||
class Subscribers extends APIEndpoint {
|
||||
function get($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$subscriber = Subscriber::findOne($id);
|
||||
if($subscriber !== false) {
|
||||
$subscriber = $subscriber
|
||||
->withCustomFields()
|
||||
->withSubscriptions()
|
||||
->asArray();
|
||||
if($subscriber === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
$subscriber
|
||||
->withCustomFields()
|
||||
->withSubscriptions()
|
||||
->asArray()
|
||||
);
|
||||
}
|
||||
return $subscriber;
|
||||
}
|
||||
|
||||
function listing($data = array()) {
|
||||
@ -36,41 +40,24 @@ class Subscribers {
|
||||
|
||||
$listing_data = $listing->get();
|
||||
|
||||
// fetch segments relations for each returned item
|
||||
foreach($listing_data['items'] as $key => $subscriber) {
|
||||
$listing_data['items'][$key] = $subscriber
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $subscriber) {
|
||||
$data[] = $subscriber
|
||||
->withSubscriptions()
|
||||
->asArray();
|
||||
}
|
||||
|
||||
return $listing_data;
|
||||
}
|
||||
|
||||
function save($data = array()) {
|
||||
$subscriber = Subscriber::createOrUpdate($data);
|
||||
$errors = $subscriber->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $errors
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'result' => true
|
||||
);
|
||||
}
|
||||
return $this->successResponse($data, array(
|
||||
'count' => $listing_data['count'],
|
||||
'filters' => $listing_data['filters'],
|
||||
'groups' => $listing_data['groups']
|
||||
));
|
||||
}
|
||||
|
||||
function subscribe($data = array()) {
|
||||
$doing_ajax = (bool)(defined('DOING_AJAX') && DOING_AJAX);
|
||||
$errors = array();
|
||||
|
||||
$form = Form::findOne($data['form_id']);
|
||||
$form_id = (isset($data['form_id']) ? (int)$data['form_id'] : false);
|
||||
$form = Form::findOne($form_id);
|
||||
unset($data['form_id']);
|
||||
if($form === false || !$form->id()) {
|
||||
$errors[] = __('This form does not exist');
|
||||
}
|
||||
|
||||
$segment_ids = (!empty($data['segments'])
|
||||
? (array)$data['segments']
|
||||
@ -79,106 +66,110 @@ class Subscribers {
|
||||
unset($data['segments']);
|
||||
|
||||
if(empty($segment_ids)) {
|
||||
$errors[] = __('Please select a list');
|
||||
}
|
||||
|
||||
if(!empty($errors)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $errors
|
||||
);
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST => __('Please select a list', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
$subscriber = Subscriber::subscribe($data, $segment_ids);
|
||||
$errors = $subscriber->getErrors();
|
||||
$result = ($errors === false && $subscriber->id() > 0);
|
||||
|
||||
// record form statistics
|
||||
if($result === true && $form !== false && $form->id > 0) {
|
||||
StatisticsForms::record($form->id, $subscriber->id);
|
||||
}
|
||||
if($errors !== false) {
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
$meta = array();
|
||||
|
||||
// get success message to display after subscription
|
||||
$form_settings = (
|
||||
isset($form->settings)
|
||||
? unserialize($form->settings)
|
||||
: null
|
||||
);
|
||||
if($form !== false) {
|
||||
// record form statistics
|
||||
StatisticsForms::record($form->id, $subscriber->id);
|
||||
|
||||
if($form_settings !== null) {
|
||||
switch($form_settings['on_success']) {
|
||||
case 'page':
|
||||
$success_page_url = get_permalink($form_settings['success_page']);
|
||||
$form = $form->asArray();
|
||||
|
||||
// response depending on context
|
||||
if($doing_ajax === true) {
|
||||
return array(
|
||||
'result' => $result,
|
||||
'page' => $success_page_url,
|
||||
'errors' => $errors
|
||||
);
|
||||
} else {
|
||||
if($result === false) {
|
||||
Url::redirectBack();
|
||||
} else {
|
||||
Url::redirectTo($success_page_url);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'message':
|
||||
default:
|
||||
// response depending on context
|
||||
if($doing_ajax === true) {
|
||||
return array(
|
||||
'result' => $result,
|
||||
'errors' => $errors
|
||||
);
|
||||
} else {
|
||||
$params = (
|
||||
($result === true)
|
||||
? array('mailpoet_success' => $form->id)
|
||||
: array()
|
||||
);
|
||||
|
||||
Url::redirectBack($params);
|
||||
}
|
||||
break;
|
||||
if($form['settings']['on_success'] === 'page') {
|
||||
// redirect to a page on a success, pass the page url in the meta
|
||||
$meta['redirect_url'] = get_permalink($form['settings']['success_page']);
|
||||
} else if($form['settings']['on_success'] === 'url') {
|
||||
$meta['redirect_url'] = $form['settings']['success_url'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->successResponse(
|
||||
Subscriber::findOne($subscriber->id)->asArray(),
|
||||
$meta
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($id) {
|
||||
function save($data = array()) {
|
||||
$subscriber = Subscriber::createOrUpdate($data);
|
||||
$errors = $subscriber->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
Subscriber::findOne($subscriber->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$subscriber = Subscriber::findOne($id);
|
||||
if($subscriber !== false) {
|
||||
if($subscriber === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$subscriber->restore();
|
||||
return $this->successResponse(
|
||||
Subscriber::findOne($subscriber->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
return ($subscriber->getErrors() === false);
|
||||
}
|
||||
|
||||
function trash($id) {
|
||||
function trash($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$subscriber = Subscriber::findOne($id);
|
||||
if($subscriber !== false) {
|
||||
if($subscriber === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$subscriber->trash();
|
||||
return $this->successResponse(
|
||||
Subscriber::findOne($subscriber->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
return ($subscriber->getErrors() === false);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
function delete($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$subscriber = Subscriber::findOne($id);
|
||||
if($subscriber !== false) {
|
||||
if($subscriber === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$subscriber->delete();
|
||||
return 1;
|
||||
return $this->successResponse(null, array('count' => 1));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function bulkAction($data = array()) {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Subscriber',
|
||||
$data
|
||||
);
|
||||
|
||||
return $bulk_action->apply();
|
||||
try {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Subscriber',
|
||||
$data
|
||||
);
|
||||
$meta = $bulk_action->apply();
|
||||
return $this->successResponse(null, $meta);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ abstract class Response {
|
||||
$response = array_merge($response, $data);
|
||||
}
|
||||
|
||||
if(empty($response)) {
|
||||
die();
|
||||
} else {
|
||||
wp_send_json($response);
|
||||
if(!empty($response)) {
|
||||
@header('Content-Type: application/json; charset='.get_option('blog_charset'));
|
||||
echo wp_json_encode($response);
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
abstract function getData();
|
||||
|
@ -27,6 +27,7 @@ class Env {
|
||||
static $db_password;
|
||||
static $db_charset;
|
||||
static $db_timezone_offset;
|
||||
static $subscribers_limit = 2000;
|
||||
|
||||
static function init($file, $version) {
|
||||
global $wpdb;
|
||||
|
@ -91,6 +91,16 @@ class Hooks {
|
||||
'admin_post_nopriv_mailpoet_subscription_update',
|
||||
'\MailPoet\Subscription\Manage::onSave'
|
||||
);
|
||||
|
||||
// Subscription form
|
||||
add_action(
|
||||
'admin_post_mailpoet_subscription_form',
|
||||
'\MailPoet\Subscription\Form::onSubmit'
|
||||
);
|
||||
add_action(
|
||||
'admin_post_nopriv_mailpoet_subscription_form',
|
||||
'\MailPoet\Subscription\Form::onSubmit'
|
||||
);
|
||||
}
|
||||
|
||||
function setupWPUsers() {
|
||||
@ -138,7 +148,7 @@ class Hooks {
|
||||
|
||||
function appendImageSize($sizes) {
|
||||
return array_merge($sizes, array(
|
||||
'mailpoet_newsletter_max' => __('MailPoet Newsletter')
|
||||
'mailpoet_newsletter_max' => __('MailPoet Newsletter', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -192,8 +192,11 @@ class Initializer {
|
||||
}
|
||||
|
||||
function setupCronTrigger() {
|
||||
$cron_trigger = new CronTrigger();
|
||||
$cron_trigger->init();
|
||||
// setup cron trigger only outside of cli environment
|
||||
if(php_sapi_name() !== 'cli') {
|
||||
$cron_trigger = new CronTrigger();
|
||||
$cron_trigger->init();
|
||||
}
|
||||
}
|
||||
|
||||
function setupImages() {
|
||||
|
@ -25,8 +25,6 @@ class Localizer {
|
||||
$language_path =
|
||||
Env::$languages_path
|
||||
. '/'
|
||||
. Env::$plugin_name
|
||||
. '-'
|
||||
. $this->locale()
|
||||
. '.mo';
|
||||
load_textdomain(Env::$plugin_name, $language_path);
|
||||
|
@ -34,6 +34,16 @@ class Menu {
|
||||
);
|
||||
}
|
||||
|
||||
function checkSubscribersLimit() {
|
||||
$subscribers_count = Subscriber::getTotalSubscribers();
|
||||
if($subscribers_count > Env::$subscribers_limit) {
|
||||
echo $this->renderer->render('limit.html', array(
|
||||
'limit' => Env::$subscribers_limit
|
||||
));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function setup() {
|
||||
$main_page_slug = 'mailpoet-newsletters';
|
||||
|
||||
@ -49,8 +59,8 @@ class Menu {
|
||||
|
||||
$newsletters_page = add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Newsletters')),
|
||||
__('Newsletters'),
|
||||
$this->setPageTitle(__('Newsletters', 'mailpoet')),
|
||||
__('Newsletters', 'mailpoet'),
|
||||
'manage_options',
|
||||
$main_page_slug,
|
||||
array($this, 'newsletters')
|
||||
@ -69,8 +79,8 @@ class Menu {
|
||||
|
||||
$forms_page = add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Forms')),
|
||||
__('Forms'),
|
||||
$this->setPageTitle(__('Forms', 'mailpoet')),
|
||||
__('Forms', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-forms',
|
||||
array($this, 'forms')
|
||||
@ -88,8 +98,8 @@ class Menu {
|
||||
|
||||
$subscribers_page = add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Subscribers')),
|
||||
__('Subscribers'),
|
||||
$this->setPageTitle(__('Subscribers', 'mailpoet')),
|
||||
__('Subscribers', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-subscribers',
|
||||
array($this, 'subscribers')
|
||||
@ -107,8 +117,8 @@ class Menu {
|
||||
|
||||
$segments_page = add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Lists')),
|
||||
__('Lists'),
|
||||
$this->setPageTitle(__('Lists', 'mailpoet')),
|
||||
__('Lists', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-segments',
|
||||
array($this, 'segments')
|
||||
@ -127,16 +137,16 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle( __('Settings')),
|
||||
__('Settings'),
|
||||
$this->setPageTitle( __('Settings', 'mailpoet')),
|
||||
__('Settings', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-settings',
|
||||
array($this, 'settings')
|
||||
);
|
||||
add_submenu_page(
|
||||
'admin.php?page=mailpoet-subscribers',
|
||||
$this->setPageTitle( __('Import')),
|
||||
__('Import'),
|
||||
$this->setPageTitle( __('Import', 'mailpoet')),
|
||||
__('Import', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-import',
|
||||
array($this, 'import')
|
||||
@ -144,8 +154,8 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Export')),
|
||||
__('Export'),
|
||||
$this->setPageTitle(__('Export', 'mailpoet')),
|
||||
__('Export', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-export',
|
||||
array($this, 'export')
|
||||
@ -153,8 +163,8 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Welcome')),
|
||||
__('Welcome'),
|
||||
$this->setPageTitle(__('Welcome', 'mailpoet')),
|
||||
__('Welcome', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-welcome',
|
||||
array($this, 'welcome')
|
||||
@ -162,8 +172,8 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Update')),
|
||||
__('Update'),
|
||||
$this->setPageTitle(__('Update', 'mailpoet')),
|
||||
__('Update', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-update',
|
||||
array($this, 'update')
|
||||
@ -171,8 +181,8 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Form Editor')),
|
||||
__('Form Editor'),
|
||||
$this->setPageTitle(__('Form Editor', 'mailpoet')),
|
||||
__('Form Editor', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-form-editor',
|
||||
array($this, 'formEditor')
|
||||
@ -180,21 +190,12 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Newsletter')),
|
||||
__('Newsletter Editor'),
|
||||
$this->setPageTitle(__('Newsletter', 'mailpoet')),
|
||||
__('Newsletter Editor', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-newsletter-editor',
|
||||
array($this, 'newletterEditor')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Cron')),
|
||||
__('Cron'),
|
||||
'manage_options',
|
||||
'mailpoet-cron',
|
||||
array($this, 'cron')
|
||||
);
|
||||
}
|
||||
|
||||
function welcome() {
|
||||
@ -251,12 +252,14 @@ class Menu {
|
||||
}
|
||||
|
||||
function settings() {
|
||||
$this->checkSubscribersLimit();
|
||||
|
||||
$settings = Setting::getAll();
|
||||
$flags = $this->_getFlags();
|
||||
|
||||
$data = array(
|
||||
'settings' => $settings,
|
||||
'segments' => Segment::getPublic()->findArray(),
|
||||
'segments' => Segment::getSegmentsWithSubscriberCount(),
|
||||
'cron_trigger' => CronTrigger::getAvailableMethods(),
|
||||
'pages' => Pages::getAll(),
|
||||
'flags' => $flags,
|
||||
@ -300,7 +303,7 @@ class Menu {
|
||||
$data = array();
|
||||
|
||||
$data['items_per_page'] = $this->getLimitPerPage('subscribers');
|
||||
$data['segments'] = Segment::findArray();
|
||||
$data['segments'] = Segment::getSegmentsWithSubscriberCount($type = false);
|
||||
|
||||
$data['custom_fields'] = array_map(function($field) {
|
||||
$field['params'] = unserialize($field['params']);
|
||||
@ -323,12 +326,16 @@ class Menu {
|
||||
}
|
||||
|
||||
function segments() {
|
||||
$this->checkSubscribersLimit();
|
||||
|
||||
$data = array();
|
||||
$data['items_per_page'] = $this->getLimitPerPage('segments');
|
||||
echo $this->renderer->render('segments.html', $data);
|
||||
}
|
||||
|
||||
function forms() {
|
||||
$this->checkSubscribersLimit();
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['items_per_page'] = $this->getLimitPerPage('forms');
|
||||
@ -338,6 +345,8 @@ class Menu {
|
||||
}
|
||||
|
||||
function newsletters() {
|
||||
$this->checkSubscribersLimit();
|
||||
|
||||
global $wp_roles;
|
||||
|
||||
$data = array();
|
||||
@ -346,7 +355,7 @@ class Menu {
|
||||
$data['segments'] = Segment::getSegmentsWithSubscriberCount($type = false);
|
||||
$data['settings'] = Setting::getAll();
|
||||
$data['roles'] = $wp_roles->get_names();
|
||||
$data['roles']['mailpoet_all'] = __('In any WordPress role');
|
||||
$data['roles']['mailpoet_all'] = __('In any WordPress role', 'mailpoet');
|
||||
|
||||
$date_time = new DateTime();
|
||||
$data['current_date'] = $date_time->getCurrentDate(DateTime::DEFAULT_DATE_FORMAT);
|
||||
@ -407,7 +416,7 @@ class Menu {
|
||||
$data = array(
|
||||
'form' => $form,
|
||||
'pages' => Pages::getAll(),
|
||||
'segments' => Segment::getPublic()->findArray(),
|
||||
'segments' => Segment::getSegmentsWithSubscriberCount(),
|
||||
'styles' => FormRenderer::getStyles($form),
|
||||
'date_types' => Block\Date::getDateTypes(),
|
||||
'date_formats' => Block\Date::getDateFormats(),
|
||||
@ -418,14 +427,10 @@ class Menu {
|
||||
echo $this->renderer->render('form/editor.html', $data);
|
||||
}
|
||||
|
||||
function cron() {
|
||||
echo $this->renderer->render('cron.html');
|
||||
}
|
||||
|
||||
function setPageTitle($title) {
|
||||
return sprintf(
|
||||
'%s - %s',
|
||||
__('MailPoet'),
|
||||
__('MailPoet', 'mailpoet'),
|
||||
$title
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,6 @@
|
||||
<?php
|
||||
namespace MailPoet\Config;
|
||||
|
||||
use MailPoet\Config\PopulatorData\Templates\FranksRoastHouseTemplate;
|
||||
use MailPoet\Config\PopulatorData\Templates\NewsletterBlank1Column;
|
||||
use MailPoet\Config\PopulatorData\Templates\NewsletterBlank12Column;
|
||||
use MailPoet\Config\PopulatorData\Templates\NewsletterBlank121Column;
|
||||
use MailPoet\Config\PopulatorData\Templates\NewsletterBlank13Column;
|
||||
use MailPoet\Config\PopulatorData\Templates\PostNotificationsBlank1Column;
|
||||
use MailPoet\Config\PopulatorData\Templates\WelcomeBlank1Column;
|
||||
use MailPoet\Config\PopulatorData\Templates\WelcomeBlank12Column;
|
||||
use MailPoet\Config\PopulatorData\Templates\SimpleText;
|
||||
use MailPoet\Cron\CronTrigger;
|
||||
use \MailPoet\Models\Segment;
|
||||
use \MailPoet\Segments\WP;
|
||||
@ -22,12 +13,31 @@ if(!defined('ABSPATH')) exit;
|
||||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
||||
|
||||
class Populator {
|
||||
public $prefix;
|
||||
public $models;
|
||||
public $templates;
|
||||
const TEMPLATES_NAMESPACE = '\MailPoet\Config\PopulatorData\Templates\\';
|
||||
|
||||
function __construct() {
|
||||
$this->prefix = Env::$db_prefix;
|
||||
$this->models = array(
|
||||
'newsletter_option_fields',
|
||||
'newsletter_templates',
|
||||
);
|
||||
$this->templates = array(
|
||||
"FranksRoastHouseTemplate",
|
||||
"NewsletterBlank1Column",
|
||||
"NewsletterBlank12Column",
|
||||
"NewsletterBlank121Column",
|
||||
"NewsletterBlank13Column",
|
||||
"PostNotificationsBlank1Column",
|
||||
"WelcomeBlank1Column",
|
||||
"WelcomeBlank12Column",
|
||||
"SimpleText",
|
||||
"Restaurant",
|
||||
"StoreDiscount",
|
||||
"TravelEmail"
|
||||
);
|
||||
}
|
||||
|
||||
function up() {
|
||||
@ -104,6 +114,10 @@ class Populator {
|
||||
'reply_to' => $sender
|
||||
));
|
||||
}
|
||||
|
||||
if(!Setting::getValue('installed_at')) {
|
||||
Setting::setValue('installed_at', date("Y-m-d H:i:s"));
|
||||
}
|
||||
}
|
||||
|
||||
private function createDefaultSegments() {
|
||||
@ -117,9 +131,9 @@ class Populator {
|
||||
if(Segment::where('type', 'default')->count() === 0) {
|
||||
$default_segment = Segment::create();
|
||||
$default_segment->hydrate(array(
|
||||
'name' => __('My First List'),
|
||||
'name' => __('My First List', 'mailpoet'),
|
||||
'description' =>
|
||||
__('This list is automatically created when you install MailPoet')
|
||||
__('This list is automatically created when you install MailPoet', 'mailpoet')
|
||||
));
|
||||
$default_segment->save();
|
||||
}
|
||||
@ -184,17 +198,13 @@ class Populator {
|
||||
}
|
||||
|
||||
private function newsletterTemplates() {
|
||||
return array(
|
||||
(new FranksRoastHouseTemplate(Env::$assets_url))->get(),
|
||||
(new NewsletterBlank1Column(Env::$assets_url))->get(),
|
||||
(new NewsletterBlank12Column(Env::$assets_url))->get(),
|
||||
(new NewsletterBlank121Column(Env::$assets_url))->get(),
|
||||
(new NewsletterBlank13Column(Env::$assets_url))->get(),
|
||||
(new PostNotificationsBlank1Column(Env::$assets_url))->get(),
|
||||
(new WelcomeBlank1Column(Env::$assets_url))->get(),
|
||||
(new WelcomeBlank12Column(Env::$assets_url))->get(),
|
||||
(new SimpleText(Env::$assets_url))->get(),
|
||||
);
|
||||
$templates = array();
|
||||
foreach($this->templates as $template) {
|
||||
$template = self::TEMPLATES_NAMESPACE . $template;
|
||||
$template = new $template(Env::$assets_url);
|
||||
$templates[] = $template->get();
|
||||
}
|
||||
return $templates;
|
||||
}
|
||||
|
||||
private function populate($model) {
|
||||
|
@ -7,14 +7,14 @@ class FranksRoastHouseTemplate {
|
||||
|
||||
function __construct($assets_url) {
|
||||
$this->assets_url = $assets_url;
|
||||
$this->template_image_url = $this->assets_url . '/img/sample_template';
|
||||
$this->template_image_url = $this->assets_url . '/img/sample_templates/coffee';
|
||||
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
||||
}
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Frank's Roast House"),
|
||||
'description' => __("Think of this as your sandbox. Play around with this example newsletter to see what MailPoet can do for you."),
|
||||
'name' => __("Frank's Roast House", 'mailpoet'),
|
||||
'description' => __("Think of this as your sandbox. Play around with this example newsletter to see what MailPoet can do for you.", 'mailpoet'),
|
||||
'readonly' => 0,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -46,7 +46,7 @@ class FranksRoastHouseTemplate {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser.</a>"),
|
||||
"text" => __("<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser.</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "#ccc6c6"
|
||||
@ -67,7 +67,7 @@ class FranksRoastHouseTemplate {
|
||||
"type" => "image",
|
||||
"link" => "http://www.example.com",
|
||||
"src" => $this->template_image_url . "/header-v2.jpg",
|
||||
"alt" => __("Frank's Café"),
|
||||
"alt" => __("Frank's Café", 'mailpoet'),
|
||||
"fullWidth" => true,
|
||||
"width" => "600px",
|
||||
"height" => "220px",
|
||||
@ -88,13 +88,13 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>Hi there [subscriber:firstname | default:coffee drinker]</p>\n<p></p>\n<p>Sit back and enjoy your favorite roast as you read this week's newsletter. </p>")
|
||||
"text" => __("<p>Hi there [subscriber:firstname | default:coffee drinker]</p>\n<p></p>\n<p>Sit back and enjoy your favorite roast as you read this week's newsletter. </p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "image",
|
||||
"link" => "http://example.org",
|
||||
"src" => $this->template_image_url . "/coffee-grain.jpg",
|
||||
"alt" => __("coffee-grain-3-1329675-1599x941"),
|
||||
"alt" => __('Coffee grain', 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "1599px",
|
||||
"height" => "777px",
|
||||
@ -106,7 +106,7 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\">--- Guest Coffee Roaster: <em>Brew Bros. ---</em></h1>\n<p><em></em></p>\n<p>Visit our Center Avenue store to try the latest guest coffee from Brew Bros, a local coffee roaster. This young duo started only two years ago, but have quickly gained popularity through pop-up shops, local events, and collaborations with food trucks.</p>\n<p></p>\n<blockquote>\n<p><span style=\"color: #ff6600;\"><em>Tasting notes: A rich, caramel flavor with subtle hints of molasses. The perfect wake-up morning espresso!</em></span></p>\n</blockquote>")
|
||||
"text" => __("<h1 style=\"text-align: center;\">--- Guest Coffee Roaster: <em>Brew Bros. ---</em></h1>\n<p><em></em></p>\n<p>Visit our Center Avenue store to try the latest guest coffee from Brew Bros, a local coffee roaster. This young duo started only two years ago, but have quickly gained popularity through pop-up shops, local events, and collaborations with food trucks.</p>\n<p></p>\n<blockquote>\n<p><span style=\"color: #ff6600;\"><em>Tasting notes: A rich, caramel flavor with subtle hints of molasses. The perfect wake-up morning espresso!</em></span></p>\n</blockquote>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -132,13 +132,13 @@ class FranksRoastHouseTemplate {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>Sandwich Competition</h2>")
|
||||
"text" => __("<h2>Sandwich Competition</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "image",
|
||||
"link" => "http://example.org",
|
||||
"src" => $this->template_image_url . "/sandwich.jpg",
|
||||
"alt" => "sandwich",
|
||||
"alt" => __('Sandwich', 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "640px",
|
||||
"height" => "344px",
|
||||
@ -150,7 +150,7 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>Have an idea for the Next Great Sandwich? Tell us! We're offering free lunch for a month if you can invent an awesome new sandwich for our menu.</p>\n<p></p>\n<p></p>\n<p>Simply tweet your ideas to <a href=\"http://www.example.com\" title=\"This isn't a real twitter account\">@franksroasthouse</a> and use #sandwichcomp and we'll let you know if you're a winner.</p>")
|
||||
"text" => __("<p>Have an idea for the Next Great Sandwich? Tell us! We're offering free lunch for a month if you can invent an awesome new sandwich for our menu.</p>\n<p></p>\n<p></p>\n<p>Simply tweet your ideas to <a href=\"http://www.example.com\" title=\"This isn't a real twitter account\">@franksroasthouse</a> and use #sandwichcomp and we'll let you know if you're a winner.</p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "button",
|
||||
@ -175,7 +175,7 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3 style=\"text-align: center;\">Follow Us</h3>")
|
||||
"text" => __("<h3 style=\"text-align: center;\">Follow Us</h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "social",
|
||||
@ -232,13 +232,13 @@ class FranksRoastHouseTemplate {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>New Store Opening!</h2>")
|
||||
"text" => __("<h2>New Store Opening!</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "image",
|
||||
"link" => "http://example.org",
|
||||
"src" => $this->template_image_url . "/map-v2.jpg",
|
||||
"alt" => __("map-v2"),
|
||||
"alt" => __('Map', 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "636px",
|
||||
"height" => "342px",
|
||||
@ -250,11 +250,11 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>Watch out Broad Street, we're coming to you very soon! </p>\n<p></p>\n<p>Keep an eye on your inbox, as we'll have some special offers for our email subscribers plus an exclusive launch party invite!<br /><br /></p>")
|
||||
"text" => __("<p>Watch out Broad Street, we're coming to you very soon! </p>\n<p></p>\n<p>Keep an eye on your inbox, as we'll have some special offers for our email subscribers plus an exclusive launch party invite!<br /><br /></p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>New and Improved Hours!</h2>\n<p></p>\n<p>Frank's is now open even later, so you can get your caffeine fix all day (and night) long! Here's our new opening hours:</p>\n<p></p>\n<ul>\n<li>Monday - Thursday: 6am - 12am</li>\n<li>Friday - Saturday: 6am - 1:30am</li>\n<li>Sunday: 7:30am - 11pm</li>\n</ul>")
|
||||
"text" => __("<h2>New and Improved Hours!</h2>\n<p></p>\n<p>Frank's is now open even later, so you can get your caffeine fix all day (and night) long! Here's our new opening hours:</p>\n<p></p>\n<ul>\n<li>Monday - Thursday: 6am - 12am</li>\n<li>Friday - Saturday: 6am - 1:30am</li>\n<li>Sunday: 7:30am - 11pm</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -280,7 +280,7 @@ class FranksRoastHouseTemplate {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a><br />12345 MailPoet Drive, EmailVille, 76543</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a><br />12345 MailPoet Drive, EmailVille, 76543</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "#a9a7a7"
|
||||
|
@ -13,8 +13,8 @@ class NewsletterBlank121Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Newsletter: Blank 1:2:1 Column"),
|
||||
'description' => __("A blank Newsletter template with a 1:2:1 column layout."),
|
||||
'name' => __("Newsletter: Blank 1:2:1 Column", 'mailpoet'),
|
||||
'description' => __("A blank Newsletter template with a 1:2:1 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class NewsletterBlank121Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class NewsletterBlank121Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake logo"),
|
||||
"alt" => __("Fake logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class NewsletterBlank121Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started!</strong></h1>\n<p>It's time to design your newsletter! On the right sidebar, you'll find four menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started!</strong></h1>\n<p>It's time to design your newsletter! On the right sidebar, you'll find four menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "divider",
|
||||
@ -154,11 +154,11 @@ class NewsletterBlank121Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>This template has...</h2>")
|
||||
"text" => __("<h2>This template has...</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>In the right sidebar, you can add layout blocks to your email:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>")
|
||||
"text" => __("<p>In the right sidebar, you can add layout blocks to your email:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -173,11 +173,11 @@ class NewsletterBlank121Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>... a 2-column layout.</h2>")
|
||||
"text" => __("<h2>... a 2-column layout.</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>You can change a layout's background color by clicking on the settings icon on the right edge of the Designer. Simply hover over this area to see the Settings (gear) icon.</p>")
|
||||
"text" => __("<p>You can change a layout's background color by clicking on the settings icon on the right edge of the Designer. Simply hover over this area to see the Settings (gear) icon.</p>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -237,7 +237,7 @@ class NewsletterBlank121Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3 style=\"text-align: center;\"><span style=\"font-weight: 600;\">Let's end with a single column. </span></h3>\n<p style=\"line-height: 25.6px;\">In the right sidebar, you can add these layout blocks to your email:</p>\n<p style=\"line-height: 25.6px;\"></p>\n<ul style=\"line-height: 25.6px;\">\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>")
|
||||
"text" => __("<h3 style=\"text-align: center;\"><span style=\"font-weight: 600;\">Let's end with a single column. </span></h3>\n<p style=\"line-height: 25.6px;\">In the right sidebar, you can add these layout blocks to your email:</p>\n<p style=\"line-height: 25.6px;\"></p>\n<ul style=\"line-height: 25.6px;\">\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -311,7 +311,7 @@ class NewsletterBlank121Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
@ -13,8 +13,8 @@ class NewsletterBlank12Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Newsletter: Blank 1:2 Column"),
|
||||
'description' => __("A blank Newsletter template with a 1:2 column layout."),
|
||||
'name' => __("Newsletter: Blank 1:2 Column", 'mailpoet'),
|
||||
'description' => __("A blank Newsletter template with a 1:2 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class NewsletterBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class NewsletterBlank12Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake Logo"),
|
||||
"alt" => __("Fake Logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class NewsletterBlank12Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started!</strong></h1>\n<p></p>\n<p>It's time to design your newsletter! In the right sidebar, you'll find 4 menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started!</strong></h1>\n<p></p>\n<p>It's time to design your newsletter! In the right sidebar, you'll find 4 menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "divider",
|
||||
@ -154,11 +154,11 @@ class NewsletterBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>This template has...</h2>")
|
||||
"text" => __("<h2>This template has...</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>In the right sidebar, you can add these layout blocks to your email:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>")
|
||||
"text" => __("<p>In the right sidebar, you can add these layout blocks to your email:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -173,11 +173,11 @@ class NewsletterBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>... a 2-column layout.</h2>")
|
||||
"text" => __("<h2>... a 2-column layout.</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p><span style=\"line-height: 25.6px;\">You can change a layout's background color by clicking on the settings icon on the right edge of the Designer. Simply hover over this area to see the Settings (gear) icon.</span></p>")
|
||||
"text" => __("<p><span style=\"line-height: 25.6px;\">You can change a layout's background color by clicking on the settings icon on the right edge of the Designer. Simply hover over this area to see the Settings (gear) icon.</span></p>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -251,7 +251,7 @@ class NewsletterBlank12Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
@ -13,8 +13,8 @@ class NewsletterBlank13Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Newsletter: Blank 1:3 Column"),
|
||||
'description' => __("A blank Newsletter template with a 1:3 column layout."),
|
||||
'name' => __("Newsletter: Blank 1:3 Column", 'mailpoet'),
|
||||
'description' => __("A blank Newsletter template with a 1:3 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class NewsletterBlank13Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class NewsletterBlank13Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake logo"),
|
||||
"alt" => __("Fake logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class NewsletterBlank13Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started! </strong></h1>\n<p></p>\n<p>It's time to design your newsletter! On the right sidebar, you'll find four menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started! </strong></h1>\n<p></p>\n<p>It's time to design your newsletter! On the right sidebar, you'll find four menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "divider",
|
||||
@ -154,11 +154,11 @@ class NewsletterBlank13Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3>This template... </h3>")
|
||||
"text" => __("<h3>This template... </h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>In the right sidebar, you can add layout blocks to your newsletter.</p>")
|
||||
"text" => __("<p>In the right sidebar, you can add layout blocks to your newsletter.</p>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -173,11 +173,11 @@ class NewsletterBlank13Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3>... has a... </h3>")
|
||||
"text" => __("<h3>... has a... </h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>You have the choice of:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>")
|
||||
"text" => __("<p>You have the choice of:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -192,11 +192,11 @@ class NewsletterBlank13Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3>3-column layout.</h3>")
|
||||
"text" => __("<h3>3-column layout.</h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>You can add as many layout blocks as you want!</p>")
|
||||
"text" => __("<p>You can add as many layout blocks as you want!</p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
@ -274,7 +274,7 @@ class NewsletterBlank13Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
@ -13,8 +13,8 @@ class NewsletterBlank1Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Newsletter: Blank 1 Column"),
|
||||
'description' => __("A blank Newsletter template with a 1 column layout."),
|
||||
'name' => __("Newsletter: Blank 1 Column", 'mailpoet'),
|
||||
'description' => __("A blank Newsletter template with a 1 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class NewsletterBlank1Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class NewsletterBlank1Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake logo"),
|
||||
"alt" => __("Fake logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class NewsletterBlank1Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started! </strong></h1>\n<p></p>\n<p>It's time to design your newsletter! In the right sidebar, you'll find 4 menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started! </strong></h1>\n<p></p>\n<p>It's time to design your newsletter! In the right sidebar, you'll find 4 menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -190,7 +190,7 @@ class NewsletterBlank1Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
@ -13,8 +13,8 @@ class PostNotificationsBlank1Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Post Notifications: Blank 1 Column"),
|
||||
'description' => __("A blank Post Notifications template with a 1 column layout."),
|
||||
'name' => __("Post Notifications: Blank 1 Column", 'mailpoet'),
|
||||
'description' => __("A blank Post Notifications template with a 1 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class PostNotificationsBlank1Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -116,7 +116,7 @@ class PostNotificationsBlank1Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Check Out Our New Blog Posts! </strong></h1>\n<p></p>\n<p>MailPoet can <span style=\"line-height: 1.6em; background-color: inherit;\"><em>automatically</em> </span><span style=\"line-height: 1.6em; background-color: inherit;\">send your new blog posts to your subscribers.</span></p>\n<p><span style=\"line-height: 1.6em; background-color: inherit;\"></span></p>\n<p><span style=\"line-height: 1.6em; background-color: inherit;\">Below, you'll find three recent posts, which are displayed automatically, thanks to the <em>Automatic Latest Content</em> widget, which can be found on the right sidebar, under <em>Content</em>.</span></p>\n<p><span style=\"line-height: 1.6em; background-color: inherit;\"></span></p>\n<p><span style=\"line-height: 1.6em; background-color: inherit;\">To edit the settings and styles of your post, simply click on a post below.</span></p>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Check Out Our New Blog Posts! </strong></h1>\n<p></p>\n<p>MailPoet can <span style=\"line-height: 1.6em; background-color: inherit;\"><em>automatically</em> </span><span style=\"line-height: 1.6em; background-color: inherit;\">send your new blog posts to your subscribers.</span></p>\n<p><span style=\"line-height: 1.6em; background-color: inherit;\"></span></p>\n<p><span style=\"line-height: 1.6em; background-color: inherit;\">Below, you'll find three recent posts, which are displayed automatically, thanks to the <em>Automatic Latest Content</em> widget, which can be found on the right sidebar, under <em>Content</em>.</span></p>\n<p><span style=\"line-height: 1.6em; background-color: inherit;\"></span></p>\n<p><span style=\"line-height: 1.6em; background-color: inherit;\">To edit the settings and styles of your post, simply click on a post below.</span></p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "divider",
|
||||
@ -174,14 +174,14 @@ class PostNotificationsBlank1Column {
|
||||
"imageFullWidth" => false,
|
||||
"featuredImagePosition" => "belowTitle",
|
||||
"showAuthor" => "no",
|
||||
"authorPrecededBy" => __("Author:"),
|
||||
"authorPrecededBy" => __("Author:", 'mailpoet'),
|
||||
"showCategories" => "no",
|
||||
"categoriesPrecededBy" => __("Categories:"),
|
||||
"categoriesPrecededBy" => __("Categories:", 'mailpoet'),
|
||||
"readMoreType" => "button",
|
||||
"readMoreText" => "Read more",
|
||||
"readMoreButton" => array(
|
||||
"type" => "button",
|
||||
"text" => __("Read the post"),
|
||||
"text" => __("Read the post", 'mailpoet'),
|
||||
"url" => "[postLink]",
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
@ -298,7 +298,7 @@ class PostNotificationsBlank1Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
412
lib/Config/PopulatorData/Templates/Restaurant.php
Normal file
@ -13,8 +13,8 @@ class SimpleText {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Simple Text"),
|
||||
'description' => __("A simple plain text template - just like a regular email."),
|
||||
'name' => __("Simple Text", 'mailpoet'),
|
||||
'description' => __("A simple plain text template - just like a regular email.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -63,7 +63,7 @@ class SimpleText {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake logo"),
|
||||
"alt" => __("Fake logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -75,7 +75,7 @@ class SimpleText {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p style=\"text-align: left;\">Hi [subscriber:firstname | default:subscriber],</p>\n<p style=\"text-align: left;\"></p>\n<p style=\"text-align: left;\">In MailPoet, you can write emails in plain text, just like in a regular email. This can make your email newsletters more personal and attention-grabbing.</p>\n<p style=\"text-align: left;\"></p>\n<p style=\"text-align: left;\">Is this too simple? You can still style your text with basic formatting, like <strong>bold</strong> or <em>italics.</em></p>\n<p style=\"text-align: left;\"></p>\n<p style=\"text-align: left;\">Finally, you can also add a call-to-action button between 2 blocks of text, like this:</p>")
|
||||
"text" => __("<p style=\"text-align: left;\">Hi [subscriber:firstname | default:subscriber],</p>\n<p style=\"text-align: left;\"></p>\n<p style=\"text-align: left;\">In MailPoet, you can write emails in plain text, just like in a regular email. This can make your email newsletters more personal and attention-grabbing.</p>\n<p style=\"text-align: left;\"></p>\n<p style=\"text-align: left;\">Is this too simple? You can still style your text with basic formatting, like <strong>bold</strong> or <em>italics.</em></p>\n<p style=\"text-align: left;\"></p>\n<p style=\"text-align: left;\">Finally, you can also add a call-to-action button between 2 blocks of text, like this:</p>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -110,7 +110,7 @@ class SimpleText {
|
||||
),
|
||||
array(
|
||||
"type" => "button",
|
||||
"text" => __("It's time to take action!"),
|
||||
"text" => __("It's time to take action!", 'mailpoet'),
|
||||
"url" => "",
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
@ -131,11 +131,11 @@ class SimpleText {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>Thanks for reading. See you soon!</p>\n<p></p>\n<p><strong><em>The MailPoet Team</em></strong></p>")
|
||||
"text" => __("<p>Thanks for reading. See you soon!</p>\n<p></p>\n<p><strong><em>The MailPoet Team</em></strong></p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
405
lib/Config/PopulatorData/Templates/StoreDiscount.php
Normal file
526
lib/Config/PopulatorData/Templates/TravelEmail.php
Normal file
@ -13,8 +13,8 @@ class WelcomeBlank12Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Welcome Email: Blank 1:2 Column"),
|
||||
'description' => __("A blank Welcome Email template with a 1:2 column layout."),
|
||||
'name' => __("Welcome Email: Blank 1:2 Column", 'mailpoet'),
|
||||
'description' => __("A blank Welcome Email template with a 1:2 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class WelcomeBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class WelcomeBlank12Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake logo"),
|
||||
"alt" => __("Fake logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class WelcomeBlank12Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Hi, new subscriber!</strong></h1>\n<p></p>\n<p>[subscriber:firstname | default:Subscriber],</p>\n<p></p>\n<p>You recently joined our list and we'd like to give you a warm welcome!</p>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Hi, new subscriber!</strong></h1>\n<p></p>\n<p>[subscriber:firstname | default:Subscriber],</p>\n<p></p>\n<p>You recently joined our list and we'd like to give you a warm welcome!</p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "divider",
|
||||
@ -163,11 +163,11 @@ class WelcomeBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3>Our Most Popular Posts</h3>")
|
||||
"text" => __("<h3>Our Most Popular Posts</h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<ul>\n<li><a href=\"http://www.mailpoet.com/the-importance-of-focus-when-writing/\">The Importance of Focus When Writing</a></li>\n<li><a href=\"http://www.mailpoet.com/write-great-subject-line/\">How to Write a Great Subject Line</a></li>\n<li><a href=\"http://www.mailpoet.com/just-sit-write-advice-motivation-ernest-hemingway/\">Just Sit Down and Write – Advice on Motivation from Ernest Hemingway</a></li>\n</ul>")
|
||||
"text" => __("<ul>\n<li><a href=\"http://www.mailpoet.com/the-importance-of-focus-when-writing/\">The Importance of Focus When Writing</a></li>\n<li><a href=\"http://www.mailpoet.com/write-great-subject-line/\">How to Write a Great Subject Line</a></li>\n<li><a href=\"http://www.mailpoet.com/just-sit-write-advice-motivation-ernest-hemingway/\">Just Sit Down and Write – Advice on Motivation from Ernest Hemingway</a></li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -182,15 +182,15 @@ class WelcomeBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3>What's Next?</h3>")
|
||||
"text" => __("<h3>What's Next?</h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>Add a single button to your newsletter in order to have one clear call-to-action, which will increase your click rates.</p>")
|
||||
"text" => __("<p>Add a single button to your newsletter in order to have one clear call-to-action, which will increase your click rates.</p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "button",
|
||||
"text" => __("Read up!"),
|
||||
"text" => __("Read up!", 'mailpoet'),
|
||||
"url" => "",
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
@ -281,7 +281,7 @@ class WelcomeBlank12Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
@ -13,8 +13,8 @@ class WelcomeBlank1Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Welcome Email: Blank 1 Column"),
|
||||
'description' => __("A blank Welcome Email template with a 1 column layout."),
|
||||
'name' => __("Welcome Email: Blank 1 Column", 'mailpoet'),
|
||||
'description' => __("A blank Welcome Email template with a 1 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class WelcomeBlank1Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class WelcomeBlank1Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake logo"),
|
||||
"alt" => __("Fake logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class WelcomeBlank1Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Hi, new subscriber!</strong></h1>\n<p></p>\n<p>[subscriber:firstname | default:Subscriber],</p>\n<p></p>\n<p>You recently joined our list and we'd like to give you a warm welcome!</p>\n<p></p>\n<p>Want to get to know us better? Check out some of our most popular articles: </p>\n<ol>\n<li><a href=\"http://www.mailpoet.com/the-importance-of-focus-when-writing/\">The Importance of Focus When Writing</a></li>\n<li><a href=\"http://www.mailpoet.com/write-great-subject-line/\">How to Write a Great Subject Line</a></li>\n<li><a href=\"http://www.mailpoet.com/just-sit-write-advice-motivation-ernest-hemingway/\">Just Sit Down and Write – Advice on Motivation from Ernest Hemingway</a></li>\n</ol>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Hi, new subscriber!</strong></h1>\n<p></p>\n<p>[subscriber:firstname | default:Subscriber],</p>\n<p></p>\n<p>You recently joined our list and we'd like to give you a warm welcome!</p>\n<p></p>\n<p>Want to get to know us better? Check out some of our most popular articles: </p>\n<ol>\n<li><a href=\"http://www.mailpoet.com/the-importance-of-focus-when-writing/\">The Importance of Focus When Writing</a></li>\n<li><a href=\"http://www.mailpoet.com/write-great-subject-line/\">How to Write a Great Subject Line</a></li>\n<li><a href=\"http://www.mailpoet.com/just-sit-write-advice-motivation-ernest-hemingway/\">Just Sit Down and Write – Advice on Motivation from Ernest Hemingway</a></li>\n</ol>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -190,7 +190,7 @@ class WelcomeBlank1Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
@ -81,7 +81,7 @@ class Shortcodes {
|
||||
if(empty($newsletters)) {
|
||||
return apply_filters(
|
||||
'mailpoet_archive_no_newsletters',
|
||||
__('Oops! There are no newsletters to display.')
|
||||
__('Oops! There are no newsletters to display.', 'mailpoet')
|
||||
);
|
||||
} else {
|
||||
$title = apply_filters('mailpoet_archive_title', '');
|
||||
@ -116,7 +116,7 @@ class Shortcodes {
|
||||
$preview_url = NewsletterUrl::getViewInBrowserUrl($newsletter);
|
||||
|
||||
return '<a href="'.esc_attr($preview_url).'" target="_blank" title="'
|
||||
.esc_attr(__('Preview in a new tab')).'">'
|
||||
.esc_attr(__('Preview in a new tab', 'mailpoet')).'">'
|
||||
.esc_attr($newsletter->subject).
|
||||
'</a>';
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ class CronHelper {
|
||||
|
||||
static function createDaemon($token) {
|
||||
$daemon = array(
|
||||
'status' => Daemon::STATUS_STARTING,
|
||||
'token' => $token
|
||||
);
|
||||
self::saveDaemon($daemon);
|
||||
@ -39,12 +38,6 @@ class CronHelper {
|
||||
);
|
||||
}
|
||||
|
||||
static function stopDaemon() {
|
||||
$daemon = self::getDaemon();
|
||||
$daemon['status'] = Daemon::STATUS_STOPPED;
|
||||
return self::saveDaemon($daemon);
|
||||
}
|
||||
|
||||
static function deleteDaemon() {
|
||||
return Setting::deleteValue(self::DAEMON_SETTING);
|
||||
}
|
||||
@ -60,6 +53,7 @@ class CronHelper {
|
||||
QueueEndpoint::ACTION_RUN,
|
||||
$data
|
||||
);
|
||||
$url = str_replace(home_url(), self::getSiteUrl(), $url);
|
||||
$args = array(
|
||||
'blocking' => false,
|
||||
'sslverify' => false,
|
||||
@ -70,27 +64,29 @@ class CronHelper {
|
||||
return wp_remote_retrieve_body($result);
|
||||
}
|
||||
|
||||
private static function getSiteUrl() {
|
||||
// additional check for some sites running on a virtual machine or behind
|
||||
static function getSiteUrl($site_url = false) {
|
||||
// additional check for some sites running inside a virtual machine or behind
|
||||
// proxy where there could be different ports (e.g., host:8080 => guest:80)
|
||||
|
||||
// if the site URL does not contain a port, return the URL
|
||||
if(!preg_match('!^https?://.*?:\d+!', site_url())) return site_url();
|
||||
preg_match('!://(?P<host>.*?):(?P<port>\d+)!', site_url(), $server);
|
||||
// connect to the URL with port
|
||||
$fp = @fsockopen($server['host'], $server['port'], $errno, $errstr, 1);
|
||||
if($fp) return site_url();
|
||||
// connect to the URL without port
|
||||
$fp = @fsockopen($server['host'], $server['port'], $errno, $errstr, 1);
|
||||
if($fp) return preg_replace('!(?=:\d+):\d+!', '$1', site_url());
|
||||
// throw an error if all connection attempts failed
|
||||
throw new \Exception(__('Site URL is unreachable.'));
|
||||
$site_url = ($site_url) ? $site_url : home_url();
|
||||
$parsed_url = parse_url($site_url);
|
||||
// 1. if site URL does not contain a port, return the URL
|
||||
if(empty($parsed_url['port'])) return $site_url;
|
||||
// 2. if site URL contains valid port, try connecting to it
|
||||
$fp = @fsockopen($parsed_url['host'], $parsed_url['port'], $errno, $errstr, 1);
|
||||
if($fp) return $site_url;
|
||||
// 3. if connection fails, attempt to connect the standard port derived from URL
|
||||
// schema
|
||||
$port = (strtolower($parsed_url['scheme']) === 'http') ? 80 : 443;
|
||||
$fp = @fsockopen($parsed_url['host'], $port, $errno, $errstr, 1);
|
||||
if($fp) return sprintf('%s://%s', $parsed_url['scheme'], $parsed_url['host']);
|
||||
// 4. throw an error if all connection attempts failed
|
||||
throw new \Exception(__('Site URL is unreachable.', 'mailpoet'));
|
||||
}
|
||||
|
||||
static function enforceExecutionLimit($timer) {
|
||||
$elapsed_time = microtime(true) - $timer;
|
||||
if($elapsed_time >= self::DAEMON_EXECUTION_LIMIT) {
|
||||
throw new \Exception(__('Maximum execution time has been reached.'));
|
||||
throw new \Exception(__('Maximum execution time has been reached.', 'mailpoet'));
|
||||
}
|
||||
}
|
||||
}
|
@ -20,8 +20,6 @@ class CronTrigger {
|
||||
|
||||
function init() {
|
||||
try {
|
||||
// configure cron trigger only outside of cli environment
|
||||
if(php_sapi_name() === 'cli') return;
|
||||
$trigger_class = __NAMESPACE__ . '\Triggers\\' . $this->current_method;
|
||||
return (class_exists($trigger_class)) ?
|
||||
$trigger_class::run() :
|
||||
|
@ -1,86 +1,82 @@
|
||||
<?php
|
||||
namespace MailPoet\Cron;
|
||||
|
||||
use MailPoet\Cron\Workers\Scheduler as SchedulerWorker;
|
||||
use MailPoet\Cron\Workers\SendingQueue\SendingQueue as SendingQueueWorker;
|
||||
|
||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
class Daemon {
|
||||
public $daemon;
|
||||
public $data;
|
||||
public $refreshed_token;
|
||||
const STATUS_STOPPED = 'stopped';
|
||||
const STATUS_STOPPING = 'stopping';
|
||||
const STATUS_STARTED = 'started';
|
||||
const STATUS_STARTING = 'starting';
|
||||
public $request_data;
|
||||
public $timer;
|
||||
const REQUEST_TIMEOUT = 5;
|
||||
private $timer;
|
||||
|
||||
function __construct($data) {
|
||||
if(empty($data)) $this->abortWithError(__('Invalid or missing Cron data.'));
|
||||
ignore_user_abort();
|
||||
function __construct($request_data = false) {
|
||||
$this->request_data = $request_data;
|
||||
$this->daemon = CronHelper::getDaemon();
|
||||
$this->token = CronHelper::createToken();
|
||||
$this->data = $data;
|
||||
$this->timer = microtime(true);
|
||||
}
|
||||
|
||||
function run() {
|
||||
ignore_user_abort(true);
|
||||
if(!$this->request_data) {
|
||||
$error = __('Invalid or missing request data.', 'mailpoet');
|
||||
} else {
|
||||
if(!$this->daemon) {
|
||||
$error = __('Daemon does not exist.', 'mailpoet');
|
||||
} else {
|
||||
if(!isset($this->request_data['token']) ||
|
||||
$this->request_data['token'] !== $this->daemon['token']
|
||||
) {
|
||||
$error = 'Invalid or missing token.';
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!empty($error)) {
|
||||
return $this->abortWithError($error);
|
||||
}
|
||||
$daemon = $this->daemon;
|
||||
if(!$daemon) {
|
||||
$this->abortWithError(__('Daemon does not exist.'));
|
||||
}
|
||||
if(!isset($this->data['token']) ||
|
||||
$this->data['token'] !== $daemon['token']
|
||||
) {
|
||||
$this->abortWithError(__('Invalid or missing token.'));
|
||||
}
|
||||
$daemon['token'] = $this->token;
|
||||
CronHelper::saveDaemon($daemon);
|
||||
$this->abortIfStopped($daemon);
|
||||
try {
|
||||
$scheduler = new SchedulerWorker($this->timer);
|
||||
$scheduler->process();
|
||||
$queue = new SendingQueueWorker($this->timer);
|
||||
$queue->process();
|
||||
$this->executeScheduleWorker();
|
||||
$this->executeQueueWorker();
|
||||
} catch(\Exception $e) {
|
||||
// continue processing, no need to handle errors
|
||||
}
|
||||
// if workers took less time to execute than the daemon execution limit,
|
||||
// pause daemon execution to ensure that daemon runs only once every X seconds
|
||||
$elapsed_time = microtime(true) - $this->timer;
|
||||
if($elapsed_time < CronHelper::DAEMON_EXECUTION_LIMIT) {
|
||||
sleep(CronHelper::DAEMON_EXECUTION_LIMIT - $elapsed_time);
|
||||
$this->pauseExecution(CronHelper::DAEMON_EXECUTION_LIMIT - $elapsed_time);
|
||||
}
|
||||
// after each execution, re-read daemon data in case its status was changed
|
||||
// its status has changed
|
||||
// after each execution, re-read daemon data in case it changed
|
||||
$daemon = CronHelper::getDaemon();
|
||||
if(!$daemon || $daemon['token'] !== $this->token) {
|
||||
$this->terminateRequest();
|
||||
return $this->terminateRequest();
|
||||
}
|
||||
$this->abortIfStopped($daemon);
|
||||
if($daemon['status'] === self::STATUS_STARTING) {
|
||||
$daemon['status'] = self::STATUS_STARTED;
|
||||
}
|
||||
CronHelper::saveDaemon($daemon);
|
||||
$this->callSelf();
|
||||
return $this->callSelf();
|
||||
}
|
||||
|
||||
function abortIfStopped($daemon) {
|
||||
if($daemon['status'] === self::STATUS_STOPPED) {
|
||||
$this->terminateRequest();
|
||||
}
|
||||
if($daemon['status'] === self::STATUS_STOPPING) {
|
||||
$daemon['status'] = self::STATUS_STOPPED;
|
||||
CronHelper::saveDaemon($daemon);
|
||||
$this->terminateRequest();
|
||||
}
|
||||
function pauseExecution($pause_time) {
|
||||
return sleep($pause_time);
|
||||
}
|
||||
|
||||
function executeScheduleWorker() {
|
||||
$scheduler = new SchedulerWorker($this->timer);
|
||||
return $scheduler->process();
|
||||
}
|
||||
|
||||
function executeQueueWorker() {
|
||||
$queue = new SendingQueueWorker($this->timer);
|
||||
return $queue->process();
|
||||
}
|
||||
|
||||
function callSelf() {
|
||||
CronHelper::accessDaemon($this->token, self::REQUEST_TIMEOUT);
|
||||
$this->terminateRequest();
|
||||
return $this->terminateRequest();
|
||||
}
|
||||
|
||||
function abortWithError($message) {
|
||||
|
@ -15,7 +15,7 @@ class Supervisor {
|
||||
function checkDaemon() {
|
||||
$daemon = $this->daemon;
|
||||
$execution_timeout_exceeded =
|
||||
(time() - (int)$daemon['updated_at']) > CronHelper::DAEMON_EXECUTION_TIMEOUT;
|
||||
(time() - (int)$daemon['updated_at']) >= CronHelper::DAEMON_EXECUTION_TIMEOUT;
|
||||
if($execution_timeout_exceeded) {
|
||||
CronHelper::restartDaemon($this->token);
|
||||
return $this->runDaemon();
|
||||
|