Compare commits

...

131 Commits

Author SHA1 Message Date
c09bcd51ad Merge pull request #675 from mailpoet/amazon_ses_fix
Fixes const value declaration for PHP <5.6
2016-10-28 17:29:57 +03:00
01af4d3401 - Fixes const value declaration for PHP <5.6 2016-10-28 10:13:56 -04:00
2ba9d95a2e Update plugin repo icon to "beta" 2016-10-28 16:03:14 +03:00
b2d4bfc760 Initial MailPoet 3.0.0-beta.1 release 2016-10-28 13:52:40 +03:00
57f5f16bb6 Merge pull request #674 from mailpoet/premium_hook
Bypasses subscriber count enforcement for premium users
2016-10-27 20:47:14 +03:00
7d2e13b9a3 - Updates license check logic
- Updates subscriber limit check logic
- Updates unit tests
- Updates Menu's check for subscriber limit
2016-10-27 12:35:57 -04:00
6d39f9fa78 Merge pull request #671 from mailpoet/plugin_repository_assets
Preparation for plugin repository
2016-10-27 11:36:57 -04:00
a4395f2350 - Adds unit tests 2016-10-27 11:16:30 -04:00
411969b3eb - Adds check for premium plugin status
- Bypasses subscriber count enforcement if premium is enabled
2016-10-27 10:20:05 -04:00
1868ca3155 Merge pull request #673 from mailpoet/scheduler_update
Scheduler update
2016-10-27 13:17:03 +03:00
e765471f5d - Changes month days count to start from 1 instead of 0
- Closes #672
2016-10-26 21:18:07 -04:00
bdce7c5e5a - Remove unused dependency 2016-10-26 11:43:32 -04:00
773be9f5c8 Add assets for plugin repository 2016-10-26 13:59:02 +03:00
6ae46b05e5 Merge pull request #669 from mailpoet/string_updates
String updates
2016-10-25 18:00:44 +03:00
217894745d - Updates text strings
- Closes #655
2016-10-25 10:21:23 -04:00
a03891895c Bump up release version to 0.0.50 and update changelog 2016-10-25 13:04:55 +03:00
3368e84a99 Merge pull request #668 from mailpoet/export_confirmed_subscribers_option_update
Fixes minor export UI issues
2016-10-25 12:46:13 +03:00
e90df2f08d - Fixes Select2 not dislaying multiple options in the list of export
fields
- Sets default "export confirmed subscriber" option to "no"
2016-10-24 13:09:48 -04:00
2391ae1cad Merge pull request #665 from mailpoet/post_notification_fix
Fixes post notification issues
2016-10-24 16:02:19 +03:00
83114a8be4 - Removes unused class declarations 2016-10-24 08:55:22 -04:00
d08d5a3b6c - Updates unit tests 2016-10-24 08:55:22 -04:00
8330bfc884 - Fixes "completed" status update of notification history
newsletters
- Fixes detection of post notification newsletters that do not contain any posts (i.e., blank ALC blocks)
- Updates unit test
2016-10-24 08:55:22 -04:00
ef21a8cca7 - Enables post notification schedule update upon newsletter saving during
step 3
2016-10-24 08:55:22 -04:00
e32c46a755 - Detaches posts_where action after posts are pulled from the database 2016-10-24 08:55:22 -04:00
092f69538a Merge pull request #667 from mailpoet/sending_to_trashed_subscribers_fix
Prevents newsletters from being sent to trashed subscribers
2016-10-24 15:26:55 +03:00
7a75367d75 Merge pull request #666 from mailpoet/export_filename_update
Increases export filename length and randomness
2016-10-24 13:36:36 +03:00
0b2701ade2 Merge pull request #656 from mailpoet/security_issue_636
API Token
2016-10-24 13:26:44 +03:00
1ac288d286 - Prevents newsletters from being sent to trashed subscribers
- Updates unit tests
- Addresses #629
2016-10-21 14:36:44 -04:00
516bc73092 - Increases export filename length and randomness 2016-10-21 11:42:13 -04:00
4088abef68 removed useless 'use' in unit test 2016-10-21 13:42:19 +02:00
f6cefc3f5c wrong email address in unit test 2016-10-21 13:38:23 +02:00
202e4b90e1 added unit test for API::checkPermissions 2016-10-21 13:36:41 +02:00
ee89bf0722 refactored API class 2016-10-21 13:36:41 +02:00
876d21300a fixed duplicated lines due to faulty rebase 2016-10-21 13:36:41 +02:00
0ca5b7a79f API Security
- added APIAccess class to define access levels of API Endpoints (permissions)
- use "mailpoet_token" for all nonce (just as before)
- merged setupPublic/setupAdmin methods in API in order to avoid duplication
- check permission if access level is not all
- fixed ABSPATH check in some classes
2016-10-21 13:36:41 +02:00
5d0ee43921 removed checkToken for admin ajax 2016-10-21 13:36:41 +02:00
cc523a3c0b ability to specify action for generateToken() method 2016-10-21 13:36:41 +02:00
2787998d32 Merge pull request #664 from mailpoet/editor_fixes
Editor fixes
2016-10-20 17:29:55 +02:00
38f6c95059 Update newsletter saving to reflect code review comments
- Switch to using full segment objects when saving newsletters
- Fix stale comment in newsletter editor's Newsletter model
- Fix typo in newsletter editor tests
2016-10-20 17:52:05 +03:00
cc03b631ff Allow newsletters.save endpoint to accept segments as list of objects 2016-10-20 16:08:41 +03:00
a3c77fb685 Fix PHP to JS date format converter to handle escaped symbols 2016-10-20 15:19:04 +03:00
3817e28960 Change newsletter not found error to a static one in editor 2016-10-20 13:38:07 +03:00
c3a78b1ea3 Fix newsletter editor to only save properties it changes 2016-10-20 13:37:32 +03:00
42877236c8 Merge pull request #663 from mailpoet/wp_repo_files
Preparation for plugin repo
2016-10-19 09:08:54 -04:00
6e87f3539c Update license.txt, readme.txt and link to plugin's repo page 2016-10-19 13:46:14 +03:00
7704ea4b68 Bump up release version to 0.0.49 2016-10-19 13:23:00 +03:00
12a3931b7b Merge pull request #662 from mailpoet/security_issue_634
PHP Object injection in front Router
2016-10-18 16:46:14 +03:00
25a55dbb67 Merge pull request #661 from mailpoet/security_issue_633
Import SQL injection
2016-10-18 14:50:08 +02:00
6758f60a81 Merge pull request #659 from mailpoet/import_data_sanitization
Sanitize import data
2016-10-18 12:35:52 +02:00
5e9e53ec41 - Updates router to use json_encode() instead of serialize() for publicly modified data payload
- Updates unit tests
- Fixes #634
2016-10-17 22:39:36 -04:00
1285252a8c - Adds unit tests 2016-10-17 20:27:58 -04:00
98f95f72ad - Adds validation for import data, including column names (fixes #633)
- Prevents nonexistent custom fields from being associated with subscribers
2016-10-17 20:22:25 -04:00
09ca788371 - Fixes subscriber count not being shown when new segment is created 2016-10-17 20:12:57 -04:00
b48cc5a959 - Updates import UI to escape HTML text
- Allows mixing of escaped and unescaped HTML text
- Removes server-side text escaping
2016-10-17 11:01:54 -04:00
812d138c4e Merge pull request #658 from mailpoet/import_and_mailer_host_restriction
Import and mailer host restriction
2016-10-17 16:19:42 +02:00
07bc35d4cd Merge pull request #625 from mailpoet/unit_tests
Adds unit test for newsletter scheduler
2016-10-17 11:37:17 +02:00
90b95a2c25 fixed 'newletter' typo and replaced integer weekdays by their carbon constant equivalent 2016-10-17 11:35:57 +02:00
78c50c41e3 - Fixes unit test
- Updates code as per code review comments
2016-10-18 14:29:53 -04:00
7eee7def63 Merge pull request #657 from mailpoet/security_issue_635
Security issue #635
2016-10-16 16:42:11 -04:00
9ba6e9806f - Adds data sanitization on the client and server side
- Closes #641
2016-10-16 13:02:49 -04:00
8c28dc3d8a - Restricts Amazon SES region to a specific list of hosts
- Updates unit tests
- Closes #647
2016-10-16 12:19:47 -04:00
9197e39fb4 - Restricts MailChimp API key to specific format
- Updates unit test
2016-10-16 11:57:56 -04:00
37f59814e5 removed unused methods in Util/CSS -> fixes security issue #635 2016-10-13 10:34:36 +02:00
bf894fc26f Bump up release version to 0.0.48, update changelog 2016-10-11 13:02:08 +03:00
0b2b42cf4d Merge pull request #654 from mailpoet/security_issue_1
Security issues round 1
2016-10-11 12:51:11 +03:00
542015a4f6 Improved removal of useless files in vendor folder during build process
- moved sort_order constraining logic to Listing handler's construct
2016-10-10 14:52:09 +02:00
f5a8323f5d removed 'test*' from removed folders in vendor as it was creating issues with Twig 2016-10-07 15:12:58 +02:00
55942cd88b prevent odd values for sort_order in listing.jsx 2016-10-07 14:38:25 +02:00
f26a2cbd26 fixes issue #651 2016-10-06 13:18:46 +02:00
4402f826c3 fixed issue with namespace AND fixed issue #649 2016-10-06 12:54:04 +02:00
b9745b555a make sure ABSPATH is defined before using it - fixes issue #648 2016-10-06 12:52:53 +02:00
f923a8063b cleanup useless files in vendor folder when building release (fixes issue #637) 2016-10-06 11:24:18 +02:00
f4367b9146 optimized the composer install a bit 2016-10-06 09:52:42 +02:00
a3395e41c9 fixes issue #632 2016-10-06 09:25:09 +02:00
be61135daf Merge pull request #627 from mailpoet/translations
Translations
2016-10-05 12:26:03 +03:00
21b4187a11 added missing text domains in _e functions 2016-10-05 10:26:59 +02:00
1c3c1e35e7 added 'lang' to gitignore 2016-10-05 10:08:24 +02:00
ded373557e Bump up release version to 0.0.47 and update changelog 2016-10-04 12:05:34 +03:00
280c4762bb Merge pull request #630 from mailpoet/subscribers_count_in_segments
Subscribers count in segments
2016-10-04 11:58:44 +03:00
bbd02260be Fix showing segment subscriber counts on newsletter creation pages 2016-10-04 11:54:07 +03:00
1b1e9abd68 Merge pull request #631 from mailpoet/issue_629
Bugs in latest release (0.0.46) - issue 629
2016-10-03 15:42:57 +03:00
b0ab9e0408 fixed import/export unit tests + added specific method for getting segments for import 2016-09-30 15:52:17 +02:00
d32abff78d display subscribers count in segments selection 2016-09-30 15:23:18 +02:00
7fbf84db1f converted text domain to string instead of constant 2016-09-30 09:58:26 +02:00
8c5aebc7d6 Don't send signup confirmation when signup confirmation is disabled
Fixed issue with select2 not selecting values by default on newsletter send step
2016-09-29 15:42:44 +02:00
42202f676a updated Env::plugin_name to constant for text domain 2016-09-27 14:54:23 +02:00
ba6198f956 added textdomain to __() calls 2016-09-27 14:53:44 +02:00
120af4170b fixed do makepot + removed mailpoet.pot from repo 2016-09-27 14:53:44 +02:00
1faa53b978 Bump up release version to 0.0.46 2016-09-27 14:10:38 +02:00
e565a7a234 - Uses Codeception's native methods to verify expectations
- Updates next run date test conditions to use account for possible time
  difference
2016-09-26 12:35:00 -04:00
90b6b57a8d Merge branch 'copy-edit' 2016-09-26 13:17:08 +01:00
548253d68e Merge branch 'master' into copy-edit 2016-09-26 11:14:21 +01:00
e1c5f609ff - Adds unit test 2016-09-23 20:16:53 -04:00
226befdef6 Merge pull request #624 from mailpoet/unit_tests
Unit tests
2016-09-23 20:15:45 +03:00
a9d57654b4 - Rebases master
- Fixes newsletter schedule options not being saved
2016-09-23 12:54:18 -04:00
ed00ae0516 - Adds unit test 2016-09-23 12:30:29 -04:00
48d738e8c4 - Updates scheduler 2016-09-23 12:30:29 -04:00
132b4ed2e8 - Passes full model object to class method 2016-09-23 12:30:29 -04:00
9a513cb27b Merge branch 'master' into copy-edit 2016-09-23 16:39:56 +01:00
5d692c0395 Merge pull request #623 from mailpoet/drag_drop
Enable dragging text blocks
2016-09-23 15:13:09 +02:00
991ab67fff Allow dragging from the first time 2016-09-23 15:38:23 +03:00
dd00640119 Merge pull request #620 from mailpoet/subscription_forms
Subscription Forms
2016-09-23 15:20:58 +03:00
fa04173cfb Activate TinyMCE on click, to fix Interact blocking 2nd and further
focus events
2016-09-23 15:07:04 +03:00
a328d3b48a avoid duplicating code 2016-09-23 12:56:27 +02:00
d5cff4f0d3 fixed indentation 2016-09-23 12:14:54 +02:00
52bf24b6db Revert back to auto preventDefault for drag&drop 2016-09-22 18:39:07 +03:00
50e134d696 Allow dragging text blocks before activating TinyMCE 2016-09-22 17:44:43 +03:00
ea5c73721b remove doing_ajax logic from API and created dedicated class for subscription form non ajax submission 2016-09-22 16:24:13 +02:00
4799882b80 Merge pull request #621 from mailpoet/unit_tests
Unit tests
2016-09-22 13:04:05 +03:00
2e4c5ca39a - Updates Mailer Log class and adds unit tests 2016-09-21 19:53:26 -04:00
13ed3aa3b9 - Adds unit test 2016-09-21 14:09:24 -04:00
6091751a4b Closes issue 480 2016-09-21 11:54:16 +02:00
c4d9e85dff - Adds unit test 2016-09-20 20:43:49 -04:00
1a85914c1b - Adds unit test 2016-09-20 20:08:44 -04:00
0ba48234de Merge pull request #616 from mailpoet/unit_tests
Final set of cron unit tests
2016-09-20 19:38:46 +03:00
1c2a532949 - Adds test to detect empty newsletter body when sending 2016-09-20 12:03:57 -04:00
9087be6ee8 - Fixes condition that checks for existance of rendered newsletter body 2016-09-20 10:33:48 -04:00
2fa5e5ead2 - Moves logic of the Subscribers task to the Sending Queue model 2016-09-19 21:53:13 -04:00
d5107be65e - Updates Sending Queue Worker and Mailer task to allow dependency
injection via constructor
- Updates unit tests to use dependency injection instead of modifying
  object's internals
2016-09-19 21:00:47 -04:00
379dfb5f6e - Removes leftover private variable 2016-09-19 20:51:08 -04:00
8360377992 - Replaces custom method to get newsletter with ORM's native one-to-one model
relationship
2016-09-19 20:47:49 -04:00
4538cab6c8 - Adds newsletter body/subject as a reusable template through
Codeception's Fixture utility class
2016-09-19 20:40:17 -04:00
1bf0988297 - Updates Sending Queue worker/tasks/unit tests use model's method to get/save rendered newsletter body 2016-09-19 20:11:58 -04:00
e1caf49ea5 - Updates depreciated method name 2016-09-19 20:10:47 -04:00
0dfae97b32 - Updates model to serialize rendered newsletter body on save 2016-09-19 20:09:44 -04:00
ef2187c175 - Updates code formatting 2016-09-19 11:10:03 -04:00
6157d17c5b - Removes transient object from the model 2016-09-19 10:55:58 -04:00
8e879047c2 - Adds additional DB tables to be cleaned during unit testing 2016-09-19 10:51:10 -04:00
e11fd66fec - Adds unit tests for cron's sending queue worker and associated tasks 2016-09-18 23:16:19 -04:00
b37e85eeb5 - Removes unused method 2016-09-18 23:15:41 -04:00
f88dabffe8 - Updates cron's sending queue worker to use model objects
- Adds new method to render newsletter to the newsletter model
- Adds new transient object to newsletter model that will hold temporary
  values (i.e., rendered body) when working with the model
2016-09-18 23:14:17 -04:00
185 changed files with 3614 additions and 5782 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ tests/javascript/testBundles
assets/css/*.css
assets/js/*.js
.vagrant
lang

View File

@ -71,30 +71,43 @@ define('date',
convertFormat: function(format) {
var format_mappings = {
date: {
D: 'ddd',
l: 'dddd',
d: 'DD',
D: 'ddd',
j: 'D',
z: 'DDDD',
l: 'dddd',
N: 'E',
S: '',
M: 'MMM',
S: 'o',
w: 'e',
z: 'DDD',
W: 'W',
F: 'MMMM',
m: 'MM',
n: '',
t: '',
y: 'YY',
M: 'MMM',
n: 'M',
t: '', // no equivalent
L: '', // no equivalent
o: 'YYYY',
Y: 'YYYY',
H: 'HH',
h: 'hh',
g: 'h',
y: 'YY',
a: 'a',
A: 'A',
B: '', // no equivalent
g: 'h',
G: 'H',
h: 'hh',
H: 'HH',
i: 'mm',
s: 'ss',
T: 'z',
O: 'ZZ',
w: 'd',
W: 'WW'
u: 'SSS',
e: 'zz', // deprecated since version 1.6.0 of moment.js
I: '', // no equivalent
O: '', // no equivalent
P: '', // no equivalent
T: '', // no equivalent
Z: '', // no equivalent
c: '', // no equivalent
r: '', // no equivalent
U: 'X'
},
strftime: {
a: 'ddd',
@ -127,20 +140,29 @@ define('date',
var replacements = format_mappings['date'];
var outputFormat = '';
var convertedFormat = [];
var escapeToken = false;
Object.keys(replacements).forEach(function(key) {
if (format.indexOf(key) !== -1) {
format = format.replace(key, '%'+key);
for (var index in format) {
var token = format[index];
if (escapeToken === true) {
convertedFormat.push('['+token+']');
escapeToken = false;
} else {
if (token === '\\') {
// Slash escapes the next symbol to be treated as literal
escapeToken = true;
continue;
} else if (replacements[token] !== undefined) {
convertedFormat.push(replacements[token]);
} else {
convertedFormat.push('['+token+']');
}
}
});
outputFormat = format;
Object.keys(replacements).forEach(function(key) {
if (outputFormat.indexOf('%'+key) !== -1) {
outputFormat = outputFormat.replace('%'+key, replacements[key]);
}
});
return outputFormat;
}
return convertedFormat.join('');
}
};
});

View File

@ -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') {
@ -115,9 +122,10 @@ function(
} else {
value = e.target.value;
}
var transformedValue = this.transformChangedValue(value);
this.props.onValueChange({
target: {
value: value,
value: transformedValue,
name: this.props.field.name
}
});
@ -141,6 +149,16 @@ function(
}
return item.id;
},
// When it's impossible to represent the desired value in DOM,
// this function may be used to transform the placeholder value into
// desired value.
transformChangedValue: function(value) {
if(typeof this.props.field['transformChangedValue'] === 'function') {
return this.props.field.transformChangedValue.call(this, value);
} else {
return value;
}
},
render: function() {
const options = this.state.items.map((item, index) => {
let label = this.getLabel(item);

View File

@ -151,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 }>

View File

@ -624,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));

View File

@ -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({

View File

@ -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({

View File

@ -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({

View File

@ -11,15 +11,16 @@ define([
// Does not hold newsletter content nor newsletter styles, those are
// handled by other components.
Module.NewsletterModel = SuperModel.extend({
stale: ['body', 'created_at', 'deleted_at', 'updated_at'],
whitelisted: ['id', 'subject', 'preheader'],
initialize: function(options) {
this.on('change', function() {
App.getChannel().trigger('autoSave');
});
},
toJSON: function() {
// Remove stale attributes from resulting JSON object
return _.omit(SuperModel.prototype.toJSON.call(this), this.stale);
// Use only whitelisted properties to ensure properties editor
// doesn't control don't change.
return _.pick(SuperModel.prototype.toJSON.call(this), this.whitelisted);
},
});

View File

@ -62,7 +62,7 @@ const _monthDayValues = _.object(
} else {
label = MailPoet.I18n.t('nth').replace("%$1d", day + 1);
}
return [day, label];
return [day + 1, label];
}
)
);

View File

@ -1,11 +1,13 @@
define(
[
'mailpoet',
'newsletters/types/notification/scheduling.jsx'
'newsletters/types/notification/scheduling.jsx',
'underscore'
],
function(
MailPoet,
Scheduling
Scheduling,
_
) {
var settings = window.mailpoet_settings || {};
@ -40,11 +42,15 @@ 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() + ')';
},
transformChangedValue: function(segment_ids) {
var all_segments = this.state.items;
return _.map(segment_ids, function(id) {
return _.find(all_segments, function(segment) {
return segment.id === id;
});
});
},
validation: {
'data-parsley-required': true,

View File

@ -346,11 +346,15 @@ 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() + ')';
},
transformChangedValue: function(segment_ids) {
var all_segments = this.state.items;
return _.map(segment_ids, function(id) {
return _.find(all_segments, function(segment) {
return segment.id === id;
});
});
},
validation: {
'data-parsley-required': true,

View File

@ -1,6 +1,5 @@
import _ from 'underscore'
import React from 'react'
import MailPoet from 'mailpoet'
import Select from 'form/fields/select.jsx'
import {
intervalValues,

View File

@ -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];
}
));

View File

@ -40,33 +40,40 @@ function(
// ajax request
MailPoet.Ajax.post({
url: MailPoetForm.ajax_url,
token: MailPoetForm.token,
token: data.token,
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);
}
});

View File

@ -134,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>
);

View File

@ -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 = '';

View File

@ -95,15 +95,18 @@ define(
});
};
// set confirmed subscribers export option to false
exportData.exportConfirmedOption = false;
renderSegmentsAndFields(subscriberFieldsContainerElement, subscriberFieldsSelect2);
renderSegmentsAndFields(segmentsContainerElement, segments);
subscriberFieldsContainerElement.select2('val', [
'status',
subscriberFieldsContainerElement.val([
'email',
'first_name',
'last_name'
]);
'last_name',
'status'
]).trigger("change");
exportConfirmedOptionElement.change(function () {
var selectedSegments = segmentsContainerElement.val();

View File

@ -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
@ -869,7 +871,7 @@ define(
'<span class="mailpoet_data_match mailpoet_import_error" title="'
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
+ MailPoet.I18n.t('emptyFirstRowDate')
+ '</span>';
+ '</span> ';
preventNextStep = true;
}
else {
@ -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;
};
});

View File

@ -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,8 +28,23 @@ 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 license.txt $plugin_name
cp index.php $plugin_name
cp $plugin_name.php $plugin_name
cp readme.txt $plugin_name

File diff suppressed because it is too large Load Diff

View File

@ -1,70 +1,44 @@
<?php
namespace MailPoet\API;
use \MailPoet\Util\Security;
if(!defined('ABSPATH')) exit;
class API {
function __construct() {
}
private $_endpoint;
private $_method;
private $_token;
private $_endpoint_class;
private $_data = array();
function init() {
// security token
// Admin Security token
add_action(
'admin_head',
array($this, 'setToken')
);
// Admin API (Ajax only)
// ajax (logged in users)
add_action(
'wp_ajax_mailpoet',
array($this, 'setupAdmin')
array($this, 'setupAjax')
);
// Public API (Ajax)
// ajax (logged out users)
add_action(
'wp_ajax_nopriv_mailpoet',
array($this, 'setupPublic')
);
// Public API (Post)
add_action(
'admin_post_nopriv_mailpoet',
array($this, 'setupPublic')
array($this, 'setupAjax')
);
}
function setupAdmin() {
function setupAjax() {
$this->getRequestData();
if($this->checkToken() === false) {
$error_response = new ErrorResponse(
array(
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
),
array(),
Response::STATUS_UNAUTHORIZED
);
$error_response->send();
}
if($this->checkPermissions() === false) {
$error_response = new ErrorResponse(
array(
Error::FORBIDDEN => __('You do not have the required permissions.')
),
array(),
Response::STATUS_FORBIDDEN
);
$error_response->send();
}
$this->processRoute();
}
function setupPublic() {
if($this->checkToken() === false) {
$error_response = new ErrorResponse(
array(
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
Error::UNAUTHORIZED => __('Invalid request.', 'mailpoet')
),
array(),
Response::STATUS_UNAUTHORIZED
@ -75,33 +49,81 @@ class API {
$this->processRoute();
}
function getRequestData() {
$this->_endpoint = isset($_POST['endpoint'])
? trim($_POST['endpoint'])
: null;
$this->_method = isset($_POST['method'])
? trim($_POST['method'])
: null;
$this->_token = isset($_POST['token'])
? trim($_POST['token'])
: null;
if(!$this->_endpoint || !$this->_method) {
// throw exception bad request
$error_response = new ErrorResponse(
array(
Error::BAD_REQUEST => __('Invalid request.', 'mailpoet')
),
array(),
Response::STATUS_BAD_REQUEST
);
$error_response->send();
} else {
$this->_endpoint_class = (
__NAMESPACE__."\\Endpoints\\".ucfirst($this->_endpoint)
);
$this->_data = isset($_POST['data'])
? stripslashes_deep($_POST['data'])
: array();
// remove reserved keywords from data
if(is_array($this->_data) && !empty($this->_data)) {
// filter out reserved keywords from data
$reserved_keywords = array(
'token',
'endpoint',
'method',
'mailpoet_redirect'
);
$this->_data = array_diff_key(
$this->_data,
array_flip($reserved_keywords)
);
}
}
}
function processRoute() {
$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;
}
if(is_array($data) && !empty($data)) {
// filter out reserved keywords from data
$reserved_keywords = array(
'token',
'endpoint',
'method',
'mailpoet_redirect'
);
$data = array_diff_key($data, array_flip($reserved_keywords));
}
try {
$endpoint = new $endpoint();
$response = $endpoint->$method($data);
$endpoint = new $this->_endpoint_class();
// check the accessibility of the requested endpoint's action
// by default, an endpoint's action is considered "private"
$permissions = $endpoint->permissions;
if(
array_key_exists($this->_method, $permissions) === false
||
$permissions[$this->_method] !== Access::ALL
) {
if($this->checkPermissions() === false) {
$error_response = new ErrorResponse(
array(
Error::FORBIDDEN => __(
'You do not have the required permissions.',
'mailpoet'
)
),
array(),
Response::STATUS_FORBIDDEN
);
$error_response->send();
}
}
$response = $endpoint->{$this->_method}($this->_data);
$response->send();
} catch(\Exception $e) {
$error_response = new ErrorResponse(
@ -111,22 +133,20 @@ class API {
}
}
function setToken() {
$global = '<script type="text/javascript">';
$global .= 'var mailpoet_token = "'.Security::generateToken().'";';
$global .= '</script>';
echo $global;
}
function checkPermissions() {
return current_user_can('manage_options');
}
function checkToken() {
return (
isset($_POST['token'])
&&
wp_verify_nonce($_POST['token'], 'mailpoet_token')
);
return wp_verify_nonce($this->_token, 'mailpoet_token');
}
function setToken() {
$global = '<script type="text/javascript">';
$global .= 'var mailpoet_token = "';
$global .= Security::generateToken();
$global .= '";';
$global .= '</script>';
echo $global;
}
}

12
lib/API/Access.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace MailPoet\API;
if(!defined('ABSPATH')) exit;
final class Access {
const ALL = 'all';
private function __construct() {
}
}

View File

@ -5,6 +5,8 @@ if(!defined('ABSPATH')) exit;
abstract class Endpoint {
public $permissions = array();
function successResponse(
$data = array(), $meta = array(), $status = Response::STATUS_OK
) {
@ -16,7 +18,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 +27,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);

View File

@ -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());

View File

@ -17,7 +17,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.')
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
return $this->successResponse($form->asArray());
@ -57,31 +57,31 @@ class Forms extends APIEndpoint {
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'
)
@ -124,7 +124,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.')
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$exports = Util\Export::getAll($form->asArray());
@ -136,7 +136,7 @@ class Forms extends APIEndpoint {
$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'] : '');
@ -156,7 +156,6 @@ class Forms extends APIEndpoint {
// 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;
@ -164,7 +163,7 @@ class Forms extends APIEndpoint {
$list_selection = array_filter(
array_map(function($segment) {
return (isset($segment['id'])
? (int)$segment['id']
? $segment['id']
: null
);
}, $block['params']['values'])
@ -177,6 +176,7 @@ class Forms extends APIEndpoint {
// check list selection
if($has_segment_selection === true) {
$settings['segments_selected_by'] = 'user';
$settings['segments'] = $list_selection;
} else {
$settings['segments_selected_by'] = 'admin';
}
@ -206,7 +206,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.')
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$form->restore();
@ -222,7 +222,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.')
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$form->trash();
@ -238,7 +238,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.')
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$form->delete();
@ -252,11 +252,11 @@ class Forms extends APIEndpoint {
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.')
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$data = array(
'name' => sprintf(__('Copy of %s'), $form->name)
'name' => sprintf(__('Copy of %s', 'mailpoet'), $form->name)
);
$duplicate = $form->duplicate($data);
$errors = $duplicate->getErrors();

View File

@ -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);

View File

@ -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();

View File

@ -27,7 +27,7 @@ class Newsletters extends APIEndpoint {
$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')
));
} else {
return $this->successResponse(
@ -40,9 +40,9 @@ class Newsletters extends APIEndpoint {
}
function save($data = array()) {
$segment_ids = array();
$segments = array();
if(isset($data['segments'])) {
$segment_ids = $data['segments'];
$segments = $data['segments'];
unset($data['segments']);
}
@ -58,13 +58,14 @@ class Newsletters extends APIEndpoint {
if(!empty($errors)) {
return $this->badRequest($errors);
} else {
if(!empty($segment_ids)) {
if(!empty($segments)) {
NewsletterSegment::where('newsletter_id', $newsletter->id)
->deleteMany();
foreach($segment_ids as $segment_id) {
foreach($segments as $segment) {
if(!is_array($segment)) continue;
$relation = NewsletterSegment::create();
$relation->segment_id = $segment_id;
$relation->segment_id = (int)$segment['id'];
$relation->newsletter_id = $newsletter->id;
$relation->save();
}
@ -90,9 +91,14 @@ class Newsletters extends APIEndpoint {
}
}
return $this->successResponse(
Newsletter::findOne($newsletter->id)->asArray()
);
$newsletter = Newsletter::filter('filterWithOptions')->findOne($newsletter->id);
// if this is a post notification, process options and update its schedule
if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
Scheduler::processPostNotificationSchedule($newsletter);
}
return $this->successResponse($newsletter->asArray());
}
}
@ -101,7 +107,7 @@ class Newsletters extends APIEndpoint {
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')
));
}
@ -110,7 +116,7 @@ class Newsletters 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')
));
}
@ -131,7 +137,7 @@ class Newsletters extends APIEndpoint {
$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')
));
} else {
$newsletter->restore();
@ -147,7 +153,7 @@ class Newsletters extends APIEndpoint {
$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')
));
} else {
$newsletter->trash();
@ -163,7 +169,7 @@ class Newsletters extends APIEndpoint {
$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')
));
} else {
$newsletter->delete();
@ -177,11 +183,11 @@ class Newsletters 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 {
$data = array(
'subject' => sprintf(__('Copy of %s'), $newsletter->subject)
'subject' => sprintf(__('Copy of %s', 'mailpoet'), $newsletter->subject)
);
$duplicate = $newsletter->duplicate($data);
$errors = $duplicate->getErrors();
@ -200,7 +206,7 @@ class Newsletters extends APIEndpoint {
function showPreview($data = array()) {
if(empty($data['body'])) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Newsletter data is missing.')
APIError::BAD_REQUEST => __('Newsletter data is missing.', 'mailpoet')
));
}
@ -209,7 +215,7 @@ class Newsletters 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 {
$newsletter->body = $data['body'];
@ -229,7 +235,7 @@ class Newsletters extends APIEndpoint {
function sendPreview($data = array()) {
if(empty($data['subscriber'])) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Please specify receiver information.')
APIError::BAD_REQUEST => __('Please specify receiver information.', 'mailpoet')
));
}
@ -238,7 +244,7 @@ class Newsletters 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 {
$newsletter = $newsletter->asArray();
@ -404,7 +410,8 @@ class Newsletters extends APIEndpoint {
&&
$data['type'] === Newsletter::TYPE_NOTIFICATION
) {
Scheduler::processPostNotificationSchedule($newsletter->id);
$newsletter = Newsletter::filter('filterWithOptions')->findOne($newsletter->id);
Scheduler::processPostNotificationSchedule($newsletter);
}
return $this->successResponse(

View File

@ -17,7 +17,7 @@ class Segments extends APIEndpoint {
$segment = Segment::findOne($id);
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.')
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
return $this->successResponse($segment->asArray());
@ -68,7 +68,7 @@ class Segments extends APIEndpoint {
$segment = Segment::findOne($id);
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.')
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
$segment->restore();
@ -84,7 +84,7 @@ class Segments extends APIEndpoint {
$segment = Segment::findOne($id);
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.')
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
$segment->trash();
@ -100,7 +100,7 @@ class Segments extends APIEndpoint {
$segment = Segment::findOne($id);
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.')
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
$segment->delete();
@ -114,11 +114,11 @@ class Segments extends APIEndpoint {
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.')
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
$data = array(
'name' => sprintf(__('Copy of %s'), $segment->name)
'name' => sprintf(__('Copy of %s', 'mailpoet'), $segment->name)
);
$duplicate = $segment->duplicate($data);
$errors = $duplicate->getErrors();

View File

@ -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();

View File

@ -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) {

View File

@ -2,6 +2,7 @@
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
use \MailPoet\API\Access as APIAccess;
use MailPoet\Listing;
use MailPoet\Models\Subscriber;
@ -11,17 +12,21 @@ 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 extends APIEndpoint {
public $permissions = array(
'subscribe' => APIAccess::ALL
);
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$subscriber = Subscriber::findOne($id);
if($subscriber === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This subscriber does not exist.')
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
));
} else {
return $this->successResponse(
@ -56,14 +61,9 @@ class Subscribers extends APIEndpoint {
}
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']
@ -72,72 +72,37 @@ class Subscribers extends APIEndpoint {
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
);
}
}
@ -159,7 +124,7 @@ class Subscribers extends APIEndpoint {
$subscriber = Subscriber::findOne($id);
if($subscriber === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This subscriber does not exist.')
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
));
} else {
$subscriber->restore();
@ -175,7 +140,7 @@ class Subscribers extends APIEndpoint {
$subscriber = Subscriber::findOne($id);
if($subscriber === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This subscriber does not exist.')
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
));
} else {
$subscriber->trash();
@ -191,7 +156,7 @@ class Subscribers extends APIEndpoint {
$subscriber = Subscriber::findOne($id);
if($subscriber === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This subscriber does not exist.')
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
));
} else {
$subscriber->delete();

View File

@ -27,7 +27,6 @@ class Env {
static $db_password;
static $db_charset;
static $db_timezone_offset;
static $subscribers_limit = 2000;
static function init($file, $version) {
global $wpdb;
@ -39,11 +38,11 @@ class Env {
self::$assets_path = self::$path . '/assets';
self::$assets_url = plugins_url('/assets', $file);
$wp_upload_dir = wp_upload_dir();
self::$temp_path = $wp_upload_dir['basedir'].'/'.self::$plugin_name;
self::$temp_path = $wp_upload_dir['basedir'] . '/' . self::$plugin_name;
if(!is_dir(self::$temp_path)) {
mkdir(self::$temp_path);
}
self::$temp_url = $wp_upload_dir['baseurl'].'/'.self::$plugin_name;
self::$temp_url = $wp_upload_dir['baseurl'] . '/' . self::$plugin_name;
self::$languages_path = self::$path . '/lang';
self::$lib_path = self::$path . '/lib';
self::$plugin_prefix = 'mailpoet_';

View File

@ -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')
));
}

View File

@ -4,6 +4,7 @@ namespace MailPoet\Config;
use MailPoet\Cron\CronTrigger;
use MailPoet\Router;
use MailPoet\API;
use MailPoet\Util\License\License as License;
use MailPoet\WP\Notice as WPNotice;
if(!defined('ABSPATH')) exit;
@ -116,6 +117,7 @@ class Initializer {
function onInit() {
if(!$this->plugin_initialized) {
define('MAILPOET_INITIALIZED', false);
return;
}
@ -126,6 +128,8 @@ class Initializer {
} catch(\Exception $e) {
$this->handleFailedInitialization($e);
}
define('MAILPOET_INITIALIZED', true);
}
function setupWidget() {
@ -206,4 +210,4 @@ class Initializer {
function handleFailedInitialization($message) {
return WPNotice::displayError($message);
}
}
}

View File

@ -25,8 +25,6 @@ class Localizer {
$language_path =
Env::$languages_path
. '/'
. Env::$plugin_name
. '-'
. $this->locale()
. '.mo';
load_textdomain(Env::$plugin_name, $language_path);

View File

@ -14,6 +14,7 @@ use MailPoet\Settings\Hosts;
use MailPoet\Settings\Pages;
use MailPoet\Subscribers\ImportExport\ImportExportFactory;
use MailPoet\Listing;
use MailPoet\Util\License\Features\Subscribers as SubscribersFeature;
use MailPoet\WP\DateTime;
if(!defined('ABSPATH')) exit;
@ -22,6 +23,8 @@ class Menu {
function __construct($renderer, $assets_url) {
$this->renderer = $renderer;
$this->assets_url = $assets_url;
$subscribers_feature = new SubscribersFeature();
$this->subscribers_over_limit = $subscribers_feature->check();
}
function init() {
@ -34,16 +37,6 @@ 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';
@ -59,8 +52,8 @@ class Menu {
$newsletters_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Newsletters')),
__('Newsletters'),
$this->setPageTitle(__('Emails', 'mailpoet')),
__('Emails', 'mailpoet'),
'manage_options',
$main_page_slug,
array($this, 'newsletters')
@ -79,8 +72,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')
@ -98,8 +91,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')
@ -117,8 +110,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')
@ -137,16 +130,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')
@ -154,8 +147,8 @@ class Menu {
add_submenu_page(
true,
$this->setPageTitle(__('Export')),
__('Export'),
$this->setPageTitle(__('Export', 'mailpoet')),
__('Export', 'mailpoet'),
'manage_options',
'mailpoet-export',
array($this, 'export')
@ -163,8 +156,8 @@ class Menu {
add_submenu_page(
true,
$this->setPageTitle(__('Welcome')),
__('Welcome'),
$this->setPageTitle(__('Welcome', 'mailpoet')),
__('Welcome', 'mailpoet'),
'manage_options',
'mailpoet-welcome',
array($this, 'welcome')
@ -172,8 +165,8 @@ class Menu {
add_submenu_page(
true,
$this->setPageTitle(__('Update')),
__('Update'),
$this->setPageTitle(__('Update', 'mailpoet')),
__('Update', 'mailpoet'),
'manage_options',
'mailpoet-update',
array($this, 'update')
@ -181,8 +174,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')
@ -190,8 +183,8 @@ 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')
@ -252,14 +245,14 @@ class Menu {
}
function settings() {
$this->checkSubscribersLimit();
if ($this->subscribers_over_limit) return $this->displaySubscriberLimitExceededTemplate();
$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,
@ -303,7 +296,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']);
@ -326,7 +319,7 @@ class Menu {
}
function segments() {
$this->checkSubscribersLimit();
if ($this->subscribers_over_limit) return $this->displaySubscriberLimitExceededTemplate();
$data = array();
$data['items_per_page'] = $this->getLimitPerPage('segments');
@ -334,7 +327,7 @@ class Menu {
}
function forms() {
$this->checkSubscribersLimit();
if ($this->subscribers_over_limit) return $this->displaySubscriberLimitExceededTemplate();
$data = array();
@ -345,7 +338,7 @@ class Menu {
}
function newsletters() {
$this->checkSubscribersLimit();
if ($this->subscribers_over_limit) return $this->displaySubscriberLimitExceededTemplate();
global $wp_roles;
@ -355,7 +348,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);
@ -416,7 +409,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(),
@ -430,7 +423,7 @@ class Menu {
function setPageTitle($title) {
return sprintf(
'%s - %s',
__('MailPoet'),
__('MailPoet', 'mailpoet'),
$title
);
}
@ -447,4 +440,11 @@ class Menu {
? (int)$listing_per_page
: Listing\Handler::DEFAULT_LIMIT_PER_PAGE;
}
}
function displaySubscriberLimitExceededTemplate() {
echo $this->renderer->render('limit.html', array(
'limit' => SubscribersFeature::SUBSCRIBERS_LIMIT
));
exit;
}
}

View File

@ -131,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();
}

View File

@ -13,8 +13,8 @@ class FranksRoastHouseTemplate {
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&nbsp;[subscriber:firstname | default:coffee drinker]</p>\n<p></p>\n<p>Sit back&nbsp;and enjoy your favorite roast as you read this week's newsletter.&nbsp;</p>")
"text" => __("<p>Hi there&nbsp;[subscriber:firstname | default:coffee drinker]</p>\n<p></p>\n<p>Sit back&nbsp;and enjoy your favorite roast as you read this week's newsletter.&nbsp;</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&nbsp;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&nbsp;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!&nbsp;</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!&nbsp;</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"

View File

@ -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?&nbsp;<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
"text" => __("Display problems?&nbsp;<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&nbsp;the right sidebar, you'll find four menu items that will help&nbsp;you&nbsp;customize your&nbsp;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&nbsp;the right sidebar, you'll find four menu items that will help&nbsp;you&nbsp;customize your&nbsp;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&nbsp;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&nbsp;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&nbsp;Designer. Simply hover&nbsp;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&nbsp;Designer. Simply hover&nbsp;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&nbsp;a single column.&nbsp;</span></h3>\n<p style=\"line-height: 25.6px;\">In the right sidebar, you can&nbsp;add these layout blocks to your&nbsp;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&nbsp;a single column.&nbsp;</span></h3>\n<p style=\"line-height: 25.6px;\">In the right sidebar, you can&nbsp;add these layout blocks to your&nbsp;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"

View File

@ -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?&nbsp;<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
"text" => __("Display problems?&nbsp;<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&nbsp;help you customize your&nbsp;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&nbsp;help you customize your&nbsp;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&nbsp;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&nbsp;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&nbsp;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&nbsp;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"

View File

@ -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?&nbsp;<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
"text" => __("Display problems?&nbsp;<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!&nbsp;</strong></h1>\n<p></p>\n<p>It's time to design your newsletter! On&nbsp;the right sidebar, you'll find four menu items that will help&nbsp;you&nbsp;customize your&nbsp;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!&nbsp;</strong></h1>\n<p></p>\n<p>It's time to design your newsletter! On&nbsp;the right sidebar, you'll find four menu items that will help&nbsp;you&nbsp;customize your&nbsp;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...&nbsp;</h3>")
"text" => __("<h3>This template...&nbsp;</h3>", 'mailpoet')
),
array(
"type" => "text",
"text" => __("<p>In the right sidebar, you can&nbsp;add layout blocks to your newsletter.</p>")
"text" => __("<p>In the right sidebar, you can&nbsp;add layout blocks to your newsletter.</p>", 'mailpoet')
)
)
),
@ -173,11 +173,11 @@ class NewsletterBlank13Column {
"blocks" => array(
array(
"type" => "text",
"text" => __("<h3>... has&nbsp;a...&nbsp;</h3>")
"text" => __("<h3>... has&nbsp;a...&nbsp;</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"

View File

@ -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?&nbsp;<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
"text" => __("Display problems?&nbsp;<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!&nbsp;</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&nbsp;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!&nbsp;</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&nbsp;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"

View File

@ -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?&nbsp;<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
"text" => __("Display problems?&nbsp;<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!&nbsp;</strong></h1>\n<p></p>\n<p>MailPoet&nbsp;can&nbsp;<span style=\"line-height: 1.6em; background-color: inherit;\"><em>automatically</em>&nbsp;</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&nbsp;recent&nbsp;posts, which are displayed automatically, thanks to the&nbsp;<em>Automatic Latest Content</em>&nbsp;widget, which can be found on the right sidebar, under&nbsp;<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&nbsp;a&nbsp;post below.</span></p>")
"text" => __("<h1 style=\"text-align: center;\"><strong>Check Out Our New Blog Posts!&nbsp;</strong></h1>\n<p></p>\n<p>MailPoet&nbsp;can&nbsp;<span style=\"line-height: 1.6em; background-color: inherit;\"><em>automatically</em>&nbsp;</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&nbsp;recent&nbsp;posts, which are displayed automatically, thanks to the&nbsp;<em>Automatic Latest Content</em>&nbsp;widget, which can be found on the right sidebar, under&nbsp;<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&nbsp;a&nbsp;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"

View File

@ -13,8 +13,8 @@ class Restaurant {
function get() {
return array(
'name' => __("Restaurant"),
'description' => __("What's fresh on the menu?"),
'name' => __("Restaurant", 'mailpoet'),
'description' => __("What's fresh on the menu?", 'mailpoet'),
'readonly' => 0,
'thumbnail' => $this->getThumbnail(),
'body' => json_encode($this->getBody()),

View 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&nbsp;[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,&nbsp;just like in a regular email.&nbsp;This can make your email newsletters&nbsp;more personal and attention-grabbing.</p>\n<p style=\"text-align: left;\"></p>\n<p style=\"text-align: left;\">Is this too&nbsp;simple?&nbsp;You can still style your text with basic&nbsp;formatting,&nbsp;like&nbsp;<strong>bold</strong>&nbsp;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&nbsp;[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,&nbsp;just like in a regular email.&nbsp;This can make your email newsletters&nbsp;more personal and attention-grabbing.</p>\n<p style=\"text-align: left;\"></p>\n<p style=\"text-align: left;\">Is this too&nbsp;simple?&nbsp;You can still style your text with basic&nbsp;formatting,&nbsp;like&nbsp;<strong>bold</strong>&nbsp;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&nbsp;reading. See you soon!</p>\n<p></p>\n<p><strong><em>The MailPoet Team</em></strong></p>")
"text" => __("<p>Thanks for&nbsp;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"

View File

@ -13,8 +13,8 @@ class StoreDiscount {
function get() {
return array(
'name' => __("Store Discount"),
'description' => __("Store discount email with coupon and shopping suggestions"),
'name' => __("Store Discount", 'mailpoet'),
'description' => __("Store discount email with coupon and shopping suggestions", 'mailpoet'),
'readonly' => 0,
'thumbnail' => $this->getThumbnail(),
'body' => json_encode($this->getBody()),
@ -59,7 +59,7 @@ class StoreDiscount {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/bicycle-header3.png",
"alt" => __("bicycle-header3"),
"alt" => __("bicycle-header3", 'mailpoet'),
"fullWidth" => false,
"width" => "423px",
"height" => "135px",
@ -70,7 +70,7 @@ class StoreDiscount {
)
), array(
"type" => "text",
"text" => __("<p></p>\n<p>Hi&nbsp;[subscriber:firstname | default:reader]</p>\n<p class=\"\"></p>\n<p>Fancy 15% off your next order? Use this coupon&nbsp;on all your favourite products from our store&nbsp;until Wednesday. Just&nbsp;enter the code on the payments page and&nbsp;your discount will applied.</p>")
"text" => __("<p></p>\n<p>Hi&nbsp;[subscriber:firstname | default:reader]</p>\n<p class=\"\"></p>\n<p>Fancy 15% off your next order? Use this coupon&nbsp;on all your favourite products from our store&nbsp;until Wednesday. Just&nbsp;enter the code on the payments page and&nbsp;your discount will applied.</p>", 'mailpoet')
), array(
"type" => "spacer",
"styles" => array(
@ -110,10 +110,10 @@ class StoreDiscount {
)
), array(
"type" => "text",
"text" => __("<h1 style=\"text-align: center;\"><em><strong>Get 15% discount off your next order</strong></em></h1>")
"text" => __("<h1 style=\"text-align: center;\"><em><strong>Get 15% discount off your next order</strong></em></h1>", 'mailpoet')
), array(
"type" => "text",
"text" => __("<h2 style=\"text-align: center;\"><strong>USE CODE: WELOVEMAILPOET</strong></h2>")
"text" => __("<h2 style=\"text-align: center;\"><strong>USE CODE: WELOVEMAILPOET</strong></h2>", 'mailpoet')
), array(
"type" => "divider",
"styles" => array(
@ -153,7 +153,7 @@ class StoreDiscount {
)
), array(
"type" => "button",
"text" => __("SHOP NOW"),
"text" => __("SHOP NOW", 'mailpoet'),
"url" => "",
"styles" => array(
"block" => array(
@ -173,7 +173,7 @@ class StoreDiscount {
)
), array(
"type" => "text",
"text" => __("<h1 style=\"text-align: center;\"><strong><em>Use your discount on these great&nbsp;products...</em></strong></h1>")
"text" => __("<h1 style=\"text-align: center;\"><strong><em>Use your discount on these great&nbsp;products...</em></strong></h1>", 'mailpoet')
), array(
"type" => "spacer",
"styles" => array(
@ -204,7 +204,7 @@ class StoreDiscount {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/red-icycle.jpg",
"alt" => __("red-icycle"),
"alt" => __("red-icycle", 'mailpoet'),
"fullWidth" => false,
"width" => "558px",
"height" => "399px",
@ -215,10 +215,10 @@ class StoreDiscount {
)
), array(
"type" => "text",
"text" => __("<h3 style=\"text-align: center;\">Lovely Red Bicycle</h3>\n<p>What can we say? It's a totally awesome red bike, and it's the first of its kind in our collection. No sweat!</p>\n<h3 style=\"text-align: center;\"><strong><span style=\"color: #488e88;\">$289.99</span></strong></h3>")
"text" => __("<h3 style=\"text-align: center;\">Lovely Red Bicycle</h3>\n<p>What can we say? It's a totally awesome red bike, and it's the first of its kind in our collection. No sweat!</p>\n<h3 style=\"text-align: center;\"><strong><span style=\"color: #488e88;\">$289.99</span></strong></h3>", 'mailpoet')
), array(
"type" => "button",
"text" => __("Buy"),
"text" => __("Buy", 'mailpoet'),
"url" => "",
"styles" => array(
"block" => array(
@ -249,7 +249,7 @@ class StoreDiscount {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/orange-bicycle.jpg",
"alt" => __("orange-bicycle"),
"alt" => __("orange-bicycle", 'mailpoet'),
"fullWidth" => false,
"width" => "639px",
"height" => "457px",
@ -260,10 +260,10 @@ class StoreDiscount {
)
), array(
"type" => "text",
"text" => __("<h3 style=\"text-align: center;\">Little Orange Bicycle</h3>\n<p>Another product that's just as awesome but it's the second type, and more orange, with some blue. Cool beans!</p>\n<h3 style=\"line-height: 22.4px; text-align: center;\"><span style=\"color: #488e88;\"><strong>$209.99</strong></span></h3>")
"text" => __("<h3 style=\"text-align: center;\">Little Orange Bicycle</h3>\n<p>Another product that's just as awesome but it's the second type, and more orange, with some blue. Cool beans!</p>\n<h3 style=\"line-height: 22.4px; text-align: center;\"><span style=\"color: #488e88;\"><strong>$209.99</strong></span></h3>", 'mailpoet')
), array(
"type" => "button",
"text" => __("Buy"),
"text" => __("Buy", 'mailpoet'),
"url" => "",
"styles" => array(
"block" => array(
@ -320,7 +320,7 @@ class StoreDiscount {
)
), array(
"type" => "text",
"text" => __("<p><em>Terms and Conditions:</em></p>\n<ul>\n<li><span style=\"line-height: 1.6em; background-color: inherit;\">Must be used by midnight EST December 15 2016.</span></li>\n<li><span style=\"line-height: 1.6em; background-color: inherit;\">Discount does not include shipping.</span></li>\n<li><span style=\"line-height: 1.6em; background-color: inherit;\">Cannot be used in conjunction with any other offer.</span></li>\n</ul>")
"text" => __("<p><em>Terms and Conditions:</em></p>\n<ul>\n<li><span style=\"line-height: 1.6em; background-color: inherit;\">Must be used by midnight EST December 15 2016.</span></li>\n<li><span style=\"line-height: 1.6em; background-color: inherit;\">Discount does not include shipping.</span></li>\n<li><span style=\"line-height: 1.6em; background-color: inherit;\">Cannot be used in conjunction with any other offer.</span></li>\n</ul>", 'mailpoet')
), array(
"type" => "social",
"iconSet" => "grey",
@ -331,7 +331,7 @@ class StoreDiscount {
"image" => $this->social_icon_url . "/02-grey/Facebook.png",
"height" => "32px",
"width" => "32px",
"text" => __("Facebook")
"text" => __("Facebook", 'mailpoet')
), array(
"type" => "socialIcon",
"iconType" => "twitter",
@ -339,11 +339,11 @@ class StoreDiscount {
"image" => $this->social_icon_url . "/02-grey/Twitter.png",
"height" => "32px",
"width" => "32px",
"text" => __("Twitter")
"text" => __("Twitter", 'mailpoet')
))
), array(
"type" => "footer",
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a></p>\n<p>1 Store Street, Shopville, CA 1345</p>"),
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a></p>\n<p>1 Store Street, Shopville, CA 1345</p>", 'mailpoet'),
"styles" => array(
"block" => array(
"backgroundColor" => "transparent"

View File

@ -13,8 +13,8 @@ class TravelEmail {
function get() {
return array(
'name' => __("Travel email"),
'description' => __("A little postcard from your trip"),
'name' => __("Travel email", 'mailpoet'),
'description' => __("A little postcard from your trip", 'mailpoet'),
'readonly' => 0,
'thumbnail' => $this->getThumbnail(),
'body' => json_encode($this->getBody()),
@ -51,7 +51,7 @@ class TravelEmail {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/header.png",
"alt" => __("Travelling Tales with Jane & Steven"),
"alt" => __("Travelling Tales with Jane & Steven", 'mailpoet'),
"fullWidth" => true,
"width" => "660px",
"height" => "165px",
@ -70,7 +70,7 @@ class TravelEmail {
)
), array(
"type" => "text",
"text" => __("<h1 style=\"text-align: center;\">Hi&nbsp;[subscriber:firstname | default:reader]!</h1>\n<p></p>\n<p>Greetings from New Zealand, we're here enjoying the sights and sounds (and bad smells!) of Rotarua. Yesterday we took advantage of the local amenities and visited&nbsp;the hot springs!&nbsp;</p>\n<p>Don't forget to stay up-to-date via twitter!</p>")
"text" => __("<h1 style=\"text-align: center;\">Hi&nbsp;[subscriber:firstname | default:reader]!</h1>\n<p></p>\n<p>Greetings from New Zealand, we're here enjoying the sights and sounds (and bad smells!) of Rotarua. Yesterday we took advantage of the local amenities and visited&nbsp;the hot springs!&nbsp;</p>\n<p>Don't forget to stay up-to-date via twitter!</p>", 'mailpoet')
), array(
"type" => "social",
"iconSet" => "circles",
@ -81,11 +81,11 @@ class TravelEmail {
"image" => $this->social_icon_url . "/03-circles/Twitter.png",
"height" => "32px",
"width" => "32px",
"text" => __("Twitter")
"text" => __("Twitter", 'mailpoet')
))
), array(
"type" => "text",
"text" => __("<h1 style=\"text-align: center;\"><strong>Photos from Rotarua</strong></h1>")
"text" => __("<h1 style=\"text-align: center;\"><strong>Photos from Rotarua</strong></h1>", 'mailpoet')
), array(
"type" => "spacer",
"styles" => array(
@ -116,7 +116,7 @@ class TravelEmail {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/gallery1.jpg",
"alt" => __("hot thermals"),
"alt" => __("hot thermals", 'mailpoet'),
"fullWidth" => false,
"width" => "640px",
"height" => "425px",
@ -146,7 +146,7 @@ class TravelEmail {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/gallery2.jpg",
"alt" => __("The view from our campsite"),
"alt" => __("The view from our campsite", 'mailpoet'),
"fullWidth" => false,
"width" => "640px",
"height" => "425px",
@ -185,7 +185,7 @@ class TravelEmail {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/gallery3.jpg",
"alt" => __("Red sky at night"),
"alt" => __("Red sky at night", 'mailpoet'),
"fullWidth" => false,
"width" => "640px",
"height" => "425px",
@ -207,7 +207,7 @@ class TravelEmail {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/gallery4.jpg",
"alt" => __("Don't go chasing waterfalls"),
"alt" => __("Don't go chasing waterfalls", 'mailpoet'),
"fullWidth" => false,
"width" => "640px",
"height" => "425px",
@ -244,7 +244,7 @@ class TravelEmail {
)
), array(
"type" => "button",
"text" => __("View NZ Photo Gallery"),
"text" => __("View NZ Photo Gallery", 'mailpoet'),
"url" => "",
"styles" => array(
"block" => array(
@ -293,7 +293,7 @@ class TravelEmail {
)
), array(
"type" => "text",
"text" => __("<h2><em>Here's our top recommendations in Rotarua</em></h2>")
"text" => __("<h2><em>Here's our top recommendations in Rotarua</em></h2>", 'mailpoet')
), array(
"type" => "spacer",
"styles" => array(
@ -324,7 +324,7 @@ class TravelEmail {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/glow-worms.jpg",
"alt" => __("Glow worms, Waitomo Caves"),
"alt" => __("Glow worms, Waitomo Caves", 'mailpoet'),
"fullWidth" => true,
"width" => "640px",
"height" => "428px",
@ -335,7 +335,7 @@ class TravelEmail {
)
), array(
"type" => "text",
"text" => __("<p><em><a href=\"http://www.waitomo.com/Waitomo-Glowworm-Caves/Pages/default.aspx\"><strong>Waitomo Glow Worm Caves</strong></a></em></p>")
"text" => __("<p><em><a href=\"http://www.waitomo.com/Waitomo-Glowworm-Caves/Pages/default.aspx\"><strong>Waitomo Glow Worm Caves</strong></a></em></p>", 'mailpoet')
))
), array(
"type" => "container",
@ -349,7 +349,7 @@ class TravelEmail {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/luge.jpg",
"alt" => __("luge"),
"alt" => __("luge", 'mailpoet'),
"fullWidth" => false,
"width" => "375px",
"height" => "500px",
@ -360,7 +360,7 @@ class TravelEmail {
)
), array(
"type" => "text",
"text" => __("<p><em><strong><a href=\"http://www.skyline.co.nz/rotorua/ssr_luge/\">Luge!</a></strong></em></p>")
"text" => __("<p><em><strong><a href=\"http://www.skyline.co.nz/rotorua/ssr_luge/\">Luge!</a></strong></em></p>", 'mailpoet')
))
), array(
"type" => "container",
@ -374,7 +374,7 @@ class TravelEmail {
"type" => "image",
"link" => "",
"src" => $this->template_image_url . "/holiday-park.jpg",
"alt" => __("holiday-park"),
"alt" => __("holiday-park", 'mailpoet'),
"fullWidth" => true,
"width" => "640px",
"height" => "425px",
@ -385,7 +385,7 @@ class TravelEmail {
)
), array(
"type" => "text",
"text" => __("<p><em><strong><a href=\"http://rotoruathermal.co.nz/\">Roturua Thermal Holiday Park</a></strong></em></p>")
"text" => __("<p><em><strong><a href=\"http://rotoruathermal.co.nz/\">Roturua Thermal Holiday Park</a></strong></em></p>", 'mailpoet')
))
))
), array(
@ -414,7 +414,7 @@ class TravelEmail {
)
), array(
"type" => "text",
"text" => __("<p>Tomorrow we're heading towards Taupo where we'll visit the&nbsp;'Craters of the moon' and go prawn fishing!&nbsp;Hopefully the weather will stay good.</p>\n<p></p>\n<p>Keep on travellin'</p>\n<p>Jane &amp; Steven</p>")
"text" => __("<p>Tomorrow we're heading towards Taupo where we'll visit the&nbsp;'Craters of the moon' and go prawn fishing!&nbsp;Hopefully the weather will stay good.</p>\n<p></p>\n<p>Keep on travellin'</p>\n<p>Jane &amp; Steven</p>", 'mailpoet')
))
))
), array(
@ -464,7 +464,7 @@ class TravelEmail {
)
), array(
"type" => "footer",
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a></p>"),
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a></p>", 'mailpoet'),
"styles" => array(
"block" => array(
"backgroundColor" => "transparent"

View 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?&nbsp;<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
"text" => __("Display problems?&nbsp;<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&nbsp;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&nbsp;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 &ndash; 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 &ndash; 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&nbsp;Next?</h3>")
"text" => __("<h3>What's&nbsp;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"

View File

@ -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?&nbsp;<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
"text" => __("Display problems?&nbsp;<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,&nbsp;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&nbsp;you a warm welcome!</p>\n<p></p>\n<p>Want to get to know us better? Check&nbsp;out&nbsp;some of our most popular&nbsp;articles:&nbsp;</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 &ndash; Advice on Motivation from Ernest Hemingway</a></li>\n</ol>")
"text" => __("<h1 style=\"text-align: center;\"><strong>Hi,&nbsp;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&nbsp;you a warm welcome!</p>\n<p></p>\n<p>Want to get to know us better? Check&nbsp;out&nbsp;some of our most popular&nbsp;articles:&nbsp;</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 &ndash; 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"

View File

@ -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>';
}

View File

@ -69,8 +69,7 @@ class Widget {
'form' => $form_html,
'mailpoet_form' => array(
'ajax_url' => admin_url('admin-ajax.php', 'absolute'),
'is_rtl' => $is_rtl,
'token' => Security::generateToken()
'is_rtl' => $is_rtl
)
);
@ -103,8 +102,7 @@ class Widget {
wp_localize_script('mailpoet_public', 'MailPoetForm', array(
'ajax_url' => admin_url('admin-ajax.php'),
'is_rtl' => (function_exists('is_rtl') ? (bool)is_rtl() : false),
'token' => Security::generateToken()
'is_rtl' => (function_exists('is_rtl') ? (bool)is_rtl() : false)
));
}

View File

@ -38,11 +38,6 @@ class CronHelper {
);
}
static function stopDaemon() {
$daemon = self::getDaemon();
return self::saveDaemon($daemon);
}
static function deleteDaemon() {
return Setting::deleteValue(self::DAEMON_SETTING);
}
@ -85,13 +80,13 @@ class CronHelper {
$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.'));
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'));
}
}
}

View File

@ -1,12 +1,10 @@
<?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;
@ -24,10 +22,10 @@ class Daemon {
function run() {
ignore_user_abort(true);
if(!$this->request_data) {
$error = __('Invalid or missing request data.');
$error = __('Invalid or missing request data.', 'mailpoet');
} else {
if(!$this->daemon) {
$error = __('Daemon does not exist.');
$error = __('Daemon does not exist.', 'mailpoet');
} else {
if(!isset($this->request_data['token']) ||
$this->request_data['token'] !== $this->daemon['token']

View File

@ -10,9 +10,8 @@ use MailPoet\Models\SubscriberSegment;
use MailPoet\Util\Helpers;
use MailPoet\Newsletter\Scheduler\Scheduler as NewsletterScheduler;
require_once(ABSPATH . 'wp-includes/pluggable.php');
if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-includes/pluggable.php');
class Scheduler {
public $timer;

View File

@ -4,24 +4,22 @@ namespace MailPoet\Cron\Workers\SendingQueue;
use MailPoet\Cron\CronHelper;
use MailPoet\Cron\Workers\SendingQueue\Tasks\Mailer as MailerTask;
use MailPoet\Cron\Workers\SendingQueue\Tasks\Newsletter as NewsletterTask;
use MailPoet\Cron\Workers\SendingQueue\Tasks\Subscribers as SubscribersTask;
use MailPoet\Mailer\MailerLog;
use MailPoet\Models\SendingQueue as SendingQueueModel;
use MailPoet\Models\StatisticsNewsletters as StatisticsNewslettersModel;
use MailPoet\Models\Subscriber as SubscriberModel;
use MailPoet\Util\Helpers;
if(!defined('ABSPATH')) exit;
class SendingQueue {
public $mailer_task;
public $newsletter_task;
private $timer;
public $timer;
const BATCH_SIZE = 50;
function __construct($timer = false) {
$this->mailer_task = new MailerTask();
$this->newsletter_task = new NewsletterTask();
function __construct($timer = false, $mailer_task = false, $newsletter_task = false) {
$this->mailer_task = ($mailer_task) ? $mailer_task : new MailerTask();
$this->newsletter_task = ($newsletter_task) ? $newsletter_task : new NewsletterTask();
$this->timer = ($timer) ? $timer : microtime(true);
// abort if execution or sending limit are reached
CronHelper::enforceExecutionLimit($this->timer);
@ -32,17 +30,13 @@ class SendingQueue {
// abort if sending limit is reached
MailerLog::enforceSendingLimit();
// get and pre-process newsletter (render, replace shortcodes/links, etc.)
$newsletter = $this->newsletter_task->getAndPreProcess($queue->asArray());
$newsletter = $this->newsletter_task->getAndPreProcess($queue);
if(!$newsletter) {
$queue->delete();
continue;
}
// configure mailer
$this->mailer_task->configureMailer($newsletter);
if(is_null($queue->newsletter_rendered_body)) {
$queue->newsletter_rendered_body = json_encode($newsletter['rendered_body']);
$queue->save();
}
// get subscribers
$queue->subscribers = $queue->getSubscribers();
$subscriber_batches = array_chunk(
@ -50,20 +44,25 @@ class SendingQueue {
self::BATCH_SIZE
);
foreach($subscriber_batches as $subscribers_to_process_ids) {
// abort if execution limit is reached
CronHelper::enforceExecutionLimit($this->timer);
$found_subscribers = SubscriberModel::whereIn('id', $subscribers_to_process_ids)
->findArray();
$found_subscribers_ids = Helpers::arrayColumn($found_subscribers, 'id');
->whereNull('deleted_at')
->findMany();
$found_subscribers_ids = array_map(function($subscriber) {
return $subscriber->id;
}, $found_subscribers);
// if some subscribers weren't found, remove them from the processing list
if(count($found_subscribers_ids) !== count($subscribers_to_process_ids)) {
$queue->subscribers = SubscribersTask::updateToProcessList(
$found_subscribers_ids,
$subscibers_to_remove = array_diff(
$subscribers_to_process_ids,
$queue->subscribers
$found_subscribers_ids
);
}
if(!count($queue->subscribers['to_process'])) {
$this->updateQueue($queue);
continue;
$queue->removeNonexistentSubscribers($subscibers_to_remove);
if(!count($queue->subscribers['to_process'])) {
$this->newsletter_task->markNewsletterAsSent($newsletter);
continue;
}
}
$queue = $this->processQueue(
$queue,
@ -71,10 +70,8 @@ class SendingQueue {
$found_subscribers
);
if($queue->status === SendingQueueModel::STATUS_COMPLETED) {
$this->newsletter_task->markNewsletterAsSent($queue->newsletter_id);
$this->newsletter_task->markNewsletterAsSent($newsletter);
}
// abort if execution limit is reached
CronHelper::enforceExecutionLimit($this->timer);
}
}
}
@ -92,7 +89,7 @@ class SendingQueue {
$this->newsletter_task->prepareNewsletterForSending(
$newsletter,
$subscriber,
$queue->asArray()
$queue
);
if(!$queue->newsletter_rendered_subject) {
$queue->newsletter_rendered_subject = $prepared_newsletters[0]['subject'];
@ -101,11 +98,11 @@ class SendingQueue {
$prepared_subscribers[] = $this->mailer_task->prepareSubscriberForSending(
$subscriber
);
$prepared_subscribers_ids[] = $subscriber['id'];
$prepared_subscribers_ids[] = $subscriber->id;
// keep track of values for statistics purposes
$statistics[] = array(
'newsletter_id' => $newsletter['id'],
'subscriber_id' => $subscriber['id'],
'newsletter_id' => $newsletter->id,
'subscriber_id' => $subscriber->id,
'queue_id' => $queue->id
);
if($processing_method === 'individual') {
@ -145,22 +142,14 @@ class SendingQueue {
);
if(!$send_result) {
// update failed/to process list
$queue->subscribers = SubscribersTask::updateFailedList(
$prepared_subscribers_ids,
$queue->subscribers
);
$queue = $this->updateQueue($queue);
$queue->updateFailedSubscribers($prepared_subscribers_ids);
} else {
// update processed/to process list
$queue->subscribers = SubscribersTask::updateProcessedList(
$prepared_subscribers_ids,
$queue->subscribers
);
$queue->updateProcessedSubscribers($prepared_subscribers_ids);
// log statistics
StatisticsNewslettersModel::createMultiple($statistics);
// update the sent count
$this->mailer_task->updateSentCount();
$queue = $this->updateQueue($queue);
// enforce sending limit if there are still subscribers left to process
if($queue->count_to_process) {
MailerLog::enforceSendingLimit();
@ -175,18 +164,4 @@ class SendingQueue {
->whereNull('status')
->findMany();
}
function updateQueue($queue) {
$queue->count_processed =
count($queue->subscribers['processed']) + count($queue->subscribers['failed']);
$queue->count_to_process = count($queue->subscribers['to_process']);
$queue->count_failed = count($queue->subscribers['failed']);
$queue->count_total =
$queue->count_processed + $queue->count_to_process;
if(!$queue->count_to_process) {
$queue->processed_at = current_time('mysql');
$queue->status = SendingQueueModel::STATUS_COMPLETED;
}
return $queue->save();
}
}

View File

@ -7,27 +7,27 @@ use MailPoet\Util\Helpers;
if(!defined('ABSPATH')) exit;
class Links {
static function process(array $newsletter, array $queue) {
list($newsletter, $links) = self::hashAndReplaceLinks($newsletter, $queue);
static function process($rendered_newsletter, $newsletter, $queue) {
list($rendered_newsletter, $links) =
self::hashAndReplaceLinks($rendered_newsletter);
self::saveLinks($links, $newsletter, $queue);
return $newsletter;
return $rendered_newsletter;
}
static function hashAndReplaceLinks(array $newsletter, array $queue) {
static function hashAndReplaceLinks($rendered_newsletter) {
// join HTML and TEXT rendered body into a text string
$content = Helpers::joinObject($newsletter['rendered_body']);
$content = Helpers::joinObject($rendered_newsletter);
list($content, $links) = NewsletterLinks::process($content);
// split the processed body with hashed links back to HTML and TEXT
list($newsletter['rendered_body']['html'], $newsletter['rendered_body']['text'])
list($rendered_newsletter['html'], $rendered_newsletter['text'])
= Helpers::splitObject($content);
return array(
$newsletter,
$rendered_newsletter,
$links
);
}
static function saveLinks($links, $newsletter, $queue) {
return NewsletterLinks::save($links, $newsletter['id'], $queue['id']);
return NewsletterLinks::save($links, $newsletter->id, $queue->id);
}
}
}

View File

@ -9,22 +9,22 @@ if(!defined('ABSPATH')) exit;
class Mailer {
public $mailer;
function __construct() {
$this->mailer = $this->configureMailer();
function __construct($mailer = false) {
$this->mailer = ($mailer) ? $mailer : $this->configureMailer();
}
function configureMailer(array $newsletter = null) {
$sender['address'] = (!empty($newsletter['sender_address'])) ?
$newsletter['sender_address'] :
function configureMailer($newsletter = null) {
$sender['address'] = (!empty($newsletter->sender_address)) ?
$newsletter->sender_address :
false;
$sender['name'] = (!empty($newsletter['sender_name'])) ?
$newsletter['sender_name'] :
$sender['name'] = (!empty($newsletter->sender_name)) ?
$newsletter->sender_name :
false;
$reply_to['address'] = (!empty($newsletter['reply_to_address'])) ?
$newsletter['reply_to_address'] :
$reply_to['address'] = (!empty($newsletter->reply_to_address)) ?
$newsletter->reply_to_address :
false;
$reply_to['name'] = (!empty($newsletter['reply_to_name'])) ?
$newsletter['reply_to_name'] :
$reply_to['name'] = (!empty($newsletter->reply_to_name)) ?
$newsletter->reply_to_name :
false;
if(!$sender['address']) {
$sender = false;
@ -50,8 +50,8 @@ class Mailer {
'individual';
}
function prepareSubscriberForSending(array $subscriber) {
return $this->mailer->transformSubscriber($subscriber);
function prepareSubscriberForSending($subscriber) {
return $this->mailer->formatSubscriberNameAndEmailAddress($subscriber);
}
function send($prepared_newsletters, $prepared_subscribers) {

View File

@ -8,7 +8,6 @@ use MailPoet\Models\Newsletter as NewsletterModel;
use MailPoet\Models\Setting;
use MailPoet\Newsletter\Links\Links as NewsletterLinks;
use MailPoet\Newsletter\Renderer\PostProcess\OpenTracking;
use MailPoet\Newsletter\Renderer\Renderer;
use MailPoet\Util\Helpers;
if(!defined('ABSPATH')) exit;
@ -19,65 +18,54 @@ class Newsletter {
function __construct() {
$this->tracking_enabled = (boolean)Setting::getValue('tracking.enabled');
$this->tracking_image_inserted = false;
}
function get($newsletter_id) {
$newsletter = NewsletterModel::findOne($newsletter_id);
return ($newsletter) ? $newsletter->asArray() : false;
}
function getAndPreProcess(array $queue) {
$newsletter = $this->get($queue['newsletter_id']);
function getAndPreProcess($queue) {
$newsletter = $queue->newsletter()->findOne();
if(!$newsletter) {
return false;
}
// if the newsletter was previously rendered, return it
// otherwise, process/render it
if(!is_null($queue['newsletter_rendered_body'])) {
$newsletter['rendered_body'] = json_decode($queue['newsletter_rendered_body'], true);
if(!is_null($queue->getNewsletterRenderedBody())) {
return $newsletter;
}
// if tracking is enabled, do additional processing
if($this->tracking_enabled) {
// hook once to the newsletter post-processing filter and add tracking image
if(!$this->tracking_image_inserted) {
$this->tracking_image_inserted = OpenTracking::addTrackingImage();
}
// render newsletter
$newsletter = $this->render($newsletter);
// hook to the newsletter post-processing filter and add tracking image
$this->tracking_image_inserted = OpenTracking::addTrackingImage();
// render newsletter and save its
$rendered_newsletter = $newsletter->render();
// hash and save all links
$newsletter = LinksTask::process($newsletter, $queue);
$rendered_newsletter = LinksTask::process($rendered_newsletter, $newsletter, $queue);
} else {
// render newsletter
$newsletter = $this->render($newsletter);
$rendered_newsletter = $newsletter->render();
}
// check if this is a post notification and if it contains posts
$newsletter_contains_posts = strpos($newsletter['rendered_body']['html'], 'data-post-id');
if($newsletter['type'] === 'notification' && !$newsletter_contains_posts) {
$newsletter_contains_posts = strpos($rendered_newsletter['html'], 'data-post-id');
if($newsletter->type === NewsletterModel::TYPE_NOTIFICATION_HISTORY &&
!$newsletter_contains_posts
) {
return false;
}
// extract and save newsletter posts
PostsTask::extractAndSave($newsletter);
PostsTask::extractAndSave($rendered_newsletter, $newsletter);
// update queue with the rendered and pre-processed newsletter
$queue->newsletter_rendered_body = $rendered_newsletter;
$queue->save();
return $newsletter;
}
function render(array $newsletter) {
$renderer = new Renderer($newsletter);
$newsletter['rendered_body'] = $renderer->render();
return $newsletter;
}
function prepareNewsletterForSending(
array $newsletter, array $subscriber, array $queue
) {
function prepareNewsletterForSending($newsletter, $subscriber, $queue) {
// shortcodes and links will be replaced in the subject, html and text body
// to speed the processing, join content into a continuous string
$rendered_newsletter = $queue->getNewsletterRenderedBody();
$prepared_newsletter = Helpers::joinObject(
array(
$newsletter['subject'],
$newsletter['rendered_body']['html'],
$newsletter['rendered_body']['text']
$newsletter->subject,
$rendered_newsletter['html'],
$rendered_newsletter['text']
)
);
$prepared_newsletter = ShortcodesTask::process(
@ -88,8 +76,8 @@ class Newsletter {
);
if($this->tracking_enabled) {
$prepared_newsletter = NewsletterLinks::replaceSubscriberData(
$subscriber['id'],
$queue['id'],
$subscriber->id,
$queue->id,
$prepared_newsletter
);
}
@ -103,10 +91,11 @@ class Newsletter {
);
}
function markNewsletterAsSent($newsletter_id) {
$newsletter = NewsletterModel::findOne($newsletter_id);
// if it's a standard newsletter, update its status
if($newsletter->type === NewsletterModel::TYPE_STANDARD) {
function markNewsletterAsSent($newsletter) {
// if it's a standard or notification history newsletter, update its status
if($newsletter->type === NewsletterModel::TYPE_STANDARD ||
$newsletter->type === NewsletterModel::TYPE_NOTIFICATION_HISTORY
) {
$newsletter->setStatus(NewsletterModel::STATUS_SENT);
}
}

View File

@ -7,26 +7,24 @@ use MailPoet\Models\NewsletterPost;
if(!defined('ABSPATH')) exit;
class Posts {
static function extractAndSave(array $newsletter) {
if(empty($newsletter['rendered_body']['html']) || empty($newsletter['id'])) {
return;
}
static function extractAndSave($rendered_newsletter, $newsletter) {
preg_match_all(
'/data-post-id="(\d+)"/ism',
$newsletter['rendered_body']['html'],
$rendered_newsletter['html'],
$matched_posts_ids);
$matched_posts_ids = $matched_posts_ids[1];
if(!count($matched_posts_ids)) {
return $newsletter;
return false;
}
$newsletter_id = ($newsletter['type'] === NewsletterModel::TYPE_NOTIFICATION_HISTORY) ?
$newsletter['parent_id'] :
$newsletter['id'];
$newsletter_id = ($newsletter->type === NewsletterModel::TYPE_NOTIFICATION_HISTORY) ?
$newsletter->parent_id :
$newsletter->id;
foreach($matched_posts_ids as $post_id) {
$newletter_post = NewsletterPost::create();
$newletter_post->newsletter_id = $newsletter_id;
$newletter_post->post_id = $post_id;
$newletter_post->save();
$newsletter_post = NewsletterPost::create();
$newsletter_post->newsletter_id = $newsletter_id;
$newsletter_post->post_id = $post_id;
$newsletter_post->save();
}
return true;
}
}

View File

@ -6,9 +6,8 @@ use MailPoet\Newsletter\Shortcodes\Shortcodes as NewsletterShortcodes;
if(!defined('ABSPATH')) exit;
class Shortcodes {
static function process($content, array $newsletter, array $subscriber, array $queue) {
static function process($content, $newsletter, $subscriber, $queue) {
$shortcodes = new NewsletterShortcodes($newsletter, $subscriber, $queue);
return $shortcodes->replace($content);
}
}
}

View File

@ -1,52 +0,0 @@
<?php
namespace MailPoet\Cron\Workers\SendingQueue\Tasks;
if(!defined('ABSPATH')) exit;
class Subscribers {
static function updateToProcessList(
array $found_subscribers_ids,
array $subscribers_to_process_ids,
array $queue_subscribers
) {
// compare existing subscriber to the ones that queued for processing
$subscibers_to_exclude = array_diff(
$subscribers_to_process_ids,
$found_subscribers_ids
);
// remove nonexistent subscribers from the processing list
$queue_subscribers['to_process'] = array_diff(
$subscibers_to_exclude,
$queue_subscribers['to_process']
);
return $queue_subscribers;
}
static function updateFailedList(
array $failed_subscribers, array $queue_subscribers
) {
$queue_subscribers['failed'] = array_merge(
$queue_subscribers['failed'],
$failed_subscribers
);
$queue_subscribers['to_process'] = array_diff(
$queue_subscribers['to_process'],
$failed_subscribers
);
return $queue_subscribers;
}
static function updateProcessedList(
array $processed_subscribers, array $queue_subscribers
) {
$queue_subscribers['processed'] = array_merge(
$queue_subscribers['processed'],
$processed_subscribers
);
$queue_subscribers['to_process'] = array_diff(
$queue_subscribers['to_process'],
$processed_subscribers
);
return $queue_subscribers;
}
}

View File

@ -7,7 +7,7 @@ abstract class Base {
if($block['id'] === 'email') {
$rules['required'] = true;
$rules['error-message'] = __('Please specify a valid email address');
$rules['error-message'] = __('Please specify a valid email address', 'mailpoet');
}
if($block['id'] === 'segments') {
@ -15,7 +15,7 @@ abstract class Base {
$rules['mincheck'] = 1;
$rules['group'] = $block['id'];
$rules['errors-container'] = '.mailpoet_error_'.$block['id'];
$rules['required-message'] = __('Please select a list');
$rules['required-message'] = __('Please select a list', 'mailpoet');
}
if(!empty($block['params']['required'])) {
@ -25,7 +25,7 @@ abstract class Base {
if(!empty($block['params']['validate'])) {
if($block['params']['validate'] === 'phone') {
$rules['pattern'] = "^[\d\+\-\.\(\)\/\s]*$";
$rules['error-message'] = __('Please specify a valid phone number');
$rules['error-message'] = __('Please specify a valid phone number', 'mailpoet');
} else {
$rules['type'] = $block['params']['validate'];
}
@ -34,7 +34,7 @@ abstract class Base {
if(in_array($block['type'], array('radio', 'checkbox'))) {
$rules['group'] = 'custom_field_'.$block['id'];
$rules['errors-container'] = '.mailpoet_error_'.$block['id'];
$rules['required-message'] = __('Please select at least one option');
$rules['required-message'] = __('Please select at least one option', 'mailpoet');
}
if($block['type'] === 'date') {

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form\Block;
if(!defined('ABSPATH')) exit;
class Checkbox extends Base {
static function render($block) {
@ -22,7 +24,6 @@ class Checkbox extends Base {
foreach($options as $option) {
$html .= '<label class="mailpoet_checkbox_label">';
$html .= '<input type="hidden" name="'.$field_name.'" value="0" />';
$html .= '<input type="checkbox" class="mailpoet_checkbox" ';
$html .= 'name="'.$field_name.'" ';
@ -50,5 +51,4 @@ class Checkbox extends Base {
return $html;
}
}
}

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form\Block;
if(!defined('ABSPATH')) exit;
use Carbon\Carbon;
class Date extends Base {
@ -70,27 +72,27 @@ class Date extends Base {
$block['selected'] = $day;
$html .= '<select class="mailpoet_date_day" ';
$html .= static::getInputValidation($block, array(
'required-message' => __('Please select a day')
'required-message' => __('Please select a day', 'mailpoet')
));
$html .= 'name="'.$field_name.'[day]" placeholder="'.__('Day').'">';
$html .= 'name="'.$field_name.'[day]" placeholder="'.__('Day', 'mailpoet').'">';
$html .= static::getDays($block);
$html .= '</select>';
} else if($date_selector === 'MM') {
$block['selected'] = $month;
$html .= '<select class="mailpoet_date_month" ';
$html .= static::getInputValidation($block, array(
'required-message' => __('Please select a month')
'required-message' => __('Please select a month', 'mailpoet')
));
$html .= 'name="'.$field_name.'[month]" placeholder="'.__('Month').'">';
$html .= 'name="'.$field_name.'[month]" placeholder="'.__('Month', 'mailpoet').'">';
$html .= static::getMonths($block);
$html .= '</select>';
} else if($date_selector === 'YYYY') {
$block['selected'] = $year;
$html .= '<select class="mailpoet_date_year" ';
$html .= static::getInputValidation($block, array(
'required-message' => __('Please select a year')
'required-message' => __('Please select a year', 'mailpoet')
));
$html .= 'name="'.$field_name.'[year]" placeholder="'.__('Year').'">';
$html .= 'name="'.$field_name.'[year]" placeholder="'.__('Year', 'mailpoet').'">';
$html .= static::getYears($block);
$html .= '</select>';
}
@ -103,10 +105,10 @@ class Date extends Base {
static function getDateTypes() {
return array(
'year_month_day' => __('Year, month, day'),
'year_month' => __('Year, month'),
'month' => __('Month (January, February,...)'),
'year' => __('Year')
'year_month_day' => __('Year, month, day', 'mailpoet'),
'year_month' => __('Year, month', 'mailpoet'),
'month' => __('Month (January, February,...)', 'mailpoet'),
'year' => __('Year', 'mailpoet')
);
}
@ -119,9 +121,9 @@ class Date extends Base {
);
}
static function getMonthNames() {
return array(__('January'), __('February'), __('March'), __('April'),
__('May'), __('June'), __('July'), __('August'), __('September'),
__('October'), __('November'), __('December')
return array(__('January', 'mailpoet'), __('February', 'mailpoet'), __('March', 'mailpoet'), __('April', 'mailpoet'),
__('May', 'mailpoet'), __('June', 'mailpoet'), __('July', 'mailpoet'), __('August', 'mailpoet'), __('September', 'mailpoet'),
__('October', 'mailpoet'), __('November', 'mailpoet'), __('December', 'mailpoet')
);
}
@ -138,7 +140,7 @@ class Date extends Base {
$html = '';
// empty value label
$html .= '<option value="">'.__('Month').'</option>';
$html .= '<option value="">'.__('Month', 'mailpoet').'</option>';
for($i = 1; $i < 13; $i++) {
$is_selected = ($i === $block['selected']) ? 'selected="selected"' : '';
@ -168,7 +170,7 @@ class Date extends Base {
$html = '';
// empty value label
$html .= '<option value="">'.__('Year').'</option>';
$html .= '<option value="">'.__('Year', 'mailpoet').'</option>';
// return years as an array
for($i = (int)$block['to']; $i > (int)($block['from'] - 1); $i--) {
@ -194,7 +196,7 @@ class Date extends Base {
$html = '';
// empty value label
$html .= '<option value="">'.__('Day').'</option>';
$html .= '<option value="">'.__('Day', 'mailpoet').'</option>';
// return days as an array
for($i = 1; $i < 32; $i++) {

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form\Block;
if(!defined('ABSPATH')) exit;
class Radio extends Base {
static function render($block) {

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form\Block;
if(!defined('ABSPATH')) exit;
class Segment extends Base {
static function render($block) {

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form\Block;
if(!defined('ABSPATH')) exit;
class Select extends Base {
static function render($block) {

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form\Block;
if(!defined('ABSPATH')) exit;
class Submit extends Base {
static function render($block) {

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form\Block;
if(!defined('ABSPATH')) exit;
class Text extends Base {
static function render($block) {

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form\Block;
if(!defined('ABSPATH')) exit;
class Textarea extends Base {
static function render($block) {
$html = '';

View File

@ -24,13 +24,14 @@ class Export {
return join(' ', array(
'<iframe',
'width="100%"',
'height="100%"',
'scrolling="no"',
'frameborder="0"',
'src="'.$iframe_url.'"',
'class="mailpoet_form_iframe"',
'vspace="0"',
'tabindex="0"',
'onload="MailPoet.Iframe.autoSize(this);"',
'onload="if(window[\'MailPoet\']) MailPoet.Iframe.autoSize(this);"',
'marginwidth="0"',
'marginheight="0"',
'hspace="0"',

View File

@ -15,9 +15,9 @@ class Widget extends \WP_Widget {
function __construct () {
return parent::__construct(
'mailpoet_form',
__('MailPoet Form'),
__('MailPoet Form', 'mailpoet'),
array(
'description' => __('Add a newsletter subscription form')
'description' => __('Add a newsletter subscription form', 'mailpoet')
)
);
}
@ -40,7 +40,7 @@ class Widget extends \WP_Widget {
$instance = wp_parse_args(
(array)$instance,
array(
'title' => __("Subscribe to Our Newsletter")
'title' => __("Subscribe to Our Newsletter", 'mailpoet')
)
);
@ -55,7 +55,7 @@ class Widget extends \WP_Widget {
// get forms list
$forms = Form::getPublished()->orderByAsc('name')->findArray();
?><p>
<label for="<?php $this->get_field_id( 'title' ) ?>"><?php _e( 'Title:' ); ?></label>
<label for="<?php $this->get_field_id( 'title' ) ?>"><?php _e('Title:', 'mailpoet'); ?></label>
<input
type="text"
class="widefat"
@ -75,7 +75,7 @@ class Widget extends \WP_Widget {
</select>
</p>
<p>
<a href="javascript:;" onClick="createSubscriptionForm()" class="mailpoet_form_new"><?php _e("Create a new form"); ?></a>
<a href="javascript:;" onClick="createSubscriptionForm()" class="mailpoet_form_new"><?php _e('Create a new form', 'mailpoet'); ?></a>
</p>
<script type="text/javascript">
function createSubscriptionForm() {
@ -148,12 +148,17 @@ class Widget extends \WP_Widget {
'after_title' => (!empty($after_title) ? $after_title : '')
);
// check if the form was successfully submitted via POST (non ajax)
// (POST) non ajax success/error variables
$data['success'] = (
(isset($_GET['mailpoet_success']))
&&
((int)$_GET['mailpoet_success'] === (int)$form['id'])
);
$data['error'] = (
(isset($_GET['mailpoet_error']))
&&
((int)$_GET['mailpoet_error'] === (int)$form['id'])
);
// generate security token
$data['token'] = Security::generateToken();

View File

@ -15,6 +15,11 @@ class Handler {
$this->model_class = $model_class;
$this->model = \Model::factory($this->model_class);
// check if sort order was specified or default to "asc"
$sort_order = (!empty($data['sort_order'])) ? $data['sort_order'] : 'asc';
// constrain sort order value to either be "asc" or "desc"
$sort_order = ($sort_order === 'asc') ? 'asc' : 'desc';
$this->data = array(
// extra parameters
'params' => (isset($data['params']) ? $data['params'] : array()),
@ -28,7 +33,7 @@ class Handler {
'search' => (isset($data['search']) ? $data['search'] : null),
// sorting
'sort_by' => (!empty($data['sort_by']) ? $data['sort_by'] : 'id'),
'sort_order' => (!empty($data['sort_order']) ? $data['sort_order'] : 'asc'),
'sort_order' => $sort_order,
// grouping
'group' => (isset($data['group']) ? $data['group'] : null),
// filters

View File

@ -1,11 +1,9 @@
<?php
namespace MailPoet\Mailer;
use MailPoet\Models\Setting;
require_once(ABSPATH . 'wp-includes/pluggable.php');
if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-includes/pluggable.php');
class Mailer {
public $mailer_config;
@ -24,13 +22,13 @@ class Mailer {
function __construct($mailer = false, $sender = false, $reply_to = false) {
$this->mailer_config = self::getMailerConfig($mailer);
$this->sender = $this->getSender($sender);
$this->reply_to = $this->getReplyTo($reply_to);
$this->sender = $this->getSenderNameAndAddress($sender);
$this->reply_to = $this->getReplyToNameAndAddress($reply_to);
$this->mailer_instance = $this->buildMailer();
}
function send($newsletter, $subscriber) {
$subscriber = $this->transformSubscriber($subscriber);
$subscriber = $this->formatSubscriberNameAndEmailAddress($subscriber);
return $this->mailer_instance->send($newsletter, $subscriber);
}
@ -93,7 +91,7 @@ class Mailer {
);
break;
default:
throw new \Exception(__('Mailing method does not exist'));
throw new \Exception(__('Mailing method does not exist', 'mailpoet'));
}
return $mailer_instance;
}
@ -101,7 +99,7 @@ class Mailer {
static function getMailerConfig($mailer = false) {
if(!$mailer) {
$mailer = Setting::getValue(self::MAILER_CONFIG_SETTING_NAME);
if(!$mailer || !isset($mailer['method'])) throw new \Exception(__('Mailer is not configured'));
if(!$mailer || !isset($mailer['method'])) throw new \Exception(__('Mailer is not configured', 'mailpoet'));
}
if(empty($mailer['frequency'])) {
$default_settings = Setting::getDefaults();
@ -115,10 +113,10 @@ class Mailer {
return $mailer;
}
function getSender($sender = false) {
function getSenderNameAndAddress($sender = false) {
if(empty($sender)) {
$sender = Setting::getValue('sender', array());
if(empty($sender['address'])) throw new \Exception(__('Sender name and email are not configured'));
if(empty($sender['address'])) throw new \Exception(__('Sender name and email are not configured', 'mailpoet'));
}
return array(
'from_name' => $sender['name'],
@ -127,15 +125,15 @@ class Mailer {
);
}
function getReplyTo($reply_to = false) {
function getReplyToNameAndAddress($reply_to = array()) {
if(!$reply_to) {
$reply_to = Setting::getValue('reply_to', null);
if(!$reply_to) {
$reply_to = array(
'name' => $this->sender['from_name'],
'address' => $this->sender['from_email']
);
}
$reply_to['name'] = (!empty($reply_to['name'])) ?
$reply_to['name'] :
$this->sender['from_name'];
$reply_to['address'] = (!empty($reply_to['address'])) ?
$reply_to['address'] :
$this->sender['from_email'];
}
if(empty($reply_to['address'])) {
$reply_to['address'] = $this->sender['from_email'];
@ -147,7 +145,8 @@ class Mailer {
);
}
function transformSubscriber($subscriber) {
function formatSubscriberNameAndEmailAddress($subscriber) {
$subscriber = (is_object($subscriber)) ? $subscriber->asArray() : $subscriber;
if(!is_array($subscriber)) return $subscriber;
if(isset($subscriber['address'])) $subscriber['email'] = $subscriber['address'];
$first_name = (isset($subscriber['first_name'])) ? $subscriber['first_name'] : '';

View File

@ -34,8 +34,8 @@ class MailerLog {
return $mailer_log;
}
static function incrementSentCount($mailer_log = false) {
$mailer_log = ($mailer_log) ? $mailer_log : self::getMailerLog();
static function incrementSentCount() {
$mailer_log = self::getMailerLog();
(int)$mailer_log['sent']++;
return self::updateMailerLog($mailer_log);
}
@ -54,7 +54,7 @@ class MailerLog {
static function enforceSendingLimit() {
if(self::isSendingLimitReached()) {
throw new \Exception(__('Sending frequency limit has been reached'));
throw new \Exception(__('Sending frequency limit has been reached.', 'mailpoet'));
}
}
}

View File

@ -17,11 +17,19 @@ class AmazonSES {
public $reply_to;
public $date;
public $date_without_time;
private $available_regions = array(
'US East (N. Virginia)' => 'us-east-1',
'US West (Oregon)' => 'us-west-2',
'EU (Ireland)' => 'eu-west-1'
);
function __construct($region, $access_key, $secret_key, $sender, $reply_to) {
$this->aws_access_key = $access_key;
$this->aws_secret_key = $secret_key;
$this->aws_region = $region;
$this->aws_region = (in_array($region, $this->available_regions)) ? $region : false;
if(!$this->aws_region) {
throw new \Exception(__('Unsupported Amazon SES region.', 'mailpoet'));
}
$this->aws_endpoint = sprintf('email.%s.amazonaws.com', $this->aws_region);
$this->aws_signing_algorithm = 'AWS4-HMAC-SHA256';
$this->aws_service = 'ses';
@ -34,6 +42,7 @@ class AmazonSES {
$this->date_without_time = gmdate('Ymd');
}
function send($newsletter, $subscriber) {
$result = wp_remote_post(
$this->url,

View File

@ -11,10 +11,10 @@ class CustomField extends Model {
function __construct() {
parent::__construct();
$this->addValidations('name', array(
'required' => __('Please specify a name')
'required' => __('Please specify a name', 'mailpoet')
));
$this->addValidations('type', array(
'required' => __('Please specify a type')
'required' => __('Please specify a type', 'mailpoet')
));
}

View File

@ -10,7 +10,7 @@ class Form extends Model {
parent::__construct();
$this->addValidations('name', array(
'required' => __('Please specify a name')
'required' => __('Please specify a name', 'mailpoet')
));
}
@ -47,12 +47,12 @@ class Form extends Model {
return array(
array(
'name' => 'all',
'label' => __('All'),
'label' => __('All', 'mailpoet'),
'count' => Form::getPublished()->count()
),
array(
'name' => 'trash',
'label' => __('Trash'),
'label' => __('Trash', 'mailpoet'),
'count' => Form::getTrashed()->count()
)
);

View File

@ -50,7 +50,7 @@ class Model extends \Sudzy\ValidModel {
$column = $matches[1];
$this->setError(
sprintf(
__('Another record already exists. Please specify a different "%1$s".'),
__('Another record already exists. Please specify a different "%1$s".', 'mailpoet'),
$column
)
);

View File

@ -1,12 +1,12 @@
<?php
namespace MailPoet\Models;
use MailPoet\Newsletter\Renderer\Renderer;
use MailPoet\Util\Helpers;
if(!defined('ABSPATH')) exit;
class Newsletter extends Model {
public static $_table = MP_NEWSLETTERS_TABLE;
const TYPE_STANDARD = 'standard';
const TYPE_WELCOME = 'welcome';
const TYPE_NOTIFICATION = 'notification';
@ -22,9 +22,8 @@ class Newsletter extends Model {
function __construct() {
parent::__construct();
$this->addValidations('type', array(
'required' => __('Please specify a type')
'required' => __('Please specify a type', 'mailpoet')
));
}
@ -246,6 +245,11 @@ class Newsletter extends Model {
return $this;
}
function render() {
$renderer = new Renderer($this);
return $renderer->render();
}
function getStatistics() {
$statistics_query = SendingQueue::tableAlias('queues')
->selectExpr(
@ -305,7 +309,7 @@ class Newsletter extends Model {
$segments = Segment::orderByAsc('name')->findMany();
$segment_list = array();
$segment_list[] = array(
'label' => __('All Lists'),
'label' => __('All Lists', 'mailpoet'),
'value' => ''
);
@ -404,7 +408,7 @@ class Newsletter extends Model {
$groups = array(
array(
'name' => 'all',
'label' => __('All'),
'label' => __('All', 'mailpoet'),
'count' => Newsletter::getPublished()
->filter('filterType', $type)
->count()
@ -416,7 +420,7 @@ class Newsletter extends Model {
$groups = array_merge($groups, array(
array(
'name' => self::STATUS_DRAFT,
'label' => __('Draft'),
'label' => __('Draft', 'mailpoet'),
'count' => Newsletter::getPublished()
->filter('filterType', $type)
->filter('filterStatus', self::STATUS_DRAFT)
@ -424,7 +428,7 @@ class Newsletter extends Model {
),
array(
'name' => self::STATUS_SCHEDULED,
'label' => __('Scheduled'),
'label' => __('Scheduled', 'mailpoet'),
'count' => Newsletter::getPublished()
->filter('filterType', $type)
->filter('filterStatus', self::STATUS_SCHEDULED)
@ -432,7 +436,7 @@ class Newsletter extends Model {
),
array(
'name' => self::STATUS_SENDING,
'label' => __('Sending'),
'label' => __('Sending', 'mailpoet'),
'count' => Newsletter::getPublished()
->filter('filterType', $type)
->filter('filterStatus', self::STATUS_SENDING)
@ -440,7 +444,7 @@ class Newsletter extends Model {
),
array(
'name' => self::STATUS_SENT,
'label' => __('Sent'),
'label' => __('Sent', 'mailpoet'),
'count' => Newsletter::getPublished()
->filter('filterType', $type)
->filter('filterStatus', self::STATUS_SENT)
@ -454,7 +458,7 @@ class Newsletter extends Model {
$groups = array_merge($groups, array(
array(
'name' => self::STATUS_ACTIVE,
'label' => __('Active'),
'label' => __('Active', 'mailpoet'),
'count' => Newsletter::getPublished()
->filter('filterType', $type)
->filter('filterStatus', self::STATUS_ACTIVE)
@ -462,7 +466,7 @@ class Newsletter extends Model {
),
array(
'name' => self::STATUS_DRAFT,
'label' => __('Not active'),
'label' => __('Not active', 'mailpoet'),
'count' => Newsletter::getPublished()
->filter('filterType', $type)
->filter('filterStatus', self::STATUS_DRAFT)
@ -474,7 +478,7 @@ class Newsletter extends Model {
$groups[] = array(
'name' => 'trash',
'label' => __('Trash'),
'label' => __('Trash', 'mailpoet'),
'count' => Newsletter::getTrashed()
->filter('filterType', $type)
->count()

View File

@ -9,10 +9,10 @@ class NewsletterOptionField extends Model {
function __construct() {
parent::__construct();
$this->addValidations('name', array(
'required' => __('Please specify a name')
'required' => __('Please specify a name', 'mailpoet')
));
$this->addValidations('newsletter_type', array(
'required' => __('Please specify a newsletter type')
'required' => __('Please specify a newsletter type', 'mailpoet')
));
}

View File

@ -10,10 +10,10 @@ class NewsletterTemplate extends Model {
parent::__construct();
$this->addValidations('name', array(
'required' => __('Please specify a name')
'required' => __('Please specify a name', 'mailpoet')
));
$this->addValidations('body', array(
'required' => __('The template body cannot be empty')
'required' => __('The template body cannot be empty', 'mailpoet')
));
}

View File

@ -10,7 +10,7 @@ class Segment extends Model {
parent::__construct();
$this->addValidations('name', array(
'required' => __('Please specify a name')
'required' => __('Please specify a name', 'mailpoet')
));
}
@ -100,9 +100,9 @@ class Segment extends Model {
// create the wp users segment
$wp_segment = Segment::create();
$wp_segment->hydrate(array(
'name' => __('WordPress Users'),
'name' => __('WordPress Users', 'mailpoet'),
'description' =>
__('This lists containts all of your WordPress users'),
__('This lists containts all of your WordPress users', 'mailpoet'),
'type' => 'wp_users'
));
$wp_segment->save();
@ -119,12 +119,12 @@ class Segment extends Model {
return array(
array(
'name' => 'all',
'label' => __('All'),
'label' => __('All', 'mailpoet'),
'count' => Segment::getPublished()->count()
),
array(
'name' => 'trash',
'label' => __('Trash'),
'label' => __('Trash', 'mailpoet'),
'count' => Segment::getTrashed()->count()
)
);
@ -143,7 +143,41 @@ class Segment extends Model {
$query = self::selectMany(array(self::$_table.'.id', self::$_table.'.name'))
->selectExpr(
self::$_table.'.*, ' .
'COUNT(IF('.MP_SUBSCRIBER_SEGMENT_TABLE.'.status="' . Subscriber::STATUS_SUBSCRIBED .'" AND '.MP_SUBSCRIBERS_TABLE.'.deleted_at IS NULL,1,NULL)) `subscribers`'
'COUNT(IF('.
MP_SUBSCRIBER_SEGMENT_TABLE.'.status="'.Subscriber::STATUS_SUBSCRIBED.'"'
.' AND '.
MP_SUBSCRIBERS_TABLE.'.deleted_at IS NULL'
.' AND '.
MP_SUBSCRIBERS_TABLE.'.status="'.Subscriber::STATUS_SUBSCRIBED.'"'
.', 1, NULL)) `subscribers`'
)
->leftOuterJoin(
MP_SUBSCRIBER_SEGMENT_TABLE,
array(self::$_table.'.id', '=', MP_SUBSCRIBER_SEGMENT_TABLE.'.segment_id'))
->leftOuterJoin(
MP_SUBSCRIBERS_TABLE,
array(MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id', '=', MP_SUBSCRIBERS_TABLE.'.id'))
->groupBy(self::$_table.'.id')
->groupBy(self::$_table.'.name')
->orderByAsc(self::$_table.'.name')
->whereNull(self::$_table.'.deleted_at');
if(!empty($type)) {
$query->where(self::$_table.'.type', $type);
}
return $query->findArray();
}
static function getSegmentsForImport() {
$query = self::selectMany(array(self::$_table.'.id', self::$_table.'.name'))
->selectExpr(
self::$_table.'.*, ' .
'COUNT(IF('.
MP_SUBSCRIBER_SEGMENT_TABLE.'.status="'.Subscriber::STATUS_SUBSCRIBED.'"'
.' AND '.
MP_SUBSCRIBERS_TABLE.'.deleted_at IS NULL'
.', 1, NULL)) `subscribers`'
)
->leftOuterJoin(
MP_SUBSCRIBER_SEGMENT_TABLE,
@ -176,7 +210,7 @@ class Segment extends Model {
'AND relation.status = "' . Subscriber::STATUS_SUBSCRIBED . '" ' .
'GROUP BY segments.id) ' .
'UNION ALL ' .
'(SELECT 0 as id, "' . __('Not in a List') . '" as name, COUNT(*) as subscribers ' .
'(SELECT 0 as id, "' . __('Not in a List', 'mailpoet') . '" as name, COUNT(*) as subscribers ' .
'FROM ' . MP_SUBSCRIBERS_TABLE . ' subscribers ' .
'LEFT JOIN ' . MP_SUBSCRIBER_SEGMENT_TABLE . ' relation on relation.subscriber_id = subscribers.id ' .
(($withConfirmedSubscribers) ?

View File

@ -5,11 +5,14 @@ if(!defined('ABSPATH')) exit;
class SendingQueue extends Model {
public static $_table = MP_SENDING_QUEUES_TABLE;
const STATUS_COMPLETED = 'completed';
const STATUS_SCHEDULED = 'scheduled';
const STATUS_PAUSED = 'paused';
function newsletter() {
return $this->has_one(__NAMESPACE__ . '\Newsletter', 'id', 'newsletter_id');
}
function pause() {
if($this->count_processed === $this->count_total) {
return false;
@ -40,8 +43,12 @@ class SendingQueue extends Model {
if(!is_serialized($this->subscribers)) {
$this->set('subscribers', serialize($this->subscribers));
}
if(!is_serialized($this->newsletter_rendered_body)) {
$this->set('newsletter_rendered_body', serialize($this->newsletter_rendered_body));
}
parent::save();
$this->subscribers = $this->getSubscribers();
$this->newsletter_rendered_body = $this->getNewsletterRenderedBody();
return $this;
}
@ -59,8 +66,10 @@ class SendingQueue extends Model {
return $subscribers;
}
function getRenderedNewsletterBody() {
return json_decode($this->newsletter_rendered_body, true);
function getNewsletterRenderedBody() {
return (!is_serialized($this->newsletter_rendered_body)) ?
$this->newsletter_rendered_body :
unserialize($this->newsletter_rendered_body);
}
function isSubscriberProcessed($subscriber_id) {
@ -75,4 +84,62 @@ class SendingQueue extends Model {
: $this->subscribers;
return $model;
}
}
function removeNonexistentSubscribers($subscribers_to_remove) {
$subscribers = $this->getSubscribers();
$subscribers['to_process'] = array_values(
array_diff(
$subscribers['to_process'],
$subscribers_to_remove
)
);
$this->subscribers = $subscribers;
$this->updateCount();
}
function updateFailedSubscribers($failed_subscribers) {
$subscribers = $this->getSubscribers();
$subscribers['failed'] = array_merge(
$subscribers['failed'],
$failed_subscribers
);
$subscribers['to_process'] = array_values(
array_diff(
$subscribers['to_process'],
$failed_subscribers
)
);
$this->subscribers = $subscribers;
$this->updateCount();
}
function updateProcessedSubscribers($processed_subscribers) {
$subscribers = $this->getSubscribers();
$subscribers['processed'] = array_merge(
$subscribers['processed'],
$processed_subscribers
);
$subscribers['to_process'] = array_values(
array_diff(
$subscribers['to_process'],
$processed_subscribers
)
);
$this->subscribers = $subscribers;
$this->updateCount();
}
function updateCount() {
$this->subscribers = $this->getSubscribers();
$this->count_processed =
count($this->subscribers['processed']) + count($this->subscribers['failed']);
$this->count_to_process = count($this->subscribers['to_process']);
$this->count_failed = count($this->subscribers['failed']);
$this->count_total = $this->count_processed + $this->count_to_process;
if(!$this->count_to_process) {
$this->processed_at = current_time('mysql');
$this->status = self::STATUS_COMPLETED;
}
return $this->save();
}
}

View File

@ -19,7 +19,7 @@ class Setting extends Model {
parent::__construct();
$this->addValidations('name', array(
'required' => __('Please specify a name')
'required' => __('Please specify a name', 'mailpoet')
));
}
@ -45,8 +45,8 @@ class Setting extends Model {
),
'signup_confirmation' => array(
'enabled' => true,
'subject' => sprintf(__('Confirm your subscription to %1$s'), get_option('blogname')),
'body' => __("Hello!\n\nHurray! You've subscribed to our site.\n\nPlease confirm your subscription to the list(s): [lists_to_confirm] by clicking the link below: \n\n[activation_link]Click here to confirm your subscription.[/activation_link]\n\nThank you,\n\nThe Team")
'subject' => sprintf(__('Confirm your subscription to %1$s', 'mailpoet'), get_option('blogname')),
'body' => __("Hello!\n\nHurray! You've subscribed to our site.\n\nPlease confirm your subscription to the list(s): [lists_to_confirm] by clicking the link below: \n\n[activation_link]Click here to confirm your subscription.[/activation_link]\n\nThank you,\n\nThe Team", 'mailpoet')
),
'tracking' => array(
'enabled' => true

View File

@ -18,8 +18,8 @@ class Subscriber extends Model {
parent::__construct();
$this->addValidations('email', array(
'required' => __('Please enter your email address'),
'isEmail' => __('Your email address is invalid!')
'required' => __('Please enter your email address', 'mailpoet'),
'isEmail' => __('Your email address is invalid!', 'mailpoet')
));
}
@ -73,72 +73,73 @@ class Subscriber extends Model {
}
function sendConfirmationEmail() {
if($this->status === self::STATUS_UNCONFIRMED) {
$signup_confirmation = Setting::getValue('signup_confirmation');
$signup_confirmation = Setting::getValue('signup_confirmation');
$segments = $this->segments()->findMany();
$segment_names = array_map(function($segment) {
return $segment->name;
}, $segments);
$body = nl2br($signup_confirmation['body']);
// replace list of segments shortcode
$body = str_replace(
'[lists_to_confirm]',
'<strong>'.join(', ', $segment_names).'</strong>',
$body
);
// replace activation link
$body = str_replace(
array(
'[activation_link]',
'[/activation_link]'
),
array(
'<a href="'.esc_attr(Subscription\Url::getConfirmationUrl($this)).'">',
'</a>'
),
$body
);
// build email data
$email = array(
'subject' => $signup_confirmation['subject'],
'body' => array(
'html' => $body,
'text' => $body
)
);
// convert subscriber to array
$subscriber = $this->asArray();
// set from
$from = (
!empty($signup_confirmation['from'])
&& !empty($signup_confirmation['from']['address'])
) ? $signup_confirmation['from']
: false;
// set reply to
$reply_to = (
!empty($signup_confirmation['reply_to'])
&& !empty($signup_confirmation['reply_to']['address'])
) ? $signup_confirmation['reply_to']
: false;
// send email
try {
$mailer = new Mailer(false, $from, $reply_to);
return $mailer->send($email, $subscriber);
} catch(\Exception $e) {
$this->setError($e->getMessage());
return false;
}
if((bool)$signup_confirmation['enabled'] === false) {
return false;
}
$segments = $this->segments()->findMany();
$segment_names = array_map(function($segment) {
return $segment->name;
}, $segments);
$body = nl2br($signup_confirmation['body']);
// replace list of segments shortcode
$body = str_replace(
'[lists_to_confirm]',
'<strong>'.join(', ', $segment_names).'</strong>',
$body
);
// replace activation link
$body = str_replace(
array(
'[activation_link]',
'[/activation_link]'
),
array(
'<a href="'.esc_attr(Subscription\Url::getConfirmationUrl($this)).'">',
'</a>'
),
$body
);
// build email data
$email = array(
'subject' => $signup_confirmation['subject'],
'body' => array(
'html' => $body,
'text' => $body
)
);
// convert subscriber to array
$subscriber = $this->asArray();
// set from
$from = (
!empty($signup_confirmation['from'])
&& !empty($signup_confirmation['from']['address'])
) ? $signup_confirmation['from']
: false;
// set reply to
$reply_to = (
!empty($signup_confirmation['reply_to'])
&& !empty($signup_confirmation['reply_to']['address'])
) ? $signup_confirmation['reply_to']
: false;
// send email
try {
$mailer = new Mailer(false, $from, $reply_to);
return $mailer->send($email, $subscriber);
} catch(\Exception $e) {
$this->setError($e->getMessage());
return false;
}
return false;
}
static function generateToken($email = null) {
@ -149,53 +150,52 @@ class Subscriber extends Model {
}
static function verifyToken($email, $token) {
return (self::generateToken($email) === $token);
return hash_equals(self::generateToken($email), $token);
}
static function subscribe($subscriber_data = array(), $segment_ids = array()) {
if(empty($subscriber_data) or empty($segment_ids)) {
return false;
}
$signup_confirmation_enabled = (bool)Setting::getValue(
'signup_confirmation.enabled'
);
$subscriber = self::createOrUpdate($subscriber_data);
$errors = $subscriber->getErrors();
$subscriber = self::findOne($subscriber_data['email']);
if($subscriber === false) {
// create new subscriber
$subscriber = self::createOrUpdate($subscriber_data);
if($subscriber->getErrors() !== false) {
return $subscriber;
}
if($errors === false && $subscriber->id > 0) {
$subscriber = self::findOne($subscriber->id);
}
// restore deleted subscriber
if($subscriber->deleted_at !== null) {
$subscriber->setExpr('deleted_at', 'NULL');
// restore trashed subscriber
if($subscriber->deleted_at !== null) {
$subscriber->setExpr('deleted_at', 'NULL');
}
// set status depending on signup confirmation setting
if($subscriber->status !== self::STATUS_SUBSCRIBED) {
if($signup_confirmation_enabled === true) {
$subscriber->set('status', self::STATUS_UNCONFIRMED);
} else {
$subscriber->set('status', self::STATUS_SUBSCRIBED);
}
}
if($subscriber->status !== self::STATUS_SUBSCRIBED) {
// auto subscribe when signup confirmation is disabled
if($signup_confirmation_enabled === true) {
$subscriber->set('status', self::STATUS_UNCONFIRMED);
} else {
$subscriber->set('status', self::STATUS_SUBSCRIBED);
}
}
if($subscriber->save()) {
// link subscriber to segments
SubscriberSegment::subscribeToSegments($subscriber, $segment_ids);
if($subscriber->save()) {
// link subscriber to segments
SubscriberSegment::subscribeToSegments($subscriber, $segment_ids);
// signup confirmation
$subscriber->sendConfirmationEmail();
// signup confirmation
if($subscriber->status !== self::STATUS_SUBSCRIBED) {
$subscriber->sendConfirmationEmail();
}
// welcome email
Scheduler::scheduleSubscriberWelcomeNotification(
$subscriber->id,
$segment_ids
);
}
// welcome email
Scheduler::scheduleSubscriberWelcomeNotification(
$subscriber->id,
$segment_ids
);
}
return $subscriber;
@ -218,13 +218,13 @@ class Subscriber extends Model {
$segments = Segment::orderByAsc('name')->findMany();
$segment_list = array();
$segment_list[] = array(
'label' => __('All Lists'),
'label' => __('All Lists', 'mailpoet'),
'value' => ''
);
$subscribers_without_segment = self::filter('withoutSegments')->count();
$subscribers_without_segment_label = sprintf(
__('Subscribers without a list (%s)'),
__('Subscribers without a list (%s)', 'mailpoet'),
number_format($subscribers_without_segment)
);
@ -280,27 +280,27 @@ class Subscriber extends Model {
return array(
array(
'name' => 'all',
'label' => __('All'),
'label' => __('All', 'mailpoet'),
'count' => self::getPublished()->count()
),
array(
'name' => self::STATUS_SUBSCRIBED,
'label' => __('Subscribed'),
'label' => __('Subscribed', 'mailpoet'),
'count' => self::filter(self::STATUS_SUBSCRIBED)->count()
),
array(
'name' => self::STATUS_UNCONFIRMED,
'label' => __('Unconfirmed'),
'label' => __('Unconfirmed', 'mailpoet'),
'count' => self::filter(self::STATUS_UNCONFIRMED)->count()
),
array(
'name' => self::STATUS_UNSUBSCRIBED,
'label' => __('Unsubscribed'),
'label' => __('Unsubscribed', 'mailpoet'),
'count' => self::filter(self::STATUS_UNSUBSCRIBED)->count()
),
array(
'name' => 'trash',
'label' => __('Trash'),
'label' => __('Trash', 'mailpoet'),
'count' => self::getTrashed()->count()
)
);
@ -383,6 +383,7 @@ class Subscriber extends Model {
'subscribers.id = relation.subscriber_id',
'subscribers'
)
->whereNull('subscribers.deleted_at')
->where('subscribers.status', 'subscribed');
return $subscribers;
}

View File

@ -15,12 +15,6 @@ class AutomatedLatestContent {
function __construct($newsletter_id = false, $newer_than_timestamp = false) {
$this->newsletter_id = $newsletter_id;
$this->newer_than_timestamp = $newer_than_timestamp;
$this->_attachSentPostsFilter();
}
function __destruct() {
$this->_detachSentPostsFilter();
}
function filterOutSentPosts($where) {
@ -72,7 +66,10 @@ class AutomatedLatestContent {
);
}
return get_posts($parameters);
$this->_attachSentPostsFilter();
$posts = get_posts($parameters);
$this->_detachSentPostsFilter();
return $posts;
}
function transformPosts($args, $posts) {
@ -129,4 +126,4 @@ class AutomatedLatestContent {
remove_action('posts_where', array($this, 'filterOutSentPosts'));
}
}
}
}

View File

@ -77,7 +77,7 @@ class PostContentManager {
// remove embedded video and replace with links
$content = preg_replace(
'#<iframe.*?src=\"(.+?)\".*><\/iframe>#',
'<a href="$1">'.__('Click here to view media.').'</a>',
'<a href="$1">'.__('Click here to view media.', 'mailpoet').'</a>',
$content
);

View File

@ -19,81 +19,22 @@ class Scheduler {
const INTERVAL_MONTHLY = 'monthly';
const INTERVAL_NTHWEEKDAY = 'nthWeekDay';
static function processPostNotificationSchedule($newsletter_id) {
$newsletter = Newsletter::filter('filterWithOptions')
->findOne($newsletter_id);
if(!$newsletter) return;
$newsletter = $newsletter->asArray();
$interval_type = $newsletter['intervalType'];
$hour = (int)$newsletter['timeOfDay'] / self::SECONDS_IN_HOUR;
$week_day = $newsletter['weekDay'];
$month_day = $newsletter['monthDay'];
$nth_week_day = ($newsletter['nthWeekDay'] === self::LAST_WEEKDAY_FORMAT) ?
$newsletter['nthWeekDay'] :
'#' . $newsletter['nthWeekDay'];
switch($interval_type) {
case self::INTERVAL_IMMEDIATELY:
$schedule = '* * * * *';
break;
case self::INTERVAL_IMMEDIATE:
case self::INTERVAL_DAILY:
$schedule = sprintf('0 %s * * *', $hour);
break;
case self::INTERVAL_WEEKLY:
$schedule = sprintf('0 %s * * %s', $hour, $week_day);
break;
case self::INTERVAL_NTHWEEKDAY:
$schedule = sprintf('0 %s ? * %s%s', $hour, $week_day, $nth_week_day);
break;
case self::INTERVAL_MONTHLY:
$schedule = sprintf('0 %s %s * *', $hour, $month_day);
break;
}
$option_field = NewsletterOptionField::where('name', 'schedule')
->findOne()
->asArray();
$relation = NewsletterOption::where('newsletter_id', $newsletter_id)
->where('option_field_id', $option_field['id'])
->findOne();
if(!$relation) {
$relation = NewsletterOption::create();
$relation->newsletter_id = $newsletter['id'];
$relation->option_field_id = $option_field['id'];
}
$relation->value = $schedule;
$relation->save();
return Newsletter::filter('filterWithOptions')
->findOne($newsletter_id);
}
static function schedulePostNotification($post_id) {
$newsletters = self::getNewsletters(Newsletter::TYPE_NOTIFICATION);
if(!count($newsletters)) return;
if(!count($newsletters)) return false;
foreach($newsletters as $newsletter) {
$post = NewsletterPost::where('newsletter_id', $newsletter->id)
->where('post_id', $post_id)
->findOne();
if($post === false) {
$scheduled_notification = self::createPostNotificationQueue($newsletter);
self::createPostNotificationQueue($newsletter);
}
}
}
/**
* Create a properly formatted timestamp for use in Scheduler from
* arbitrarily formatted timestamp strings.
*/
static function scheduleFromTimestamp($timestamp) {
return Carbon::parse($timestamp)->format('Y-m-d H:i:s');
}
static function scheduleSubscriberWelcomeNotification(
$subscriber_id,
array $segments
) {
static function scheduleSubscriberWelcomeNotification($subscriber_id, $segments) {
$newsletters = self::getNewsletters(Newsletter::TYPE_WELCOME);
if(empty($newsletters)) return;
if(empty($newsletters)) return false;
foreach($newsletters as $newsletter) {
if($newsletter->event === 'segment' &&
in_array($newsletter->segment, $segments)
@ -105,19 +46,17 @@ class Scheduler {
static function scheduleWPUserWelcomeNotification(
$subscriber_id,
array $wp_user,
$old_user_data
$wp_user,
$old_user_data = false
) {
$newsletters = self::getNewsletters(Newsletter::TYPE_WELCOME);
if(empty($newsletters)) return;
if(empty($newsletters)) return false;
foreach($newsletters as $newsletter) {
if($newsletter->event === 'user') {
if($old_user_data) {
// do not schedule welcome newsletter if roles have not changed
$old_role = (array)$old_user_data->roles;
$new_role = (array)$wp_user->roles;
if($newsletter->role === self::WORDPRESS_ALL_ROLES ||
!array_diff($old_role, $new_role)
) {
@ -125,7 +64,7 @@ class Scheduler {
}
}
if($newsletter->role === self::WORDPRESS_ALL_ROLES ||
in_array($newsletter->role, $wp_user['roles'])
in_array($newsletter->role, (array)$wp_user->roles)
) {
self::createWelcomeNotificationQueue($newsletter, $subscriber_id);
}
@ -133,14 +72,6 @@ class Scheduler {
}
}
static function getNewsletters($type) {
return Newsletter::getPublished()
->filter('filterType', $type)
->filter('filterStatus', Newsletter::STATUS_ACTIVE)
->filter('filterWithOptions')
->findMany();
}
static function createWelcomeNotificationQueue($newsletter, $subscriber_id) {
$queue = SendingQueue::create();
$queue->newsletter_id = $newsletter->id;
@ -169,7 +100,7 @@ class Scheduler {
}
$queue->status = SendingQueue::STATUS_SCHEDULED;
$queue->scheduled_at = $scheduled_at;
$queue->save();
return $queue->save();
}
static function createPostNotificationQueue($newsletter) {
@ -187,9 +118,60 @@ class Scheduler {
return $queue;
}
static function processPostNotificationSchedule($newsletter) {
$interval_type = $newsletter->intervalType;
$hour = (int)$newsletter->timeOfDay / self::SECONDS_IN_HOUR;
$week_day = $newsletter->weekDay;
$month_day = $newsletter->monthDay;
$nth_week_day = ($newsletter->nthWeekDay === self::LAST_WEEKDAY_FORMAT) ?
$newsletter->nthWeekDay :
'#' . $newsletter->nthWeekDay;
switch($interval_type) {
case self::INTERVAL_IMMEDIATELY:
$schedule = '* * * * *';
break;
case self::INTERVAL_IMMEDIATE:
case self::INTERVAL_DAILY:
$schedule = sprintf('0 %s * * *', $hour);
break;
case self::INTERVAL_WEEKLY:
$schedule = sprintf('0 %s * * %s', $hour, $week_day);
break;
case self::INTERVAL_NTHWEEKDAY:
$schedule = sprintf('0 %s ? * %s%s', $hour, $week_day, $nth_week_day);
break;
case self::INTERVAL_MONTHLY:
$schedule = sprintf('0 %s %s * *', $hour, $month_day);
break;
}
$option_field = NewsletterOptionField::where('name', 'schedule')->findOne();
$relation = NewsletterOption::where('newsletter_id', $newsletter->id)
->where('option_field_id', $option_field->id)
->findOne();
if(!$relation) {
$relation = NewsletterOption::create();
$relation->newsletter_id = $newsletter->id;
$relation->option_field_id = $option_field->id;
}
$relation->value = $schedule;
$relation->save();
}
static function getNextRunDate($schedule) {
$schedule = \Cron\CronExpression::factory($schedule);
return $schedule->getNextRunDate(current_time('mysql'))
return $schedule->getNextRunDate(Carbon::createFromTimestamp(current_time('timestamp')))
->format('Y-m-d H:i:s');
}
}
static function getNewsletters($type) {
return Newsletter::getPublished()
->filter('filterType', $type)
->filter('filterStatus', Newsletter::STATUS_ACTIVE)
->filter('filterWithOptions')
->findMany();
}
static function formatDatetimeString($datetime_string) {
return Carbon::parse($datetime_string)->format('Y-m-d H:i:s');
}
}

View File

@ -24,7 +24,7 @@ class Link {
return sprintf(
'<a target="_blank" href="%s">%s</a>',
$url,
__('Unsubscribe')
__('Unsubscribe', 'mailpoet')
);
case 'subscription_unsubscribe_url':
@ -43,7 +43,7 @@ class Link {
return sprintf(
'<a target="_blank" href="%s">%s</a>',
$url,
__('Manage subscription')
__('Manage subscription', 'mailpoet')
);
case 'subscription_manage_url':
@ -60,7 +60,7 @@ class Link {
return sprintf(
'<a target="_blank" href="%s">%s</a>',
$url,
__('View in your browser')
__('View in your browser', 'mailpoet')
);
case 'newsletter_view_in_browser_url':

View File

@ -1,9 +1,9 @@
<?php
namespace MailPoet\Newsletter\Shortcodes\Categories;
use MailPoet\Models\SendingQueue;
use MailPoet\Newsletter\Shortcodes\ShortcodesHelper;
if(!defined('ABSPATH')) exit;
require_once( ABSPATH . "wp-includes/pluggable.php" );
class Newsletter {
@ -54,4 +54,4 @@ class Newsletter {
$posts->posts[0]->to_array() :
false;
}
}
}

View File

@ -1,9 +1,9 @@
<?php
namespace MailPoet\Newsletter\Shortcodes\Categories;
use MailPoet\Models\Subscriber as SubscriberModel;
use MailPoet\Models\SubscriberCustomField;
if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-includes/pluggable.php');
class Subscriber {
@ -42,4 +42,4 @@ class Subscriber {
return false;
}
}
}
}

View File

@ -7,93 +7,93 @@ class ShortcodesHelper {
static function getShortcodes() {
$shortcodes = array(
__('Subscriber') => array(
__('Subscriber', 'mailpoet') => array(
array(
'text' => __('First Name'),
'text' => __('First Name', 'mailpoet'),
'shortcode' => 'subscriber:firstname | default:reader',
),
array(
'text' => __('Last Name'),
'text' => __('Last Name', 'mailpoet'),
'shortcode' => 'subscriber:lastname | default:reader',
),
array(
'text' => __('Email Address'),
'text' => __('Email Address', 'mailpoet'),
'shortcode' => 'subscriber:email',
),
array(
'text' => __('WordPress User Display Name'),
'text' => __('WordPress User Display Name', 'mailpoet'),
'shortcode' => 'subscriber:displayname | default:member',
),
array(
'text' => __('Total Number of Subscribers'),
'text' => __('Total Number of Subscribers', 'mailpoet'),
'shortcode' => 'subscriber:count',
)
),
__('Newsletter') => array(
__('Newsletter', 'mailpoet') => array(
array(
'text' => __('Newsletter Subject'),
'text' => __('Newsletter Subject', 'mailpoet'),
'shortcode' => 'newsletter:subject',
)
),
__('Post Notifications') => array(
__('Post Notifications', 'mailpoet') => array(
array(
'text' => __('Total Number of Posts or Pages'),
'text' => __('Total Number of Posts or Pages', 'mailpoet'),
'shortcode' => 'newsletter:total',
),
array(
'text' => __('Most Recent Post Title'),
'text' => __('Most Recent Post Title', 'mailpoet'),
'shortcode' => 'newsletter:post_title',
),
array(
'text' => __('Issue Number'),
'text' => __('Issue Number', 'mailpoet'),
'shortcode' => 'newsletter:number',
)
),
__('Date') => array(
__('Date', 'mailpoet') => array(
array(
'text' => __('Current day of the month number'),
'text' => __('Current day of the month number', 'mailpoet'),
'shortcode' => 'date:d',
),
array(
'text' => __('Current day of the month in ordinal form, i.e. 2nd, 3rd, 4th, etc.'),
'text' => __('Current day of the month in ordinal form, i.e. 2nd, 3rd, 4th, etc.', 'mailpoet'),
'shortcode' => 'date:dordinal',
),
array(
'text' => __('Full name of current day'),
'text' => __('Full name of current day', 'mailpoet'),
'shortcode' => 'date:dtext',
),
array(
'text' => __('Current month number'),
'text' => __('Current month number', 'mailpoet'),
'shortcode' => 'date:m',
),
array(
'text' => __('Full name of current month'),
'text' => __('Full name of current month', 'mailpoet'),
'shortcode' => 'date:mtext',
),
array(
'text' => __('Year'),
'text' => __('Year', 'mailpoet'),
'shortcode' => 'date:y',
)
),
__('Links') => array(
__('Links', 'mailpoet') => array(
array(
'text' => __('Unsubscribe link'),
'text' => __('Unsubscribe link', 'mailpoet'),
'shortcode' => 'link:subscription_unsubscribe',
),
array(
'text' => __('Edit subscription page link'),
'text' => __('Edit subscription page link', 'mailpoet'),
'shortcode' => 'link:subscription_manage',
),
array(
'text' => __('View in browser link'),
'text' => __('View in browser link', 'mailpoet'),
'shortcode' => 'link:newsletter_view_in_browser',
)
)
);
$custom_fields = self::getCustomFields();
if($custom_fields) {
$shortcodes[__('Subscriber')] = array_merge(
$shortcodes[__('Subscriber')],
$shortcodes[__('Subscriber', 'mailpoet')] = array_merge(
$shortcodes[__('Subscriber', 'mailpoet')],
$custom_fields
);
}

View File

@ -19,7 +19,7 @@ class ViewInBrowser {
function renderNewsletter($newsletter, $subscriber, $queue, $wp_user_preview) {
if($queue && $queue->newsletter_rendered_body) {
$newsletter_body = $queue->getRenderedNewsletterBody();
$newsletter_body = $queue->getNewsletterRenderedBody();
} else {
$renderer = new Renderer($newsletter, $wp_user_preview);
$newsletter_body = $renderer->render();

View File

@ -31,11 +31,11 @@ class Router {
$endpoint_class = __NAMESPACE__ . "\\Endpoints\\" . ucfirst($this->endpoint);
if(!$this->api_request) return;
if(!$this->endpoint || !class_exists($endpoint_class)) {
return $this->terminateRequest(self::RESPONSE_ERROR, __('Invalid router endpoint.'));
return $this->terminateRequest(self::RESPONSE_ERROR, __('Invalid router endpoint.', 'mailpoet'));
}
$endpoint = new $endpoint_class($this->data);
if(!method_exists($endpoint, $this->action) || !in_array($this->action, $endpoint->allowed_actions)) {
return $this->terminateRequest(self::RESPONSE_ERROR, __('Invalid router endpoint action.'));
return $this->terminateRequest(self::RESPONSE_ERROR, __('Invalid router endpoint action.', 'mailpoet'));
}
return call_user_func(
array(
@ -46,10 +46,7 @@ class Router {
}
static function decodeRequestData($data) {
$data = base64_decode($data);
if(is_serialized($data)) {
$data = unserialize($data);
}
$data = json_decode(base64_decode($data), true);
if(!is_array($data)) {
$data = array();
}
@ -57,7 +54,7 @@ class Router {
}
static function encodeRequestData($data) {
return rtrim(base64_encode(serialize($data)), '=');
return rtrim(base64_encode(json_encode($data)), '=');
}
static function buildRequest($endpoint, $action, $data) {

View File

@ -9,8 +9,8 @@ class Pages {
function init() {
register_post_type('mailpoet_page', array(
'labels' => array(
'name' => __('MailPoet Page'),
'singular_name' => __('MailPoet Page')
'name' => __('MailPoet Page', 'mailpoet'),
'singular_name' => __('MailPoet Page', 'mailpoet')
),
'public' => true,
'has_archive' => false,
@ -34,7 +34,7 @@ class Pages {
'post_type' => 'mailpoet_page',
'post_author' => 1,
'post_content' => '[mailpoet_page]',
'post_title' => __('MailPoet Page'),
'post_title' => __('MailPoet Page', 'mailpoet'),
'post_name' => 'subscriptions'
));
flush_rewrite_rules();

View File

@ -8,6 +8,7 @@ use MailPoet\Models\Subscriber;
use MailPoet\Models\SubscriberSegment;
use MailPoet\Subscribers\ImportExport\ImportExportFactory;
use MailPoet\Util\Helpers;
use MailPoet\Util\Security;
use MailPoet\Util\XLSXWriter;
class Export {
@ -46,10 +47,10 @@ class Export {
function process() {
try {
if(is_writable($this->export_path) === false) {
throw new \Exception(__("Couldn't save export file on the server"));
throw new \Exception(__("Couldn't save export file on the server", 'mailpoet'));
}
if(!extension_loaded('zip')) {
throw new \Exception(__('Export requires a ZIP extension to be installed on the host'));
throw new \Exception(__('Export requires a ZIP extension to be installed on the host', 'mailpoet'));
}
$processed_subscribers = call_user_func(
array(
@ -78,7 +79,7 @@ class Export {
// Excel to automatically recognize the encoding
fwrite($CSV_file, chr(0xEF) . chr(0xBB) . chr(0xBF));
if($this->group_by_segment_option) {
$formatted_subscriber_fields[] = __('List');
$formatted_subscriber_fields[] = __('List', 'mailpoet');
}
fwrite(
$CSV_file,
@ -166,7 +167,7 @@ class Export {
return $XLSX_writer->writeSheetRow(
($this->group_by_segment_option) ?
ucwords($segment) :
__('All Lists'),
__('All Lists', 'mailpoet'),
$data
);
}
@ -199,7 +200,7 @@ class Export {
->selectExpr(
'MAX(CASE WHEN ' . Segment::$_table . '.name IS NOT NULL ' .
'THEN ' . Segment::$_table . '.name ' .
'ELSE "' . __('Not In Segment') . '" END) as segment_name'
'ELSE "' . __('Not In Segment', 'mailpoet') . '" END) as segment_name'
)
->whereRaw(
SubscriberSegment::$_table . '.segment_id IN (' .
@ -240,7 +241,7 @@ class Export {
function getExportFile($format) {
return sprintf(
$this->export_path . '/MailPoet_export_%s.%s',
substr(md5(time()), 0, 4),
Security::generateRandomString(15),
$format
);
}

View File

@ -21,6 +21,7 @@ class Import {
public $updated_at;
public function __construct($data) {
$this->validateData($data);
$this->subscribers_data = $this->transformSubscribersData(
$data['subscribers'],
$data['columns']
@ -41,6 +42,23 @@ class Import {
$this->updated_at = date('Y-m-d H:i:s', (int)$data['timestamp'] + 1);
}
function validateData($data) {
$required_data_fields = array(
'subscribers',
'columns',
'segments',
'timestamp',
'updateSubscribers'
);
// 1. data should contain all required fields
// 2. column names should only contain alphanumeric & underscore characters
if(count(array_intersect_key(array_flip($required_data_fields), $data)) !== count($required_data_fields) ||
preg_grep('/[^a-zA-Z0-9_]/', array_keys($data['columns']))
) {
throw new \Exception(__('Missing or invalid subscriber data.', 'mailpoet'));
}
}
function getSubscriberFieldsValidationRules($subscriber_fields) {
$validation_rules = array();
foreach($subscriber_fields as $column => $field) {
@ -89,8 +107,8 @@ class Import {
$this->synchronizeWPUsers($wp_users);
}
}
} catch(\PDOException $e) {
throw new \Exception($e->getMessage());
} catch(\Exception $e) {
throw new \Exception(__('Unable to save imported subscribers.', 'mailpoet'));
}
$import_factory = new ImportExportFactory('import');
$segments = $import_factory->getSegments();
@ -364,6 +382,11 @@ class Import {
$subscribers_data,
$subscriber_custom_fields
) {
// check if custom fields exist in the database
$subscriber_custom_fields = Helpers::flattenArray(
CustomField::whereIn('id', $subscriber_custom_fields)->select('id')->findArray()
);
if(!$subscriber_custom_fields) return;
$subscribers = array_map(
function($column) use ($db_subscribers, $subscribers_data) {
$count = range(0, count($subscribers_data[$column]) - 1);
@ -406,4 +429,4 @@ class Import {
);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More