Compare commits
285 Commits
0.0.41
...
3.0.0-beta
Author | SHA1 | Date | |
---|---|---|---|
1220f47d87 | |||
583b34a5c1 | |||
b36d13a087 | |||
1a3aa7a4e4 | |||
6ce13df2f3 | |||
4eb85c5d7e | |||
6eb6636e8b | |||
9635fb5365 | |||
d4b39cb1f4 | |||
af36e7a0d9 | |||
1db8626e35 | |||
61c255564f | |||
7e5047d98f | |||
4698d5a4db | |||
864c9cbe95 | |||
011b6f9b3c | |||
e45fc0c0a0 | |||
6bebdd6e95 | |||
8df4da768a | |||
67f4c21aa8 | |||
5eba0e2731 | |||
3efa429a1b | |||
3a78441a83 | |||
c05be7d987 | |||
b8cb1da777 | |||
ac8d1d808f | |||
9cd7b1a204 | |||
0d32c09df3 | |||
9f288ae11a | |||
e87ccd6b92 | |||
8a2b6ac69b | |||
43bd2d4413 | |||
9fdb99a06b | |||
f3c69c8353 | |||
29a32d3da9 | |||
8412cc852d | |||
b4e4320508 | |||
dbd6e6f310 | |||
bdcb7f0e58 | |||
85c9b121f5 | |||
069bc95297 | |||
0b711e6341 | |||
2a961cca01 | |||
e855fdbbaf | |||
288464e8cb | |||
1331ed70f1 | |||
411188c345 | |||
ee275532b1 | |||
b2eef93516 | |||
40ca54c447 | |||
b65db1afbf | |||
c258b1c3a2 | |||
7a5a726400 | |||
e553922eca | |||
04e9e8a45d | |||
f037e1271d | |||
f4563e18cd | |||
feaac5eb54 | |||
a6059d5bc3 | |||
f2104ef30f | |||
e7f760328e | |||
c09bcd51ad | |||
01af4d3401 | |||
2ba9d95a2e | |||
b2d4bfc760 | |||
57f5f16bb6 | |||
7d2e13b9a3 | |||
6d39f9fa78 | |||
a4395f2350 | |||
411969b3eb | |||
1868ca3155 | |||
e765471f5d | |||
bdce7c5e5a | |||
773be9f5c8 | |||
6ae46b05e5 | |||
217894745d | |||
a03891895c | |||
3368e84a99 | |||
e90df2f08d | |||
2391ae1cad | |||
83114a8be4 | |||
d08d5a3b6c | |||
8330bfc884 | |||
ef21a8cca7 | |||
e32c46a755 | |||
092f69538a | |||
7a75367d75 | |||
0b2701ade2 | |||
1ac288d286 | |||
516bc73092 | |||
4088abef68 | |||
f6cefc3f5c | |||
202e4b90e1 | |||
ee89bf0722 | |||
876d21300a | |||
0ca5b7a79f | |||
5d0ee43921 | |||
cc523a3c0b | |||
2787998d32 | |||
38f6c95059 | |||
cc03b631ff | |||
a3c77fb685 | |||
3817e28960 | |||
c3a78b1ea3 | |||
42877236c8 | |||
6e87f3539c | |||
7704ea4b68 | |||
12a3931b7b | |||
25a55dbb67 | |||
6758f60a81 | |||
5e9e53ec41 | |||
1285252a8c | |||
98f95f72ad | |||
09ca788371 | |||
b48cc5a959 | |||
812d138c4e | |||
07bc35d4cd | |||
90b95a2c25 | |||
78c50c41e3 | |||
7eee7def63 | |||
9ba6e9806f | |||
8c28dc3d8a | |||
9197e39fb4 | |||
37f59814e5 | |||
bf894fc26f | |||
0b2b42cf4d | |||
542015a4f6 | |||
f5a8323f5d | |||
55942cd88b | |||
f26a2cbd26 | |||
4402f826c3 | |||
b9745b555a | |||
f923a8063b | |||
f4367b9146 | |||
a3395e41c9 | |||
be61135daf | |||
21b4187a11 | |||
1c3c1e35e7 | |||
ded373557e | |||
280c4762bb | |||
bbd02260be | |||
1b1e9abd68 | |||
b0ab9e0408 | |||
d32abff78d | |||
7fbf84db1f | |||
8c5aebc7d6 | |||
42202f676a | |||
ba6198f956 | |||
120af4170b | |||
1faa53b978 | |||
e565a7a234 | |||
90b6b57a8d | |||
548253d68e | |||
e1c5f609ff | |||
226befdef6 | |||
a9d57654b4 | |||
ed00ae0516 | |||
48d738e8c4 | |||
132b4ed2e8 | |||
9a513cb27b | |||
5d692c0395 | |||
991ab67fff | |||
dd00640119 | |||
fa04173cfb | |||
a328d3b48a | |||
d5cff4f0d3 | |||
52bf24b6db | |||
50e134d696 | |||
ea5c73721b | |||
4799882b80 | |||
2e4c5ca39a | |||
13ed3aa3b9 | |||
6091751a4b | |||
c4d9e85dff | |||
1a85914c1b | |||
0ba48234de | |||
1c2a532949 | |||
9087be6ee8 | |||
5b2ede8b83 | |||
2fa5e5ead2 | |||
d5107be65e | |||
379dfb5f6e | |||
8360377992 | |||
4538cab6c8 | |||
1bf0988297 | |||
e1caf49ea5 | |||
0dfae97b32 | |||
ef2187c175 | |||
6157d17c5b | |||
8e879047c2 | |||
bff6aecd0d | |||
a121583c2d | |||
e11fd66fec | |||
b37e85eeb5 | |||
f88dabffe8 | |||
8c436180d9 | |||
b834a6af4d | |||
1bd8aed192 | |||
cfdf72867e | |||
5888620fc1 | |||
55ba605eb0 | |||
7a73ca7d1a | |||
1918894c5c | |||
0c5589a3e3 | |||
d6eaa4ac8a | |||
b0571b97f5 | |||
6d51ca8011 | |||
d3289dfb84 | |||
bfffdd7274 | |||
c5b8b2aef0 | |||
d7bcf1b817 | |||
f30ed153ce | |||
f436088a16 | |||
db8cb7499d | |||
49c4adc754 | |||
405e743171 | |||
3508ac36b4 | |||
f17c8228cd | |||
3dd5ac0536 | |||
4ebdff49e0 | |||
4a72995bf4 | |||
ef27ac0b84 | |||
2b4adef6c2 | |||
f650455a90 | |||
afbe25e215 | |||
d93249f077 | |||
6223ef77d9 | |||
a423123b66 | |||
1b3d3082b0 | |||
fa117cc7dd | |||
acd407c1f1 | |||
9baf4b068f | |||
18d852e147 | |||
b8dc306741 | |||
6ea056c042 | |||
bcf1b37c6a | |||
2986cdba85 | |||
53a8ae74e2 | |||
8bab01506c | |||
c664045444 | |||
6b8149210d | |||
f31d30b318 | |||
d9fbbdc02d | |||
8136ee2d9b | |||
f7cf6e2131 | |||
f2d1787bd5 | |||
fb51765d3f | |||
088ad5fb42 | |||
2f5b3c0c0a | |||
04ac4d896c | |||
f3b96af863 | |||
eb42b0b98d | |||
304667eb49 | |||
dad1082cd7 | |||
37cf0f3d29 | |||
d61c6dff58 | |||
3734ac578d | |||
b3f56c9d8e | |||
3603eeee77 | |||
59d30cc139 | |||
6ff3bbbb72 | |||
a561e10156 | |||
99f2cf6702 | |||
c6b72e729b | |||
c5bc0f36a4 | |||
efc5c34bf9 | |||
3929efbdd9 | |||
0e0c41882e | |||
79cc708fc6 | |||
8fa98879b8 | |||
331ba385e9 | |||
71ce46d78d | |||
c493de6569 | |||
ff2c2ace86 | |||
7fa789cfd1 | |||
ae6269eb63 | |||
a8f4779bfe | |||
6868142e35 | |||
133d123919 | |||
05c128d12d | |||
bdab0c12fa | |||
75b94690e2 | |||
80fddd6c58 | |||
c807ead5fd | |||
f004bb5368 |
15
.circle_ci/apache/mailpoet.loc.conf
Normal file
@ -0,0 +1,15 @@
|
||||
Listen 8080
|
||||
|
||||
<VirtualHost *:8080>
|
||||
UseCanonicalName Off
|
||||
ServerName mailpoet.loc
|
||||
DocumentRoot /home/ubuntu/mailpoet/wordpress
|
||||
DirectoryIndex index.php
|
||||
LogLevel notice
|
||||
|
||||
<Directory /home/ubuntu/mailpoet/wordpress>
|
||||
AllowOverride All
|
||||
Allow from All
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
|
1
.gitignore
vendored
@ -17,3 +17,4 @@ tests/javascript/testBundles
|
||||
assets/css/*.css
|
||||
assets/js/*.js
|
||||
.vagrant
|
||||
lang
|
85
RoboFile.php
@ -3,14 +3,21 @@
|
||||
class RoboFile extends \Robo\Tasks {
|
||||
|
||||
function install() {
|
||||
$this->_exec('./composer.phar install');
|
||||
$this->_exec('npm install');
|
||||
return $this->taskExecStack()
|
||||
->stopOnFail()
|
||||
->exec('./composer.phar install')
|
||||
->exec('npm install')
|
||||
->run();
|
||||
}
|
||||
|
||||
function update() {
|
||||
$this->say(getenv('WP_TEST_URL'));
|
||||
$this->_exec('./composer.phar update');
|
||||
$this->_exec('npm update');
|
||||
|
||||
return $this->taskExecStack()
|
||||
->stopOnFail()
|
||||
->exec('./composer.phar update')
|
||||
->exec('npm update')
|
||||
->run();
|
||||
}
|
||||
|
||||
protected function rsearch($folder, $extensions = array()) {
|
||||
@ -61,12 +68,14 @@ class RoboFile extends \Robo\Tasks {
|
||||
}
|
||||
|
||||
function compileAll() {
|
||||
$this->compileJs();
|
||||
$this->compileCss();
|
||||
$collection = $this->collection();
|
||||
$collection->add(array($this, 'compileJs'));
|
||||
$collection->add(array($this, 'compileCss'));
|
||||
return $collection->run();
|
||||
}
|
||||
|
||||
function compileJs() {
|
||||
$this->_exec('./node_modules/webpack/bin/webpack.js');
|
||||
return $this->_exec('./node_modules/webpack/bin/webpack.js --bail');
|
||||
}
|
||||
|
||||
function compileCss() {
|
||||
@ -78,7 +87,7 @@ class RoboFile extends \Robo\Tasks {
|
||||
'assets/css/src/importExport.styl'
|
||||
);
|
||||
|
||||
$this->_exec(join(' ', array(
|
||||
return $this->_exec(join(' ', array(
|
||||
'./node_modules/stylus/bin/stylus',
|
||||
'--include ./node_modules',
|
||||
'--include-css',
|
||||
@ -89,65 +98,89 @@ class RoboFile extends \Robo\Tasks {
|
||||
}
|
||||
|
||||
function makepot() {
|
||||
$this->_exec('./node_modules/.bin/grunt makepot'.
|
||||
return $this->_exec('./node_modules/.bin/grunt makepot'.
|
||||
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
||||
' --base_path '.__DIR__
|
||||
);
|
||||
}
|
||||
|
||||
function pushpot() {
|
||||
$this->_exec('./node_modules/.bin/grunt pushpot'.
|
||||
return $this->_exec('./node_modules/.bin/grunt pushpot'.
|
||||
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
||||
' --base_path '.__DIR__
|
||||
);
|
||||
}
|
||||
|
||||
function testUnit($file = null) {
|
||||
function testUnit($opts=['file' => null, 'xml' => false]) {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec('vendor/bin/codecept run unit -f '.(($file) ? $file : ''));
|
||||
|
||||
$command = 'vendor/bin/codecept run unit -f '.(($opts['file']) ? $opts['file'] : '');
|
||||
|
||||
if($opts['xml']) {
|
||||
$command .= ' --xml';
|
||||
}
|
||||
return $this->_exec($command);
|
||||
}
|
||||
|
||||
function testCoverage($file = null) {
|
||||
function testCoverage($opts=['file' => null, 'xml' => false]) {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec(join(' ', array(
|
||||
$command = join(' ', array(
|
||||
'vendor/bin/codecept run',
|
||||
(($file) ? $file : ''),
|
||||
(($opts['file']) ? $opts['file'] : ''),
|
||||
'--coverage',
|
||||
'--coverage-html'
|
||||
)));
|
||||
($opts['xml']) ? '--coverage-xml' : '--coverage-html'
|
||||
));
|
||||
|
||||
if($opts['xml']) {
|
||||
$command .= ' --xml';
|
||||
}
|
||||
return $this->_exec($command);
|
||||
}
|
||||
|
||||
function testJavascript() {
|
||||
function testJavascript($xml_output_file = null) {
|
||||
$this->compileJs();
|
||||
|
||||
$this->_exec(join(' ', array(
|
||||
$command = join(' ', array(
|
||||
'./node_modules/.bin/mocha',
|
||||
'-r tests/javascript/mochaTestHelper.js',
|
||||
'tests/javascript/testBundles/**/*.js'
|
||||
)));
|
||||
));
|
||||
|
||||
if(!empty($xml_output_file)) {
|
||||
$command .= sprintf(
|
||||
' --reporter xunit --reporter-options output="%s"',
|
||||
$xml_output_file
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_exec($command);
|
||||
}
|
||||
|
||||
function testDebug() {
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept run unit --debug');
|
||||
return $this->_exec('vendor/bin/codecept run unit --debug');
|
||||
}
|
||||
|
||||
function testFailed() {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec('vendor/bin/codecept run -g failed');
|
||||
return $this->_exec('vendor/bin/codecept run -g failed');
|
||||
}
|
||||
|
||||
function qa() {
|
||||
$this->qaLint();
|
||||
$this->qaCodeSniffer('all');
|
||||
$collection = $this->collection();
|
||||
$collection->add(array($this, 'qaLint'));
|
||||
$collection->add(function() {
|
||||
return $this->qaCodeSniffer('all');
|
||||
});
|
||||
return $collection->run();
|
||||
}
|
||||
|
||||
function qaLint() {
|
||||
$this->_exec('./tasks/php_lint.sh lib/ tests/ mailpoet.php');
|
||||
return $this->_exec('./tasks/php_lint.sh lib/ tests/ mailpoet.php');
|
||||
}
|
||||
|
||||
function qaCodeSniffer($severity='errors') {
|
||||
@ -156,7 +189,7 @@ class RoboFile extends \Robo\Tasks {
|
||||
} else {
|
||||
$severityFlag = '-n';
|
||||
}
|
||||
$this->_exec(
|
||||
return $this->_exec(
|
||||
'./vendor/bin/phpcs '.
|
||||
'--standard=./tasks/code_sniffer/MailPoet '.
|
||||
'--ignore=./lib/Util/Sudzy/*,./lib/Util/CSS.php,./lib/Util/XLSXWriter.php,'.
|
||||
|
@ -1,3 +1,15 @@
|
||||
$box-width = 425px
|
||||
$box-height = 150px
|
||||
$thumbnail-width = $box-height
|
||||
$thumbnail-height = $thumbnail-width
|
||||
$box-description-space-between-heading-and-paragraph = 5px
|
||||
$box-description-height = 110px
|
||||
$box-description-text-height = $box-description-height - $box-description-space-between-heading-and-paragraph
|
||||
$box-heading-line-height = $box-description-text-height / 4
|
||||
$box-heading-font-size = $box-heading-line-height * 5/7
|
||||
$box-description-line-height = $box-heading-line-height / 2
|
||||
$box-description-font-size = $box-description-line-height
|
||||
|
||||
.mailpoet_boxes.mailpoet_boxes_loading
|
||||
opacity: 0.2
|
||||
|
||||
@ -6,8 +18,8 @@
|
||||
position: relative
|
||||
padding: 15px
|
||||
margin: 15px 25px 0 0
|
||||
width: 425px
|
||||
height: 150px
|
||||
width: $box-width
|
||||
height: $box-height
|
||||
border: 1px solid #dedede
|
||||
background-color: #fff
|
||||
|
||||
@ -18,15 +30,15 @@
|
||||
background-position: center
|
||||
color: #222
|
||||
border: 1px solid #ccc
|
||||
width: 150px
|
||||
height: 150px
|
||||
width: $thumbnail-height
|
||||
height: $thumbnail-width
|
||||
margin-right: 15px
|
||||
float: left
|
||||
overflow: hidden
|
||||
position: relative
|
||||
|
||||
img
|
||||
min-width: 150px
|
||||
min-width: $thumbnail-width
|
||||
height: auto
|
||||
width: 110%
|
||||
position: relative
|
||||
@ -60,15 +72,21 @@
|
||||
.mailpoet_boxes .mailpoet_description
|
||||
float:left
|
||||
width: 245px
|
||||
max-height: calc(110px - 2em)
|
||||
padding-bottom: 2em
|
||||
max-height: $box-description-height
|
||||
padding-bottom: 0
|
||||
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 $box-description-space-between-heading-and-paragraph 0
|
||||
overflow: hidden
|
||||
max-width: 210px
|
||||
line-height: $box-heading-line-height
|
||||
font-size: $box-heading-font-size
|
||||
|
||||
p
|
||||
font-size: $box-description-font-size
|
||||
line-height: $box-description-line-height
|
||||
margin: 0
|
||||
|
||||
.mailpoet_boxes .mailpoet_actions
|
||||
position: absolute
|
||||
|
@ -1,6 +1,6 @@
|
||||
$tool-inactive-color = #bbbbbb
|
||||
$tool-inactive-color = #333333
|
||||
$tool-inactive-secondary-color = #ffffff
|
||||
$tool-hover-color = #333333
|
||||
$tool-hover-color = #bbbbbb
|
||||
$tool-hover-secondary-color = #ffffff
|
||||
$tool-active-color = #d2d2d4
|
||||
$tool-active-secondary-color = #ffffff
|
||||
@ -12,21 +12,42 @@ $master-column-tool-width = 24px
|
||||
position: absolute
|
||||
top: 0
|
||||
right: 0
|
||||
display: none
|
||||
z-index: 20
|
||||
padding: 2px
|
||||
text-align: right
|
||||
overflow: hidden
|
||||
|
||||
.mailpoet_tool_slider
|
||||
position: relative
|
||||
right: -100%
|
||||
transition: all 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000)
|
||||
opacity: 0
|
||||
|
||||
&.mailpoet_display_tools
|
||||
.mailpoet_tool_slider
|
||||
right: 0
|
||||
opacity: 1
|
||||
|
||||
a
|
||||
vertical-align: top
|
||||
|
||||
.mailpoet_container_horizontal + &
|
||||
left: 100%
|
||||
right: initial
|
||||
padding-left: 5px
|
||||
|
||||
.mailpoet_tool_slider
|
||||
left: -100%
|
||||
right: initial
|
||||
|
||||
&.mailpoet_display_tools
|
||||
.mailpoet_tool_slider
|
||||
left: 0
|
||||
|
||||
.mailpoet_tool
|
||||
width: $master-column-tool-width
|
||||
height: $master-column-tool-width
|
||||
display: block
|
||||
|
||||
.mailpoet_tool_icon
|
||||
width: $master-column-tool-width
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
.mailpoet_input_title,
|
||||
.mailpoet_input_preheader
|
||||
width: 400px
|
||||
width: 500px
|
||||
padding: 3px
|
||||
line-height: normal
|
||||
|
||||
|
@ -5,8 +5,8 @@ $active-social-icon-set-border-color = #adadad
|
||||
$active-social-icon-set-background-color = #daebf2
|
||||
$social-icon-set-hover-border-color = $primary-active-color
|
||||
|
||||
$tool-inactive-color = #bbbbbb
|
||||
$tool-hover-color = #333333
|
||||
$tool-inactive-color = #333333
|
||||
$tool-hover-color = #bbbbbb
|
||||
$tool-active-color = #d2d2d4
|
||||
|
||||
$tool-width = 16px
|
||||
|
@ -1,12 +1,12 @@
|
||||
animation-slide-open-downwards()
|
||||
animation-slide-open-downwards($max-height = 2000px)
|
||||
transition: all 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000) /* ease-in-out */
|
||||
max-height: 2000px
|
||||
max-height: $max-height
|
||||
opacity: 1
|
||||
overflow-y: hidden
|
||||
|
||||
&.mailpoet_closed
|
||||
max-height: 0
|
||||
max-height: 0px
|
||||
opacity: 0
|
||||
overflow-y: hidden
|
||||
|
||||
animation-background-color()
|
||||
transition: background 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000) /* ease-in-out */
|
||||
|
Before Width: | Height: | Size: 178 KiB After Width: | Height: | Size: 178 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
BIN
assets/img/sample_templates/discount/bicycle-header2.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
assets/img/sample_templates/discount/bicycle-header3.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
assets/img/sample_templates/discount/orange-bicycle.jpg
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
assets/img/sample_templates/discount/red-icycle.jpg
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
assets/img/sample_templates/restaurant/boyga-1329911-639x852.jpg
Normal file
After Width: | Height: | Size: 303 KiB |
BIN
assets/img/sample_templates/restaurant/burger.jpg
Normal file
After Width: | Height: | Size: 289 KiB |
BIN
assets/img/sample_templates/restaurant/header.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 498 KiB |
BIN
assets/img/sample_templates/travel/gallery1.jpg
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
assets/img/sample_templates/travel/gallery2.jpg
Normal file
After Width: | Height: | Size: 106 KiB |
BIN
assets/img/sample_templates/travel/gallery3.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
assets/img/sample_templates/travel/gallery4.jpg
Normal file
After Width: | Height: | Size: 156 KiB |
BIN
assets/img/sample_templates/travel/glow-worms.jpg
Normal file
After Width: | Height: | Size: 145 KiB |
BIN
assets/img/sample_templates/travel/header.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
assets/img/sample_templates/travel/holiday-park.jpg
Normal file
After Width: | Height: | Size: 136 KiB |
BIN
assets/img/sample_templates/travel/luge.jpg
Normal file
After Width: | Height: | Size: 77 KiB |
BIN
assets/img/welcome_template/beacon.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 4.8 KiB |
BIN
assets/img/welcome_template/mailpoet-logo.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
@ -1,72 +0,0 @@
|
||||
define(
|
||||
[
|
||||
'react',
|
||||
'react-dom',
|
||||
'mailpoet'
|
||||
],
|
||||
function(
|
||||
React,
|
||||
ReactDOM,
|
||||
MailPoet
|
||||
) {
|
||||
var CronControl = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
status: 'loading'
|
||||
};
|
||||
},
|
||||
getCronData: function() {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'cron',
|
||||
action: 'getStatus'
|
||||
}).done((response) => {
|
||||
this.setState({
|
||||
status: response.data.status
|
||||
});
|
||||
}).fail((response) => {
|
||||
this.setState({
|
||||
status: false
|
||||
});
|
||||
});
|
||||
},
|
||||
componentDidMount: function() {
|
||||
if(this.isMounted()) {
|
||||
this.getCronData();
|
||||
setInterval(this.getCronData, 5000);
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
let status;
|
||||
|
||||
switch(this.state.status) {
|
||||
case false:
|
||||
case 'stopping':
|
||||
case 'stopped':
|
||||
status = MailPoet.I18n.t('cronDaemonIsNotRunning');
|
||||
break;
|
||||
case 'starting':
|
||||
case 'started':
|
||||
status = MailPoet.I18n.t('cronDaemonIsRunning');
|
||||
break;
|
||||
case 'loading':
|
||||
status = MailPoet.I18n.t('loadingDaemonStatus');
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{ status }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const container = document.getElementById('cron_container');
|
||||
|
||||
if(container) {
|
||||
ReactDOM.render(
|
||||
<CronControl />,
|
||||
container
|
||||
);
|
||||
}
|
||||
});
|
@ -71,30 +71,43 @@ define('date',
|
||||
convertFormat: function(format) {
|
||||
var format_mappings = {
|
||||
date: {
|
||||
D: 'ddd',
|
||||
l: 'dddd',
|
||||
d: 'DD',
|
||||
D: 'ddd',
|
||||
j: 'D',
|
||||
z: 'DDDD',
|
||||
l: 'dddd',
|
||||
N: 'E',
|
||||
S: '',
|
||||
M: 'MMM',
|
||||
S: 'o',
|
||||
w: 'e',
|
||||
z: 'DDD',
|
||||
W: 'W',
|
||||
F: 'MMMM',
|
||||
m: 'MM',
|
||||
n: '',
|
||||
t: '',
|
||||
y: 'YY',
|
||||
M: 'MMM',
|
||||
n: 'M',
|
||||
t: '', // no equivalent
|
||||
L: '', // no equivalent
|
||||
o: 'YYYY',
|
||||
Y: 'YYYY',
|
||||
H: 'HH',
|
||||
h: 'hh',
|
||||
g: 'h',
|
||||
y: 'YY',
|
||||
a: 'a',
|
||||
A: 'A',
|
||||
B: '', // no equivalent
|
||||
g: 'h',
|
||||
G: 'H',
|
||||
h: 'hh',
|
||||
H: 'HH',
|
||||
i: 'mm',
|
||||
s: 'ss',
|
||||
T: 'z',
|
||||
O: 'ZZ',
|
||||
w: 'd',
|
||||
W: 'WW'
|
||||
u: 'SSS',
|
||||
e: 'zz', // deprecated since version 1.6.0 of moment.js
|
||||
I: '', // no equivalent
|
||||
O: '', // no equivalent
|
||||
P: '', // no equivalent
|
||||
T: '', // no equivalent
|
||||
Z: '', // no equivalent
|
||||
c: '', // no equivalent
|
||||
r: '', // no equivalent
|
||||
U: 'X'
|
||||
},
|
||||
strftime: {
|
||||
a: 'ddd',
|
||||
@ -127,20 +140,29 @@ define('date',
|
||||
|
||||
var replacements = format_mappings['date'];
|
||||
|
||||
var outputFormat = '';
|
||||
var convertedFormat = [];
|
||||
var escapeToken = false;
|
||||
|
||||
Object.keys(replacements).forEach(function(key) {
|
||||
if (format.indexOf(key) !== -1) {
|
||||
format = format.replace(key, '%'+key);
|
||||
for (var index in format) {
|
||||
var token = format[index];
|
||||
|
||||
if (escapeToken === true) {
|
||||
convertedFormat.push('['+token+']');
|
||||
escapeToken = false;
|
||||
} else {
|
||||
if (token === '\\') {
|
||||
// Slash escapes the next symbol to be treated as literal
|
||||
escapeToken = true;
|
||||
continue;
|
||||
} else if (replacements[token] !== undefined) {
|
||||
convertedFormat.push(replacements[token]);
|
||||
} else {
|
||||
convertedFormat.push('['+token+']');
|
||||
}
|
||||
}
|
||||
});
|
||||
outputFormat = format;
|
||||
Object.keys(replacements).forEach(function(key) {
|
||||
if (outputFormat.indexOf('%'+key) !== -1) {
|
||||
outputFormat = outputFormat.replace('%'+key, replacements[key]);
|
||||
}
|
||||
});
|
||||
return outputFormat;
|
||||
}
|
||||
|
||||
return convertedFormat.join('');
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -89,10 +89,17 @@ function(
|
||||
if(this.props.field['selected'] !== undefined) {
|
||||
return this.props.field['selected'](this.props.item);
|
||||
} else if(this.props.item !== undefined && this.props.field.name !== undefined) {
|
||||
return this.props.item[this.props.field.name];
|
||||
} else {
|
||||
return null;
|
||||
if (this.allowMultipleValues()) {
|
||||
if (Array.isArray(this.props.item[this.props.field.name])) {
|
||||
return this.props.item[this.props.field.name].map(function(item) {
|
||||
return item.id;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return this.props.item[this.props.field.name];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
loadCachedItems: function() {
|
||||
if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
|
||||
@ -115,9 +122,10 @@ function(
|
||||
} else {
|
||||
value = e.target.value;
|
||||
}
|
||||
var transformedValue = this.transformChangedValue(value);
|
||||
this.props.onValueChange({
|
||||
target: {
|
||||
value: value,
|
||||
value: transformedValue,
|
||||
name: this.props.field.name
|
||||
}
|
||||
});
|
||||
@ -141,6 +149,16 @@ function(
|
||||
}
|
||||
return item.id;
|
||||
},
|
||||
// When it's impossible to represent the desired value in DOM,
|
||||
// this function may be used to transform the placeholder value into
|
||||
// desired value.
|
||||
transformChangedValue: function(value) {
|
||||
if(typeof this.props.field['transformChangedValue'] === 'function') {
|
||||
return this.props.field.transformChangedValue.call(this, value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
const options = this.state.items.map((item, index) => {
|
||||
let label = this.getLabel(item);
|
||||
|
@ -66,22 +66,22 @@ define(
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'get',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
if(response === false) {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {}
|
||||
}, function() {
|
||||
this.context.router.push('/new');
|
||||
}.bind(this));
|
||||
} else {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response
|
||||
});
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}.bind(this));
|
||||
}).done((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response.data
|
||||
});
|
||||
}).fail((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {}
|
||||
}, function() {
|
||||
this.context.router.push('/new');
|
||||
});
|
||||
});
|
||||
},
|
||||
handleSubmit: function(e) {
|
||||
e.preventDefault();
|
||||
@ -115,29 +115,25 @@ define(
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'save',
|
||||
data: item
|
||||
}).done(function(response) {
|
||||
}).always(() => {
|
||||
this.setState({ loading: false });
|
||||
|
||||
if(response.result === true) {
|
||||
if(this.props.onSuccess !== undefined) {
|
||||
this.props.onSuccess();
|
||||
} else {
|
||||
this.context.router.push('/');
|
||||
}
|
||||
|
||||
if(this.props.params.id !== undefined) {
|
||||
this.props.messages.onUpdate();
|
||||
} else {
|
||||
this.props.messages.onCreate();
|
||||
}
|
||||
}).done((response) => {
|
||||
if(this.props.onSuccess !== undefined) {
|
||||
this.props.onSuccess();
|
||||
} else {
|
||||
if(response.result === false) {
|
||||
if(response.errors.length > 0) {
|
||||
this.setState({ errors: response.errors });
|
||||
}
|
||||
}
|
||||
this.context.router.push('/');
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
if(this.props.params.id !== undefined) {
|
||||
this.props.messages.onUpdate();
|
||||
} else {
|
||||
this.props.messages.onCreate();
|
||||
}
|
||||
}).fail((response) => {
|
||||
if(response.errors.length > 0) {
|
||||
this.setState({ errors: response.errors });
|
||||
}
|
||||
});
|
||||
},
|
||||
handleValueChange: function(e) {
|
||||
if (this.props.onChange) {
|
||||
@ -159,7 +155,7 @@ define(
|
||||
var errors = this.getErrors().map(function(error, index) {
|
||||
return (
|
||||
<p key={ 'error-'+index } className="mailpoet_error">
|
||||
{ error }
|
||||
{ error.message }
|
||||
</p>
|
||||
);
|
||||
});
|
||||
|
@ -27,48 +27,48 @@ const columns = [
|
||||
];
|
||||
|
||||
const messages = {
|
||||
onTrash: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormTrashed')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormDeleted')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormRestored')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -99,14 +99,21 @@ const item_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'forms',
|
||||
action: 'duplicate',
|
||||
data: item.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response['name'] !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.name)
|
||||
data: {
|
||||
id: item.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.data.name)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -120,9 +127,14 @@ const FormList = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'forms',
|
||||
action: 'create'
|
||||
}).done(function(response) {
|
||||
if(response.result && response.form_id) {
|
||||
window.location = mailpoet_form_edit_url + response.form_id;
|
||||
}).done((response) => {
|
||||
window.location = mailpoet_form_edit_url + response.data.id;
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -139,6 +151,10 @@ const FormList = React.createClass({
|
||||
return segment.name;
|
||||
}).join(', ');
|
||||
|
||||
if (form.settings.segments_selected_by === 'user') {
|
||||
segments = MailPoet.I18n.t('userChoice') + ' ' + segments;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<td className={ row_classes }>
|
||||
|
@ -53,7 +53,10 @@ function(
|
||||
}
|
||||
|
||||
if(data.action) {
|
||||
this.props.onBulkAction(selected_ids, data).then(onSuccess);
|
||||
const promise = this.props.onBulkAction(selected_ids, data);
|
||||
if (promise !== false) {
|
||||
promise.then(onSuccess);
|
||||
};
|
||||
}
|
||||
|
||||
this.setState({
|
||||
|
@ -456,22 +456,29 @@ const Listing = React.createClass({
|
||||
sort_by: this.state.sort_by,
|
||||
sort_order: this.state.sort_order
|
||||
}
|
||||
}).done(function(response) {
|
||||
}).always(() => {
|
||||
this.setState({ loading: false });
|
||||
}).done((response) => {
|
||||
this.setState({
|
||||
items: response.items || [],
|
||||
filters: response.filters || {},
|
||||
groups: response.groups || [],
|
||||
count: response.count || 0,
|
||||
loading: false
|
||||
}, function() {
|
||||
if (this.props['onGetItems'] !== undefined) {
|
||||
const count = (response.groups[0] !== undefined)
|
||||
? ~~(response.groups[0].count)
|
||||
: 0;
|
||||
this.props.onGetItems(count);
|
||||
items: response.data || [],
|
||||
filters: response.meta.filters || {},
|
||||
groups: response.meta.groups || [],
|
||||
count: response.meta.count || 0
|
||||
}, () => {
|
||||
// if viewing an empty trash
|
||||
if (this.state.group === 'trash' && response.meta.count === 0) {
|
||||
// redirect to default group
|
||||
this.handleGroup('all');
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
});
|
||||
}).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
handleRestoreItem: function(id) {
|
||||
@ -483,8 +490,10 @@ const Listing = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'restore',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).done((response) => {
|
||||
if (
|
||||
this.props.messages !== undefined
|
||||
&& this.props.messages['onRestore'] !== undefined
|
||||
@ -492,7 +501,12 @@ const Listing = React.createClass({
|
||||
this.props.messages.onRestore(response);
|
||||
}
|
||||
this.getItems();
|
||||
}.bind(this));
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
handleTrashItem: function(id) {
|
||||
this.setState({
|
||||
@ -503,8 +517,10 @@ const Listing = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'trash',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).done((response) => {
|
||||
if (
|
||||
this.props.messages !== undefined
|
||||
&& this.props.messages['onTrash'] !== undefined
|
||||
@ -512,7 +528,12 @@ const Listing = React.createClass({
|
||||
this.props.messages.onTrash(response);
|
||||
}
|
||||
this.getItems();
|
||||
}.bind(this));
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
handleDeleteItem: function(id) {
|
||||
this.setState({
|
||||
@ -523,8 +544,10 @@ const Listing = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'delete',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).done((response) => {
|
||||
if (
|
||||
this.props.messages !== undefined
|
||||
&& this.props.messages['onDelete'] !== undefined
|
||||
@ -532,22 +555,29 @@ const Listing = React.createClass({
|
||||
this.props.messages.onDelete(response);
|
||||
}
|
||||
this.getItems();
|
||||
}.bind(this));
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
handleEmptyTrash: function() {
|
||||
return this.handleBulkAction('all', {
|
||||
action: 'delete',
|
||||
group: 'trash'
|
||||
}).then(function(response) {
|
||||
if (~~(response) > 0) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response)
|
||||
);
|
||||
}
|
||||
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response.meta.count)
|
||||
);
|
||||
// redirect to default group
|
||||
this.handleGroup('all');
|
||||
}.bind(this));
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
handleBulkAction: function(selected_ids, params) {
|
||||
if (
|
||||
@ -555,7 +585,7 @@ const Listing = React.createClass({
|
||||
&& this.state.selected_ids.length === 0
|
||||
&& selected_ids !== 'all'
|
||||
) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
this.setState({ loading: true });
|
||||
@ -594,7 +624,7 @@ const Listing = React.createClass({
|
||||
handleSort: function(sort_by, sort_order = 'asc') {
|
||||
this.setState({
|
||||
sort_by: sort_by,
|
||||
sort_order: sort_order,
|
||||
sort_order: (sort_order === 'asc') ? 'asc' : 'desc',
|
||||
}, function() {
|
||||
this.setParams();
|
||||
}.bind(this));
|
||||
|
@ -35,7 +35,12 @@ define([
|
||||
|
||||
Module.ALCSupervisor = SuperModel.extend({
|
||||
initialize: function() {
|
||||
this.listenTo(App.getChannel(), 'automatedLatestContentRefresh', this.refresh);
|
||||
var DELAY_REFRESH_FOR_MS = 500;
|
||||
this.listenTo(
|
||||
App.getChannel(),
|
||||
'automatedLatestContentRefresh',
|
||||
_.debounce(this.refresh, DELAY_REFRESH_FOR_MS)
|
||||
);
|
||||
},
|
||||
refresh: function() {
|
||||
var models = App.findModels(function(model) {
|
||||
@ -107,9 +112,7 @@ define([
|
||||
this.on('change:amount change:contentType change:terms change:inclusionType change:displayType change:titleFormat change:featuredImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:showAuthor change:authorPrecededBy change:showCategories change:categoriesPrecededBy change:readMoreType change:readMoreText change:sortBy change:showDivider', this._scheduleFetchPosts, this);
|
||||
this.listenTo(this.get('readMoreButton'), 'change', this._scheduleFetchPosts);
|
||||
this.listenTo(this.get('divider'), 'change', this._scheduleFetchPosts);
|
||||
this.on('add remove update reset', function(model, collection, options) {
|
||||
App.getChannel().trigger('automatedLatestContentRefresh');
|
||||
});
|
||||
this.on('add remove update reset', this._scheduleFetchPosts);
|
||||
this.on('refreshPosts', this.updatePosts, this);
|
||||
},
|
||||
updatePosts: function(posts) {
|
||||
@ -120,16 +123,7 @@ define([
|
||||
* ALC posts on each model change
|
||||
*/
|
||||
_scheduleFetchPosts: function() {
|
||||
var TIMEOUT = 500,
|
||||
that = this;
|
||||
if (this._fetchPostsTimer !== undefined) {
|
||||
clearTimeout(this._fetchPostsTimer);
|
||||
}
|
||||
this._fetchPostsTimer = setTimeout(function() {
|
||||
//that.fetchPosts();
|
||||
App.getChannel().trigger('automatedLatestContentRefresh');
|
||||
that._fetchPostsTimer = undefined;
|
||||
}, TIMEOUT);
|
||||
App.getChannel().trigger('automatedLatestContentRefresh');
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -99,12 +99,12 @@ define([
|
||||
},
|
||||
showTools: function(_event) {
|
||||
if (!this.showingToolsDisabled) {
|
||||
this.$('> .mailpoet_tools').show();
|
||||
this.$('> .mailpoet_tools').addClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('showTools');
|
||||
}
|
||||
},
|
||||
hideTools: function(e) {
|
||||
this.$('> .mailpoet_tools').hide();
|
||||
this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('hideTools');
|
||||
},
|
||||
enableShowingTools: function() {
|
||||
|
@ -186,13 +186,13 @@ define([
|
||||
},
|
||||
showTools: function() {
|
||||
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
||||
this.$(this.ui.tools).show();
|
||||
this.$(this.ui.tools).addClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('showTools');
|
||||
}
|
||||
},
|
||||
hideTools: function() {
|
||||
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
||||
this.$(this.ui.tools).hide();
|
||||
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('hideTools');
|
||||
}
|
||||
},
|
||||
|
@ -71,11 +71,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -84,6 +90,12 @@ define([
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'),
|
||||
});
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.FooterBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -71,11 +71,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -84,6 +90,12 @@ define([
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'),
|
||||
});
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.HeaderBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -171,11 +171,11 @@ define([
|
||||
this.regionManager.destroy();
|
||||
},
|
||||
showTools: function(_event) {
|
||||
this.$(this.ui.tools).show();
|
||||
this.$(this.ui.tools).addClass('mailpoet_display_tools');
|
||||
_event.stopPropagation();
|
||||
},
|
||||
hideTools: function(_event) {
|
||||
this.$(this.ui.tools).hide();
|
||||
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
|
||||
_event.stopPropagation();
|
||||
},
|
||||
showSettings: function(options) {
|
||||
|
@ -69,11 +69,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -83,6 +89,12 @@ define([
|
||||
});
|
||||
}
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.TextBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -11,7 +11,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'automatedLatestContent',
|
||||
action: args.action,
|
||||
data: args.options || {},
|
||||
data: args.options || {}
|
||||
});
|
||||
};
|
||||
Module._cachedQuery = _.memoize(Module._query, JSON.stringify);
|
||||
@ -19,14 +19,14 @@ define([
|
||||
Module.getNewsletter = function(options) {
|
||||
return Module._query({
|
||||
action: 'get',
|
||||
options: options,
|
||||
options: options
|
||||
});
|
||||
};
|
||||
|
||||
Module.getPostTypes = function() {
|
||||
return Module._cachedQuery({
|
||||
action: 'getPostTypes',
|
||||
options: {},
|
||||
options: {}
|
||||
}).then(function(response) {
|
||||
return _.values(response.data);
|
||||
});
|
||||
@ -83,7 +83,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'save',
|
||||
data: options || {},
|
||||
data: options || {}
|
||||
});
|
||||
};
|
||||
|
||||
@ -91,7 +91,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'sendPreview',
|
||||
data: options || {},
|
||||
data: options || {}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -11,15 +11,16 @@ define([
|
||||
// Does not hold newsletter content nor newsletter styles, those are
|
||||
// handled by other components.
|
||||
Module.NewsletterModel = SuperModel.extend({
|
||||
stale: ['body', 'created_at', 'deleted_at', 'updated_at'],
|
||||
whitelisted: ['id', 'subject', 'preheader'],
|
||||
initialize: function(options) {
|
||||
this.on('change', function() {
|
||||
App.getChannel().trigger('autoSave');
|
||||
});
|
||||
},
|
||||
toJSON: function() {
|
||||
// Remove stale attributes from resulting JSON object
|
||||
return _.omit(SuperModel.prototype.toJSON.call(this), this.stale);
|
||||
// Use only whitelisted properties to ensure properties editor
|
||||
// doesn't control don't change.
|
||||
return _.pick(SuperModel.prototype.toJSON.call(this), this.whitelisted);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -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 }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
@ -61,7 +61,7 @@ const _QueueMixin = {
|
||||
);
|
||||
|
||||
// calculate percentage done
|
||||
const percentage = Math.round(
|
||||
let percentage = Math.round(
|
||||
(newsletter.queue.count_processed * 100) / (newsletter.queue.count_total)
|
||||
);
|
||||
|
||||
@ -108,15 +108,24 @@ const _QueueMixin = {
|
||||
);
|
||||
}
|
||||
|
||||
let progress_bar_width = 0;
|
||||
|
||||
if (isNaN(percentage)) {
|
||||
percentage = MailPoet.I18n.t('noSubscribers');
|
||||
} else {
|
||||
progress_bar_width = percentage;
|
||||
percentage += "%";
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={ progressClasses }>
|
||||
<span
|
||||
className="mailpoet_progress_bar"
|
||||
style={ { width: percentage + "%"} }
|
||||
style={ { width: progress_bar_width + "%"} }
|
||||
></span>
|
||||
<span className="mailpoet_progress_label">
|
||||
{ percentage + "%" }
|
||||
{ percentage }
|
||||
</span>
|
||||
</div>
|
||||
<p style={{ textAlign:'center' }}>
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -68,7 +68,7 @@ const NewsletterListNotificationHistory = React.createClass({
|
||||
<a
|
||||
href={ newsletter.preview_url }
|
||||
target="_blank"
|
||||
>{ newsletter.subject }</a>
|
||||
>{ newsletter.queue.newsletter_rendered_subject }</a>
|
||||
</strong>
|
||||
{ actions }
|
||||
</td>
|
||||
|
@ -12,8 +12,8 @@ import { QueueMixin, StatisticsMixin } from 'newsletters/listings/mixins.jsx'
|
||||
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
|
||||
|
||||
const messages = {
|
||||
onTrash(response) {
|
||||
const count = ~~response;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -23,12 +23,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete(response) {
|
||||
const count = ~~response;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -38,12 +38,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore(response) {
|
||||
const count = ~~response;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -53,7 +53,7 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -122,16 +122,23 @@ const newsletter_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'duplicate',
|
||||
data: newsletter.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response.subject !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.subject
|
||||
)
|
||||
data: {
|
||||
id: newsletter.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.data.subject
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -15,8 +15,8 @@ const mailpoet_segments = window.mailpoet_segments || {};
|
||||
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
|
||||
|
||||
const messages = {
|
||||
onTrash(response) {
|
||||
const count = ~~response;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -26,12 +26,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete(response) {
|
||||
const count = ~~response;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -41,12 +41,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore(response) {
|
||||
const count = ~~response;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -56,7 +56,7 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -125,16 +125,23 @@ const newsletter_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'duplicate',
|
||||
data: newsletter.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response.subject !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.subject
|
||||
)
|
||||
data: {
|
||||
id: newsletter.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.data.subject
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -62,7 +62,7 @@ const _monthDayValues = _.object(
|
||||
} else {
|
||||
label = MailPoet.I18n.t('nth').replace("%$1d", day + 1);
|
||||
}
|
||||
return [day, label];
|
||||
return [day + 1, label];
|
||||
}
|
||||
)
|
||||
);
|
||||
|
@ -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) {
|
||||
|
@ -1,11 +1,13 @@
|
||||
define(
|
||||
[
|
||||
'mailpoet',
|
||||
'newsletters/types/notification/scheduling.jsx'
|
||||
'newsletters/types/notification/scheduling.jsx',
|
||||
'underscore'
|
||||
],
|
||||
function(
|
||||
MailPoet,
|
||||
Scheduling
|
||||
Scheduling,
|
||||
_
|
||||
) {
|
||||
|
||||
var settings = window.mailpoet_settings || {};
|
||||
@ -40,11 +42,15 @@ define(
|
||||
return !!(!segment.deleted_at);
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
var name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
return name;
|
||||
return segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
},
|
||||
transformChangedValue: function(segment_ids) {
|
||||
var all_segments = this.state.items;
|
||||
return _.map(segment_ids, function(id) {
|
||||
return _.find(all_segments, function(segment) {
|
||||
return segment.id === id;
|
||||
});
|
||||
});
|
||||
},
|
||||
validation: {
|
||||
'data-parsley-required': true,
|
||||
|
@ -346,11 +346,15 @@ define(
|
||||
return !!(!segment.deleted_at);
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
var name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
return name;
|
||||
return segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
},
|
||||
transformChangedValue: function(segment_ids) {
|
||||
var all_segments = this.state.items;
|
||||
return _.map(segment_ids, function(id) {
|
||||
return _.find(all_segments, function(segment) {
|
||||
return segment.id === id;
|
||||
});
|
||||
});
|
||||
},
|
||||
validation: {
|
||||
'data-parsley-required': true,
|
||||
|
@ -28,17 +28,16 @@ define(
|
||||
type: type,
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.context.router.push(`/template/${response.newsletter.id}`);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.context.router.push(`/template/${response.data.id}`);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
|
@ -50,17 +50,16 @@ define(
|
||||
type: 'notification',
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}),
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${newsletterId}`);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import _ from 'underscore'
|
||||
import React from 'react'
|
||||
import MailPoet from 'mailpoet'
|
||||
import Select from 'form/fields/select.jsx'
|
||||
import {
|
||||
intervalValues,
|
||||
|
@ -25,19 +25,18 @@ define(
|
||||
endpoint: 'newsletters',
|
||||
action: 'create',
|
||||
data: {
|
||||
type: 'standard',
|
||||
type: 'standard'
|
||||
}
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
|
@ -27,10 +27,7 @@ const events = {
|
||||
const availableSegmentValues = _.object(_.map(
|
||||
availableSegments,
|
||||
function(segment) {
|
||||
let name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
let name = segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
return [segment.id, name];
|
||||
}
|
||||
));
|
||||
@ -113,17 +110,16 @@ const WelcomeScheduling = React.createClass({
|
||||
type: 'welcome',
|
||||
options: this.state
|
||||
}
|
||||
}).done(function(response) {
|
||||
if (response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${ newsletterId }`);
|
||||
|
@ -57,18 +57,17 @@ define(
|
||||
data: _.extend({}, this.state, {
|
||||
type: 'welcome',
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}),
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
})
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${newsletterId}`);
|
||||
|
@ -40,33 +40,40 @@ function(
|
||||
// ajax request
|
||||
MailPoet.Ajax.post({
|
||||
url: MailPoetForm.ajax_url,
|
||||
token: MailPoetForm.token,
|
||||
token: data.token,
|
||||
endpoint: 'subscribers',
|
||||
action: 'subscribe',
|
||||
data: data
|
||||
}).fail(function(response) {
|
||||
form.find('.mailpoet_validate_error').html(
|
||||
response.errors.map(function(error) {
|
||||
return error.message;
|
||||
}).join('<br />')
|
||||
).show();
|
||||
}).done(function(response) {
|
||||
if(response.result === false) {
|
||||
form.find('.mailpoet_validate_error').html(
|
||||
response.errors.join('<br />')
|
||||
).show();
|
||||
// successfully subscribed
|
||||
if (
|
||||
response.meta !== undefined
|
||||
&& response.meta.redirect_url !== undefined
|
||||
) {
|
||||
// go to page
|
||||
window.location.href = response.meta.redirect_url;
|
||||
} else {
|
||||
// successfully subscribed
|
||||
if(response.page !== undefined) {
|
||||
// go to page
|
||||
window.location.href = response.page;
|
||||
} else {
|
||||
// display success message
|
||||
form.find('.mailpoet_validate_success').show();
|
||||
}
|
||||
|
||||
// reset form
|
||||
form.trigger('reset');
|
||||
// reset validation
|
||||
parsley.reset();
|
||||
// display success message
|
||||
form.find('.mailpoet_validate_success').show();
|
||||
}
|
||||
|
||||
// reset form
|
||||
form.trigger('reset');
|
||||
// reset validation
|
||||
parsley.reset();
|
||||
|
||||
// resize iframe
|
||||
if(window.frameElement !== null) {
|
||||
if (
|
||||
window.frameElement !== null
|
||||
&& MailPoet !== undefined
|
||||
&& MailPoet['Iframe']
|
||||
) {
|
||||
MailPoet.Iframe.autoSize(window.frameElement);
|
||||
}
|
||||
});
|
||||
|
@ -36,48 +36,48 @@ var columns = [
|
||||
];
|
||||
|
||||
const messages = {
|
||||
onTrash: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentTrashed')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentDeleted')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentRestored')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -106,16 +106,23 @@ const item_actions = [
|
||||
{
|
||||
name: 'duplicate_segment',
|
||||
label: MailPoet.I18n.t('duplicate'),
|
||||
onClick: function(item, refresh) {
|
||||
onClick: (item, refresh) => {
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'segments',
|
||||
action: 'duplicate',
|
||||
data: item.id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: item.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('listDuplicated')).replace('%$1s', response.name)
|
||||
MailPoet.I18n.t('listDuplicated').replace('%$1s', response.data.name)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
display: function(segment) {
|
||||
@ -127,7 +134,7 @@ const item_actions = [
|
||||
link: function(item) {
|
||||
return (
|
||||
<a
|
||||
href="https://www.mailpoet.com/#TODO"
|
||||
href="http://docs.mailpoet.com/article/133-the-wordpress-users-list"
|
||||
target="_blank"
|
||||
>{MailPoet.I18n.t('readMore')}</a>
|
||||
);
|
||||
|
@ -75,6 +75,9 @@ define(
|
||||
filter: function(segment) {
|
||||
return !!(!segment.deleted_at && segment.type === 'default');
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
return segment.name + ' ('+ segment.subscribers +')';
|
||||
},
|
||||
getSearchLabel: function(segment, subscriber) {
|
||||
let label = '';
|
||||
|
||||
|
@ -95,15 +95,18 @@ define(
|
||||
});
|
||||
};
|
||||
|
||||
// set confirmed subscribers export option to false
|
||||
exportData.exportConfirmedOption = false;
|
||||
|
||||
renderSegmentsAndFields(subscriberFieldsContainerElement, subscriberFieldsSelect2);
|
||||
renderSegmentsAndFields(segmentsContainerElement, segments);
|
||||
|
||||
subscriberFieldsContainerElement.select2('val', [
|
||||
'status',
|
||||
subscriberFieldsContainerElement.val([
|
||||
'email',
|
||||
'first_name',
|
||||
'last_name'
|
||||
]);
|
||||
'last_name',
|
||||
'status'
|
||||
]).trigger("change");
|
||||
|
||||
exportConfirmedOptionElement.change(function () {
|
||||
var selectedSegments = segmentsContainerElement.val();
|
||||
|
@ -7,7 +7,6 @@ define(
|
||||
'handlebars',
|
||||
'papaparse',
|
||||
'asyncqueue',
|
||||
'xss',
|
||||
'moment',
|
||||
'select2'
|
||||
],
|
||||
@ -19,7 +18,6 @@ define(
|
||||
Handlebars,
|
||||
Papa,
|
||||
AsyncQueue,
|
||||
xss,
|
||||
Moment
|
||||
) {
|
||||
if (!jQuery('#mailpoet_subscribers_import').length) {
|
||||
@ -337,9 +335,9 @@ define(
|
||||
complete: function (CSV) {
|
||||
for (var rowCount in CSV.data) {
|
||||
var rowData = CSV.data[rowCount].map(function (el) {
|
||||
return filterXSS(el.trim());
|
||||
}),
|
||||
rowColumnCount = rowData.length;
|
||||
return el.trim();
|
||||
});
|
||||
var rowColumnCount = rowData.length;
|
||||
// set the number of row elements based on the first non-empty row
|
||||
if (columnCount === null) {
|
||||
columnCount = rowColumnCount;
|
||||
@ -530,15 +528,11 @@ define(
|
||||
width: '20em',
|
||||
templateResult: function (item) {
|
||||
item.subscriberCount = parseInt(item.subscriberCount);
|
||||
return (item.subscriberCount > 0)
|
||||
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
|
||||
: item.name;
|
||||
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
item.subscriberCount = parseInt(item.subscriberCount);
|
||||
return (item.subscriberCount > 0)
|
||||
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
|
||||
: item.name;
|
||||
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
|
||||
}
|
||||
})
|
||||
.change(function () {
|
||||
@ -586,7 +580,8 @@ define(
|
||||
}).done(function(response) {
|
||||
mailpoetSegments.push({
|
||||
'id': response.data.id,
|
||||
'name': response.data.name
|
||||
'name': response.data.name,
|
||||
'subscriberCount': 0
|
||||
});
|
||||
|
||||
var selected_values = segmentSelectElement.val();
|
||||
@ -673,8 +668,15 @@ define(
|
||||
return options.fn(displayedColumns);
|
||||
});
|
||||
|
||||
// sanitize unsafe data
|
||||
Handlebars.registerHelper('sanitize_data', function(data) {
|
||||
return (data instanceof Handlebars.SafeString) ?
|
||||
data :
|
||||
new Handlebars.SafeString(Handlebars.Utils.escapeExpression(data));
|
||||
});
|
||||
|
||||
// start array index from 1
|
||||
Handlebars.registerHelper('show_real_index', function (index) {
|
||||
Handlebars.registerHelper('calculate_index', function (index) {
|
||||
var index = parseInt(index);
|
||||
// display filler data (e.g., ellipsis) if we've reached the maximum number of rows and
|
||||
// subscribers count is greater than the maximum number of rows we're displaying
|
||||
@ -869,7 +871,7 @@ define(
|
||||
'<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
|
||||
+ MailPoet.I18n.t('emptyFirstRowDate')
|
||||
+ '</span>';
|
||||
+ '</span> ';
|
||||
preventNextStep = true;
|
||||
}
|
||||
else {
|
||||
@ -883,7 +885,9 @@ define(
|
||||
jQuery(matchedColumn.element).data('validation-rule', validationRule);
|
||||
break;
|
||||
}
|
||||
if (validationRule === 'datetime') validationRule = Moment.ISO_8601;
|
||||
if (validationRule === 'datetime') {
|
||||
validationRule = Moment.ISO_8601;
|
||||
}
|
||||
}
|
||||
}
|
||||
jQuery.map(subscribersClone.subscribers, function (data, index) {
|
||||
@ -892,18 +896,22 @@ define(
|
||||
var date = Moment(rowData, testedFormat, true);
|
||||
// validate date
|
||||
if (date.isValid()) {
|
||||
data[matchedColumn.index] +=
|
||||
'<span class="mailpoet_data_match" title="'
|
||||
+ MailPoet.I18n.t('verifyDateMatch') + '">'
|
||||
+ MailPoet.Date.format(date)
|
||||
+ '</span>';
|
||||
data[matchedColumn.index] = new Handlebars.SafeString(
|
||||
Handlebars.Utils.escapeExpression(data[matchedColumn.index])
|
||||
+ '<span class="mailpoet_data_match" title="'
|
||||
+ MailPoet.I18n.t('verifyDateMatch') + '">'
|
||||
+ MailPoet.Date.format(date)
|
||||
+ '</span> '
|
||||
);
|
||||
}
|
||||
else {
|
||||
data[matchedColumn.index] +=
|
||||
'<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
data[matchedColumn.index] = new Handlebars.SafeString(
|
||||
Handlebars.Utils.escapeExpression(data[matchedColumn.index])
|
||||
+ '<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
|
||||
+ MailPoet.I18n.t('dateMatchError')
|
||||
+ '</span>';
|
||||
+ (new Handlebars.SafeString(MailPoet.I18n.t('dateMatchError')))
|
||||
+ '</span> '
|
||||
);
|
||||
preventNextStep = true;
|
||||
};
|
||||
});
|
||||
|
@ -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' }
|
||||
/>
|
||||
|
48
build.sh
@ -1,25 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Translations (npm install & composer install need to be run before)
|
||||
echo '[BUILD] Generating translations'
|
||||
./do makepot
|
||||
|
||||
plugin_name='mailpoet'
|
||||
|
||||
# Remove previous build.
|
||||
echo '[BUILD] Removing previous build'
|
||||
rm $plugin_name.zip
|
||||
|
||||
# Create temp dir.
|
||||
echo '[BUILD] Creating temporary directory'
|
||||
mkdir $plugin_name
|
||||
|
||||
# Production assets.
|
||||
echo '[BUILD] Generating production CSS and JS assets'
|
||||
rm -rf node_modules
|
||||
npm install
|
||||
./do compile:all
|
||||
|
||||
# Production libraries.
|
||||
./composer.phar install --no-dev
|
||||
|
||||
# Translations
|
||||
./do makepot
|
||||
echo '[BUILD] Fetching production libraries'
|
||||
rm -rf vendor
|
||||
./composer.phar install --no-dev --prefer-dist --optimize-autoloader --no-scripts
|
||||
|
||||
# Copy release folders.
|
||||
echo '[BUILD] Copying release folders'
|
||||
cp -Rf lang $plugin_name
|
||||
cp -RfL assets $plugin_name
|
||||
cp -Rf lib $plugin_name
|
||||
@ -28,18 +35,49 @@ 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
|
||||
echo '[BUILD] Removing obsolete files from vendor libraries'
|
||||
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
|
||||
echo '[BUILD] Removing unit tests from vendor libraries'
|
||||
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
|
||||
|
||||
# Remove risky files from 3rd party extensions
|
||||
echo '[BUILD] Removing risky and demo files from vendor libraries'
|
||||
rm -f $plugin_name/vendor/j4mie/idiorm/demo.php
|
||||
rm -f $plugin_name/vendor/cerdic/css-tidy/css_optimiser.php
|
||||
|
||||
# Copy release files.
|
||||
cp LICENSE $plugin_name
|
||||
echo '[BUILD] Copying release files'
|
||||
cp license.txt $plugin_name
|
||||
cp index.php $plugin_name
|
||||
cp $plugin_name.php $plugin_name
|
||||
cp readme.txt $plugin_name
|
||||
cp uninstall.php $plugin_name
|
||||
|
||||
# Add index files if they don't exist to all folders
|
||||
echo '[BUILD] Adding index files to all project folders'
|
||||
find $plugin_name -type d -exec touch {}/index.php \;
|
||||
|
||||
# Zip final release.
|
||||
echo '[BUILD] Creating final release zip'
|
||||
zip -r $plugin_name.zip $plugin_name
|
||||
|
||||
# Remove temp dir.
|
||||
echo '[BUILD] Removing temp directory'
|
||||
rm -rf $plugin_name
|
||||
|
||||
# Reinstall dev dependencies.
|
||||
echo '[BUILD] Reinstalling dev dependencies'
|
||||
./composer.phar install
|
||||
|
||||
echo '[BUILD] Build finished!'
|
||||
|
66
circle.yml
Normal file
@ -0,0 +1,66 @@
|
||||
machine:
|
||||
timezone:
|
||||
UTC
|
||||
|
||||
hosts:
|
||||
mailpoet.loc: 127.0.0.1
|
||||
|
||||
## 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
|
||||
- curl -sS https://getcomposer.org/installer | php
|
||||
- ./composer.phar install
|
||||
- ./do install
|
||||
# Set up Wordpress
|
||||
# No password is required for the MySQL user `ubuntu`
|
||||
- mysql -u ubuntu -e "create database wordpress"
|
||||
# Use cURL to fetch WP-CLI
|
||||
- curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
||||
# Make sure WP-CLI is executable
|
||||
- chmod +x wp-cli.phar
|
||||
# Download WordPress into `wordpress` directory
|
||||
- ./wp-cli.phar core download --allow-root --path=wordpress
|
||||
# Generate `wp-config.php` file
|
||||
- echo "define(\"WP_DEBUG\", true);" | ./wp-cli.phar core config --allow-root --dbname=wordpress --dbuser=ubuntu --dbhost=127.0.0.1:3306 --path=wordpress --extra-php
|
||||
# Install WordPress
|
||||
- ./wp-cli.phar core install --allow-root --admin_name=admin --admin_password=admin --admin_email=admin@mailpoet.loc --url=http://mailpoet.loc:8080 --title=WordPress --path=wordpress
|
||||
# Softlink MailPoet to plugin path
|
||||
- ln -s ../../.. wordpress/wp-content/plugins/mailpoet
|
||||
# Activate MailPoet
|
||||
- ./wp-cli.phar plugin activate mailpoet --path=wordpress
|
||||
# Create .env file with correct path to WP installation
|
||||
- echo "WP_TEST_PATH=\"/home/ubuntu/mailpoet/wordpress\"" > .env
|
||||
|
||||
# Enable XDebug for coverage reports.
|
||||
# Comment out if not running PHP coverage reports, for performance
|
||||
#- sed -i 's/^;//' /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
|
||||
|
||||
## tests override
|
||||
test:
|
||||
override:
|
||||
# Add default timezone to PHP's configuration (required for PHP >=5.4)
|
||||
- echo "date.timezone = UTC" > /opt/circleci/php/$(phpenv global)/etc/conf.d/date.ini
|
||||
# Run QA scripts
|
||||
- ./do qa
|
||||
# Run JS tests
|
||||
- mkdir $CIRCLE_TEST_REPORTS/mocha
|
||||
- ./do t:j $CIRCLE_TEST_REPORTS/mocha/junit.xml
|
||||
|
||||
# Run PHP tests
|
||||
- ./do t:u --xml
|
||||
# Uncomment to run coverage tests instead
|
||||
#- ./do t:c --xml
|
||||
# Copy the report
|
||||
- mkdir $CIRCLE_TEST_REPORTS/codeception
|
||||
- cp tests/_output/report.xml $CIRCLE_TEST_REPORTS/codeception/report.xml
|
||||
# Uncomment to copy PHP coverage report
|
||||
#- cp tests/_output/coverage.xml $CIRCLE_TEST_REPORTS/codeception/coverage.xml
|
@ -10,6 +10,7 @@ settings:
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
log: true
|
||||
strict_xml: true
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
||||
@ -26,6 +27,7 @@ coverage:
|
||||
include:
|
||||
- lib/*
|
||||
exclude:
|
||||
- lib/Config/PopulatorData/*
|
||||
- lib/Util/Sudzy/*
|
||||
- lib/Util/CSS.php
|
||||
- lib/Util/Helpers.php
|
||||
|
@ -8,13 +8,10 @@
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"twig/twig": "1.*",
|
||||
"phpmailer/phpmailer": "~5.2",
|
||||
"cerdic/css-tidy": "*",
|
||||
"sunra/php-simple-html-dom-parser": "*",
|
||||
"tburry/pquery": "*",
|
||||
"j4mie/paris": "1.5.4",
|
||||
"swiftmailer/swiftmailer": "^5.4",
|
||||
"phpseclib/phpseclib": "*",
|
||||
"mtdowling/cron-expression": "^1.1",
|
||||
"nesbot/carbon": "^1.21",
|
||||
"soundasleep/html2text": "dev-master"
|
||||
@ -26,12 +23,18 @@
|
||||
"vlucas/phpdotenv": "*",
|
||||
"umpirsky/twig-gettext-extractor": "1.1.*",
|
||||
"raveren/kint": "^1.0",
|
||||
"squizlabs/php_codesniffer": "2.*"
|
||||
"squizlabs/php_codesniffer": "*",
|
||||
"wimg/php-compatibility": "*",
|
||||
"simplyadmire/composer-plugins" : "@dev"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"MailPoet\\": "lib/",
|
||||
"Sudzy\\": "lib/Util/Sudzy"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-update-cmd": "rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rpd vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility",
|
||||
"post-install-cmd": "rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rpd vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility"
|
||||
}
|
||||
}
|
||||
}
|
841
composer.lock
generated
4160
lang/mailpoet.pot
181
lib/API/API.php
@ -1,124 +1,136 @@
|
||||
<?php
|
||||
namespace MailPoet\API;
|
||||
|
||||
use \MailPoet\Util\Security;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class API {
|
||||
function __construct() {
|
||||
}
|
||||
private $_endpoint;
|
||||
private $_method;
|
||||
private $_token;
|
||||
|
||||
private $_endpoint_class;
|
||||
private $_data = array();
|
||||
|
||||
function init() {
|
||||
// security token
|
||||
// Admin Security token
|
||||
add_action(
|
||||
'admin_head',
|
||||
array($this, 'setToken')
|
||||
);
|
||||
|
||||
// Admin API (Ajax only)
|
||||
// ajax (logged in users)
|
||||
add_action(
|
||||
'wp_ajax_mailpoet',
|
||||
array($this, 'setupAdmin')
|
||||
array($this, 'setupAjax')
|
||||
);
|
||||
|
||||
// Public API (Ajax)
|
||||
// ajax (logged out users)
|
||||
add_action(
|
||||
'wp_ajax_nopriv_mailpoet',
|
||||
array($this, 'setupPublic')
|
||||
);
|
||||
// Public API (Post)
|
||||
add_action(
|
||||
'admin_post_nopriv_mailpoet',
|
||||
array($this, 'setupPublic')
|
||||
array($this, 'setupAjax')
|
||||
);
|
||||
}
|
||||
|
||||
function setupAdmin() {
|
||||
function setupAjax() {
|
||||
$this->getRequestData();
|
||||
|
||||
if($this->checkToken() === false) {
|
||||
(new ErrorResponse(
|
||||
$error_response = new ErrorResponse(
|
||||
array(
|
||||
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
|
||||
Error::UNAUTHORIZED => __('Invalid request.', 'mailpoet')
|
||||
),
|
||||
array(),
|
||||
Response::STATUS_UNAUTHORIZED
|
||||
))->send();
|
||||
}
|
||||
|
||||
if($this->checkPermissions() === false) {
|
||||
(new ErrorResponse(
|
||||
array(
|
||||
Error::FORBIDDEN => __('You do not have the required permissions.')
|
||||
),
|
||||
array(),
|
||||
Response::STATUS_FORBIDDEN
|
||||
))->send();
|
||||
);
|
||||
$error_response->send();
|
||||
}
|
||||
|
||||
$this->processRoute();
|
||||
}
|
||||
|
||||
function setupPublic() {
|
||||
if($this->checkToken() === false) {
|
||||
(new ErrorResponse(
|
||||
function getRequestData() {
|
||||
$this->_endpoint = isset($_POST['endpoint'])
|
||||
? trim($_POST['endpoint'])
|
||||
: null;
|
||||
$this->_method = isset($_POST['method'])
|
||||
? trim($_POST['method'])
|
||||
: null;
|
||||
$this->_token = isset($_POST['token'])
|
||||
? trim($_POST['token'])
|
||||
: null;
|
||||
|
||||
if(!$this->_endpoint || !$this->_method) {
|
||||
// throw exception bad request
|
||||
$error_response = new ErrorResponse(
|
||||
array(
|
||||
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
|
||||
Error::BAD_REQUEST => __('Invalid request.', 'mailpoet')
|
||||
),
|
||||
array(),
|
||||
Response::STATUS_UNAUTHORIZED
|
||||
))->send();
|
||||
}
|
||||
Response::STATUS_BAD_REQUEST
|
||||
);
|
||||
$error_response->send();
|
||||
} else {
|
||||
$this->_endpoint_class = (
|
||||
__NAMESPACE__."\\Endpoints\\".ucfirst($this->_endpoint)
|
||||
);
|
||||
|
||||
$this->processRoute();
|
||||
$this->_data = isset($_POST['data'])
|
||||
? stripslashes_deep($_POST['data'])
|
||||
: array();
|
||||
|
||||
// remove reserved keywords from data
|
||||
if(is_array($this->_data) && !empty($this->_data)) {
|
||||
// filter out reserved keywords from data
|
||||
$reserved_keywords = array(
|
||||
'token',
|
||||
'endpoint',
|
||||
'method',
|
||||
'mailpoet_redirect'
|
||||
);
|
||||
$this->_data = array_diff_key(
|
||||
$this->_data,
|
||||
array_flip($reserved_keywords)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function processRoute() {
|
||||
$class = ucfirst($_POST['endpoint']);
|
||||
$endpoint = __NAMESPACE__ . "\\Endpoints\\" . $class;
|
||||
$method = $_POST['method'];
|
||||
|
||||
$doing_ajax = (bool)(defined('DOING_AJAX') && DOING_AJAX);
|
||||
|
||||
if($doing_ajax) {
|
||||
$data = isset($_POST['data']) ? stripslashes_deep($_POST['data']) : array();
|
||||
} else {
|
||||
$data = $_POST;
|
||||
}
|
||||
|
||||
if(is_array($data) && !empty($data)) {
|
||||
// filter out reserved keywords from data
|
||||
$reserved_keywords = array(
|
||||
'token',
|
||||
'endpoint',
|
||||
'method',
|
||||
'mailpoet_redirect'
|
||||
);
|
||||
$data = array_diff_key($data, array_flip($reserved_keywords));
|
||||
}
|
||||
|
||||
try {
|
||||
$endpoint = new $endpoint();
|
||||
$response = $endpoint->$method($data);
|
||||
$endpoint = new $this->_endpoint_class();
|
||||
|
||||
// TODO: remove this condition once the API unification is complete
|
||||
if(is_object($response)) {
|
||||
$response->send();
|
||||
} else {
|
||||
// LEGACY API
|
||||
wp_send_json($response);
|
||||
// check the accessibility of the requested endpoint's action
|
||||
// by default, an endpoint's action is considered "private"
|
||||
$permissions = $endpoint->permissions;
|
||||
if(
|
||||
array_key_exists($this->_method, $permissions) === false
|
||||
||
|
||||
$permissions[$this->_method] !== Access::ALL
|
||||
) {
|
||||
if($this->checkPermissions() === false) {
|
||||
$error_response = new ErrorResponse(
|
||||
array(
|
||||
Error::FORBIDDEN => __(
|
||||
'You do not have the required permissions.',
|
||||
'mailpoet'
|
||||
)
|
||||
),
|
||||
array(),
|
||||
Response::STATUS_FORBIDDEN
|
||||
);
|
||||
$error_response->send();
|
||||
}
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
(new ErrorResponse(
|
||||
array($e->getCode() => $e->getMessage())
|
||||
))->send();
|
||||
}
|
||||
}
|
||||
|
||||
function setToken() {
|
||||
$global = '<script type="text/javascript">';
|
||||
$global .= 'var mailpoet_token = "'.Security::generateToken().'";';
|
||||
$global .= '</script>';
|
||||
echo $global;
|
||||
$response = $endpoint->{$this->_method}($this->_data);
|
||||
$response->send();
|
||||
} catch(\Exception $e) {
|
||||
$error_response = new ErrorResponse(
|
||||
array($e->getCode() => $e->getMessage())
|
||||
);
|
||||
$error_response->send();
|
||||
}
|
||||
}
|
||||
|
||||
function checkPermissions() {
|
||||
@ -126,10 +138,15 @@ class API {
|
||||
}
|
||||
|
||||
function checkToken() {
|
||||
return (
|
||||
isset($_POST['token'])
|
||||
&&
|
||||
wp_verify_nonce($_POST['token'], 'mailpoet_token')
|
||||
);
|
||||
return wp_verify_nonce($this->_token, 'mailpoet_token');
|
||||
}
|
||||
|
||||
function setToken() {
|
||||
$global = '<script type="text/javascript">';
|
||||
$global .= 'var mailpoet_token = "';
|
||||
$global .= Security::generateToken();
|
||||
$global .= '";';
|
||||
$global .= '</script>';
|
||||
echo $global;
|
||||
}
|
||||
}
|
12
lib/API/Access.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace MailPoet\API;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
final class Access {
|
||||
const ALL = 'all';
|
||||
|
||||
private function __construct() {
|
||||
|
||||
}
|
||||
}
|
@ -5,6 +5,8 @@ if(!defined('ABSPATH')) exit;
|
||||
|
||||
abstract class Endpoint {
|
||||
|
||||
public $permissions = array();
|
||||
|
||||
function successResponse(
|
||||
$data = array(), $meta = array(), $status = Response::STATUS_OK
|
||||
) {
|
||||
@ -16,7 +18,7 @@ abstract class Endpoint {
|
||||
) {
|
||||
if(empty($errors)) {
|
||||
$errors = array(
|
||||
Error::UNKNOWN => __('An unknown error occurred.')
|
||||
Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet')
|
||||
);
|
||||
}
|
||||
return new ErrorResponse($errors, $meta, $status);
|
||||
@ -25,7 +27,7 @@ abstract class Endpoint {
|
||||
function badRequest($errors = array(), $meta = array()) {
|
||||
if(empty($errors)) {
|
||||
$errors = array(
|
||||
Error::BAD_REQUEST => __('Invalid request parameters.')
|
||||
Error::BAD_REQUEST => __('Invalid request parameters.', 'mailpoet')
|
||||
);
|
||||
}
|
||||
return new ErrorResponse($errors, $meta, Response::STATUS_BAD_REQUEST);
|
||||
|
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
use \MailPoet\API\Endpoint as APIEndpoint;
|
||||
use \MailPoet\API\Error as APIError;
|
||||
|
||||
use MailPoet\Cron\CronHelper;
|
||||
use MailPoet\Models\Setting;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Cron extends APIEndpoint {
|
||||
function getStatus() {
|
||||
$daemon = Setting::getValue(CronHelper::DAEMON_SETTING, false);
|
||||
|
||||
if($daemon === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('Cron daemon is not running.')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse($daemon);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ if(!defined('ABSPATH')) exit;
|
||||
|
||||
class CustomFields extends APIEndpoint {
|
||||
function getAll() {
|
||||
$collection = CustomField::findMany();
|
||||
$collection = CustomField::orderByAsc('created_at')->findMany();
|
||||
$custom_fields = array_map(function($custom_field) {
|
||||
return $custom_field->asArray();
|
||||
}, $collection);
|
||||
@ -21,7 +21,7 @@ class CustomFields extends APIEndpoint {
|
||||
$custom_field = CustomField::findOne($id);
|
||||
if($custom_field === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This custom field does not exist.')
|
||||
APIError::NOT_FOUND => __('This custom field does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$custom_field->delete();
|
||||
@ -48,7 +48,7 @@ class CustomFields extends APIEndpoint {
|
||||
$custom_field = CustomField::findOne($id);
|
||||
if($custom_field === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This custom field does not exist.')
|
||||
APIError::NOT_FOUND => __('This custom field does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse($custom_field->asArray());
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
use MailPoet\API\Endpoint as APIEndpoint;
|
||||
use MailPoet\API\Error as APIError;
|
||||
|
||||
use \MailPoet\Models\Form;
|
||||
use \MailPoet\Models\StatisticsForms;
|
||||
@ -9,16 +11,17 @@ use \MailPoet\Form\Util;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Forms {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function get($id = false) {
|
||||
class Forms extends APIEndpoint {
|
||||
function get($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
$form = $form->asArray();
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse($form->asArray());
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
function listing($data = array()) {
|
||||
@ -29,8 +32,8 @@ class Forms {
|
||||
|
||||
$listing_data = $listing->get();
|
||||
|
||||
// fetch segments relations for each returned item
|
||||
foreach($listing_data['items'] as $key => $form) {
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $form) {
|
||||
$form = $form->asArray();
|
||||
|
||||
$form['signups'] = StatisticsForms::getTotalSignups($form['id']);
|
||||
@ -40,40 +43,45 @@ class Forms {
|
||||
? $form['settings']['segments']
|
||||
: array()
|
||||
);
|
||||
$listing_data['items'][$key] = $form;
|
||||
|
||||
$data[] = $form;
|
||||
}
|
||||
|
||||
return $listing_data;
|
||||
return $this->successResponse($data, array(
|
||||
'count' => $listing_data['count'],
|
||||
'filters' => $listing_data['filters'],
|
||||
'groups' => $listing_data['groups']
|
||||
));
|
||||
}
|
||||
|
||||
function create() {
|
||||
// create new form
|
||||
$form_data = array(
|
||||
'name' => __('New form'),
|
||||
'name' => __('New form', 'mailpoet'),
|
||||
'body' => array(
|
||||
array(
|
||||
'id' => 'email',
|
||||
'name' => __('Email'),
|
||||
'name' => __('Email', 'mailpoet'),
|
||||
'type' => 'text',
|
||||
'static' => true,
|
||||
'params' => array(
|
||||
'label' => __('Email'),
|
||||
'label' => __('Email', 'mailpoet'),
|
||||
'required' => true
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'submit',
|
||||
'name' => __('Submit'),
|
||||
'name' => __('Submit', 'mailpoet'),
|
||||
'type' => 'submit',
|
||||
'static' => true,
|
||||
'params' => array(
|
||||
'label' => __('Subscribe!')
|
||||
'label' => __('Subscribe!', 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
'settings' => array(
|
||||
'on_success' => 'message',
|
||||
'success_message' => __('Check your inbox or spam folder to confirm your subscription.'),
|
||||
'success_message' => __('Check your inbox or spam folder to confirm your subscription.', 'mailpoet'),
|
||||
'segments' => null,
|
||||
'segments_selected_by' => 'admin'
|
||||
)
|
||||
@ -87,14 +95,10 @@ class Forms {
|
||||
$errors = $form->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $errors
|
||||
);
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
return array(
|
||||
'result' => true,
|
||||
'form_id' => $form->id()
|
||||
return $this->successResponse(
|
||||
Form::findOne($form->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -109,76 +113,74 @@ class Forms {
|
||||
// styles
|
||||
$css = new Util\Styles(FormRenderer::getStyles($data));
|
||||
|
||||
return array(
|
||||
return $this->successResponse(array(
|
||||
'html' => $html,
|
||||
'css' => $css->render()
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
function exportsEditor($id) {
|
||||
$exports = false;
|
||||
|
||||
function exportsEditor($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
|
||||
if($form !== false) {
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$exports = Util\Export::getAll($form->asArray());
|
||||
return $this->successResponse($exports);
|
||||
}
|
||||
|
||||
return $exports;
|
||||
}
|
||||
|
||||
function saveEditor($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
|
||||
$form_id = (isset($data['id']) ? (int)$data['id'] : 0);
|
||||
$name = (isset($data['name']) ? $data['name'] : __('New form'));
|
||||
$name = (isset($data['name']) ? $data['name'] : __('New form', 'mailpoet'));
|
||||
$body = (isset($data['body']) ? $data['body'] : array());
|
||||
$settings = (isset($data['settings']) ? $data['settings'] : array());
|
||||
$styles = (isset($data['styles']) ? $data['styles'] : '');
|
||||
|
||||
if(empty($body) || empty($settings)) {
|
||||
// error
|
||||
return false;
|
||||
} else {
|
||||
// check if the form is used as a widget
|
||||
$is_widget = false;
|
||||
$widgets = get_option('widget_mailpoet_form');
|
||||
if(!empty($widgets)) {
|
||||
foreach($widgets as $widget) {
|
||||
if(isset($widget['form']) && (int)$widget['form'] === $form_id) {
|
||||
$is_widget = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if the user gets to pick his own lists
|
||||
// or if it's selected by the admin
|
||||
$has_segment_selection = false;
|
||||
|
||||
foreach($body as $i => $block) {
|
||||
if($block['type'] === 'segment') {
|
||||
$has_segment_selection = true;
|
||||
if(!empty($block['params']['values'])) {
|
||||
$list_selection = array_filter(
|
||||
array_map(function($segment) {
|
||||
return (isset($segment['id'])
|
||||
? (int)$segment['id']
|
||||
: null
|
||||
);
|
||||
}, $block['params']['values'])
|
||||
);
|
||||
}
|
||||
// check if the form is used as a widget
|
||||
$is_widget = false;
|
||||
$widgets = get_option('widget_mailpoet_form');
|
||||
if(!empty($widgets)) {
|
||||
foreach($widgets as $widget) {
|
||||
if(isset($widget['form']) && (int)$widget['form'] === $form_id) {
|
||||
$is_widget = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check list selection
|
||||
if($has_segment_selection === true) {
|
||||
$settings['segments_selected_by'] = 'user';
|
||||
} else {
|
||||
$settings['segments_selected_by'] = 'admin';
|
||||
// check if the user gets to pick his own lists
|
||||
// or if it's selected by the admin
|
||||
$has_segment_selection = false;
|
||||
foreach($body as $i => $block) {
|
||||
if($block['type'] === 'segment') {
|
||||
$has_segment_selection = true;
|
||||
if(!empty($block['params']['values'])) {
|
||||
$list_selection = array_filter(
|
||||
array_map(function($segment) {
|
||||
return (isset($segment['id'])
|
||||
? $segment['id']
|
||||
: null
|
||||
);
|
||||
}, $block['params']['values'])
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// check list selection
|
||||
if($has_segment_selection === true) {
|
||||
$settings['segments_selected_by'] = 'user';
|
||||
$settings['segments'] = $list_selection;
|
||||
} else {
|
||||
$settings['segments_selected_by'] = 'admin';
|
||||
}
|
||||
|
||||
$form = Form::createOrUpdate(array(
|
||||
'id' => $form_id,
|
||||
'name' => $name,
|
||||
@ -187,64 +189,101 @@ class Forms {
|
||||
'styles' => $styles
|
||||
));
|
||||
|
||||
if($form->getErrors() === false) {
|
||||
return array(
|
||||
'result' => true,
|
||||
'is_widget' => $is_widget
|
||||
);
|
||||
$errors = $form->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $form->getErrors()
|
||||
return $this->successResponse(
|
||||
Form::findOne($form->id)->asArray(),
|
||||
array('is_widget' => $is_widget)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($id) {
|
||||
function restore($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$form->restore();
|
||||
}
|
||||
return ($form->getErrors() === false);
|
||||
}
|
||||
|
||||
function trash($id) {
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
$form->trash();
|
||||
}
|
||||
return ($form->getErrors() === false);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
$form->delete();
|
||||
return 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function duplicate($id) {
|
||||
$result = false;
|
||||
|
||||
$form = Form::findOne($id);
|
||||
if($form !== false) {
|
||||
$data = array(
|
||||
'name' => sprintf(__('Copy of %s'), $form->name)
|
||||
return $this->successResponse(
|
||||
Form::findOne($form->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
$result = $form->duplicate($data)->asArray();
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
function trash($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$form->trash();
|
||||
return $this->successResponse(
|
||||
Form::findOne($form->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function delete($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$form->delete();
|
||||
return $this->successResponse(null, array('count' => 1));
|
||||
}
|
||||
}
|
||||
|
||||
function duplicate($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$form = Form::findOne($id);
|
||||
|
||||
if($form === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$data = array(
|
||||
'name' => sprintf(__('Copy of %s', 'mailpoet'), $form->name)
|
||||
);
|
||||
$duplicate = $form->duplicate($data);
|
||||
$errors = $duplicate->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->errorResponse($errors);
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
Form::findOne($duplicate->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bulkAction($data = array()) {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Form',
|
||||
$data
|
||||
);
|
||||
|
||||
return $bulk_action->apply();
|
||||
try {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Form',
|
||||
$data
|
||||
);
|
||||
$meta = $bulk_action->apply();
|
||||
return $this->successResponse(null, $meta);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class Mailer extends APIEndpoint {
|
||||
|
||||
if($result === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::BAD_REQUEST => __("The email could not be sent. Please check your settings.")
|
||||
APIError::BAD_REQUEST => __("The email could not be sent. Please check your settings.", 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse(null);
|
||||
|
@ -13,7 +13,7 @@ class NewsletterTemplates extends APIEndpoint {
|
||||
$template = NewsletterTemplate::findOne($id);
|
||||
if($template === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This template does not exist.')
|
||||
APIError::NOT_FOUND => __('This template does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
@ -49,7 +49,7 @@ class NewsletterTemplates extends APIEndpoint {
|
||||
$template = NewsletterTemplate::findOne($id);
|
||||
if($template === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This template does not exist.')
|
||||
APIError::NOT_FOUND => __('This template does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$template->delete();
|
||||
|
@ -22,26 +22,27 @@ 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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function save($data = array()) {
|
||||
$segment_ids = array();
|
||||
$segments = array();
|
||||
if(isset($data['segments'])) {
|
||||
$segment_ids = $data['segments'];
|
||||
$segments = $data['segments'];
|
||||
unset($data['segments']);
|
||||
}
|
||||
|
||||
@ -57,13 +58,14 @@ class Newsletters extends APIEndpoint {
|
||||
if(!empty($errors)) {
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
if(!empty($segment_ids)) {
|
||||
if(!empty($segments)) {
|
||||
NewsletterSegment::where('newsletter_id', $newsletter->id)
|
||||
->deleteMany();
|
||||
|
||||
foreach($segment_ids as $segment_id) {
|
||||
foreach($segments as $segment) {
|
||||
if(!is_array($segment)) continue;
|
||||
$relation = NewsletterSegment::create();
|
||||
$relation->segment_id = $segment_id;
|
||||
$relation->segment_id = (int)$segment['id'];
|
||||
$relation->newsletter_id = $newsletter->id;
|
||||
$relation->save();
|
||||
}
|
||||
@ -89,26 +91,32 @@ class Newsletters extends APIEndpoint {
|
||||
}
|
||||
}
|
||||
|
||||
return $this->successResponse(
|
||||
Newsletter::findOne($newsletter->id)->asArray()
|
||||
);
|
||||
$newsletter = Newsletter::filter('filterWithOptions')->findOne($newsletter->id);
|
||||
|
||||
// if this is a post notification, process options and update its schedule
|
||||
if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
|
||||
Scheduler::processPostNotificationSchedule($newsletter);
|
||||
}
|
||||
|
||||
return $this->successResponse($newsletter->asArray());
|
||||
}
|
||||
}
|
||||
|
||||
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 +127,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 +330,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 +367,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 +402,20 @@ class Newsletters extends APIEndpoint {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isset($data['id']) &&
|
||||
isset($data['type']) &&
|
||||
$data['type'] === 'notification'
|
||||
|
||||
if(
|
||||
empty($data['id'])
|
||||
&&
|
||||
isset($data['type'])
|
||||
&&
|
||||
$data['type'] === Newsletter::TYPE_NOTIFICATION
|
||||
) {
|
||||
Scheduler::processPostNotificationSchedule($newsletter->id);
|
||||
$newsletter = Newsletter::filter('filterWithOptions')->findOne($newsletter->id);
|
||||
Scheduler::processPostNotificationSchedule($newsletter);
|
||||
}
|
||||
return array(
|
||||
'result' => true,
|
||||
'newsletter' => $newsletter->asArray()
|
||||
|
||||
return $this->successResponse(
|
||||
Newsletter::findOne($newsletter->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
use \MailPoet\API\Endpoint as APIEndpoint;
|
||||
use \MailPoet\API\Error as APIError;
|
||||
|
||||
use \MailPoet\Models\Segment;
|
||||
use \MailPoet\Models\SubscriberSegment;
|
||||
@ -9,16 +11,16 @@ use \MailPoet\Segments\WP;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Segments {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function get($id = false) {
|
||||
class Segments extends APIEndpoint {
|
||||
function get($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment === false) {
|
||||
return false;
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
return $segment->asArray();
|
||||
return $this->successResponse($segment->asArray());
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,18 +32,22 @@ class Segments {
|
||||
|
||||
$listing_data = $listing->get();
|
||||
|
||||
// fetch segments relations for each returned item
|
||||
foreach($listing_data['items'] as $key => $segment) {
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $segment) {
|
||||
$segment->subscribers_url = admin_url(
|
||||
'admin.php?page=mailpoet-subscribers#/filter[segment='.$segment->id.']'
|
||||
);
|
||||
|
||||
$listing_data['items'][$key] = $segment
|
||||
$data[] = $segment
|
||||
->withSubscribersCount()
|
||||
->asArray();
|
||||
}
|
||||
|
||||
return $listing_data;
|
||||
return $this->successResponse($data, array(
|
||||
'count' => $listing_data['count'],
|
||||
'filters' => $listing_data['filters'],
|
||||
'groups' => $listing_data['groups']
|
||||
));
|
||||
}
|
||||
|
||||
function save($data = array()) {
|
||||
@ -49,68 +55,109 @@ class Segments {
|
||||
$errors = $segment->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $errors
|
||||
);
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
return array(
|
||||
'result' => true
|
||||
return $this->successResponse(
|
||||
Segment::findOne($segment->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($id) {
|
||||
function restore($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment !== false) {
|
||||
if($segment === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$segment->restore();
|
||||
}
|
||||
return ($segment->getErrors() === false);
|
||||
}
|
||||
|
||||
function trash($id) {
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment !== false) {
|
||||
$segment->trash();
|
||||
}
|
||||
return ($segment->getErrors() === false);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment !== false) {
|
||||
$segment->delete();
|
||||
return 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function duplicate($id) {
|
||||
$result = false;
|
||||
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment !== false) {
|
||||
$data = array(
|
||||
'name' => sprintf(__('Copy of %s'), $segment->name)
|
||||
return $this->successResponse(
|
||||
Segment::findOne($segment->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
$result = $segment->duplicate($data)->asArray();
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
function trash($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$segment->trash();
|
||||
return $this->successResponse(
|
||||
Segment::findOne($segment->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function delete($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
if($segment === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$segment->delete();
|
||||
return $this->successResponse(null, array('count' => 1));
|
||||
}
|
||||
}
|
||||
|
||||
function duplicate($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$segment = Segment::findOne($id);
|
||||
|
||||
if($segment === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This list does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$data = array(
|
||||
'name' => sprintf(__('Copy of %s', 'mailpoet'), $segment->name)
|
||||
);
|
||||
$duplicate = $segment->duplicate($data);
|
||||
$errors = $duplicate->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->errorResponse($errors);
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
Segment::findOne($duplicate->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function synchronize() {
|
||||
$result = WP::synchronizeUsers();
|
||||
try {
|
||||
WP::synchronizeUsers();
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->successResponse(null);
|
||||
}
|
||||
|
||||
function bulkAction($data = array()) {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Segment',
|
||||
$data
|
||||
);
|
||||
|
||||
return $bulk_action->apply();
|
||||
try {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Segment',
|
||||
$data
|
||||
);
|
||||
$meta = $bulk_action->apply();
|
||||
return $this->successResponse(null, $meta);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class SendingQueue extends APIEndpoint {
|
||||
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.')
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ class SendingQueue extends APIEndpoint {
|
||||
|
||||
if(!empty($queue)) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter is already being sent.')
|
||||
APIError::NOT_FOUND => __('This newsletter is already being sent.', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class SendingQueue extends APIEndpoint {
|
||||
|
||||
// set queue status
|
||||
$queue->status = SendingQueueModel::STATUS_SCHEDULED;
|
||||
$queue->scheduled_at = Scheduler::scheduleFromTimestamp(
|
||||
$queue->scheduled_at = Scheduler::formatDatetimeString(
|
||||
$newsletter->scheduledAt
|
||||
);
|
||||
$queue->subscribers = null;
|
||||
@ -83,7 +83,7 @@ class SendingQueue extends APIEndpoint {
|
||||
$subscribers = array_unique($subscribers);
|
||||
if(!count($subscribers)) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::UNKNOWN => __('There are no subscribers in that list!')
|
||||
APIError::UNKNOWN => __('There are no subscribers in that list!', 'mailpoet')
|
||||
));
|
||||
}
|
||||
$queue->status = null;
|
||||
@ -119,14 +119,14 @@ class SendingQueue extends APIEndpoint {
|
||||
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.')
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$queue = $newsletter->getQueue();
|
||||
|
||||
if($queue === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::UNKNOWN => __('This newsletter has not been sent yet.')
|
||||
APIError::UNKNOWN => __('This newsletter has not been sent yet.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$queue->pause();
|
||||
@ -145,14 +145,14 @@ class SendingQueue extends APIEndpoint {
|
||||
$newsletter = Newsletter::findOne($newsletter_id);
|
||||
if($newsletter === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.')
|
||||
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$queue = $newsletter->getQueue();
|
||||
|
||||
if($queue === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::UNKNOWN => __('This newsletter has not been sent yet.')
|
||||
APIError::UNKNOWN => __('This newsletter has not been sent yet.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$queue->resume();
|
||||
|
@ -15,7 +15,7 @@ class Settings extends APIEndpoint {
|
||||
if(empty($settings)) {
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST =>
|
||||
__("You have not specified any settings to be saved.")
|
||||
__("You have not specified any settings to be saved.", 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
use \MailPoet\API\Endpoint as APIEndpoint;
|
||||
use \MailPoet\API\Error as APIError;
|
||||
use \MailPoet\API\Access as APIAccess;
|
||||
|
||||
use MailPoet\Listing;
|
||||
use MailPoet\Models\Subscriber;
|
||||
@ -9,23 +12,30 @@ 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() {
|
||||
}
|
||||
class Subscribers extends APIEndpoint {
|
||||
|
||||
function get($id = null) {
|
||||
public $permissions = array(
|
||||
'subscribe' => APIAccess::ALL
|
||||
);
|
||||
|
||||
function get($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$subscriber = Subscriber::findOne($id);
|
||||
if($subscriber !== false) {
|
||||
$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 +46,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 +72,110 @@ class Subscribers {
|
||||
unset($data['segments']);
|
||||
|
||||
if(empty($segment_ids)) {
|
||||
$errors[] = __('Please select a list');
|
||||
}
|
||||
|
||||
if(!empty($errors)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => $errors
|
||||
);
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST => __('Please select a list', 'mailpoet')
|
||||
));
|
||||
}
|
||||
|
||||
$subscriber = Subscriber::subscribe($data, $segment_ids);
|
||||
$errors = $subscriber->getErrors();
|
||||
$result = ($errors === false && $subscriber->id() > 0);
|
||||
|
||||
// record form statistics
|
||||
if($result === true && $form !== false && $form->id > 0) {
|
||||
StatisticsForms::record($form->id, $subscriber->id);
|
||||
}
|
||||
if($errors !== false) {
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
$meta = array();
|
||||
|
||||
// get success message to display after subscription
|
||||
$form_settings = (
|
||||
isset($form->settings)
|
||||
? unserialize($form->settings)
|
||||
: null
|
||||
);
|
||||
if($form !== false) {
|
||||
// record form statistics
|
||||
StatisticsForms::record($form->id, $subscriber->id);
|
||||
|
||||
if($form_settings !== null) {
|
||||
switch($form_settings['on_success']) {
|
||||
case 'page':
|
||||
$success_page_url = get_permalink($form_settings['success_page']);
|
||||
$form = $form->asArray();
|
||||
|
||||
// response depending on context
|
||||
if($doing_ajax === true) {
|
||||
return array(
|
||||
'result' => $result,
|
||||
'page' => $success_page_url,
|
||||
'errors' => $errors
|
||||
);
|
||||
} else {
|
||||
if($result === false) {
|
||||
Url::redirectBack();
|
||||
} else {
|
||||
Url::redirectTo($success_page_url);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'message':
|
||||
default:
|
||||
// response depending on context
|
||||
if($doing_ajax === true) {
|
||||
return array(
|
||||
'result' => $result,
|
||||
'errors' => $errors
|
||||
);
|
||||
} else {
|
||||
$params = (
|
||||
($result === true)
|
||||
? array('mailpoet_success' => $form->id)
|
||||
: array()
|
||||
);
|
||||
|
||||
Url::redirectBack($params);
|
||||
}
|
||||
break;
|
||||
if($form['settings']['on_success'] === 'page') {
|
||||
// redirect to a page on a success, pass the page url in the meta
|
||||
$meta['redirect_url'] = get_permalink($form['settings']['success_page']);
|
||||
} else if($form['settings']['on_success'] === 'url') {
|
||||
$meta['redirect_url'] = $form['settings']['success_url'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->successResponse(
|
||||
Subscriber::findOne($subscriber->id)->asArray(),
|
||||
$meta
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($id) {
|
||||
function save($data = array()) {
|
||||
$subscriber = Subscriber::createOrUpdate($data);
|
||||
$errors = $subscriber->getErrors();
|
||||
|
||||
if(!empty($errors)) {
|
||||
return $this->badRequest($errors);
|
||||
} else {
|
||||
return $this->successResponse(
|
||||
Subscriber::findOne($subscriber->id)->asArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function restore($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$subscriber = Subscriber::findOne($id);
|
||||
if($subscriber !== false) {
|
||||
if($subscriber === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$subscriber->restore();
|
||||
return $this->successResponse(
|
||||
Subscriber::findOne($subscriber->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
return ($subscriber->getErrors() === false);
|
||||
}
|
||||
|
||||
function trash($id) {
|
||||
function trash($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$subscriber = Subscriber::findOne($id);
|
||||
if($subscriber !== false) {
|
||||
if($subscriber === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$subscriber->trash();
|
||||
return $this->successResponse(
|
||||
Subscriber::findOne($subscriber->id)->asArray(),
|
||||
array('count' => 1)
|
||||
);
|
||||
}
|
||||
return ($subscriber->getErrors() === false);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
function delete($data = array()) {
|
||||
$id = (isset($data['id']) ? (int)$data['id'] : false);
|
||||
$subscriber = Subscriber::findOne($id);
|
||||
if($subscriber !== false) {
|
||||
if($subscriber === false) {
|
||||
return $this->errorResponse(array(
|
||||
APIError::NOT_FOUND => __('This subscriber does not exist.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
$subscriber->delete();
|
||||
return 1;
|
||||
return $this->successResponse(null, array('count' => 1));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function bulkAction($data = array()) {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Subscriber',
|
||||
$data
|
||||
);
|
||||
|
||||
return $bulk_action->apply();
|
||||
try {
|
||||
$bulk_action = new Listing\BulkAction(
|
||||
'\MailPoet\Models\Subscriber',
|
||||
$data
|
||||
);
|
||||
$meta = $bulk_action->apply();
|
||||
return $this->successResponse(null, $meta);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ abstract class Response {
|
||||
$response = array_merge($response, $data);
|
||||
}
|
||||
|
||||
if(empty($response)) {
|
||||
die();
|
||||
} else {
|
||||
wp_send_json($response);
|
||||
if(!empty($response)) {
|
||||
@header('Content-Type: application/json; charset='.get_option('blog_charset'));
|
||||
echo wp_json_encode($response);
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
abstract function getData();
|
||||
|
@ -38,11 +38,11 @@ class Env {
|
||||
self::$assets_path = self::$path . '/assets';
|
||||
self::$assets_url = plugins_url('/assets', $file);
|
||||
$wp_upload_dir = wp_upload_dir();
|
||||
self::$temp_path = $wp_upload_dir['basedir'].'/'.self::$plugin_name;
|
||||
self::$temp_path = $wp_upload_dir['basedir'] . '/' . self::$plugin_name;
|
||||
if(!is_dir(self::$temp_path)) {
|
||||
mkdir(self::$temp_path);
|
||||
}
|
||||
self::$temp_url = $wp_upload_dir['baseurl'].'/'.self::$plugin_name;
|
||||
self::$temp_url = $wp_upload_dir['baseurl'] . '/' . self::$plugin_name;
|
||||
self::$languages_path = self::$path . '/lang';
|
||||
self::$lib_path = self::$path . '/lib';
|
||||
self::$plugin_prefix = 'mailpoet_';
|
||||
|
@ -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')
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace MailPoet\Config;
|
||||
|
||||
use MailPoet\Models;
|
||||
use MailPoet\Cron\CronTrigger;
|
||||
use MailPoet\Router;
|
||||
use MailPoet\API;
|
||||
use MailPoet\Util\License\License as License;
|
||||
use MailPoet\WP\Notice as WPNotice;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
@ -117,16 +117,19 @@ class Initializer {
|
||||
|
||||
function onInit() {
|
||||
if(!$this->plugin_initialized) {
|
||||
define('MAILPOET_INITIALIZED', false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->setupAPI();
|
||||
$this->setupFrontRouter();
|
||||
$this->setupRouter();
|
||||
$this->setupPages();
|
||||
} catch(\Exception $e) {
|
||||
$this->handleFailedInitialization($e);
|
||||
}
|
||||
|
||||
define('MAILPOET_INITIALIZED', true);
|
||||
}
|
||||
|
||||
function setupWidget() {
|
||||
@ -187,14 +190,17 @@ class Initializer {
|
||||
$api->init();
|
||||
}
|
||||
|
||||
function setupFrontRouter() {
|
||||
$router = new Router\Front();
|
||||
function setupRouter() {
|
||||
$router = new Router\Router();
|
||||
$router->init();
|
||||
}
|
||||
|
||||
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() {
|
||||
@ -204,4 +210,4 @@ class Initializer {
|
||||
function handleFailedInitialization($message) {
|
||||
return WPNotice::displayError($message);
|
||||
}
|
||||
}
|
||||
}
|
@ -25,8 +25,6 @@ class Localizer {
|
||||
$language_path =
|
||||
Env::$languages_path
|
||||
. '/'
|
||||
. Env::$plugin_name
|
||||
. '-'
|
||||
. $this->locale()
|
||||
. '.mo';
|
||||
load_textdomain(Env::$plugin_name, $language_path);
|
||||
|
@ -8,11 +8,13 @@ use MailPoet\Models\CustomField;
|
||||
use MailPoet\Models\Form;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Newsletter\Shortcodes\ShortcodesHelper;
|
||||
use MailPoet\Settings\Hosts;
|
||||
use MailPoet\Settings\Pages;
|
||||
use MailPoet\Subscribers\ImportExport\ImportExportFactory;
|
||||
use MailPoet\Listing;
|
||||
use MailPoet\Util\License\Features\Subscribers as SubscribersFeature;
|
||||
use MailPoet\WP\DateTime;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
@ -21,6 +23,8 @@ class Menu {
|
||||
function __construct($renderer, $assets_url) {
|
||||
$this->renderer = $renderer;
|
||||
$this->assets_url = $assets_url;
|
||||
$subscribers_feature = new SubscribersFeature();
|
||||
$this->subscribers_over_limit = $subscribers_feature->check();
|
||||
}
|
||||
|
||||
function init() {
|
||||
@ -48,8 +52,8 @@ class Menu {
|
||||
|
||||
$newsletters_page = add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Newsletters')),
|
||||
__('Newsletters'),
|
||||
$this->setPageTitle(__('Emails', 'mailpoet')),
|
||||
__('Emails', 'mailpoet'),
|
||||
'manage_options',
|
||||
$main_page_slug,
|
||||
array($this, 'newsletters')
|
||||
@ -68,8 +72,8 @@ class Menu {
|
||||
|
||||
$forms_page = add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Forms')),
|
||||
__('Forms'),
|
||||
$this->setPageTitle(__('Forms', 'mailpoet')),
|
||||
__('Forms', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-forms',
|
||||
array($this, 'forms')
|
||||
@ -87,8 +91,8 @@ class Menu {
|
||||
|
||||
$subscribers_page = add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Subscribers')),
|
||||
__('Subscribers'),
|
||||
$this->setPageTitle(__('Subscribers', 'mailpoet')),
|
||||
__('Subscribers', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-subscribers',
|
||||
array($this, 'subscribers')
|
||||
@ -106,8 +110,8 @@ class Menu {
|
||||
|
||||
$segments_page = add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle(__('Lists')),
|
||||
__('Lists'),
|
||||
$this->setPageTitle(__('Lists', 'mailpoet')),
|
||||
__('Lists', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-segments',
|
||||
array($this, 'segments')
|
||||
@ -126,16 +130,16 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
$main_page_slug,
|
||||
$this->setPageTitle( __('Settings')),
|
||||
__('Settings'),
|
||||
$this->setPageTitle( __('Settings', 'mailpoet')),
|
||||
__('Settings', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-settings',
|
||||
array($this, 'settings')
|
||||
);
|
||||
add_submenu_page(
|
||||
'admin.php?page=mailpoet-subscribers',
|
||||
$this->setPageTitle( __('Import')),
|
||||
__('Import'),
|
||||
$this->setPageTitle( __('Import', 'mailpoet')),
|
||||
__('Import', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-import',
|
||||
array($this, 'import')
|
||||
@ -143,8 +147,8 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Export')),
|
||||
__('Export'),
|
||||
$this->setPageTitle(__('Export', 'mailpoet')),
|
||||
__('Export', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-export',
|
||||
array($this, 'export')
|
||||
@ -152,8 +156,8 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Welcome')),
|
||||
__('Welcome'),
|
||||
$this->setPageTitle(__('Welcome', 'mailpoet')),
|
||||
__('Welcome', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-welcome',
|
||||
array($this, 'welcome')
|
||||
@ -161,8 +165,8 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Update')),
|
||||
__('Update'),
|
||||
$this->setPageTitle(__('Update', 'mailpoet')),
|
||||
__('Update', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-update',
|
||||
array($this, 'update')
|
||||
@ -170,8 +174,8 @@ class Menu {
|
||||
|
||||
add_submenu_page(
|
||||
true,
|
||||
$this->setPageTitle(__('Form Editor')),
|
||||
__('Form Editor'),
|
||||
$this->setPageTitle(__('Form Editor', 'mailpoet')),
|
||||
__('Form Editor', 'mailpoet'),
|
||||
'manage_options',
|
||||
'mailpoet-form-editor',
|
||||
array($this, 'formEditor')
|
||||
@ -179,21 +183,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() {
|
||||
@ -250,12 +245,14 @@ class Menu {
|
||||
}
|
||||
|
||||
function settings() {
|
||||
if ($this->subscribers_over_limit) return $this->displaySubscriberLimitExceededTemplate();
|
||||
|
||||
$settings = Setting::getAll();
|
||||
$flags = $this->_getFlags();
|
||||
|
||||
$data = array(
|
||||
'settings' => $settings,
|
||||
'segments' => Segment::getPublic()->findArray(),
|
||||
'segments' => Segment::getSegmentsWithSubscriberCount(),
|
||||
'cron_trigger' => CronTrigger::getAvailableMethods(),
|
||||
'pages' => Pages::getAll(),
|
||||
'flags' => $flags,
|
||||
@ -299,7 +296,7 @@ class Menu {
|
||||
$data = array();
|
||||
|
||||
$data['items_per_page'] = $this->getLimitPerPage('subscribers');
|
||||
$data['segments'] = Segment::findArray();
|
||||
$data['segments'] = Segment::getSegmentsWithSubscriberCount($type = false);
|
||||
|
||||
$data['custom_fields'] = array_map(function($field) {
|
||||
$field['params'] = unserialize($field['params']);
|
||||
@ -322,12 +319,16 @@ class Menu {
|
||||
}
|
||||
|
||||
function segments() {
|
||||
if ($this->subscribers_over_limit) return $this->displaySubscriberLimitExceededTemplate();
|
||||
|
||||
$data = array();
|
||||
$data['items_per_page'] = $this->getLimitPerPage('segments');
|
||||
echo $this->renderer->render('segments.html', $data);
|
||||
}
|
||||
|
||||
function forms() {
|
||||
if ($this->subscribers_over_limit) return $this->displaySubscriberLimitExceededTemplate();
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['items_per_page'] = $this->getLimitPerPage('forms');
|
||||
@ -337,6 +338,8 @@ class Menu {
|
||||
}
|
||||
|
||||
function newsletters() {
|
||||
if ($this->subscribers_over_limit) return $this->displaySubscriberLimitExceededTemplate();
|
||||
|
||||
global $wp_roles;
|
||||
|
||||
$data = array();
|
||||
@ -345,7 +348,7 @@ class Menu {
|
||||
$data['segments'] = Segment::getSegmentsWithSubscriberCount($type = false);
|
||||
$data['settings'] = Setting::getAll();
|
||||
$data['roles'] = $wp_roles->get_names();
|
||||
$data['roles']['mailpoet_all'] = __('In any WordPress role');
|
||||
$data['roles']['mailpoet_all'] = __('In any WordPress role', 'mailpoet');
|
||||
|
||||
$date_time = new DateTime();
|
||||
$data['current_date'] = $date_time->getCurrentDate(DateTime::DEFAULT_DATE_FORMAT);
|
||||
@ -368,6 +371,7 @@ class Menu {
|
||||
$data = array(
|
||||
'shortcodes' => ShortcodesHelper::getShortcodes(),
|
||||
'settings' => Setting::getAll(),
|
||||
'current_wp_user' => Subscriber::getCurrentWPUser(),
|
||||
'sub_menu' => 'mailpoet-newsletters'
|
||||
);
|
||||
wp_enqueue_media();
|
||||
@ -405,7 +409,7 @@ class Menu {
|
||||
$data = array(
|
||||
'form' => $form,
|
||||
'pages' => Pages::getAll(),
|
||||
'segments' => Segment::getPublic()->findArray(),
|
||||
'segments' => Segment::getSegmentsWithSubscriberCount(),
|
||||
'styles' => FormRenderer::getStyles($form),
|
||||
'date_types' => Block\Date::getDateTypes(),
|
||||
'date_formats' => Block\Date::getDateFormats(),
|
||||
@ -416,14 +420,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
|
||||
);
|
||||
}
|
||||
@ -440,4 +440,11 @@ class Menu {
|
||||
? (int)$listing_per_page
|
||||
: Listing\Handler::DEFAULT_LIMIT_PER_PAGE;
|
||||
}
|
||||
|
||||
function displaySubscriberLimitExceededTemplate() {
|
||||
echo $this->renderer->render('limit.html', array(
|
||||
'limit' => SubscribersFeature::SUBSCRIBERS_LIMIT
|
||||
));
|
||||
exit;
|
||||
}
|
||||
}
|
@ -52,8 +52,9 @@ class Migrator {
|
||||
function down() {
|
||||
global $wpdb;
|
||||
|
||||
$drop_table = function($model) use($wpdb) {
|
||||
$table = $this->prefix . $model;
|
||||
$_this = $this;
|
||||
$drop_table = function($model) use($wpdb, $_this) {
|
||||
$table = $_this->prefix . $model;
|
||||
$wpdb->query("DROP TABLE {$table}");
|
||||
};
|
||||
|
||||
|
@ -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,30 +198,25 @@ 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) {
|
||||
$modelMethod = Helpers::underscoreToCamelCase($model);
|
||||
$rows = $this->$modelMethod();
|
||||
$table = $this->prefix . $model;
|
||||
$_this = $this;
|
||||
|
||||
array_map(function($row) use ($_this, $table) {
|
||||
if(!$_this->rowExists($table, $row)) {
|
||||
$_this->insertRow($table, $row);
|
||||
foreach($rows as $row) {
|
||||
if(!$this->rowExists($table, $row)) {
|
||||
$this->insertRow($table, $row);
|
||||
}
|
||||
}, $rows);
|
||||
}
|
||||
}
|
||||
|
||||
private function rowExists($table, $columns) {
|
||||
|
@ -7,14 +7,14 @@ class FranksRoastHouseTemplate {
|
||||
|
||||
function __construct($assets_url) {
|
||||
$this->assets_url = $assets_url;
|
||||
$this->template_image_url = $this->assets_url . '/img/sample_template';
|
||||
$this->template_image_url = $this->assets_url . '/img/sample_templates/coffee';
|
||||
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
||||
}
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Frank's Roast House"),
|
||||
'description' => __("Think of this as your sandbox. Play around with this example newsletter to see what MailPoet can do for you."),
|
||||
'name' => __("Frank's Roast House", 'mailpoet'),
|
||||
'description' => __("Think of this as your sandbox. Play around with this example newsletter to see what MailPoet can do for you.", 'mailpoet'),
|
||||
'readonly' => 0,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -46,7 +46,7 @@ class FranksRoastHouseTemplate {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser.</a>"),
|
||||
"text" => __("<a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser.</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "#ccc6c6"
|
||||
@ -67,7 +67,7 @@ class FranksRoastHouseTemplate {
|
||||
"type" => "image",
|
||||
"link" => "http://www.example.com",
|
||||
"src" => $this->template_image_url . "/header-v2.jpg",
|
||||
"alt" => __("Frank's Café"),
|
||||
"alt" => __("Frank's Café", 'mailpoet'),
|
||||
"fullWidth" => true,
|
||||
"width" => "600px",
|
||||
"height" => "220px",
|
||||
@ -88,13 +88,13 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>Hi there [subscriber:firstname | default:coffee drinker]</p>\n<p></p>\n<p>Sit back and enjoy your favorite roast as you read this week's newsletter. </p>")
|
||||
"text" => __("<p>Hi there [subscriber:firstname | default:coffee drinker]</p>\n<p></p>\n<p>Sit back and enjoy your favorite roast as you read this week's newsletter. </p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "image",
|
||||
"link" => "http://example.org",
|
||||
"src" => $this->template_image_url . "/coffee-grain.jpg",
|
||||
"alt" => __("coffee-grain-3-1329675-1599x941"),
|
||||
"alt" => __('Coffee grain', 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "1599px",
|
||||
"height" => "777px",
|
||||
@ -106,7 +106,7 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\">--- Guest Coffee Roaster: <em>Brew Bros. ---</em></h1>\n<p><em></em></p>\n<p>Visit our Center Avenue store to try the latest guest coffee from Brew Bros, a local coffee roaster. This young duo started only two years ago, but have quickly gained popularity through pop-up shops, local events, and collaborations with food trucks.</p>\n<p></p>\n<blockquote>\n<p><span style=\"color: #ff6600;\"><em>Tasting notes: A rich, caramel flavor with subtle hints of molasses. The perfect wake-up morning espresso!</em></span></p>\n</blockquote>")
|
||||
"text" => __("<h1 style=\"text-align: center;\">--- Guest Coffee Roaster: <em>Brew Bros. ---</em></h1>\n<p><em></em></p>\n<p>Visit our Center Avenue store to try the latest guest coffee from Brew Bros, a local coffee roaster. This young duo started only two years ago, but have quickly gained popularity through pop-up shops, local events, and collaborations with food trucks.</p>\n<p></p>\n<blockquote>\n<p><span style=\"color: #ff6600;\"><em>Tasting notes: A rich, caramel flavor with subtle hints of molasses. The perfect wake-up morning espresso!</em></span></p>\n</blockquote>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -132,13 +132,13 @@ class FranksRoastHouseTemplate {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>Sandwich Competition</h2>")
|
||||
"text" => __("<h2>Sandwich Competition</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "image",
|
||||
"link" => "http://example.org",
|
||||
"src" => $this->template_image_url . "/sandwich.jpg",
|
||||
"alt" => "sandwich",
|
||||
"alt" => __('Sandwich', 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "640px",
|
||||
"height" => "344px",
|
||||
@ -150,7 +150,7 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>Have an idea for the Next Great Sandwich? Tell us! We're offering free lunch for a month if you can invent an awesome new sandwich for our menu.</p>\n<p></p>\n<p></p>\n<p>Simply tweet your ideas to <a href=\"http://www.example.com\" title=\"This isn't a real twitter account\">@franksroasthouse</a> and use #sandwichcomp and we'll let you know if you're a winner.</p>")
|
||||
"text" => __("<p>Have an idea for the Next Great Sandwich? Tell us! We're offering free lunch for a month if you can invent an awesome new sandwich for our menu.</p>\n<p></p>\n<p></p>\n<p>Simply tweet your ideas to <a href=\"http://www.example.com\" title=\"This isn't a real twitter account\">@franksroasthouse</a> and use #sandwichcomp and we'll let you know if you're a winner.</p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "button",
|
||||
@ -175,7 +175,7 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3 style=\"text-align: center;\">Follow Us</h3>")
|
||||
"text" => __("<h3 style=\"text-align: center;\">Follow Us</h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "social",
|
||||
@ -232,13 +232,13 @@ class FranksRoastHouseTemplate {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>New Store Opening!</h2>")
|
||||
"text" => __("<h2>New Store Opening!</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "image",
|
||||
"link" => "http://example.org",
|
||||
"src" => $this->template_image_url . "/map-v2.jpg",
|
||||
"alt" => __("map-v2"),
|
||||
"alt" => __('Map', 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "636px",
|
||||
"height" => "342px",
|
||||
@ -250,11 +250,11 @@ class FranksRoastHouseTemplate {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>Watch out Broad Street, we're coming to you very soon! </p>\n<p></p>\n<p>Keep an eye on your inbox, as we'll have some special offers for our email subscribers plus an exclusive launch party invite!<br /><br /></p>")
|
||||
"text" => __("<p>Watch out Broad Street, we're coming to you very soon! </p>\n<p></p>\n<p>Keep an eye on your inbox, as we'll have some special offers for our email subscribers plus an exclusive launch party invite!<br /><br /></p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>New and Improved Hours!</h2>\n<p></p>\n<p>Frank's is now open even later, so you can get your caffeine fix all day (and night) long! Here's our new opening hours:</p>\n<p></p>\n<ul>\n<li>Monday - Thursday: 6am - 12am</li>\n<li>Friday - Saturday: 6am - 1:30am</li>\n<li>Sunday: 7:30am - 11pm</li>\n</ul>")
|
||||
"text" => __("<h2>New and Improved Hours!</h2>\n<p></p>\n<p>Frank's is now open even later, so you can get your caffeine fix all day (and night) long! Here's our new opening hours:</p>\n<p></p>\n<ul>\n<li>Monday - Thursday: 6am - 12am</li>\n<li>Friday - Saturday: 6am - 1:30am</li>\n<li>Sunday: 7:30am - 11pm</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -280,7 +280,7 @@ class FranksRoastHouseTemplate {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a><br />12345 MailPoet Drive, EmailVille, 76543</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a><br />12345 MailPoet Drive, EmailVille, 76543</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "#a9a7a7"
|
||||
|
@ -13,8 +13,8 @@ class NewsletterBlank121Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Newsletter: Blank 1:2:1 Column"),
|
||||
'description' => __("A blank Newsletter template with a 1:2:1 column layout."),
|
||||
'name' => __("Newsletter: Blank 1:2:1 Column", 'mailpoet'),
|
||||
'description' => __("A blank Newsletter template with a 1:2:1 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class NewsletterBlank121Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class NewsletterBlank121Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake logo"),
|
||||
"alt" => __("Fake logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class NewsletterBlank121Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started!</strong></h1>\n<p>It's time to design your newsletter! On the right sidebar, you'll find four menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started!</strong></h1>\n<p>It's time to design your newsletter! On the right sidebar, you'll find four menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "divider",
|
||||
@ -154,11 +154,11 @@ class NewsletterBlank121Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>This template has...</h2>")
|
||||
"text" => __("<h2>This template has...</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>In the right sidebar, you can add layout blocks to your email:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>")
|
||||
"text" => __("<p>In the right sidebar, you can add layout blocks to your email:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -173,11 +173,11 @@ class NewsletterBlank121Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>... a 2-column layout.</h2>")
|
||||
"text" => __("<h2>... a 2-column layout.</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>You can change a layout's background color by clicking on the settings icon on the right edge of the Designer. Simply hover over this area to see the Settings (gear) icon.</p>")
|
||||
"text" => __("<p>You can change a layout's background color by clicking on the settings icon on the right edge of the Designer. Simply hover over this area to see the Settings (gear) icon.</p>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -237,7 +237,7 @@ class NewsletterBlank121Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3 style=\"text-align: center;\"><span style=\"font-weight: 600;\">Let's end with a single column. </span></h3>\n<p style=\"line-height: 25.6px;\">In the right sidebar, you can add these layout blocks to your email:</p>\n<p style=\"line-height: 25.6px;\"></p>\n<ul style=\"line-height: 25.6px;\">\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>")
|
||||
"text" => __("<h3 style=\"text-align: center;\"><span style=\"font-weight: 600;\">Let's end with a single column. </span></h3>\n<p style=\"line-height: 25.6px;\">In the right sidebar, you can add these layout blocks to your email:</p>\n<p style=\"line-height: 25.6px;\"></p>\n<ul style=\"line-height: 25.6px;\">\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -311,7 +311,7 @@ class NewsletterBlank121Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
@ -13,8 +13,8 @@ class NewsletterBlank12Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Newsletter: Blank 1:2 Column"),
|
||||
'description' => __("A blank Newsletter template with a 1:2 column layout."),
|
||||
'name' => __("Newsletter: Blank 1:2 Column", 'mailpoet'),
|
||||
'description' => __("A blank Newsletter template with a 1:2 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class NewsletterBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class NewsletterBlank12Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake Logo"),
|
||||
"alt" => __("Fake Logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class NewsletterBlank12Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started!</strong></h1>\n<p></p>\n<p>It's time to design your newsletter! In the right sidebar, you'll find 4 menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started!</strong></h1>\n<p></p>\n<p>It's time to design your newsletter! In the right sidebar, you'll find 4 menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "divider",
|
||||
@ -154,11 +154,11 @@ class NewsletterBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>This template has...</h2>")
|
||||
"text" => __("<h2>This template has...</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>In the right sidebar, you can add these layout blocks to your email:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>")
|
||||
"text" => __("<p>In the right sidebar, you can add these layout blocks to your email:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -173,11 +173,11 @@ class NewsletterBlank12Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h2>... a 2-column layout.</h2>")
|
||||
"text" => __("<h2>... a 2-column layout.</h2>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p><span style=\"line-height: 25.6px;\">You can change a layout's background color by clicking on the settings icon on the right edge of the Designer. Simply hover over this area to see the Settings (gear) icon.</span></p>")
|
||||
"text" => __("<p><span style=\"line-height: 25.6px;\">You can change a layout's background color by clicking on the settings icon on the right edge of the Designer. Simply hover over this area to see the Settings (gear) icon.</span></p>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -251,7 +251,7 @@ class NewsletterBlank12Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|
@ -13,8 +13,8 @@ class NewsletterBlank13Column {
|
||||
|
||||
function get() {
|
||||
return array(
|
||||
'name' => __("Newsletter: Blank 1:3 Column"),
|
||||
'description' => __("A blank Newsletter template with a 1:3 column layout."),
|
||||
'name' => __("Newsletter: Blank 1:3 Column", 'mailpoet'),
|
||||
'description' => __("A blank Newsletter template with a 1:3 column layout.", 'mailpoet'),
|
||||
'readonly' => 1,
|
||||
'thumbnail' => $this->getThumbnail(),
|
||||
'body' => json_encode($this->getBody()),
|
||||
@ -52,7 +52,7 @@ class NewsletterBlank13Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "header",
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>"),
|
||||
"text" => __("Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser</a>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
@ -104,7 +104,7 @@ class NewsletterBlank13Column {
|
||||
"type" => "image",
|
||||
"link" => "",
|
||||
"src" => $this->template_image_url . "/fake-logo.png",
|
||||
"alt" => __("Fake logo"),
|
||||
"alt" => __("Fake logo", 'mailpoet'),
|
||||
"fullWidth" => false,
|
||||
"width" => "598px",
|
||||
"height" => "71px",
|
||||
@ -116,7 +116,7 @@ class NewsletterBlank13Column {
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started! </strong></h1>\n<p></p>\n<p>It's time to design your newsletter! On the right sidebar, you'll find four menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>")
|
||||
"text" => __("<h1 style=\"text-align: center;\"><strong>Let's Get Started! </strong></h1>\n<p></p>\n<p>It's time to design your newsletter! On the right sidebar, you'll find four menu items that will help you customize your newsletter:</p>\n<ol>\n<li>Content</li>\n<li>Layout</li>\n<li>Styles</li>\n<li>Preview</li>\n</ol>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "divider",
|
||||
@ -154,11 +154,11 @@ class NewsletterBlank13Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3>This template... </h3>")
|
||||
"text" => __("<h3>This template... </h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>In the right sidebar, you can add layout blocks to your newsletter.</p>")
|
||||
"text" => __("<p>In the right sidebar, you can add layout blocks to your newsletter.</p>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -173,11 +173,11 @@ class NewsletterBlank13Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3>... has a... </h3>")
|
||||
"text" => __("<h3>... has a... </h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>You have the choice of:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>")
|
||||
"text" => __("<p>You have the choice of:</p>\n<ul>\n<li>1 column</li>\n<li>2 columns</li>\n<li>3 columns</li>\n</ul>", 'mailpoet')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -192,11 +192,11 @@ class NewsletterBlank13Column {
|
||||
"blocks" => array(
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<h3>3-column layout.</h3>")
|
||||
"text" => __("<h3>3-column layout.</h3>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
"text" => __("<p>You can add as many layout blocks as you want!</p>")
|
||||
"text" => __("<p>You can add as many layout blocks as you want!</p>", 'mailpoet')
|
||||
),
|
||||
array(
|
||||
"type" => "text",
|
||||
@ -274,7 +274,7 @@ class NewsletterBlank13Column {
|
||||
),
|
||||
array(
|
||||
"type" => "footer",
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>"),
|
||||
"text" => __("<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage your subscription</a><br />Add your postal address here!</p>", 'mailpoet'),
|
||||
"styles" => array(
|
||||
"block" => array(
|
||||
"backgroundColor" => "transparent"
|
||||
|