Compare commits

...

139 Commits

Author SHA1 Message Date
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
5b2ede8b83 Bump up release version to 0.0.45 2016-09-20 12:53:33 +03: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
bff6aecd0d Merge pull request #617 from mailpoet/copy-edit
Updated text
2016-09-19 17:08:19 +03:00
a121583c2d Updated text 2016-09-19 10:13:34 +01: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
8c436180d9 Merge pull request #615 from mailpoet/unit_tests
Adds unit tests for cron scheduler worker
2016-09-15 13:21:34 +03:00
b834a6af4d - Updates cron scheduler worker
- Adds unit tests
2016-09-14 19:00:08 -04:00
1bd8aed192 Bump up release version to 0.0.44, add changelog 2016-09-13 15:59:18 +03:00
cfdf72867e Merge pull request #612 from mailpoet/subscribers_limit
Subscribers limit
2016-09-13 08:49:06 -04:00
5888620fc1 - Updates link to support area 2016-09-13 08:41:37 -04:00
55ba605eb0 fixed typo in test function name 2016-09-13 11:45:33 +02:00
7a73ca7d1a Merge pull request #608 from mailpoet/api_uniform_h
Listing method update for Newsletters/Forms/Segments/Subscribers
2016-09-12 10:12:18 -04:00
1918894c5c fix status code in API + PHP 5.3 errors on object instantiation 2016-09-12 15:59:30 +02:00
0c5589a3e3 Listing method update for Newsletters/Forms/Segments/Subscribers
- updated unit tests
2016-09-12 15:57:16 +02:00
d6eaa4ac8a Merge pull request #614 from mailpoet/links_to_support_articles
Updates links to KB articles
2016-09-12 14:37:32 +02:00
b0571b97f5 added missing KB link in Send with 3rd party 2016-09-12 14:32:59 +02:00
6d51ca8011 Merge pull request #613 from mailpoet/class_instance_creation_update
Class instance creation fix for PHP 5.3
2016-09-12 14:07:38 +02:00
d3289dfb84 Merge pull request #609 from mailpoet/unit_tests
Cron unit tests (batch 1 of 2)
2016-09-12 14:30:29 +03:00
bfffdd7274 - Updates links to KB articles
- Closes #571
2016-09-10 21:12:43 -04:00
c5b8b2aef0 - Fixes "class not found" error in Daemon
- Moves ignore_user_abort() to the run() method
- Updates unit tests
2016-09-10 18:06:48 -04:00
d7bcf1b817 - Updates the way errorResponse class is instantiated 2016-09-10 10:49:20 -04:00
f30ed153ce - Updates the way template classes are instantiated 2016-09-10 10:44:24 -04:00
f436088a16 Subscribers limit
- added "limit.html" template
- subscribers_limit set in Env class
2016-09-09 16:12:59 +02:00
db8cb7499d Merge pull request #611 from mailpoet/copy-editing
Update September 9 2016
2016-09-09 16:49:42 +03:00
49c4adc754 Increase the width of subject and preheader inputs 2016-09-09 16:45:19 +03:00
405e743171 update September 9 2016 2016-09-09 15:04:00 +02:00
3508ac36b4 - Removes daemon status logic and updates tests
- Refactors daemon
- Adds daemon unit tests
2016-09-08 19:22:42 -04:00
f17c8228cd - Adds units tests for cron triggers 2016-09-07 18:21:31 -04:00
3dd5ac0536 Merge pull request #607 from mailpoet/api_uniform_g
Forms / Newsletters / Segments / Subscribers
2016-09-07 14:52:21 -04:00
4ebdff49e0 make Model::setTimestamp() public 2016-09-07 10:26:08 +02:00
4a72995bf4 fix bulk actions and messages 2016-09-06 17:21:15 +02:00
ef27ac0b84 Update changelog for 0.0.43 2016-09-06 12:27:58 +03:00
2b4adef6c2 Bump up release version to 0.0.43 2016-09-06 12:13:21 +03:00
f650455a90 forms & newsletters endpoints 2016-09-05 11:55:01 +02:00
afbe25e215 Segments & Subscribers endpoints
- unit tests
2016-09-05 11:51:58 +02:00
d93249f077 form & listing jsx update + Segment endpoint conversion 2016-09-05 11:51:58 +02:00
6223ef77d9 Merge pull request #605 from mailpoet/editor_fixes
Editor fixes
2016-09-02 08:30:59 -04:00
a423123b66 Add 3 new sample templates Becs prepared 2016-09-02 14:12:19 +03:00
1b3d3082b0 Fix text in template selection boxes to not overflow 2016-09-02 12:48:44 +03:00
fa117cc7dd Add an animation to display tools 2016-09-02 12:48:44 +03:00
acd407c1f1 Clarify label of preheader field 2016-09-02 12:48:44 +03:00
9baf4b068f Swapped block tool default and hover colors. Dark normally, light on
hover
2016-09-02 12:48:44 +03:00
18d852e147 Changed Trash and Move SVG icons to new ones for newsletter editor 2016-09-02 12:48:44 +03:00
b8dc306741 Merge pull request #604 from mailpoet/unit_tests
Unit tests (Cron Supervisor and Trigger)
2016-09-02 12:46:39 +03:00
6ea056c042 - Removes references to cron from webpack's configuration 2016-09-01 19:19:47 -04:00
bcf1b37c6a - Adds unit tests for Cron Trigger class 2016-09-01 19:19:47 -04:00
2986cdba85 - Removes Cron status from MailPoet's WP admin panel 2016-09-01 19:19:47 -04:00
53a8ae74e2 - Adds unit tests for Supervisor class
- Updates execution limit condition check in Supervisor
2016-09-01 19:19:47 -04:00
8bab01506c - Updates CircleCI configuration to run Apache 2016-09-01 19:18:47 -04:00
c664045444 Merge pull request #603 from mailpoet/welcome_page
Welcome and Update pages
2016-09-01 14:02:20 +03:00
6b8149210d Remove installed_at default value from default settings 2016-08-31 16:59:50 +03:00
f31d30b318 Merge pull request #602 from mailpoet/cron_update
Cron update
2016-08-31 16:48:05 +03:00
d9fbbdc02d - Updates code comments 2016-08-31 09:23:12 -04:00
8136ee2d9b Add a timestamp to log when the plugin was installed 2016-08-31 14:42:43 +03:00
f7cf6e2131 Welcome and Update pages 2016-08-31 13:51:33 +03:00
f2d1787bd5 - Updates site URL detection logic
- Adds unit test for Cron Helper class
2016-08-30 12:37:30 -04:00
223 changed files with 7272 additions and 7003 deletions

View File

@ -0,0 +1,15 @@
Listen 8080
<VirtualHost *:8080>
UseCanonicalName Off
ServerName mailpoet.loc
DocumentRoot /home/ubuntu/mailpoet/wordpress
DirectoryIndex index.php
LogLevel notice
<Directory /home/ubuntu/mailpoet/wordpress>
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

1
.gitignore vendored
View File

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

View File

@ -60,15 +60,20 @@
.mailpoet_boxes .mailpoet_description
float:left
width: 245px
max-height: calc(110px - 2em)
max-height: calc(115px - 2em)
padding-bottom: 2em
overflow: hidden
.mailpoet_boxes .mailpoet_description h3
margin: 0 0 0.7em 0
overflow: hidden
max-width: 210px
line-height: 1.4em
h3
margin: 0 0 0.7em 0
overflow: hidden
max-width: 210px
line-height: 1.4em
p
font-size: 13px
line-height: 1.5
margin: 1em 0
.mailpoet_boxes .mailpoet_actions
position: absolute

View File

@ -1,6 +1,6 @@
$tool-inactive-color = #bbbbbb
$tool-inactive-color = #333333
$tool-inactive-secondary-color = #ffffff
$tool-hover-color = #333333
$tool-hover-color = #bbbbbb
$tool-hover-secondary-color = #ffffff
$tool-active-color = #d2d2d4
$tool-active-secondary-color = #ffffff
@ -12,21 +12,42 @@ $master-column-tool-width = 24px
position: absolute
top: 0
right: 0
display: none
z-index: 20
padding: 2px
text-align: right
overflow: hidden
.mailpoet_tool_slider
position: relative
right: -100%
transition: all 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000)
opacity: 0
&.mailpoet_display_tools
.mailpoet_tool_slider
right: 0
opacity: 1
a
vertical-align: top
.mailpoet_container_horizontal + &
left: 100%
right: initial
padding-left: 5px
.mailpoet_tool_slider
left: -100%
right: initial
&.mailpoet_display_tools
.mailpoet_tool_slider
left: 0
.mailpoet_tool
width: $master-column-tool-width
height: $master-column-tool-width
display: block
.mailpoet_tool_icon
width: $master-column-tool-width

View File

@ -4,7 +4,7 @@
.mailpoet_input_title,
.mailpoet_input_preheader
width: 400px
width: 500px
padding: 3px
line-height: normal

View File

@ -5,8 +5,8 @@ $active-social-icon-set-border-color = #adadad
$active-social-icon-set-background-color = #daebf2
$social-icon-set-hover-border-color = $primary-active-color
$tool-inactive-color = #bbbbbb
$tool-hover-color = #333333
$tool-inactive-color = #333333
$tool-hover-color = #bbbbbb
$tool-active-color = #d2d2d4
$tool-width = 16px

View File

@ -1,12 +1,12 @@
animation-slide-open-downwards()
animation-slide-open-downwards($max-height = 2000px)
transition: all 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000) /* ease-in-out */
max-height: 2000px
max-height: $max-height
opacity: 1
overflow-y: hidden
&.mailpoet_closed
max-height: 0
max-height: 0px
opacity: 0
overflow-y: hidden
animation-background-color()
transition: background 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000) /* ease-in-out */

View File

Before

Width:  |  Height:  |  Size: 178 KiB

After

Width:  |  Height:  |  Size: 178 KiB

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -1,72 +0,0 @@
define(
[
'react',
'react-dom',
'mailpoet'
],
function(
React,
ReactDOM,
MailPoet
) {
var CronControl = React.createClass({
getInitialState: function() {
return {
status: 'loading'
};
},
getCronData: function() {
MailPoet.Ajax.post({
endpoint: 'cron',
action: 'getStatus'
}).done((response) => {
this.setState({
status: response.data.status
});
}).fail((response) => {
this.setState({
status: false
});
});
},
componentDidMount: function() {
if(this.isMounted()) {
this.getCronData();
setInterval(this.getCronData, 5000);
}
},
render: function() {
let status;
switch(this.state.status) {
case false:
case 'stopping':
case 'stopped':
status = MailPoet.I18n.t('cronDaemonIsNotRunning');
break;
case 'starting':
case 'started':
status = MailPoet.I18n.t('cronDaemonIsRunning');
break;
case 'loading':
status = MailPoet.I18n.t('loadingDaemonStatus');
break;
}
return (
<div>
{ status }
</div>
);
}
});
const container = document.getElementById('cron_container');
if(container) {
ReactDOM.render(
<CronControl />,
container
);
}
});

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

View File

@ -66,22 +66,22 @@ define(
MailPoet.Ajax.post({
endpoint: this.props.endpoint,
action: 'get',
data: id
}).done(function(response) {
if(response === false) {
this.setState({
loading: false,
item: {}
}, function() {
this.context.router.push('/new');
}.bind(this));
} else {
this.setState({
loading: false,
item: response
});
data: {
id: id
}
}.bind(this));
}).done((response) => {
this.setState({
loading: false,
item: response.data
});
}).fail((response) => {
this.setState({
loading: false,
item: {}
}, function() {
this.context.router.push('/new');
});
});
},
handleSubmit: function(e) {
e.preventDefault();
@ -115,29 +115,25 @@ define(
endpoint: this.props.endpoint,
action: 'save',
data: item
}).done(function(response) {
}).always(() => {
this.setState({ loading: false });
if(response.result === true) {
if(this.props.onSuccess !== undefined) {
this.props.onSuccess();
} else {
this.context.router.push('/');
}
if(this.props.params.id !== undefined) {
this.props.messages.onUpdate();
} else {
this.props.messages.onCreate();
}
}).done((response) => {
if(this.props.onSuccess !== undefined) {
this.props.onSuccess();
} else {
if(response.result === false) {
if(response.errors.length > 0) {
this.setState({ errors: response.errors });
}
}
this.context.router.push('/');
}
}.bind(this));
if(this.props.params.id !== undefined) {
this.props.messages.onUpdate();
} else {
this.props.messages.onCreate();
}
}).fail((response) => {
if(response.errors.length > 0) {
this.setState({ errors: response.errors });
}
});
},
handleValueChange: function(e) {
if (this.props.onChange) {
@ -159,7 +155,7 @@ define(
var errors = this.getErrors().map(function(error, index) {
return (
<p key={ 'error-'+index } className="mailpoet_error">
{ error }
{ error.message }
</p>
);
});

View File

@ -27,48 +27,48 @@ const columns = [
];
const messages = {
onTrash: function(response) {
var count = ~~response;
var message = null;
onTrash: (response) => {
const count = ~~response.meta.count;
let message = null;
if(count === 1) {
if (count === 1) {
message = (
MailPoet.I18n.t('oneFormTrashed')
);
} else {
message = (
MailPoet.I18n.t('multipleFormsTrashed')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onDelete: function(response) {
var count = ~~response;
var message = null;
onDelete: (response) => {
const count = ~~response.meta.count;
let message = null;
if(count === 1) {
if (count === 1) {
message = (
MailPoet.I18n.t('oneFormDeleted')
);
} else {
message = (
MailPoet.I18n.t('multipleFormsDeleted')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onRestore: function(response) {
var count = ~~response;
var message = null;
onRestore: (response) => {
const count = ~~response.meta.count;
let message = null;
if(count === 1) {
if (count === 1) {
message = (
MailPoet.I18n.t('oneFormRestored')
);
} else {
message = (
MailPoet.I18n.t('multipleFormsRestored')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
@ -99,14 +99,21 @@ const item_actions = [
return MailPoet.Ajax.post({
endpoint: 'forms',
action: 'duplicate',
data: item.id
}).done(function(response) {
if (response !== false && response['name'] !== undefined) {
MailPoet.Notice.success(
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.name)
data: {
id: item.id
}
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.data.name)
);
refresh();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
refresh();
});
}
},
@ -120,9 +127,14 @@ const FormList = React.createClass({
MailPoet.Ajax.post({
endpoint: 'forms',
action: 'create'
}).done(function(response) {
if(response.result && response.form_id) {
window.location = mailpoet_form_edit_url + response.form_id;
}).done((response) => {
window.location = mailpoet_form_edit_url + response.data.id;
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
});
},
@ -139,6 +151,10 @@ const FormList = React.createClass({
return segment.name;
}).join(', ');
if (form.settings.segments_selected_by === 'user') {
segments = MailPoet.I18n.t('userChoice') + ' ' + segments;
}
return (
<div>
<td className={ row_classes }>

View File

@ -53,7 +53,10 @@ function(
}
if(data.action) {
this.props.onBulkAction(selected_ids, data).then(onSuccess);
const promise = this.props.onBulkAction(selected_ids, data);
if (promise !== false) {
promise.then(onSuccess);
};
}
this.setState({

View File

@ -456,22 +456,29 @@ const Listing = React.createClass({
sort_by: this.state.sort_by,
sort_order: this.state.sort_order
}
}).done(function(response) {
}).always(() => {
this.setState({ loading: false });
}).done((response) => {
this.setState({
items: response.items || [],
filters: response.filters || {},
groups: response.groups || [],
count: response.count || 0,
loading: false
}, function() {
if (this.props['onGetItems'] !== undefined) {
const count = (response.groups[0] !== undefined)
? ~~(response.groups[0].count)
: 0;
this.props.onGetItems(count);
items: response.data || [],
filters: response.meta.filters || {},
groups: response.meta.groups || [],
count: response.meta.count || 0
}, () => {
// if viewing an empty trash
if (this.state.group === 'trash' && response.meta.count === 0) {
// redirect to default group
this.handleGroup('all');
}
}.bind(this));
}.bind(this));
});
}).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
});
}
},
handleRestoreItem: function(id) {
@ -483,8 +490,10 @@ const Listing = React.createClass({
MailPoet.Ajax.post({
endpoint: this.props.endpoint,
action: 'restore',
data: id
}).done(function(response) {
data: {
id: id
}
}).done((response) => {
if (
this.props.messages !== undefined
&& this.props.messages['onRestore'] !== undefined
@ -492,7 +501,12 @@ const Listing = React.createClass({
this.props.messages.onRestore(response);
}
this.getItems();
}.bind(this));
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
});
},
handleTrashItem: function(id) {
this.setState({
@ -503,8 +517,10 @@ const Listing = React.createClass({
MailPoet.Ajax.post({
endpoint: this.props.endpoint,
action: 'trash',
data: id
}).done(function(response) {
data: {
id: id
}
}).done((response) => {
if (
this.props.messages !== undefined
&& this.props.messages['onTrash'] !== undefined
@ -512,7 +528,12 @@ const Listing = React.createClass({
this.props.messages.onTrash(response);
}
this.getItems();
}.bind(this));
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
});
},
handleDeleteItem: function(id) {
this.setState({
@ -523,8 +544,10 @@ const Listing = React.createClass({
MailPoet.Ajax.post({
endpoint: this.props.endpoint,
action: 'delete',
data: id
}).done(function(response) {
data: {
id: id
}
}).done((response) => {
if (
this.props.messages !== undefined
&& this.props.messages['onDelete'] !== undefined
@ -532,22 +555,29 @@ const Listing = React.createClass({
this.props.messages.onDelete(response);
}
this.getItems();
}.bind(this));
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
});
},
handleEmptyTrash: function() {
return this.handleBulkAction('all', {
action: 'delete',
group: 'trash'
}).then(function(response) {
if (~~(response) > 0) {
MailPoet.Notice.success(
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response)
);
}
}).done((response) => {
MailPoet.Notice.success(
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response.meta.count)
);
// redirect to default group
this.handleGroup('all');
}.bind(this));
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
});
},
handleBulkAction: function(selected_ids, params) {
if (
@ -555,7 +585,7 @@ const Listing = React.createClass({
&& this.state.selected_ids.length === 0
&& selected_ids !== 'all'
) {
return;
return false;
}
this.setState({ loading: true });
@ -594,7 +624,7 @@ const Listing = React.createClass({
handleSort: function(sort_by, sort_order = 'asc') {
this.setState({
sort_by: sort_by,
sort_order: sort_order,
sort_order: (sort_order === 'asc') ? 'asc' : 'desc',
}, function() {
this.setParams();
}.bind(this));

View File

@ -99,12 +99,12 @@ define([
},
showTools: function(_event) {
if (!this.showingToolsDisabled) {
this.$('> .mailpoet_tools').show();
this.$('> .mailpoet_tools').addClass('mailpoet_display_tools');
this.toolsView.triggerMethod('showTools');
}
},
hideTools: function(e) {
this.$('> .mailpoet_tools').hide();
this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools');
this.toolsView.triggerMethod('hideTools');
},
enableShowingTools: function() {

View File

@ -186,13 +186,13 @@ define([
},
showTools: function() {
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
this.$(this.ui.tools).show();
this.$(this.ui.tools).addClass('mailpoet_display_tools');
this.toolsView.triggerMethod('showTools');
}
},
hideTools: function() {
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
this.$(this.ui.tools).hide();
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
this.toolsView.triggerMethod('hideTools');
}
},

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

@ -171,11 +171,11 @@ define([
this.regionManager.destroy();
},
showTools: function(_event) {
this.$(this.ui.tools).show();
this.$(this.ui.tools).addClass('mailpoet_display_tools');
_event.stopPropagation();
},
hideTools: function(_event) {
this.$(this.ui.tools).hide();
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
_event.stopPropagation();
},
showSettings: function(options) {

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,7 +11,7 @@ define([
return MailPoet.Ajax.post({
endpoint: 'automatedLatestContent',
action: args.action,
data: args.options || {},
data: args.options || {}
});
};
Module._cachedQuery = _.memoize(Module._query, JSON.stringify);
@ -19,14 +19,14 @@ define([
Module.getNewsletter = function(options) {
return Module._query({
action: 'get',
options: options,
options: options
});
};
Module.getPostTypes = function() {
return Module._cachedQuery({
action: 'getPostTypes',
options: {},
options: {}
}).then(function(response) {
return _.values(response.data);
});
@ -83,7 +83,7 @@ define([
return MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'save',
data: options || {},
data: options || {}
});
};
@ -91,7 +91,7 @@ define([
return MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'sendPreview',
data: options || {},
data: options || {}
});
};

View File

@ -252,32 +252,31 @@ define([
endpoint: 'newsletters',
action: 'showPreview',
data: json,
}).done(function(response) {
if (response.result === true) {
this.previewView = new Module.NewsletterPreviewView({
previewUrl: response.data.url
});
var view = this.previewView.render();
MailPoet.Modal.popup({
template: '',
element: this.previewView.$el,
title: MailPoet.I18n.t('newsletterPreview'),
onCancel: function() {
this.previewView.destroy();
this.previewView = null;
}.bind(this)
});
} else {
MailPoet.Notice.error(response.errors);
}
}.bind(this)).fail(function(error) {
MailPoet.Notice.error(
MailPoet.I18n.t('newsletterPreviewFailed')
);
}).always(function() {
MailPoet.Modal.loading(false);
}).done(function(response) {
this.previewView = new Module.NewsletterPreviewView({
previewUrl: response.meta.preview_url
});
var view = this.previewView.render();
MailPoet.Modal.popup({
template: '',
element: this.previewView.$el,
title: MailPoet.I18n.t('newsletterPreview'),
onCancel: function() {
this.previewView.destroy();
this.previewView = null;
}.bind(this)
});
}.bind(this)).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
});
},
sendPreview: function() {
@ -302,28 +301,19 @@ define([
// send test email
MailPoet.Modal.loading(true);
CommunicationComponent.previewNewsletter(data).done(function(response) {
if(response.result !== undefined && response.result === true) {
MailPoet.Notice.success(MailPoet.I18n.t('newsletterPreviewSent'), { scroll: true });
} else {
if (_.isArray(response.errors)) {
response.errors.map(function(error) {
MailPoet.Notice.error(error, { scroll: true });
});
} else {
MailPoet.Notice.error(
MailPoet.I18n.t('newsletterPreviewFailedToSend'),
{
scroll: true,
static: true,
}
);
}
}
CommunicationComponent.previewNewsletter(data).always(function() {
MailPoet.Modal.loading(false);
}).done(function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterPreviewSent'),
{ scroll: true });
}).fail(function(response) {
// an error occurred
MailPoet.Modal.loading(false);
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true, static: true }
);
}
});
},
});

View File

@ -17,8 +17,8 @@ import {
} from 'newsletters/scheduling/common.jsx'
const messages = {
onTrash(response) {
const count = ~~response;
onTrash: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -28,12 +28,12 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersTrashed')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onDelete(response) {
const count = ~~response;
onDelete: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -43,12 +43,12 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersDeleted')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onRestore(response) {
const count = ~~response;
onRestore: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -58,7 +58,7 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersRestored')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
@ -127,16 +127,23 @@ const newsletter_actions = [
return MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'duplicate',
data: newsletter.id
}).done(function(response) {
if (response !== false && response.subject !== undefined) {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
'%$1s', response.subject
)
data: {
id: newsletter.id
}
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
'%$1s', response.data.subject
)
);
refresh();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
refresh();
});
}
},

View File

@ -12,8 +12,8 @@ import { QueueMixin, StatisticsMixin } from 'newsletters/listings/mixins.jsx'
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
const messages = {
onTrash(response) {
const count = ~~response;
onTrash: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -23,12 +23,12 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersTrashed')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onDelete(response) {
const count = ~~response;
onDelete: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -38,12 +38,12 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersDeleted')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onRestore(response) {
const count = ~~response;
onRestore: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -53,7 +53,7 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersRestored')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
@ -122,16 +122,23 @@ const newsletter_actions = [
return MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'duplicate',
data: newsletter.id
}).done(function(response) {
if (response !== false && response.subject !== undefined) {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
'%$1s', response.subject
)
data: {
id: newsletter.id
}
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
'%$1s', response.data.subject
)
);
refresh();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
refresh();
});
}
},

View File

@ -15,8 +15,8 @@ const mailpoet_segments = window.mailpoet_segments || {};
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
const messages = {
onTrash(response) {
const count = ~~response;
onTrash: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -26,12 +26,12 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersTrashed')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onDelete(response) {
const count = ~~response;
onDelete: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -41,12 +41,12 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersDeleted')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onRestore(response) {
const count = ~~response;
onRestore: (response) => {
const count = ~~response.meta.count;
let message = null;
if (count === 1) {
@ -56,7 +56,7 @@ const messages = {
} else {
message = (
MailPoet.I18n.t('multipleNewslettersRestored')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
@ -125,16 +125,23 @@ const newsletter_actions = [
return MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'duplicate',
data: newsletter.id
}).done(function(response) {
if (response !== false && response.subject !== undefined) {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
'%$1s', response.subject
)
data: {
id: newsletter.id
}
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
'%$1s', response.data.subject
)
);
refresh();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
refresh();
});
}
},

View File

@ -66,22 +66,22 @@ define(
MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'get',
data: id
}).done((response) => {
if(response === false) {
this.setState({
loading: false,
item: {},
}, function() {
this.context.router.push('/new');
}.bind(this));
} else {
this.setState({
loading: false,
item: response,
fields: this.getFieldsByNewsletter(response),
});
data: {
id: id
}
}).done((response) => {
this.setState({
loading: false,
item: response.data,
fields: this.getFieldsByNewsletter(response.data)
});
}).fail((response) => {
this.setState({
loading: false,
item: {}
}, () => {
this.context.router.push('/new');
});
});
},
handleSend: function(e) {

View File

@ -40,11 +40,7 @@ define(
return !!(!segment.deleted_at);
},
getLabel: function(segment) {
var name = segment.name;
if (segment.subscribers > 0) {
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
}
return name;
return segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
},
validation: {
'data-parsley-required': true,

View File

@ -346,11 +346,7 @@ define(
return !!(!segment.deleted_at);
},
getLabel: function(segment) {
var name = segment.name;
if (segment.subscribers > 0) {
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
}
return name;
return segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
},
validation: {
'data-parsley-required': true,

View File

@ -28,17 +28,16 @@ define(
type: type,
subject: MailPoet.I18n.t('draftNewsletterTitle'),
}
}).done(function(response) {
if(response.result && response.newsletter.id) {
this.context.router.push(`/template/${response.newsletter.id}`);
} else {
if(response.errors.length > 0) {
response.errors.map(function(error) {
MailPoet.Notice.error(error);
});
}
}).done((response) => {
this.context.router.push(`/template/${response.data.id}`);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
}.bind(this));
});
},
render: function() {
return (

View File

@ -50,17 +50,16 @@ define(
type: 'notification',
subject: MailPoet.I18n.t('draftNewsletterTitle'),
}),
}).done(function(response) {
if(response.result && response.newsletter.id) {
this.showTemplateSelection(response.newsletter.id);
} else {
if(response.errors.length > 0) {
response.errors.map(function(error) {
MailPoet.Notice.error(error);
});
}
}).done((response) => {
this.showTemplateSelection(response.data.id);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
}.bind(this));
});
},
showTemplateSelection: function(newsletterId) {
this.context.router.push(`/template/${newsletterId}`);

View File

@ -25,19 +25,18 @@ define(
endpoint: 'newsletters',
action: 'create',
data: {
type: 'standard',
type: 'standard'
}
}).done(function(response) {
if(response.result && response.newsletter.id) {
this.showTemplateSelection(response.newsletter.id);
} else {
if(response.errors.length > 0) {
response.errors.map(function(error) {
MailPoet.Notice.error(error);
});
}
}).done((response) => {
this.showTemplateSelection(response.data.id);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
}.bind(this));
});
},
render: function() {
return (

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];
}
));
@ -113,17 +110,16 @@ const WelcomeScheduling = React.createClass({
type: 'welcome',
options: this.state
}
}).done(function(response) {
if (response.result && response.newsletter.id) {
this.showTemplateSelection(response.newsletter.id);
} else {
}).done((response) => {
this.showTemplateSelection(response.data.id);
}).fail((response) => {
if (response.errors.length > 0) {
response.errors.map(function(error) {
MailPoet.Notice.error(error);
});
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
}
}.bind(this));
});
},
showTemplateSelection: function(newsletterId) {
this.context.router.push(`/template/${ newsletterId }`);

View File

@ -57,18 +57,17 @@ define(
data: _.extend({}, this.state, {
type: 'welcome',
subject: MailPoet.I18n.t('draftNewsletterTitle'),
}),
}).done(function(response) {
if(response.result && response.newsletter.id) {
this.showTemplateSelection(response.newsletter.id);
} else {
if(response.errors.length > 0) {
response.errors.map(function(error) {
MailPoet.Notice.error(error);
});
}
})
}).done((response) => {
this.showTemplateSelection(response.data.id);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
}.bind(this));
});
},
showTemplateSelection: function(newsletterId) {
this.context.router.push(`/template/${newsletterId}`);

View File

@ -44,29 +44,36 @@ function(
endpoint: 'subscribers',
action: 'subscribe',
data: data
}).fail(function(response) {
form.find('.mailpoet_validate_error').html(
response.errors.map(function(error) {
return error.message;
}).join('<br />')
).show();
}).done(function(response) {
if(response.result === false) {
form.find('.mailpoet_validate_error').html(
response.errors.join('<br />')
).show();
// successfully subscribed
if (
response.meta !== undefined
&& response.meta.redirect_url !== undefined
) {
// go to page
window.location.href = response.meta.redirect_url;
} else {
// successfully subscribed
if(response.page !== undefined) {
// go to page
window.location.href = response.page;
} else {
// display success message
form.find('.mailpoet_validate_success').show();
}
// reset form
form.trigger('reset');
// reset validation
parsley.reset();
// display success message
form.find('.mailpoet_validate_success').show();
}
// reset form
form.trigger('reset');
// reset validation
parsley.reset();
// resize iframe
if(window.frameElement !== null) {
if (
window.frameElement !== null
&& MailPoet !== undefined
&& MailPoet['Iframe']
) {
MailPoet.Iframe.autoSize(window.frameElement);
}
});

View File

@ -36,48 +36,48 @@ var columns = [
];
const messages = {
onTrash: function(response) {
var count = ~~response;
var message = null;
onTrash: (response) => {
const count = ~~response.meta.count;
let message = null;
if(count === 1) {
if (count === 1) {
message = (
MailPoet.I18n.t('oneSegmentTrashed')
);
} else {
message = (
MailPoet.I18n.t('multipleSegmentsTrashed')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onDelete: function(response) {
var count = ~~response;
var message = null;
onDelete: (response) => {
const count = ~~response.meta.count;
let message = null;
if(count === 1) {
if (count === 1) {
message = (
MailPoet.I18n.t('oneSegmentDeleted')
);
} else {
message = (
MailPoet.I18n.t('multipleSegmentsDeleted')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onRestore: function(response) {
var count = ~~response;
var message = null;
onRestore: (response) => {
const count = ~~response.meta.count;
let message = null;
if(count === 1) {
if (count === 1) {
message = (
MailPoet.I18n.t('oneSegmentRestored')
);
} else {
message = (
MailPoet.I18n.t('multipleSegmentsRestored')
).replace('%$1d', count);
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
@ -106,16 +106,23 @@ const item_actions = [
{
name: 'duplicate_segment',
label: MailPoet.I18n.t('duplicate'),
onClick: function(item, refresh) {
onClick: (item, refresh) => {
return MailPoet.Ajax.post({
endpoint: 'segments',
action: 'duplicate',
data: item.id
}).done(function(response) {
data: {
id: item.id
}
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('listDuplicated')).replace('%$1s', response.name)
MailPoet.I18n.t('listDuplicated').replace('%$1s', response.data.name)
);
refresh();
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
});
},
display: function(segment) {
@ -127,7 +134,7 @@ const item_actions = [
link: function(item) {
return (
<a
href="https://www.mailpoet.com/#TODO"
href="http://docs.mailpoet.com/article/133-the-wordpress-users-list"
target="_blank"
>{MailPoet.I18n.t('readMore')}</a>
);

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

@ -7,7 +7,6 @@ define(
'handlebars',
'papaparse',
'asyncqueue',
'xss',
'moment',
'select2'
],
@ -19,7 +18,6 @@ define(
Handlebars,
Papa,
AsyncQueue,
xss,
Moment
) {
if (!jQuery('#mailpoet_subscribers_import').length) {
@ -337,9 +335,9 @@ define(
complete: function (CSV) {
for (var rowCount in CSV.data) {
var rowData = CSV.data[rowCount].map(function (el) {
return filterXSS(el.trim());
}),
rowColumnCount = rowData.length;
return el.trim();
});
var rowColumnCount = rowData.length;
// set the number of row elements based on the first non-empty row
if (columnCount === null) {
columnCount = rowColumnCount;
@ -530,15 +528,11 @@ define(
width: '20em',
templateResult: function (item) {
item.subscriberCount = parseInt(item.subscriberCount);
return (item.subscriberCount > 0)
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
: item.name;
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
},
templateSelection: function (item) {
item.subscriberCount = parseInt(item.subscriberCount);
return (item.subscriberCount > 0)
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
: item.name;
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
}
})
.change(function () {
@ -586,7 +580,8 @@ define(
}).done(function(response) {
mailpoetSegments.push({
'id': response.data.id,
'name': response.data.name
'name': response.data.name,
'subscriberCount': 0
});
var selected_values = segmentSelectElement.val();
@ -673,8 +668,15 @@ define(
return options.fn(displayedColumns);
});
// sanitize unsafe data
Handlebars.registerHelper('sanitize_data', function(data) {
return (data instanceof Handlebars.SafeString) ?
data :
new Handlebars.SafeString(Handlebars.Utils.escapeExpression(data));
});
// start array index from 1
Handlebars.registerHelper('show_real_index', function (index) {
Handlebars.registerHelper('calculate_index', function (index) {
var index = parseInt(index);
// display filler data (e.g., ellipsis) if we've reached the maximum number of rows and
// subscribers count is greater than the maximum number of rows we're displaying
@ -883,7 +885,9 @@ define(
jQuery(matchedColumn.element).data('validation-rule', validationRule);
break;
}
if (validationRule === 'datetime') validationRule = Moment.ISO_8601;
if (validationRule === 'datetime') {
validationRule = Moment.ISO_8601;
}
}
}
jQuery.map(subscribersClone.subscribers, function (data, index) {
@ -892,18 +896,22 @@ define(
var date = Moment(rowData, testedFormat, true);
// validate date
if (date.isValid()) {
data[matchedColumn.index] +=
'<span class="mailpoet_data_match" title="'
+ MailPoet.I18n.t('verifyDateMatch') + '">'
+ MailPoet.Date.format(date)
+ '</span>';
data[matchedColumn.index] = new Handlebars.SafeString(
Handlebars.Utils.escapeExpression(data[matchedColumn.index])
+ '<span class="mailpoet_data_match" title="'
+ MailPoet.I18n.t('verifyDateMatch') + '">'
+ MailPoet.Date.format(date)
+ '</span>'
);
}
else {
data[matchedColumn.index] +=
'<span class="mailpoet_data_match mailpoet_import_error" title="'
data[matchedColumn.index] = new Handlebars.SafeString(
Handlebars.Utils.escapeExpression(data[matchedColumn.index])
+ '<span class="mailpoet_data_match mailpoet_import_error" title="'
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
+ MailPoet.I18n.t('dateMatchError')
+ '</span>';
+ (new Handlebars.SafeString(MailPoet.I18n.t('dateMatchError')))
+ '</span>'
);
preventNextStep = true;
};
});

View File

@ -37,59 +37,50 @@ const columns = [
];
const messages = {
onTrash: function(response) {
if (response) {
var message = null;
if (~~response === 1) {
message = (
MailPoet.I18n.t('oneSubscriberTrashed')
);
} else if (~~response > 1) {
message = (
MailPoet.I18n.t('multipleSubscribersTrashed')
).replace('%$1d', (~~response).toLocaleString());
}
onTrash: (response) => {
const count = ~~response.meta.count;
let message = null;
if (message !== null) {
MailPoet.Notice.success(message);
}
if (count === 1) {
message = (
MailPoet.I18n.t('oneSubscriberTrashed')
);
} else {
message = (
MailPoet.I18n.t('multipleSubscribersTrashed')
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onDelete: function(response) {
if (response) {
var message = null;
if (~~response === 1) {
message = (
MailPoet.I18n.t('oneSubscriberDeleted')
);
} else if (~~response > 1) {
message = (
MailPoet.I18n.t('multipleSubscribersDeleted')
).replace('%$1d', ~~response);
}
onDelete: (response) => {
const count = ~~response.meta.count;
let message = null;
if (message !== null) {
MailPoet.Notice.success(message);
}
if (count === 1) {
message = (
MailPoet.I18n.t('oneSubscriberDeleted')
);
} else {
message = (
MailPoet.I18n.t('multipleSubscribersDeleted')
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onRestore: function(response) {
if (response) {
var message = null;
if (~~response === 1) {
message = (
MailPoet.I18n.t('oneSubscriberRestored')
);
} else if (~~response > 1) {
message = (
MailPoet.I18n.t('multipleSubscribersRestored')
).replace('%$1d', (~~response).toLocaleString());
}
onRestore: (response) => {
const count = ~~response.meta.count;
let message = null;
if (message !== null) {
MailPoet.Notice.success(message);
}
if (count === 1) {
message = (
MailPoet.I18n.t('oneSubscriberRestored')
);
} else {
message = (
MailPoet.I18n.t('multipleSubscribersRestored')
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
};
@ -120,8 +111,8 @@ const bulk_actions = [
onSuccess: function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersMovedToList')
.replace('%$1d', (~~(response.subscribers)).toLocaleString())
.replace('%$2s', response.segment)
.replace('%$1d', (~~(response.meta.count)).toLocaleString())
.replace('%$2s', response.meta.segment)
);
}
},
@ -151,8 +142,8 @@ const bulk_actions = [
onSuccess: function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersAddedToList')
.replace('%$1d', (~~response.subscribers).toLocaleString())
.replace('%$2s', response.segment)
.replace('%$1d', (~~response.meta.count).toLocaleString())
.replace('%$2s', response.meta.segment)
);
}
},
@ -182,8 +173,8 @@ const bulk_actions = [
onSuccess: function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersRemovedFromList')
.replace('%$1d', (~~response.subscribers).toLocaleString())
.replace('%$2s', response.segment)
.replace('%$1d', (~~response.meta.count).toLocaleString())
.replace('%$2s', response.meta.segment)
);
}
},
@ -193,7 +184,7 @@ const bulk_actions = [
onSuccess: function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersRemovedFromAllLists')
.replace('%$1d', (~~response).toLocaleString())
.replace('%$1d', (~~response.meta.count).toLocaleString())
);
}
},
@ -203,7 +194,7 @@ const bulk_actions = [
onSuccess: function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleConfirmationEmailsSent')
.replace('%$1d', (~~response).toLocaleString())
.replace('%$1d', (~~response.meta.count).toLocaleString())
);
}
},
@ -330,16 +321,23 @@ const SubscriberList = React.createClass({
</div>
);
},
onGetItems: function(count) {
jQuery('#mailpoet_export_button')[(count > 0) ? 'show' : 'hide']();
},
render: function() {
return (
<div>
<h1 className="title">
{MailPoet.I18n.t('pageTitle')} <Link className="page-title-action" to="/new">{MailPoet.I18n.t('new')}</Link>
<a className="page-title-action" href="?page=mailpoet-import#step1">{MailPoet.I18n.t('import')}</a>
<a id="mailpoet_export_button" className="page-title-action" href="?page=mailpoet-export">{MailPoet.I18n.t('export')}</a>
{MailPoet.I18n.t('pageTitle')} <Link
className="page-title-action"
to="/new"
>{MailPoet.I18n.t('new')}</Link>
<a
className="page-title-action"
href="?page=mailpoet-import#step1"
>{MailPoet.I18n.t('import')}</a>
<a
id="mailpoet_export_button"
className="page-title-action"
href="?page=mailpoet-export"
>{MailPoet.I18n.t('export')}</a>
</h1>
<Listing
@ -352,7 +350,6 @@ const SubscriberList = React.createClass({
bulk_actions={ bulk_actions }
item_actions={ item_actions }
messages={ messages }
onGetItems={ this.onGetItems }
sort_by={ 'created_at' }
sort_order={ 'desc' }
/>

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,6 +28,21 @@ cp -Rf views $plugin_name
rm -Rf $plugin_name/assets/css/src
rm -Rf $plugin_name/assets/js/src
# Remove extra files (docs, examples,...) from 3rd party extensions
find $plugin_name/vendor -type f -regextype posix-egrep -iregex ".*\/*\.(markdown|md|txt)" -print0 | xargs -0 rm -f
find $plugin_name/vendor -type f -regextype posix-egrep -iregex ".*\/(readme|license|version|changes|changelog)" -print0 | xargs -0 rm -f
find $plugin_name/vendor -type d -regextype posix-egrep -iregex ".*\/(docs?|examples?|\.git)" -print0 | xargs -0 rm -rf
# Remove unit tests from 3rd party extensions
rm $plugin_name/vendor/j4mie/idiorm/demo.php
rm -rf $plugin_name/vendor/twig/twig/test
rm -rf $plugin_name/vendor/symfony/translation/Tests
rm -rf $plugin_name/vendor/phpmailer/phpmailer/test
rm -rf $plugin_name/vendor/soundasleep/html2text/tests
rm -rf $plugin_name/vendor/mtdowling/cron-expression/tests
rm -rf $plugin_name/vendor/swiftmailer/swiftmailer/tests
rm -rf $plugin_name/vendor/cerdic/css-tidy/testing
# Copy release files.
cp LICENSE $plugin_name
cp index.php $plugin_name

View File

@ -8,9 +8,17 @@ machine:
## Customize dependencies
dependencies:
pre:
# install PHP dependencies for WordPress
- sudo apt-get update
- sudo apt-get --assume-yes install php5-mysql
# configure Apache
- sudo cp ./.circle_ci/apache/mailpoet.loc.conf /etc/apache2/sites-available
- sudo a2ensite mailpoet.loc
- sudo a2enmod rewrite
- sudo service apache2 restart
# install Phoenix dependencies
- composer install
- ./do install
# Set up Wordpress
# No password is required for the MySQL user `ubuntu`
- mysql -u ubuntu -e "create database wordpress"

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,10 @@
<?php
namespace MailPoet\API;
use \MailPoet\Util\Security;
if(!defined('ABSPATH')) exit;
class API {
function __construct() {
}
function init() {
// security token
add_action(
@ -27,32 +23,29 @@ class API {
'wp_ajax_nopriv_mailpoet',
array($this, 'setupPublic')
);
// Public API (Post)
add_action(
'admin_post_nopriv_mailpoet',
array($this, 'setupPublic')
);
}
function setupAdmin() {
if($this->checkToken() === false) {
(new ErrorResponse(
$error_response = new ErrorResponse(
array(
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
Error::UNAUTHORIZED => __('You need to specify a valid API token.', 'mailpoet')
),
array(),
Response::STATUS_UNAUTHORIZED
))->send();
);
$error_response->send();
}
if($this->checkPermissions() === false) {
(new ErrorResponse(
$error_response = new ErrorResponse(
array(
Error::FORBIDDEN => __('You do not have the required permissions.')
Error::FORBIDDEN => __('You do not have the required permissions.', 'mailpoet')
),
array(),
Response::STATUS_FORBIDDEN
))->send();
);
$error_response->send();
}
$this->processRoute();
@ -60,13 +53,14 @@ class API {
function setupPublic() {
if($this->checkToken() === false) {
(new ErrorResponse(
$error_response = new ErrorResponse(
array(
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
Error::UNAUTHORIZED => __('You need to specify a valid API token.', 'mailpoet')
),
array(),
Response::STATUS_UNAUTHORIZED
))->send();
);
$error_response->send();
}
$this->processRoute();
@ -76,14 +70,7 @@ class API {
$class = ucfirst($_POST['endpoint']);
$endpoint = __NAMESPACE__ . "\\Endpoints\\" . $class;
$method = $_POST['method'];
$doing_ajax = (bool)(defined('DOING_AJAX') && DOING_AJAX);
if($doing_ajax) {
$data = isset($_POST['data']) ? stripslashes_deep($_POST['data']) : array();
} else {
$data = $_POST;
}
$data = isset($_POST['data']) ? stripslashes_deep($_POST['data']) : array();
if(is_array($data) && !empty($data)) {
// filter out reserved keywords from data
@ -99,18 +86,12 @@ class API {
try {
$endpoint = new $endpoint();
$response = $endpoint->$method($data);
// TODO: remove this condition once the API unification is complete
if(is_object($response)) {
$response->send();
} else {
// LEGACY API
wp_send_json($response);
}
$response->send();
} catch(\Exception $e) {
(new ErrorResponse(
$error_response = new ErrorResponse(
array($e->getCode() => $e->getMessage())
))->send();
);
$error_response->send();
}
}

View File

@ -16,7 +16,7 @@ abstract class Endpoint {
) {
if(empty($errors)) {
$errors = array(
Error::UNKNOWN => __('An unknown error occurred.')
Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet')
);
}
return new ErrorResponse($errors, $meta, $status);
@ -25,7 +25,7 @@ abstract class Endpoint {
function badRequest($errors = array(), $meta = array()) {
if(empty($errors)) {
$errors = array(
Error::BAD_REQUEST => __('Invalid request parameters.')
Error::BAD_REQUEST => __('Invalid request parameters.', 'mailpoet')
);
}
return new ErrorResponse($errors, $meta, Response::STATUS_BAD_REQUEST);

View File

@ -1,23 +0,0 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
use MailPoet\Cron\CronHelper;
use MailPoet\Models\Setting;
if(!defined('ABSPATH')) exit;
class Cron extends APIEndpoint {
function getStatus() {
$daemon = Setting::getValue(CronHelper::DAEMON_SETTING, false);
if($daemon === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('Cron daemon is not running.')
));
} else {
return $this->successResponse($daemon);
}
}
}

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

@ -1,5 +1,7 @@
<?php
namespace MailPoet\API\Endpoints;
use MailPoet\API\Endpoint as APIEndpoint;
use MailPoet\API\Error as APIError;
use \MailPoet\Models\Form;
use \MailPoet\Models\StatisticsForms;
@ -9,16 +11,17 @@ use \MailPoet\Form\Util;
if(!defined('ABSPATH')) exit;
class Forms {
function __construct() {
}
function get($id = false) {
class Forms extends APIEndpoint {
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form = Form::findOne($id);
if($form !== false) {
$form = $form->asArray();
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
return $this->successResponse($form->asArray());
}
return $form;
}
function listing($data = array()) {
@ -29,8 +32,8 @@ class Forms {
$listing_data = $listing->get();
// fetch segments relations for each returned item
foreach($listing_data['items'] as $key => $form) {
$data = array();
foreach($listing_data['items'] as $form) {
$form = $form->asArray();
$form['signups'] = StatisticsForms::getTotalSignups($form['id']);
@ -40,40 +43,45 @@ class Forms {
? $form['settings']['segments']
: array()
);
$listing_data['items'][$key] = $form;
$data[] = $form;
}
return $listing_data;
return $this->successResponse($data, array(
'count' => $listing_data['count'],
'filters' => $listing_data['filters'],
'groups' => $listing_data['groups']
));
}
function create() {
// create new form
$form_data = array(
'name' => __('New form'),
'name' => __('New form', 'mailpoet'),
'body' => array(
array(
'id' => 'email',
'name' => __('Email'),
'name' => __('Email', 'mailpoet'),
'type' => 'text',
'static' => true,
'params' => array(
'label' => __('Email'),
'label' => __('Email', 'mailpoet'),
'required' => true
)
),
array(
'id' => 'submit',
'name' => __('Submit'),
'name' => __('Submit', 'mailpoet'),
'type' => 'submit',
'static' => true,
'params' => array(
'label' => __('Subscribe!')
'label' => __('Subscribe!', 'mailpoet')
)
)
),
'settings' => array(
'on_success' => 'message',
'success_message' => __('Check your inbox or spam folder to confirm your subscription.'),
'success_message' => __('Check your inbox or spam folder to confirm your subscription.', 'mailpoet'),
'segments' => null,
'segments_selected_by' => 'admin'
)
@ -87,14 +95,10 @@ class Forms {
$errors = $form->getErrors();
if(!empty($errors)) {
return array(
'result' => false,
'errors' => $errors
);
return $this->badRequest($errors);
} else {
return array(
'result' => true,
'form_id' => $form->id()
return $this->successResponse(
Form::findOne($form->id)->asArray()
);
}
}
@ -109,76 +113,74 @@ class Forms {
// styles
$css = new Util\Styles(FormRenderer::getStyles($data));
return array(
return $this->successResponse(array(
'html' => $html,
'css' => $css->render()
);
));
}
function exportsEditor($id) {
$exports = false;
function exportsEditor($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form = Form::findOne($id);
if($form !== false) {
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$exports = Util\Export::getAll($form->asArray());
return $this->successResponse($exports);
}
return $exports;
}
function saveEditor($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form_id = (isset($data['id']) ? (int)$data['id'] : 0);
$name = (isset($data['name']) ? $data['name'] : __('New form'));
$name = (isset($data['name']) ? $data['name'] : __('New form', 'mailpoet'));
$body = (isset($data['body']) ? $data['body'] : array());
$settings = (isset($data['settings']) ? $data['settings'] : array());
$styles = (isset($data['styles']) ? $data['styles'] : '');
if(empty($body) || empty($settings)) {
// error
return false;
} else {
// check if the form is used as a widget
$is_widget = false;
$widgets = get_option('widget_mailpoet_form');
if(!empty($widgets)) {
foreach($widgets as $widget) {
if(isset($widget['form']) && (int)$widget['form'] === $form_id) {
$is_widget = true;
break;
}
}
}
// check if the user gets to pick his own lists
// or if it's selected by the admin
$has_segment_selection = false;
foreach($body as $i => $block) {
if($block['type'] === 'segment') {
$has_segment_selection = true;
if(!empty($block['params']['values'])) {
$list_selection = array_filter(
array_map(function($segment) {
return (isset($segment['id'])
? (int)$segment['id']
: null
);
}, $block['params']['values'])
);
}
// check if the form is used as a widget
$is_widget = false;
$widgets = get_option('widget_mailpoet_form');
if(!empty($widgets)) {
foreach($widgets as $widget) {
if(isset($widget['form']) && (int)$widget['form'] === $form_id) {
$is_widget = true;
break;
}
}
}
// check list selection
if($has_segment_selection === true) {
$settings['segments_selected_by'] = 'user';
} else {
$settings['segments_selected_by'] = 'admin';
// check if the user gets to pick his own lists
// or if it's selected by the admin
$has_segment_selection = false;
foreach($body as $i => $block) {
if($block['type'] === 'segment') {
$has_segment_selection = true;
if(!empty($block['params']['values'])) {
$list_selection = array_filter(
array_map(function($segment) {
return (isset($segment['id'])
? $segment['id']
: null
);
}, $block['params']['values'])
);
}
break;
}
}
// check list selection
if($has_segment_selection === true) {
$settings['segments_selected_by'] = 'user';
$settings['segments'] = $list_selection;
} else {
$settings['segments_selected_by'] = 'admin';
}
$form = Form::createOrUpdate(array(
'id' => $form_id,
'name' => $name,
@ -187,64 +189,101 @@ class Forms {
'styles' => $styles
));
if($form->getErrors() === false) {
return array(
'result' => true,
'is_widget' => $is_widget
);
$errors = $form->getErrors();
if(!empty($errors)) {
return $this->badRequest($errors);
} else {
return array(
'result' => false,
'errors' => $form->getErrors()
return $this->successResponse(
Form::findOne($form->id)->asArray(),
array('is_widget' => $is_widget)
);
}
}
function restore($id) {
function restore($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form = Form::findOne($id);
if($form !== false) {
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$form->restore();
}
return ($form->getErrors() === false);
}
function trash($id) {
$form = Form::findOne($id);
if($form !== false) {
$form->trash();
}
return ($form->getErrors() === false);
}
function delete($id) {
$form = Form::findOne($id);
if($form !== false) {
$form->delete();
return 1;
}
return false;
}
function duplicate($id) {
$result = false;
$form = Form::findOne($id);
if($form !== false) {
$data = array(
'name' => sprintf(__('Copy of %s'), $form->name)
return $this->successResponse(
Form::findOne($form->id)->asArray(),
array('count' => 1)
);
$result = $form->duplicate($data)->asArray();
}
}
return $result;
function trash($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form = Form::findOne($id);
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$form->trash();
return $this->successResponse(
Form::findOne($form->id)->asArray(),
array('count' => 1)
);
}
}
function delete($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form = Form::findOne($id);
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$form->delete();
return $this->successResponse(null, array('count' => 1));
}
}
function duplicate($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form = Form::findOne($id);
if($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
));
} else {
$data = array(
'name' => sprintf(__('Copy of %s', 'mailpoet'), $form->name)
);
$duplicate = $form->duplicate($data);
$errors = $duplicate->getErrors();
if(!empty($errors)) {
return $this->errorResponse($errors);
} else {
return $this->successResponse(
Form::findOne($duplicate->id)->asArray(),
array('count' => 1)
);
}
}
}
function bulkAction($data = array()) {
$bulk_action = new Listing\BulkAction(
'\MailPoet\Models\Form',
$data
);
return $bulk_action->apply();
try {
$bulk_action = new Listing\BulkAction(
'\MailPoet\Models\Form',
$data
);
$meta = $bulk_action->apply();
return $this->successResponse(null, $meta);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
}

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

@ -22,19 +22,20 @@ if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-includes/pluggable.php');
class Newsletters extends APIEndpoint {
function get($id = false) {
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$newsletter = Newsletter::findOne($id);
if($newsletter === false) {
return false;
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
$segments = $newsletter->segments()->findArray();
$options = $newsletter->options()->findArray();
$newsletter = $newsletter->asArray();
$newsletter['segments'] = array_map(function($segment) {
return $segment['id'];
}, $segments);
$newsletter['options'] = Helpers::arrayColumn($options, 'value', 'name');
return $newsletter;
return $this->successResponse(
$newsletter
->withSegments()
->withOptions()
->asArray()
);
}
}
@ -96,19 +97,20 @@ class Newsletters extends APIEndpoint {
}
function setStatus($data = array()) {
$id = (isset($data['id'])) ? (int)$data['id'] : false;
$newsletter = Newsletter::findOne($id);
$status = (isset($data['status']) ? $data['status'] : null);
if(!$status) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('You need to specify a status.')
APIError::BAD_REQUEST => __('You need to specify a status.', 'mailpoet')
));
}
$id = (isset($data['id'])) ? (int)$data['id'] : false;
$newsletter = Newsletter::findOne($id);
if($newsletter === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This newsletter does not exist.')
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
}
@ -119,143 +121,178 @@ class Newsletters extends APIEndpoint {
return $this->errorResponse($errors);
} else {
return $this->successResponse(
$newsletter->asArray()
Newsletter::findOne($newsletter->id)->asArray()
);
}
}
function restore($id) {
function restore($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$newsletter = Newsletter::findOne($id);
if($newsletter !== false) {
$newsletter->restore();
}
return ($newsletter->getErrors() === false);
}
function trash($id) {
$newsletter = Newsletter::findOne($id);
if($newsletter !== false) {
$newsletter->trash();
}
return ($newsletter->getErrors() === false);
}
function delete($id) {
$newsletter = Newsletter::findOne($id);
if($newsletter !== false) {
$newsletter->delete();
return 1;
}
return false;
}
function duplicate($id = false) {
$result = false;
$newsletter = Newsletter::findOne($id);
if($newsletter !== false) {
$duplicate = $newsletter->duplicate(array(
'subject' => sprintf(__('Copy of %s'), $newsletter->subject)
if($newsletter === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
$newsletter->restore();
return $this->successResponse(
Newsletter::findOne($newsletter->id)->asArray(),
array('count' => 1)
);
}
}
if($duplicate !== false && $duplicate->getErrors() === false) {
$result = $duplicate->asArray();
function trash($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$newsletter = Newsletter::findOne($id);
if($newsletter === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
$newsletter->trash();
return $this->successResponse(
Newsletter::findOne($newsletter->id)->asArray(),
array('count' => 1)
);
}
}
function delete($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$newsletter = Newsletter::findOne($id);
if($newsletter === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
$newsletter->delete();
return $this->successResponse(null, array('count' => 1));
}
}
function duplicate($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$newsletter = Newsletter::findOne($id);
if($newsletter === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
$data = array(
'subject' => sprintf(__('Copy of %s', 'mailpoet'), $newsletter->subject)
);
$duplicate = $newsletter->duplicate($data);
$errors = $duplicate->getErrors();
if(!empty($errors)) {
return $this->errorResponse($errors);
} else {
return $this->successResponse(
Newsletter::findOne($duplicate->id)->asArray(),
array('count' => 1)
);
}
}
return $result;
}
function showPreview($data = array()) {
if(!isset($data['body'])) {
return array(
'result' => false,
'errors' => array(__('Newsletter data is missing'))
);
if(empty($data['body'])) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Newsletter data is missing.', 'mailpoet')
));
}
$newsletter_id = (isset($data['id'])) ? (int)$data['id'] : null;
$newsletter = Newsletter::findOne($newsletter_id);
if(!$newsletter) {
return array(
'result' => false,
'errors' => array(__('Newsletter could not be read'))
);
}
$newsletter->body = $data['body'];
$newsletter->save();
$subscriber = Subscriber::getCurrentWPUser();
$preview_url = NewsletterUrl::getViewInBrowserUrl(
$data, $subscriber, $queue = false, $preview = true
);
return array(
'result' => true,
'data' => array('url' => $preview_url)
);
}
function sendPreview($data = array()) {
$id = (isset($data['id'])) ? (int)$data['id'] : false;
$newsletter = Newsletter::findOne($id);
if($newsletter === false) {
return array(
'result' => false
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
$newsletter->body = $data['body'];
$newsletter->save();
$subscriber = Subscriber::getCurrentWPUser();
$preview_url = NewsletterUrl::getViewInBrowserUrl(
$data, $subscriber, $queue = false, $preview = true
);
}
if(empty($data['subscriber'])) {
return array(
'result' => false,
'errors' => array(__('Please specify receiver information.'))
);
}
$newsletter = $newsletter->asArray();
$renderer = new Renderer($newsletter, $preview = true);
$rendered_newsletter = $renderer->render();
$divider = '***MailPoet***';
$data_for_shortcodes =
array_merge(array($newsletter['subject']), $rendered_newsletter);
$body = implode($divider, $data_for_shortcodes);
$subscriber = Subscriber::getCurrentWPUser();
$subscriber = ($subscriber) ? $subscriber->asArray() : false;
$shortcodes = new \MailPoet\Newsletter\Shortcodes\Shortcodes(
$newsletter,
$subscriber
);
list($newsletter['subject'],
$newsletter['body']['html'],
$newsletter['body']['text']
) = explode($divider, $shortcodes->replace($body));
try {
$mailer = new \MailPoet\Mailer\Mailer(
$mailer = false,
$sender = false,
$reply_to = false
);
$result = $mailer->send($newsletter, $data['subscriber']);
return array('result' => $result);
} catch(\Exception $e) {
return array(
'result' => false,
'errors' => array($e->getMessage()),
return $this->successResponse(
Newsletter::findOne($newsletter->id)->asArray(),
array('preview_url' => $preview_url)
);
}
}
function listing($data = array()) {
function sendPreview($data = array()) {
if(empty($data['subscriber'])) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Please specify receiver information.', 'mailpoet')
));
}
$id = (isset($data['id'])) ? (int)$data['id'] : false;
$newsletter = Newsletter::findOne($id);
if($newsletter === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
$newsletter = $newsletter->asArray();
$renderer = new Renderer($newsletter, $preview = true);
$rendered_newsletter = $renderer->render();
$divider = '***MailPoet***';
$data_for_shortcodes = array_merge(
array($newsletter['subject']),
$rendered_newsletter
);
$body = implode($divider, $data_for_shortcodes);
$subscriber = Subscriber::getCurrentWPUser();
$subscriber = ($subscriber) ? $subscriber->asArray() : false;
$shortcodes = new \MailPoet\Newsletter\Shortcodes\Shortcodes(
$newsletter,
$subscriber
);
list(
$newsletter['subject'],
$newsletter['body']['html'],
$newsletter['body']['text']
) = explode($divider, $shortcodes->replace($body));
try {
$mailer = new \MailPoet\Mailer\Mailer(
$mailer = false,
$sender = false,
$reply_to = false
);
$mailer->send($newsletter, $data['subscriber']);
return $this->successResponse(
Newsletter::findOne($id)->asArray()
);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
}
function listing($data = array()) {
$listing = new Listing\Handler(
'\MailPoet\Models\Newsletter',
$data
);
$listing_data = $listing->get();
$subscriber = Subscriber::getCurrentWPUser();
foreach($listing_data['items'] as $key => $newsletter) {
$data = array();
foreach($listing_data['items'] as $newsletter) {
$queue = false;
if($newsletter->type === Newsletter::TYPE_STANDARD) {
@ -287,22 +324,33 @@ class Newsletters extends APIEndpoint {
}
// get preview url
$subscriber = Subscriber::getCurrentWPUser();
$newsletter->preview_url = NewsletterUrl::getViewInBrowserUrl(
$newsletter, $subscriber, $queue, $preview = true);
// convert object to array
$listing_data['items'][$key] = $newsletter->asArray();
$data[] = $newsletter->asArray();
}
return $listing_data;
return $this->successResponse($data, array(
'count' => $listing_data['count'],
'filters' => $listing_data['filters'],
'groups' => $listing_data['groups']
));
}
function bulkAction($data = array()) {
$bulk_action = new Listing\BulkAction(
'\MailPoet\Models\Newsletter',
$data
);
return $bulk_action->apply();
try {
$bulk_action = new Listing\BulkAction(
'\MailPoet\Models\Newsletter',
$data
);
$meta = $bulk_action->apply();
return $this->successResponse(null, $meta);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
function create($data = array()) {
@ -313,23 +361,25 @@ class Newsletters extends APIEndpoint {
}
$newsletter = Newsletter::createOrUpdate($data);
$errors = $newsletter->getErrors();
// try to load template data
$template_id = (!empty($data['template']) ? (int)$data['template'] : false);
$template = NewsletterTemplate::findOne($template_id);
if($template !== false) {
$newsletter->body = $template->body;
if(!empty($errors)) {
return $this->badRequest($errors);
} else {
$newsletter->body = array();
// try to load template data
$template_id = (isset($data['template']) ? (int)$data['template'] : false);
$template = NewsletterTemplate::findOne($template_id);
if($template === false) {
$newsletter->body = array();
} else {
$newsletter->body = $template->body;
}
}
$newsletter->save();
$errors = $newsletter->getErrors();
if(!empty($errors)) {
return array(
'result' => false,
'errors' =>$errors
);
return $this->badRequest($errors);
} else {
if(!empty($options)) {
$option_fields = NewsletterOptionField::where(
@ -346,15 +396,20 @@ class Newsletters extends APIEndpoint {
}
}
}
if(!isset($data['id']) &&
isset($data['type']) &&
$data['type'] === 'notification'
if(
empty($data['id'])
&&
isset($data['type'])
&&
$data['type'] === Newsletter::TYPE_NOTIFICATION
) {
Scheduler::processPostNotificationSchedule($newsletter->id);
$newsletter = Newsletter::filter('filterWithOptions')->findOne($newsletter->id);
Scheduler::processPostNotificationSchedule($newsletter);
}
return array(
'result' => true,
'newsletter' => $newsletter->asArray()
return $this->successResponse(
Newsletter::findOne($newsletter->id)->asArray()
);
}
}

View File

@ -1,5 +1,7 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
use \MailPoet\Models\Segment;
use \MailPoet\Models\SubscriberSegment;
@ -9,16 +11,16 @@ use \MailPoet\Segments\WP;
if(!defined('ABSPATH')) exit;
class Segments {
function __construct() {
}
function get($id = false) {
class Segments extends APIEndpoint {
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$segment = Segment::findOne($id);
if($segment === false) {
return false;
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
return $segment->asArray();
return $this->successResponse($segment->asArray());
}
}
@ -30,18 +32,22 @@ class Segments {
$listing_data = $listing->get();
// fetch segments relations for each returned item
foreach($listing_data['items'] as $key => $segment) {
$data = array();
foreach($listing_data['items'] as $segment) {
$segment->subscribers_url = admin_url(
'admin.php?page=mailpoet-subscribers#/filter[segment='.$segment->id.']'
);
$listing_data['items'][$key] = $segment
$data[] = $segment
->withSubscribersCount()
->asArray();
}
return $listing_data;
return $this->successResponse($data, array(
'count' => $listing_data['count'],
'filters' => $listing_data['filters'],
'groups' => $listing_data['groups']
));
}
function save($data = array()) {
@ -49,68 +55,109 @@ class Segments {
$errors = $segment->getErrors();
if(!empty($errors)) {
return array(
'result' => false,
'errors' => $errors
);
return $this->badRequest($errors);
} else {
return array(
'result' => true
return $this->successResponse(
Segment::findOne($segment->id)->asArray()
);
}
}
function restore($id) {
function restore($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$segment = Segment::findOne($id);
if($segment !== false) {
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
$segment->restore();
}
return ($segment->getErrors() === false);
}
function trash($id) {
$segment = Segment::findOne($id);
if($segment !== false) {
$segment->trash();
}
return ($segment->getErrors() === false);
}
function delete($id) {
$segment = Segment::findOne($id);
if($segment !== false) {
$segment->delete();
return 1;
}
return false;
}
function duplicate($id) {
$result = false;
$segment = Segment::findOne($id);
if($segment !== false) {
$data = array(
'name' => sprintf(__('Copy of %s'), $segment->name)
return $this->successResponse(
Segment::findOne($segment->id)->asArray(),
array('count' => 1)
);
$result = $segment->duplicate($data)->asArray();
}
}
return $result;
function trash($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$segment = Segment::findOne($id);
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
$segment->trash();
return $this->successResponse(
Segment::findOne($segment->id)->asArray(),
array('count' => 1)
);
}
}
function delete($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$segment = Segment::findOne($id);
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
$segment->delete();
return $this->successResponse(null, array('count' => 1));
}
}
function duplicate($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$segment = Segment::findOne($id);
if($segment === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
));
} else {
$data = array(
'name' => sprintf(__('Copy of %s', 'mailpoet'), $segment->name)
);
$duplicate = $segment->duplicate($data);
$errors = $duplicate->getErrors();
if(!empty($errors)) {
return $this->errorResponse($errors);
} else {
return $this->successResponse(
Segment::findOne($duplicate->id)->asArray(),
array('count' => 1)
);
}
}
}
function synchronize() {
$result = WP::synchronizeUsers();
try {
WP::synchronizeUsers();
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
return $result;
return $this->successResponse(null);
}
function bulkAction($data = array()) {
$bulk_action = new Listing\BulkAction(
'\MailPoet\Models\Segment',
$data
);
return $bulk_action->apply();
try {
$bulk_action = new Listing\BulkAction(
'\MailPoet\Models\Segment',
$data
);
$meta = $bulk_action->apply();
return $this->successResponse(null, $meta);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
}

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

@ -1,5 +1,7 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
use MailPoet\Listing;
use MailPoet\Models\Subscriber;
@ -9,23 +11,25 @@ use MailPoet\Models\Segment;
use MailPoet\Models\Setting;
use MailPoet\Models\Form;
use MailPoet\Models\StatisticsForms;
use MailPoet\Util\Url;
if(!defined('ABSPATH')) exit;
class Subscribers {
function __construct() {
}
function get($id = null) {
class Subscribers extends APIEndpoint {
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$subscriber = Subscriber::findOne($id);
if($subscriber !== false) {
$subscriber = $subscriber
->withCustomFields()
->withSubscriptions()
->asArray();
if($subscriber === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
));
} else {
return $this->successResponse(
$subscriber
->withCustomFields()
->withSubscriptions()
->asArray()
);
}
return $subscriber;
}
function listing($data = array()) {
@ -36,41 +40,24 @@ class Subscribers {
$listing_data = $listing->get();
// fetch segments relations for each returned item
foreach($listing_data['items'] as $key => $subscriber) {
$listing_data['items'][$key] = $subscriber
$data = array();
foreach($listing_data['items'] as $subscriber) {
$data[] = $subscriber
->withSubscriptions()
->asArray();
}
return $listing_data;
}
function save($data = array()) {
$subscriber = Subscriber::createOrUpdate($data);
$errors = $subscriber->getErrors();
if(!empty($errors)) {
return array(
'result' => false,
'errors' => $errors
);
} else {
return array(
'result' => true
);
}
return $this->successResponse($data, array(
'count' => $listing_data['count'],
'filters' => $listing_data['filters'],
'groups' => $listing_data['groups']
));
}
function subscribe($data = array()) {
$doing_ajax = (bool)(defined('DOING_AJAX') && DOING_AJAX);
$errors = array();
$form = Form::findOne($data['form_id']);
$form_id = (isset($data['form_id']) ? (int)$data['form_id'] : false);
$form = Form::findOne($form_id);
unset($data['form_id']);
if($form === false || !$form->id()) {
$errors[] = __('This form does not exist');
}
$segment_ids = (!empty($data['segments'])
? (array)$data['segments']
@ -79,106 +66,110 @@ class Subscribers {
unset($data['segments']);
if(empty($segment_ids)) {
$errors[] = __('Please select a list');
}
if(!empty($errors)) {
return array(
'result' => false,
'errors' => $errors
);
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Please select a list', 'mailpoet')
));
}
$subscriber = Subscriber::subscribe($data, $segment_ids);
$errors = $subscriber->getErrors();
$result = ($errors === false && $subscriber->id() > 0);
// record form statistics
if($result === true && $form !== false && $form->id > 0) {
StatisticsForms::record($form->id, $subscriber->id);
}
if($errors !== false) {
return $this->badRequest($errors);
} else {
$meta = array();
// get success message to display after subscription
$form_settings = (
isset($form->settings)
? unserialize($form->settings)
: null
);
if($form !== false) {
// record form statistics
StatisticsForms::record($form->id, $subscriber->id);
if($form_settings !== null) {
switch($form_settings['on_success']) {
case 'page':
$success_page_url = get_permalink($form_settings['success_page']);
$form = $form->asArray();
// response depending on context
if($doing_ajax === true) {
return array(
'result' => $result,
'page' => $success_page_url,
'errors' => $errors
);
} else {
if($result === false) {
Url::redirectBack();
} else {
Url::redirectTo($success_page_url);
}
}
break;
case 'message':
default:
// response depending on context
if($doing_ajax === true) {
return array(
'result' => $result,
'errors' => $errors
);
} else {
$params = (
($result === true)
? array('mailpoet_success' => $form->id)
: array()
);
Url::redirectBack($params);
}
break;
if($form['settings']['on_success'] === 'page') {
// redirect to a page on a success, pass the page url in the meta
$meta['redirect_url'] = get_permalink($form['settings']['success_page']);
} else if($form['settings']['on_success'] === 'url') {
$meta['redirect_url'] = $form['settings']['success_url'];
}
}
return $this->successResponse(
Subscriber::findOne($subscriber->id)->asArray(),
$meta
);
}
}
function restore($id) {
function save($data = array()) {
$subscriber = Subscriber::createOrUpdate($data);
$errors = $subscriber->getErrors();
if(!empty($errors)) {
return $this->badRequest($errors);
} else {
return $this->successResponse(
Subscriber::findOne($subscriber->id)->asArray()
);
}
}
function restore($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$subscriber = Subscriber::findOne($id);
if($subscriber !== false) {
if($subscriber === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
));
} else {
$subscriber->restore();
return $this->successResponse(
Subscriber::findOne($subscriber->id)->asArray(),
array('count' => 1)
);
}
return ($subscriber->getErrors() === false);
}
function trash($id) {
function trash($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$subscriber = Subscriber::findOne($id);
if($subscriber !== false) {
if($subscriber === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
));
} else {
$subscriber->trash();
return $this->successResponse(
Subscriber::findOne($subscriber->id)->asArray(),
array('count' => 1)
);
}
return ($subscriber->getErrors() === false);
}
function delete($id) {
function delete($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$subscriber = Subscriber::findOne($id);
if($subscriber !== false) {
if($subscriber === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
));
} else {
$subscriber->delete();
return 1;
return $this->successResponse(null, array('count' => 1));
}
return false;
}
function bulkAction($data = array()) {
$bulk_action = new Listing\BulkAction(
'\MailPoet\Models\Subscriber',
$data
);
return $bulk_action->apply();
try {
$bulk_action = new Listing\BulkAction(
'\MailPoet\Models\Subscriber',
$data
);
$meta = $bulk_action->apply();
return $this->successResponse(null, $meta);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
}

View File

@ -31,11 +31,11 @@ abstract class Response {
$response = array_merge($response, $data);
}
if(empty($response)) {
die();
} else {
wp_send_json($response);
if(!empty($response)) {
@header('Content-Type: application/json; charset='.get_option('blog_charset'));
echo wp_json_encode($response);
}
die();
}
abstract function getData();

View File

@ -27,6 +27,7 @@ class Env {
static $db_password;
static $db_charset;
static $db_timezone_offset;
static $subscribers_limit = 2000;
static function init($file, $version) {
global $wpdb;

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

@ -192,8 +192,11 @@ class Initializer {
}
function setupCronTrigger() {
$cron_trigger = new CronTrigger();
$cron_trigger->init();
// setup cron trigger only outside of cli environment
if(php_sapi_name() !== 'cli') {
$cron_trigger = new CronTrigger();
$cron_trigger->init();
}
}
function setupImages() {

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

@ -34,6 +34,16 @@ class Menu {
);
}
function checkSubscribersLimit() {
$subscribers_count = Subscriber::getTotalSubscribers();
if($subscribers_count > Env::$subscribers_limit) {
echo $this->renderer->render('limit.html', array(
'limit' => Env::$subscribers_limit
));
exit;
}
}
function setup() {
$main_page_slug = 'mailpoet-newsletters';
@ -49,8 +59,8 @@ class Menu {
$newsletters_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Newsletters')),
__('Newsletters'),
$this->setPageTitle(__('Newsletters', 'mailpoet')),
__('Newsletters', 'mailpoet'),
'manage_options',
$main_page_slug,
array($this, 'newsletters')
@ -69,8 +79,8 @@ class Menu {
$forms_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Forms')),
__('Forms'),
$this->setPageTitle(__('Forms', 'mailpoet')),
__('Forms', 'mailpoet'),
'manage_options',
'mailpoet-forms',
array($this, 'forms')
@ -88,8 +98,8 @@ class Menu {
$subscribers_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Subscribers')),
__('Subscribers'),
$this->setPageTitle(__('Subscribers', 'mailpoet')),
__('Subscribers', 'mailpoet'),
'manage_options',
'mailpoet-subscribers',
array($this, 'subscribers')
@ -107,8 +117,8 @@ class Menu {
$segments_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Lists')),
__('Lists'),
$this->setPageTitle(__('Lists', 'mailpoet')),
__('Lists', 'mailpoet'),
'manage_options',
'mailpoet-segments',
array($this, 'segments')
@ -127,16 +137,16 @@ class Menu {
add_submenu_page(
$main_page_slug,
$this->setPageTitle( __('Settings')),
__('Settings'),
$this->setPageTitle( __('Settings', 'mailpoet')),
__('Settings', 'mailpoet'),
'manage_options',
'mailpoet-settings',
array($this, 'settings')
);
add_submenu_page(
'admin.php?page=mailpoet-subscribers',
$this->setPageTitle( __('Import')),
__('Import'),
$this->setPageTitle( __('Import', 'mailpoet')),
__('Import', 'mailpoet'),
'manage_options',
'mailpoet-import',
array($this, 'import')
@ -144,8 +154,8 @@ class Menu {
add_submenu_page(
true,
$this->setPageTitle(__('Export')),
__('Export'),
$this->setPageTitle(__('Export', 'mailpoet')),
__('Export', 'mailpoet'),
'manage_options',
'mailpoet-export',
array($this, 'export')
@ -153,8 +163,8 @@ class Menu {
add_submenu_page(
true,
$this->setPageTitle(__('Welcome')),
__('Welcome'),
$this->setPageTitle(__('Welcome', 'mailpoet')),
__('Welcome', 'mailpoet'),
'manage_options',
'mailpoet-welcome',
array($this, 'welcome')
@ -162,8 +172,8 @@ class Menu {
add_submenu_page(
true,
$this->setPageTitle(__('Update')),
__('Update'),
$this->setPageTitle(__('Update', 'mailpoet')),
__('Update', 'mailpoet'),
'manage_options',
'mailpoet-update',
array($this, 'update')
@ -171,8 +181,8 @@ class Menu {
add_submenu_page(
true,
$this->setPageTitle(__('Form Editor')),
__('Form Editor'),
$this->setPageTitle(__('Form Editor', 'mailpoet')),
__('Form Editor', 'mailpoet'),
'manage_options',
'mailpoet-form-editor',
array($this, 'formEditor')
@ -180,21 +190,12 @@ class Menu {
add_submenu_page(
true,
$this->setPageTitle(__('Newsletter')),
__('Newsletter Editor'),
$this->setPageTitle(__('Newsletter', 'mailpoet')),
__('Newsletter Editor', 'mailpoet'),
'manage_options',
'mailpoet-newsletter-editor',
array($this, 'newletterEditor')
);
add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Cron')),
__('Cron'),
'manage_options',
'mailpoet-cron',
array($this, 'cron')
);
}
function welcome() {
@ -251,12 +252,14 @@ class Menu {
}
function settings() {
$this->checkSubscribersLimit();
$settings = Setting::getAll();
$flags = $this->_getFlags();
$data = array(
'settings' => $settings,
'segments' => Segment::getPublic()->findArray(),
'segments' => Segment::getSegmentsWithSubscriberCount(),
'cron_trigger' => CronTrigger::getAvailableMethods(),
'pages' => Pages::getAll(),
'flags' => $flags,
@ -300,7 +303,7 @@ class Menu {
$data = array();
$data['items_per_page'] = $this->getLimitPerPage('subscribers');
$data['segments'] = Segment::findArray();
$data['segments'] = Segment::getSegmentsWithSubscriberCount($type = false);
$data['custom_fields'] = array_map(function($field) {
$field['params'] = unserialize($field['params']);
@ -323,12 +326,16 @@ class Menu {
}
function segments() {
$this->checkSubscribersLimit();
$data = array();
$data['items_per_page'] = $this->getLimitPerPage('segments');
echo $this->renderer->render('segments.html', $data);
}
function forms() {
$this->checkSubscribersLimit();
$data = array();
$data['items_per_page'] = $this->getLimitPerPage('forms');
@ -338,6 +345,8 @@ class Menu {
}
function newsletters() {
$this->checkSubscribersLimit();
global $wp_roles;
$data = array();
@ -346,7 +355,7 @@ class Menu {
$data['segments'] = Segment::getSegmentsWithSubscriberCount($type = false);
$data['settings'] = Setting::getAll();
$data['roles'] = $wp_roles->get_names();
$data['roles']['mailpoet_all'] = __('In any WordPress role');
$data['roles']['mailpoet_all'] = __('In any WordPress role', 'mailpoet');
$date_time = new DateTime();
$data['current_date'] = $date_time->getCurrentDate(DateTime::DEFAULT_DATE_FORMAT);
@ -407,7 +416,7 @@ class Menu {
$data = array(
'form' => $form,
'pages' => Pages::getAll(),
'segments' => Segment::getPublic()->findArray(),
'segments' => Segment::getSegmentsWithSubscriberCount(),
'styles' => FormRenderer::getStyles($form),
'date_types' => Block\Date::getDateTypes(),
'date_formats' => Block\Date::getDateFormats(),
@ -418,14 +427,10 @@ class Menu {
echo $this->renderer->render('form/editor.html', $data);
}
function cron() {
echo $this->renderer->render('cron.html');
}
function setPageTitle($title) {
return sprintf(
'%s - %s',
__('MailPoet'),
__('MailPoet', 'mailpoet'),
$title
);
}

View File

@ -1,15 +1,6 @@
<?php
namespace MailPoet\Config;
use MailPoet\Config\PopulatorData\Templates\FranksRoastHouseTemplate;
use MailPoet\Config\PopulatorData\Templates\NewsletterBlank1Column;
use MailPoet\Config\PopulatorData\Templates\NewsletterBlank12Column;
use MailPoet\Config\PopulatorData\Templates\NewsletterBlank121Column;
use MailPoet\Config\PopulatorData\Templates\NewsletterBlank13Column;
use MailPoet\Config\PopulatorData\Templates\PostNotificationsBlank1Column;
use MailPoet\Config\PopulatorData\Templates\WelcomeBlank1Column;
use MailPoet\Config\PopulatorData\Templates\WelcomeBlank12Column;
use MailPoet\Config\PopulatorData\Templates\SimpleText;
use MailPoet\Cron\CronTrigger;
use \MailPoet\Models\Segment;
use \MailPoet\Segments\WP;
@ -22,12 +13,31 @@ if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
class Populator {
public $prefix;
public $models;
public $templates;
const TEMPLATES_NAMESPACE = '\MailPoet\Config\PopulatorData\Templates\\';
function __construct() {
$this->prefix = Env::$db_prefix;
$this->models = array(
'newsletter_option_fields',
'newsletter_templates',
);
$this->templates = array(
"FranksRoastHouseTemplate",
"NewsletterBlank1Column",
"NewsletterBlank12Column",
"NewsletterBlank121Column",
"NewsletterBlank13Column",
"PostNotificationsBlank1Column",
"WelcomeBlank1Column",
"WelcomeBlank12Column",
"SimpleText",
"Restaurant",
"StoreDiscount",
"TravelEmail"
);
}
function up() {
@ -104,6 +114,10 @@ class Populator {
'reply_to' => $sender
));
}
if(!Setting::getValue('installed_at')) {
Setting::setValue('installed_at', date("Y-m-d H:i:s"));
}
}
private function createDefaultSegments() {
@ -117,9 +131,9 @@ class Populator {
if(Segment::where('type', 'default')->count() === 0) {
$default_segment = Segment::create();
$default_segment->hydrate(array(
'name' => __('My First List'),
'name' => __('My First List', 'mailpoet'),
'description' =>
__('This list is automatically created when you install MailPoet')
__('This list is automatically created when you install MailPoet', 'mailpoet')
));
$default_segment->save();
}
@ -184,17 +198,13 @@ class Populator {
}
private function newsletterTemplates() {
return array(
(new FranksRoastHouseTemplate(Env::$assets_url))->get(),
(new NewsletterBlank1Column(Env::$assets_url))->get(),
(new NewsletterBlank12Column(Env::$assets_url))->get(),
(new NewsletterBlank121Column(Env::$assets_url))->get(),
(new NewsletterBlank13Column(Env::$assets_url))->get(),
(new PostNotificationsBlank1Column(Env::$assets_url))->get(),
(new WelcomeBlank1Column(Env::$assets_url))->get(),
(new WelcomeBlank12Column(Env::$assets_url))->get(),
(new SimpleText(Env::$assets_url))->get(),
);
$templates = array();
foreach($this->templates as $template) {
$template = self::TEMPLATES_NAMESPACE . $template;
$template = new $template(Env::$assets_url);
$templates[] = $template->get();
}
return $templates;
}
private function populate($model) {

View File

@ -7,14 +7,14 @@ class FranksRoastHouseTemplate {
function __construct($assets_url) {
$this->assets_url = $assets_url;
$this->template_image_url = $this->assets_url . '/img/sample_template';
$this->template_image_url = $this->assets_url . '/img/sample_templates/coffee';
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
}
function get() {
return array(
'name' => __("Frank's Roast House"),
'description' => __("Think of this as your sandbox. Play around with this example newsletter to see what MailPoet can do for you."),
'name' => __("Frank's Roast House", 'mailpoet'),
'description' => __("Think of this as your sandbox. Play around with this example newsletter to see what MailPoet can do for you.", 'mailpoet'),
'readonly' => 0,
'thumbnail' => $this->getThumbnail(),
'body' => json_encode($this->getBody()),
@ -46,7 +46,7 @@ class FranksRoastHouseTemplate {
"blocks" => array(
array(
"type" => "header",
"text" => __("<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser.</a>"),
"text" => __("<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser.</a>", 'mailpoet'),
"styles" => array(
"block" => array(
"backgroundColor" => "#ccc6c6"
@ -67,7 +67,7 @@ class FranksRoastHouseTemplate {
"type" => "image",
"link" => "http://www.example.com",
"src" => $this->template_image_url . "/header-v2.jpg",
"alt" => __("Frank's Café"),
"alt" => __("Frank's Café", 'mailpoet'),
"fullWidth" => true,
"width" => "600px",
"height" => "220px",
@ -88,13 +88,13 @@ class FranksRoastHouseTemplate {
),
array(
"type" => "text",
"text" => __("<p>Hi there&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"

File diff suppressed because one or more lines are too long

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"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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

@ -1,32 +0,0 @@
<?php
namespace MailPoet\Cron;
use Carbon\Carbon;
use MailPoet\Models\Setting;
class BootStrapMenu {
function __construct() {
$this->daemon = Setting::where('name', 'cron_daemon')
->findOne();
}
function bootStrap() {
return ($this->daemon) ?
array_merge(
array(
'timeSinceStart' => Carbon::createFromFormat(
'Y-m-d H:i:s',
$this->daemon->created_at,
'UTC'
)->diffForHumans(),
'timeSinceUpdate' => Carbon::createFromFormat(
'Y-m-d H:i:s',
$this->daemon->updated_at,
'UTC'
)->diffForHumans()
),
json_decode($this->daemon->value, true)
) :
"false";
}
}

View File

@ -16,7 +16,6 @@ class CronHelper {
static function createDaemon($token) {
$daemon = array(
'status' => Daemon::STATUS_STARTING,
'token' => $token
);
self::saveDaemon($daemon);
@ -39,12 +38,6 @@ class CronHelper {
);
}
static function stopDaemon() {
$daemon = self::getDaemon();
$daemon['status'] = Daemon::STATUS_STOPPED;
return self::saveDaemon($daemon);
}
static function deleteDaemon() {
return Setting::deleteValue(self::DAEMON_SETTING);
}
@ -60,6 +53,7 @@ class CronHelper {
QueueEndpoint::ACTION_RUN,
$data
);
$url = str_replace(home_url(), self::getSiteUrl(), $url);
$args = array(
'blocking' => false,
'sslverify' => false,
@ -70,27 +64,29 @@ class CronHelper {
return wp_remote_retrieve_body($result);
}
private static function getSiteUrl() {
// additional check for some sites running on a virtual machine or behind
static function getSiteUrl($site_url = false) {
// additional check for some sites running inside a virtual machine or behind
// proxy where there could be different ports (e.g., host:8080 => guest:80)
// if the site URL does not contain a port, return the URL
if(!preg_match('!^https?://.*?:\d+!', site_url())) return site_url();
preg_match('!://(?P<host>.*?):(?P<port>\d+)!', site_url(), $server);
// connect to the URL with port
$fp = @fsockopen($server['host'], $server['port'], $errno, $errstr, 1);
if($fp) return site_url();
// connect to the URL without port
$fp = @fsockopen($server['host'], $server['port'], $errno, $errstr, 1);
if($fp) return preg_replace('!(?=:\d+):\d+!', '$1', site_url());
// throw an error if all connection attempts failed
throw new \Exception(__('Site URL is unreachable.'));
$site_url = ($site_url) ? $site_url : home_url();
$parsed_url = parse_url($site_url);
// 1. if site URL does not contain a port, return the URL
if(empty($parsed_url['port'])) return $site_url;
// 2. if site URL contains valid port, try connecting to it
$fp = @fsockopen($parsed_url['host'], $parsed_url['port'], $errno, $errstr, 1);
if($fp) return $site_url;
// 3. if connection fails, attempt to connect the standard port derived from URL
// schema
$port = (strtolower($parsed_url['scheme']) === 'http') ? 80 : 443;
$fp = @fsockopen($parsed_url['host'], $port, $errno, $errstr, 1);
if($fp) return sprintf('%s://%s', $parsed_url['scheme'], $parsed_url['host']);
// 4. throw an error if all connection attempts failed
throw new \Exception(__('Site URL is unreachable.', 'mailpoet'));
}
static function enforceExecutionLimit($timer) {
$elapsed_time = microtime(true) - $timer;
if($elapsed_time >= self::DAEMON_EXECUTION_LIMIT) {
throw new \Exception(__('Maximum execution time has been reached.'));
throw new \Exception(__('Maximum execution time has been reached.', 'mailpoet'));
}
}
}

View File

@ -20,8 +20,6 @@ class CronTrigger {
function init() {
try {
// configure cron trigger only outside of cli environment
if(php_sapi_name() === 'cli') return;
$trigger_class = __NAMESPACE__ . '\Triggers\\' . $this->current_method;
return (class_exists($trigger_class)) ?
$trigger_class::run() :

View File

@ -1,86 +1,82 @@
<?php
namespace MailPoet\Cron;
use MailPoet\Cron\Workers\Scheduler as SchedulerWorker;
use MailPoet\Cron\Workers\SendingQueue\SendingQueue as SendingQueueWorker;
require_once(ABSPATH . 'wp-includes/pluggable.php');
if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-includes/pluggable.php');
class Daemon {
public $daemon;
public $data;
public $refreshed_token;
const STATUS_STOPPED = 'stopped';
const STATUS_STOPPING = 'stopping';
const STATUS_STARTED = 'started';
const STATUS_STARTING = 'starting';
public $request_data;
public $timer;
const REQUEST_TIMEOUT = 5;
private $timer;
function __construct($data) {
if(empty($data)) $this->abortWithError(__('Invalid or missing Cron data.'));
ignore_user_abort();
function __construct($request_data = false) {
$this->request_data = $request_data;
$this->daemon = CronHelper::getDaemon();
$this->token = CronHelper::createToken();
$this->data = $data;
$this->timer = microtime(true);
}
function run() {
ignore_user_abort(true);
if(!$this->request_data) {
$error = __('Invalid or missing request data.', 'mailpoet');
} else {
if(!$this->daemon) {
$error = __('Daemon does not exist.', 'mailpoet');
} else {
if(!isset($this->request_data['token']) ||
$this->request_data['token'] !== $this->daemon['token']
) {
$error = 'Invalid or missing token.';
}
}
}
if(!empty($error)) {
return $this->abortWithError($error);
}
$daemon = $this->daemon;
if(!$daemon) {
$this->abortWithError(__('Daemon does not exist.'));
}
if(!isset($this->data['token']) ||
$this->data['token'] !== $daemon['token']
) {
$this->abortWithError(__('Invalid or missing token.'));
}
$daemon['token'] = $this->token;
CronHelper::saveDaemon($daemon);
$this->abortIfStopped($daemon);
try {
$scheduler = new SchedulerWorker($this->timer);
$scheduler->process();
$queue = new SendingQueueWorker($this->timer);
$queue->process();
$this->executeScheduleWorker();
$this->executeQueueWorker();
} catch(\Exception $e) {
// continue processing, no need to handle errors
}
// if workers took less time to execute than the daemon execution limit,
// pause daemon execution to ensure that daemon runs only once every X seconds
$elapsed_time = microtime(true) - $this->timer;
if($elapsed_time < CronHelper::DAEMON_EXECUTION_LIMIT) {
sleep(CronHelper::DAEMON_EXECUTION_LIMIT - $elapsed_time);
$this->pauseExecution(CronHelper::DAEMON_EXECUTION_LIMIT - $elapsed_time);
}
// after each execution, re-read daemon data in case its status was changed
// its status has changed
// after each execution, re-read daemon data in case it changed
$daemon = CronHelper::getDaemon();
if(!$daemon || $daemon['token'] !== $this->token) {
$this->terminateRequest();
return $this->terminateRequest();
}
$this->abortIfStopped($daemon);
if($daemon['status'] === self::STATUS_STARTING) {
$daemon['status'] = self::STATUS_STARTED;
}
CronHelper::saveDaemon($daemon);
$this->callSelf();
return $this->callSelf();
}
function abortIfStopped($daemon) {
if($daemon['status'] === self::STATUS_STOPPED) {
$this->terminateRequest();
}
if($daemon['status'] === self::STATUS_STOPPING) {
$daemon['status'] = self::STATUS_STOPPED;
CronHelper::saveDaemon($daemon);
$this->terminateRequest();
}
function pauseExecution($pause_time) {
return sleep($pause_time);
}
function executeScheduleWorker() {
$scheduler = new SchedulerWorker($this->timer);
return $scheduler->process();
}
function executeQueueWorker() {
$queue = new SendingQueueWorker($this->timer);
return $queue->process();
}
function callSelf() {
CronHelper::accessDaemon($this->token, self::REQUEST_TIMEOUT);
$this->terminateRequest();
return $this->terminateRequest();
}
function abortWithError($message) {

View File

@ -15,7 +15,7 @@ class Supervisor {
function checkDaemon() {
$daemon = $this->daemon;
$execution_timeout_exceeded =
(time() - (int)$daemon['updated_at']) > CronHelper::DAEMON_EXECUTION_TIMEOUT;
(time() - (int)$daemon['updated_at']) >= CronHelper::DAEMON_EXECUTION_TIMEOUT;
if($execution_timeout_exceeded) {
CronHelper::restartDaemon($this->token);
return $this->runDaemon();

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