Compare commits

...

75 Commits

Author SHA1 Message Date
546e012fbf releasing 3.0.0-rc.2.0.0 2017-08-29 13:43:15 +00:00
83adf089c5 Merge pull request #1070 from mailpoet/permissions
Fix Endpoint to use single global permission and not array of them [MAILPOET-1057]
2017-08-29 14:47:18 +02:00
2f45bb05d7 Fix Endpoint to use single global permission and not array of them
[MAILPOET-1057]
2017-08-29 15:34:35 +03:00
9ef8ab3e28 Merge pull request #1065 from mailpoet/events
Track extra events on MixPanel [MAILPOET-970]
2017-08-29 15:26:24 +03:00
f4db4f05c4 minor fixes 2017-08-29 12:18:12 +00:00
e7e08dbb3a minor fixes 2017-08-29 12:07:57 +00:00
02e2f0c07a Merge pull request #1066 from mailpoet/premium-update-warning
Premium update warning [PREMIUM-28]
2017-08-29 12:52:18 +03:00
c75b6bd7eb Show warning only on plugins page
[PREMIUM-28]
2017-08-29 11:22:51 +02:00
b74be8777a Display warning on Email pages
[PREMIUM-28]
2017-08-29 11:22:51 +02:00
7463e0d1f1 Update invalid key message
[PREMIUM-28]
2017-08-29 11:22:51 +02:00
a378880cf8 Merge pull request #1069 from mailpoet/bridge_forbidden_response
Adds 403 response code that mirrors 401 behavior [MAILPOET-1070]
2017-08-29 11:20:56 +03:00
33fa496913 Add a message for an already used MSS key [MAILPOET-1070] 2017-08-29 11:10:09 +03:00
eff996e1f8 Unify key state constant names, leave back compat with unlocker [MAILPOET-1070] 2017-08-29 10:58:16 +03:00
28b894b26b Add test cases [MAILPOET-1070] 2017-08-29 09:20:03 +03:00
c914aedc0d Simplify API response codes handling [MAILPOET-1070] 2017-08-29 09:18:08 +03:00
1745b67d64 Adds 403 response code that mirrors 401 behavior 2017-08-28 21:25:54 -04:00
2d25974fdc Merge pull request #1068 from mailpoet/helpscout
Update HS Beacon icon to question mark [MAILPOET-869]
2017-08-28 19:49:12 -04:00
51a02784e2 Update HS Beacon icon to question mark [MAILPOET-869] 2017-08-28 19:12:27 +03:00
e580e6b92b Merge pull request #1041 from mailpoet/access_control
Allows granular control of access to various parts of the plugin [MAILPOET-1057] [MAILPOET-1048]
2017-08-28 16:48:47 +03:00
96f77498f7 Merge pull request #1061 from mailpoet/safari-error-fix
Safari error fix [MAILPOET-1011]
2017-08-28 13:33:43 +02:00
62ce7c0437 Merge pull request #1062 from mailpoet/wp_user_subscription_update_fix
Prevents WP subscribers' first/last name from being erased [MAILPOET-1062]
2017-08-28 12:57:25 +03:00
c1e542cb5a Reschedules past due scheduled queues when reactivating notification 2017-08-28 09:20:17 +02:00
544bf0ddfd Merge pull request #1064 from mailpoet/welcome_alc_fix
Don't track sent ALC posts for welcome and standard emails, always send the latest posts [MAILPOET-1069]
2017-08-25 10:36:46 -04:00
609f1b5e67 Tracking new events 2017-08-25 13:19:52 +00:00
4616cf67bf Fix a test [MAILPOET-1069] 2017-08-25 16:10:01 +03:00
cc5227ca0d Don't track sent ALC posts for welcome and standard emails (always send the latest posts) [MAILPOET-1069] 2017-08-25 15:51:45 +03:00
26bccd95d4 Uses method vs. accessing class internals to get user capability 2017-08-24 13:58:54 -04:00
af58814fe7 Moves AccessControl intialization outside of Router to Initializer 2017-08-24 13:56:17 -04:00
7d9b4b31aa Removes unused constructor parameter 2017-08-24 13:37:49 -04:00
8a8108b41d Prevents WP subscribers' first/last name from being erased when updating
subscription
2017-08-24 13:19:42 -04:00
d92b1f57bd Merge pull request #1060 from mailpoet/mp2_forms_fix
Don't process the wysija_form shortcode to allow MP2 forms to work [MAILPOET-1067]
2017-08-24 10:40:10 -04:00
52ef7bece4 Merge pull request #1053 from mailpoet/editor_save
Save newsletter when clicked on "Next" button [MAILPOET-1051]
2017-08-24 09:03:34 -04:00
dc11046ad1 Fixes undefined JS error when vendor.js is loaded deferred
[MAILPOET-1026]
2017-08-24 13:37:15 +02:00
01f41b9798 Fix App and Application argument naming 2017-08-24 14:17:32 +03:00
9c0d9c31f8 Refactor cancelAutosave to return early 2017-08-24 13:48:13 +03:00
df499095c4 Fix test indentation 2017-08-24 13:40:46 +03:00
05dca3d2ce Excludes honeypot from subscription management form 2017-08-24 11:17:40 +02:00
ec35b90f3e Fix react warning
[MAILPOET-1011]
2017-08-24 11:01:33 +02:00
1b7e3a997f Fix not fully formated selector
[MAILPOET-1011]
2017-08-24 10:23:42 +02:00
c598537025 Remove empty lines 2017-08-24 09:16:51 +02:00
6f149e3ec4 tests: quote-props 2017-08-24 09:16:51 +02:00
d181bde0e9 tests: quotes 2017-08-24 09:16:51 +02:00
2985705b14 ES6: quote-props 2017-08-24 09:16:51 +02:00
6ce925fbe8 ES6: quotes 2017-08-24 09:16:51 +02:00
b8aceff61f ES5: quote-props 2017-08-24 09:16:51 +02:00
cd091c2af6 ES5: quotes 2017-08-24 09:16:51 +02:00
510cacf2fd Don't process the wysija_form shortcode to allow MP2 forms to work [MAILPOET-1067] 2017-08-24 08:22:10 +03:00
eac6b1b414 Corrects coding style 2017-08-23 11:45:33 -04:00
316fa91a10 Moves AccessControl initialization outside of API to Initializer 2017-08-23 11:28:09 -04:00
7c23415d26 Updates unit test as a result of AccessControl implementation 2017-08-23 11:28:09 -04:00
28320cdbb6 Updates permission validation method on AccessControl
Adds/updates unit tests
2017-08-23 11:28:08 -04:00
48f3ae4ea1 Adds access control unit tests 2017-08-23 11:28:08 -04:00
e47c8bc701 Adds access control tests for Router 2017-08-23 11:28:08 -04:00
78429d8f91 Validates global permission at the AccessControl level
Changes error response code on invalid permission
2017-08-23 11:27:54 -04:00
80c4eeed5e Merge pull request #1055 from mailpoet/new-poll
New poll [MAILPOET-1040]
2017-08-23 14:45:05 +02:00
5985d659f9 New poll
[MAILPOET-1040]
2017-08-23 14:11:35 +02:00
638de3cf55 Merge pull request #1054 from mailpoet/coverage-fix
Coverage fix [MAILPOET-1064]
2017-08-23 13:41:43 +03:00
967fa09f4f Remove redundant build
[MAILPOET-1064]
2017-08-23 12:32:34 +02:00
a15e1200b5 Upgrade codeception version
[MAILPOET-1064]
2017-08-23 12:32:34 +02:00
a15b46cbab Fix Code coverage reporting
[MAILPOET-1064]
2017-08-23 12:15:56 +02:00
dcb0b45c21 Save newsletter before navigating away when clicked on "Next" button 2017-08-22 17:34:23 +03:00
1b756ef0b2 Adds access management to router and updates endpoints accordingly 2017-08-22 09:06:20 -04:00
5553817f9a Creates method to get user's first capability 2017-08-22 09:06:20 -04:00
4b7fb3ae3d Updates access permission names to improve clarity 2017-08-22 09:06:20 -04:00
efa231b08f Removes AccessControl from Migrator and Changelog 2017-08-22 09:06:20 -04:00
8d8dfaa11f Uses Intializer to check permissions before running Activator 2017-08-22 09:06:20 -04:00
5ba2c4bc3a Removes AccessControl from individual API endpoints 2017-08-22 09:06:20 -04:00
788494ec47 Updates API initialization 2017-08-22 09:06:20 -04:00
5e7f9e3edf Passes AccessControl to JSON API via constructor parameter
Removes passing AccessControl to individual API endpoints
2017-08-22 09:06:20 -04:00
2e5554a3af Refactors AccessControl and passes it as dependency to JSON API and Menu 2017-08-22 09:06:20 -04:00
51fbf29031 Modifies Activator to use AccessControl 2017-08-22 09:06:19 -04:00
c3c6ce989c Modifies Menu to use AccessControl 2017-08-22 09:06:19 -04:00
a241d0c7bc Modifies JSON API to use AccessControl 2017-08-22 09:06:19 -04:00
632bce7894 Adds AccessControl class that defines permissions for major plugin
operations
2017-08-22 09:04:39 -04:00
1151354278 Conditionally uses set_time_limit() when function is not disabled 2017-08-22 09:04:39 -04:00
151 changed files with 2834 additions and 2061 deletions

View File

@ -9,11 +9,6 @@
},
"rules": {
"import/no-amd": 0,
"space-before-function-paren": 0,
"prefer-arrow-callback": 0,
"no-undef": 0,
@ -72,7 +67,6 @@
"one-var": 0,
"camelcase": 0,
"spaced-comment": 0,
"quotes": 0,
"padded-blocks": 0,
"object-curly-spacing": 0,
"strict": 0,
@ -87,7 +81,6 @@
"dot-notation": 0,
"linebreak-style": 0,
"indent": 0,
"quote-props": 0,
"prefer-template": 0,
"func-names": 0
}

View File

@ -12,11 +12,7 @@
},
"rules": {
"comma-dangle": ["error", "always-multiline"],
"import/no-amd": 0,
"react/no-multi-comp": 0,
"react/sort-comp": 0,
"react/jsx-max-props-per-line": 0,
@ -37,11 +33,9 @@
"react/jsx-curly-spacing": 0,
"react/no-did-mount-set-state": 0,
"react/prefer-stateless-function": 0,
"jsx-a11y/label-has-for": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/alt-text": 0,
"func-names": 0,
"object-shorthand": 0,
"no-bitwise": 0,
@ -49,7 +43,6 @@
"prefer-template": 0,
"keyword-spacing": 0,
"default-case": 0,
"quote-props": 0,
"array-callback-return": 0,
"consistent-return": 0,
"no-unreachable": 0,
@ -59,7 +52,6 @@
"import/no-extraneous-dependencies": 0,
"camelcase": 0,
"template-curly-spacing": 0,
"quotes": 0,
"eqeqeq": 0,
"no-lonely-if": 0,
"space-unary-ops": 0,

View File

@ -9,9 +9,6 @@
},
"rules": {
"import/no-amd": 0,
"no-undef": 0,
"one-var": 0,
"indent": 0,
@ -27,11 +24,9 @@
"func-call-spacing": 0,
"max-len": 0,
"space-unary-ops": 0,
"quotes": 0,
"no-unused-vars": 0,
"no-unused-expressions": 0,
"no-underscore-dangle": 0,
"quote-props": 0,
"no-shadow": 0,
"padded-blocks": 0,
"vars-on-top": 0,

View File

@ -154,7 +154,6 @@ class RoboFile extends \Robo\Tasks {
function testUnit($opts=['file' => null, 'xml' => false]) {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
$command = 'vendor/bin/codecept run unit -c codeception.unit.yml -f '.(($opts['file']) ? $opts['file'] : '');
@ -166,9 +165,8 @@ class RoboFile extends \Robo\Tasks {
function testCoverage($opts=['file' => null, 'xml' => false]) {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
$command = join(' ', array(
'vendor/bin/codecept run -c codeception.unit.yml ',
'vendor/bin/codecept run unit -c codeception.unit.yml ',
(($opts['file']) ? $opts['file'] : ''),
'--coverage',
($opts['xml']) ? '--coverage-xml' : '--coverage-html'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 819 B

After

Width:  |  Height:  |  Size: 814 B

View File

@ -2,7 +2,7 @@ function requestFailed(errorMessage, xhr) {
if (xhr.responseJSON) {
return xhr.responseJSON;
}
var message = errorMessage.replace("%d", xhr.status);
var message = errorMessage.replace('%d', xhr.status);
return {
errors: [
{

View File

@ -18,7 +18,7 @@
var eventsCache = [];
function track(name, data){
if (typeof window.mixpanel.track !== "function") {
if (typeof window.mixpanel.track !== 'function') {
window.mixpanel.init(window.mixpanelTrackingId);
}
window.mixpanel.track(name, data);
@ -44,7 +44,7 @@ function trackCachedEvents() {
}
function initializeMixpanelWhenLoaded() {
if (typeof window.mixpanel === "object") {
if (typeof window.mixpanel === 'object') {
exportMixpanel(MailPoet);
trackCachedEvents();
} else {

View File

@ -143,28 +143,28 @@ define([
switch(dateType) {
case 'year_month_day':
value = {
'year': this.state.year,
'month': this.state.month,
'day': this.state.day,
year: this.state.year,
month: this.state.month,
day: this.state.day,
};
break;
case 'year_month':
value = {
'year': this.state.year,
'month': this.state.month,
year: this.state.year,
month: this.state.month,
};
break;
case 'month':
value = {
'month': this.state.month,
month: this.state.month,
};
break;
case 'year':
value = {
'year': this.state.year,
year: this.state.year,
};
break;
}

View File

@ -166,7 +166,7 @@ define(
const formClasses = classNames(
'mailpoet_form',
{ 'mailpoet_form_loading': this.state.loading || this.props.loading }
{ mailpoet_form_loading: this.state.loading || this.props.loading }
);
let beforeFormContent = false;

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
}
// set date format
var f = block.hash.format || "MMM Do, YYYY";
var f = block.hash.format || 'MMM Do, YYYY';
// check if we passed a timestamp
if(parseInt(timestamp, 10) == timestamp) {
return moment.unix(timestamp).format(f);
@ -67,7 +67,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
});
Handlebars.registerHelper('nl2br', function(value, block) {
return value.gsub("\n", "<br />");
return value.gsub('\n', '<br />');
});
Handlebars.registerHelper('json_encode', function(value, block) {
@ -78,7 +78,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
return JSON.parse(value);
});
Handlebars.registerHelper('url', function(value, block) {
var url = window.location.protocol + "//" + window.location.host + window.location.pathname;
var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
return url + value;
});
@ -99,7 +99,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
// extract all lines into an array
if(value === undefined) return '';
var lines = value.trim().split("\n");
var lines = value.trim().split('\n');
// remove header & footer
lines.shift();
@ -148,10 +148,10 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
case 'Courier New': return new Handlebars.SafeString("'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace");
case 'Georgia': return new Handlebars.SafeString("Georgia, Times, 'Times New Roman', serif");
case 'Lucida': return new Handlebars.SafeString("'Lucida Sans Unicode', 'Lucida Grande', sans-serif");
case 'Tahoma': return new Handlebars.SafeString("Tahoma, Verdana, Segoe, sans-serif");
case 'Tahoma': return new Handlebars.SafeString('Tahoma, Verdana, Segoe, sans-serif');
case 'Times New Roman': return new Handlebars.SafeString("'Times New Roman', Times, Baskerville, Georgia, serif");
case 'Trebuchet MS': return new Handlebars.SafeString("'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif");
case 'Verdana': return new Handlebars.SafeString("Verdana, Geneva, sans-serif");
case 'Verdana': return new Handlebars.SafeString('Verdana, Geneva, sans-serif');
default: return font;
}
});

View File

@ -6,16 +6,16 @@ function Tooltip(props) {
let tooltipId = props.tooltipId;
let tooltip = props.tooltip;
// tooltip ID must be unique, defaults to tooltip text
if(!props.tooltipId && typeof props.tooltip === "string") {
if(!props.tooltipId && typeof props.tooltip === 'string') {
tooltipId = props.tooltip;
}
if(typeof props.tooltip === "string") {
if(typeof props.tooltip === 'string') {
tooltip = (<span
style={{
pointerEvents: "all",
maxWidth: "400",
display: "inline-block",
pointerEvents: 'all',
maxWidth: '400',
display: 'inline-block',
}}
>
{ReactHtmlParser(props.tooltip)}
@ -26,7 +26,7 @@ function Tooltip(props) {
<span className={props.className}>
<span
style={{
cursor: "pointer",
cursor: 'pointer',
}}
className="tooltip dashicons dashicons-editor-help"
data-event="click"

View File

@ -17,10 +17,10 @@ function printData(data) {
return (<textarea
readOnly={true}
onFocus={handleFocus}
value={printableData.join("\n")}
value={printableData.join('\n')}
style={{
width: "100%",
height: "400px",
width: '100%',
height: '400px',
}}
/>);
} else {
@ -35,7 +35,7 @@ function KnowledgeBase() {
<Tabs tab="systemInfo" />
<div className="mailpoet_notice notice inline notice-success" style={{ marginTop: "1em" }}>
<div className="mailpoet_notice notice inline notice-success" style={{ marginTop: '1em' }}>
<p>{MailPoet.I18n.t('systemInfoIntro')}</p>
</div>

View File

@ -41,6 +41,6 @@ function Tabs(props) {
};
Tabs.propTypes = { tab: React.PropTypes.string };
Tabs.defaultProps = { tab: "knowledgeBase" };
Tabs.defaultProps = { tab: 'knowledgeBase' };
module.exports = Tabs;

View File

@ -14,7 +14,7 @@ define('i18n',
translations[key] = value;
},
t: function(key) {
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace("%$1s", key);
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace('%$1s', key);
},
all: function() {
return translations;

View File

@ -17,7 +17,7 @@ define('iframe', ['mailpoet'], function(mp) {
iframe.style.height = (
parseInt(i, 10) + this.marginY
) + "px";
) + 'px';
}
};

View File

@ -25,7 +25,7 @@ define(
*/
$.fn.serializeObject = function(coerce) {
var obj = {},
coerce_types = { 'true': !0, 'false': !1, 'null': null };
coerce_types = { true: !0, false: !1, null: null };
// Iterate over all name=value pairs.
$.each( this.serializeArray(), function(j, v){

View File

@ -11,7 +11,7 @@ define(['react', 'classnames'], (React, classNames) => {
}
const classes = classNames(
{ 'current' : (group.name === this.props.group) }
{ current : (group.name === this.props.group) }
);
return (

View File

@ -62,9 +62,9 @@ const ListingColumn = React.createClass({
const classes = classNames(
'manage-column',
{ 'column-primary': this.props.column.is_primary },
{ 'sortable': this.props.column.sortable },
{ sortable: this.props.column.sortable },
this.props.column.sorted,
{ 'sorted': (this.props.sort_by === this.props.column.name) }
{ sorted: (this.props.sort_by === this.props.column.name) }
);
let label;

View File

@ -226,7 +226,7 @@ const ListingItems = React.createClass({
} else {
const select_all_classes = classNames(
'mailpoet_select_all',
{ 'mailpoet_hidden': (
{ mailpoet_hidden: (
this.props.selection === false
|| (this.props.count <= this.props.limit)
),
@ -783,7 +783,7 @@ const Listing = React.createClass({
'widefat',
'fixed',
'striped',
{ 'mailpoet_listing_loading': this.state.loading }
{ mailpoet_listing_loading: this.state.loading }
);
// search

View File

@ -309,7 +309,6 @@ define('modal', ['mailpoet', 'jquery'],
setDimensions: function() {
switch(this.options.type) {
case 'popup':
console.log(this.options)
// set popup dimensions
jQuery('#mailpoet_popup').css({
width: this.options.width,

View File

@ -28,8 +28,8 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(mp, jQuery) {
url: mailpoet_mp2_migrator.log_file_url,
cache: false
}).done(function (result) {
jQuery("#logger").html('');
result.split("\n").forEach(function (resultRow) {
jQuery('#logger').html('');
result.split('\n').forEach(function (resultRow) {
var row = resultRow;
if(row.substr(0, 7) === '[ERROR]' || row.substr(0, 9) === '[WARNING]' || row === MailPoet.I18n.t('import_stopped_by_user')) {
row = '<span class="error_msg">' + row + '</span>'; // Mark the errors in red
@ -39,10 +39,10 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(mp, jQuery) {
jQuery('#import-actions').hide();
jQuery('#upgrade-completed').show();
}
jQuery("#logger").append(row + "<br />\n");
jQuery('#logger').append(row + '<br />\n');
});
jQuery("#logger").append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + "<br />\n");
jQuery('#logger').append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + '<br />\n');
}).always(function () {
if(MailPoet.MP2Migrator.is_logging) {
MailPoet.MP2Migrator.displayLogs_timeout = setTimeout(MailPoet.MP2Migrator.displayLogs, 1000);

View File

@ -17,7 +17,7 @@ define([
clickoutFiresChange: true,
showInput: true,
showInitial: true,
preferredFormat: "hex6",
preferredFormat: 'hex6',
allowEmpty: true,
chooseText: MailPoet.I18n.t('selectColor'),
cancelText: MailPoet.I18n.t('cancelColorSelection')

View File

@ -11,8 +11,8 @@ define([
BL.HighlightEditingBehavior = Marionette.Behavior.extend({
modelEvents: {
'startEditing': 'enableHighlight',
'stopEditing': 'disableHighlight'
startEditing: 'enableHighlight',
stopEditing: 'disableHighlight'
},
enableHighlight: function() {
this.$el.addClass('mailpoet_highlight');

View File

@ -19,8 +19,8 @@ define([
modelField: 'styles.block.height'
},
events: {
"mouseenter": 'showResizeHandle',
"mouseleave": 'hideResizeHandle'
mouseenter: 'showResizeHandle',
mouseleave: 'hideResizeHandle'
},
onRender: function() {
this.attachResize();

View File

@ -16,7 +16,7 @@ define([
if (_.isFunction(this.$el.sortable)) {
this.$el.sortable({
cursor: "move",
cursor: 'move',
start: function(event, ui) {
ui.item.data('previousIndex', ui.item.index());
},

View File

@ -13,12 +13,12 @@ define([
BL.TextEditorBehavior = Marionette.Behavior.extend({
defaults: {
selector: '.mailpoet_content',
toolbar1: "bold italic link unlink forecolor mailpoet_shortcodes",
toolbar2: "",
validElements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
invalidElements: "script",
toolbar1: 'bold italic link unlink forecolor mailpoet_shortcodes',
toolbar2: '',
validElements: 'p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br',
invalidElements: 'script',
blockFormats: 'Paragraph=p',
plugins: "link textcolor colorpicker mailpoet_shortcodes",
plugins: 'link textcolor colorpicker mailpoet_shortcodes',
configurationFilter: function(originalConfig) { return originalConfig; }
},
onDomRefresh: function() {

View File

@ -28,7 +28,7 @@ define([
jQuery
) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -128,12 +128,12 @@ define([
});
Module.AutomatedLatestContentBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block',
initialize: function() {
function replaceButtonStylesHandler(data) {
this.model.set({"readMoreButton": data});
this.model.set({readMoreButton: data});
}
App.getChannel().on("replaceAllButtonStyles", replaceButtonStylesHandler.bind(this));
App.getChannel().on('replaceAllButtonStyles', replaceButtonStylesHandler.bind(this));
},
getTemplate: function() { return templates.automatedLatestContentBlock; },
regions: {
@ -143,7 +143,7 @@ define([
modelEvents: _.extend(
_.omit(base.BlockView.prototype.modelEvents, 'change'),
{
'postsChanged': 'render'
postsChanged: 'render'
}),
events: _.extend(base.BlockView.prototype.events, {
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings'
@ -171,28 +171,28 @@ define([
getTemplate: function() { return templates.automatedLatestContentBlockSettings; },
events: function() {
return {
"click .mailpoet_automated_latest_content_hide_display_options": 'toggleDisplayOptions',
"click .mailpoet_automated_latest_content_show_display_options": 'toggleDisplayOptions',
"click .mailpoet_automated_latest_content_select_button": 'showButtonSettings',
"click .mailpoet_automated_latest_content_select_divider": 'showDividerSettings',
"change .mailpoet_automated_latest_content_read_more_type": 'changeReadMoreType',
"change .mailpoet_automated_latest_content_display_type": 'changeDisplayType',
"change .mailpoet_automated_latest_content_title_format": 'changeTitleFormat',
"change .mailpoet_automated_latest_content_title_as_links": _.partial(this.changeBoolField, 'titleIsLink'),
"change .mailpoet_automated_latest_content_show_divider": _.partial(this.changeBoolField, 'showDivider'),
"input .mailpoet_automated_latest_content_show_amount": _.partial(this.changeField, "amount"),
"change .mailpoet_automated_latest_content_content_type": _.partial(this.changeField, "contentType"),
"change .mailpoet_automated_latest_content_include_or_exclude": _.partial(this.changeField, "inclusionType"),
"change .mailpoet_automated_latest_content_title_alignment": _.partial(this.changeField, "titleAlignment"),
"change .mailpoet_automated_latest_content_image_full_width": _.partial(this.changeBoolField, "imageFullWidth"),
"change .mailpoet_automated_latest_content_featured_image_position": _.partial(this.changeField, "featuredImagePosition"),
"change .mailpoet_automated_latest_content_show_author": _.partial(this.changeField, "showAuthor"),
"input .mailpoet_automated_latest_content_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
"change .mailpoet_automated_latest_content_show_categories": _.partial(this.changeField, "showCategories"),
"input .mailpoet_automated_latest_content_categories": _.partial(this.changeField, "categoriesPrecededBy"),
"input .mailpoet_automated_latest_content_read_more_text": _.partial(this.changeField, "readMoreText"),
"change .mailpoet_automated_latest_content_sort_by": _.partial(this.changeField, "sortBy"),
"click .mailpoet_done_editing": "close"
'click .mailpoet_automated_latest_content_hide_display_options': 'toggleDisplayOptions',
'click .mailpoet_automated_latest_content_show_display_options': 'toggleDisplayOptions',
'click .mailpoet_automated_latest_content_select_button': 'showButtonSettings',
'click .mailpoet_automated_latest_content_select_divider': 'showDividerSettings',
'change .mailpoet_automated_latest_content_read_more_type': 'changeReadMoreType',
'change .mailpoet_automated_latest_content_display_type': 'changeDisplayType',
'change .mailpoet_automated_latest_content_title_format': 'changeTitleFormat',
'change .mailpoet_automated_latest_content_title_as_links': _.partial(this.changeBoolField, 'titleIsLink'),
'change .mailpoet_automated_latest_content_show_divider': _.partial(this.changeBoolField, 'showDivider'),
'input .mailpoet_automated_latest_content_show_amount': _.partial(this.changeField, 'amount'),
'change .mailpoet_automated_latest_content_content_type': _.partial(this.changeField, 'contentType'),
'change .mailpoet_automated_latest_content_include_or_exclude': _.partial(this.changeField, 'inclusionType'),
'change .mailpoet_automated_latest_content_title_alignment': _.partial(this.changeField, 'titleAlignment'),
'change .mailpoet_automated_latest_content_image_full_width': _.partial(this.changeBoolField, 'imageFullWidth'),
'change .mailpoet_automated_latest_content_featured_image_position': _.partial(this.changeField, 'featuredImagePosition'),
'change .mailpoet_automated_latest_content_show_author': _.partial(this.changeField, 'showAuthor'),
'input .mailpoet_automated_latest_content_author_preceded_by': _.partial(this.changeField, 'authorPrecededBy'),
'change .mailpoet_automated_latest_content_show_categories': _.partial(this.changeField, 'showCategories'),
'input .mailpoet_automated_latest_content_categories': _.partial(this.changeField, 'categoriesPrecededBy'),
'input .mailpoet_automated_latest_content_read_more_text': _.partial(this.changeField, 'readMoreText'),
'change .mailpoet_automated_latest_content_sort_by': _.partial(this.changeField, 'sortBy'),
'click .mailpoet_done_editing': 'close'
};
},
onRender: function() {

View File

@ -14,7 +14,7 @@ define([
'modal'
], function(App, Marionette, SuperModel, _, jQuery, MailPoet, Modal) {
"use strict";
'use strict';
var Module = {},
AugmentedView = Marionette.View.extend({});
@ -50,13 +50,13 @@ define([
toolsRegion: '> .mailpoet_tools'
},
modelEvents: {
'change': 'render',
'delete': 'deleteBlock',
'duplicate': 'duplicateBlock'
change: 'render',
delete: 'deleteBlock',
duplicate: 'duplicateBlock'
},
events: {
"mouseenter": "showTools",
"mouseleave": "hideTools"
mouseenter: 'showTools',
mouseleave: 'hideTools'
},
behaviors: {
DraggableBehavior: {
@ -180,11 +180,11 @@ define([
Module.BlockToolsView = AugmentedView.extend({
getTemplate: function() { return templates.genericBlockTools; },
events: {
"click .mailpoet_edit_block": "changeSettings",
"click .mailpoet_delete_block_activate": "showDeletionConfirmation",
"click .mailpoet_delete_block_cancel": "hideDeletionConfirmation",
"click .mailpoet_delete_block_confirm": "deleteBlock",
"click .mailpoet_duplicate_block": "duplicateBlock"
'click .mailpoet_edit_block': 'changeSettings',
'click .mailpoet_delete_block_activate': 'showDeletionConfirmation',
'click .mailpoet_delete_block_cancel': 'hideDeletionConfirmation',
'click .mailpoet_delete_block_confirm': 'deleteBlock',
'click .mailpoet_duplicate_block': 'duplicateBlock'
},
// Markers of whether these particular tools will be used for this instance
tools: {
@ -298,7 +298,7 @@ define([
behaviors: {
DraggableBehavior: {
drop: function() {
throw "Unsupported operation";
throw 'Unsupported operation';
}
}
}

View File

@ -9,7 +9,7 @@ define([
'jquery'
], function(App, BaseBlock, MailPoet, _, jQuery) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -41,7 +41,7 @@ define([
});
Module.ButtonBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_button_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_button_block mailpoet_droppable_block',
getTemplate: function() { return templates.buttonBlock; },
onDragSubstituteBy: function() { return Module.ButtonWidgetView; },
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
@ -68,34 +68,34 @@ define([
getTemplate: function() { return templates.buttonBlockSettings; },
events: function() {
return {
"input .mailpoet_field_button_text": _.partial(this.changeField, "text"),
"input .mailpoet_field_button_url": _.partial(this.changeField, "url"),
"change .mailpoet_field_button_alignment": _.partial(this.changeField, "styles.block.textAlign"),
"change .mailpoet_field_button_font_color": _.partial(this.changeColorField, "styles.block.fontColor"),
"change .mailpoet_field_button_font_family": _.partial(this.changeField, "styles.block.fontFamily"),
"change .mailpoet_field_button_font_size": _.partial(this.changeField, "styles.block.fontSize"),
"change .mailpoet_field_button_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"change .mailpoet_field_button_border_color": _.partial(this.changeColorField, "styles.block.borderColor"),
"change .mailpoet_field_button_font_weight": "changeFontWeight",
'input .mailpoet_field_button_text': _.partial(this.changeField, 'text'),
'input .mailpoet_field_button_url': _.partial(this.changeField, 'url'),
'change .mailpoet_field_button_alignment': _.partial(this.changeField, 'styles.block.textAlign'),
'change .mailpoet_field_button_font_color': _.partial(this.changeColorField, 'styles.block.fontColor'),
'change .mailpoet_field_button_font_family': _.partial(this.changeField, 'styles.block.fontFamily'),
'change .mailpoet_field_button_font_size': _.partial(this.changeField, 'styles.block.fontSize'),
'change .mailpoet_field_button_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'change .mailpoet_field_button_border_color': _.partial(this.changeColorField, 'styles.block.borderColor'),
'change .mailpoet_field_button_font_weight': 'changeFontWeight',
"input .mailpoet_field_button_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
"change .mailpoet_field_button_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
"input .mailpoet_field_button_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
'input .mailpoet_field_button_border_width': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
'change .mailpoet_field_button_border_width': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
'input .mailpoet_field_button_border_width_input': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
"input .mailpoet_field_button_border_radius": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
"change .mailpoet_field_button_border_radius": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
"input .mailpoet_field_button_border_radius_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
'input .mailpoet_field_button_border_radius': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, 'styles.block.borderRadius').bind(this)),
'change .mailpoet_field_button_border_radius': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, 'styles.block.borderRadius').bind(this)),
'input .mailpoet_field_button_border_radius_input': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius', _.partial(this.changePixelField, 'styles.block.borderRadius').bind(this)),
"input .mailpoet_field_button_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, "styles.block.width").bind(this)),
"change .mailpoet_field_button_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, "styles.block.width").bind(this)),
"input .mailpoet_field_button_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width', _.partial(this.changePixelField, "styles.block.width").bind(this)),
'input .mailpoet_field_button_width': _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, 'styles.block.width').bind(this)),
'change .mailpoet_field_button_width': _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, 'styles.block.width').bind(this)),
'input .mailpoet_field_button_width_input': _.partial(this.updateValueAndCall, '.mailpoet_field_button_width', _.partial(this.changePixelField, 'styles.block.width').bind(this)),
"input .mailpoet_field_button_line_height": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
"change .mailpoet_field_button_line_height": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
"input .mailpoet_field_button_line_height_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
'input .mailpoet_field_button_line_height': _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, 'styles.block.lineHeight').bind(this)),
'change .mailpoet_field_button_line_height': _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, 'styles.block.lineHeight').bind(this)),
'input .mailpoet_field_button_line_height_input': _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height', _.partial(this.changePixelField, 'styles.block.lineHeight').bind(this)),
"click .mailpoet_field_button_replace_all_styles": "applyToAll",
"click .mailpoet_done_editing": "close"
'click .mailpoet_field_button_replace_all_styles': 'applyToAll',
'click .mailpoet_done_editing': 'close'
};
},
templateContext: function() {

View File

@ -12,7 +12,7 @@ define([
'newsletter_editor/blocks/base'
], function(Backbone, Marionette, _, jQuery, App, BaseBlock) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock,
@ -105,7 +105,7 @@ define([
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
getTemplate: function() { return templates.containerBlock; },
events: _.extend({}, base.BlockView.prototype.events, {
"click .mailpoet_newsletter_layer_selector": "toggleEditingLayer"
'click .mailpoet_newsletter_layer_selector': 'toggleEditingLayer'
}),
ui: {
tools: '> .mailpoet_tools'
@ -237,8 +237,8 @@ define([
getTemplate: function() { return templates.containerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_container_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_container_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'click .mailpoet_done_editing': 'close'
};
},
regions: {

View File

@ -9,7 +9,7 @@ define([
'mailpoet'
], function(App, BaseBlock, _, jQuery, MailPoet) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -32,7 +32,7 @@ define([
});
Module.DividerBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_divider_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_divider_block mailpoet_droppable_block',
getTemplate: function() { return templates.dividerBlock; },
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
behaviors: _.defaults({
@ -87,16 +87,16 @@ define([
getTemplate: function() { return templates.dividerBlockSettings; },
events: function() {
return {
"click .mailpoet_field_divider_style": 'changeStyle',
'click .mailpoet_field_divider_style': 'changeStyle',
"input .mailpoet_field_divider_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
"change .mailpoet_field_divider_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
"input .mailpoet_field_divider_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
'input .mailpoet_field_divider_border_width': _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
'change .mailpoet_field_divider_border_width': _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
'input .mailpoet_field_divider_border_width_input': _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
"change .mailpoet_field_divider_border_color": _.partial(this.changeColorField, "styles.block.borderColor"),
"change .mailpoet_field_divider_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"click .mailpoet_button_divider_apply_to_all": "applyToAll",
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_divider_border_color': _.partial(this.changeColorField, 'styles.block.borderColor'),
'change .mailpoet_field_divider_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'click .mailpoet_button_divider_apply_to_all': 'applyToAll',
'click .mailpoet_done_editing': 'close'
};
},
modelEvents: function() {

View File

@ -7,7 +7,7 @@ define([
'underscore'
], function(App, BaseBlock, _) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -37,7 +37,7 @@ define([
});
Module.FooterBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_footer_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_footer_block mailpoet_droppable_block',
getTemplate: function() { return templates.footerBlock; },
modelEvents: _.extend({
'change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration': 'render'
@ -78,16 +78,16 @@ define([
getTemplate: function() { return templates.footerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_footer_text_color": _.partial(this.changeColorField, "styles.text.fontColor"),
"change .mailpoet_field_footer_text_font_family": _.partial(this.changeField, "styles.text.fontFamily"),
"change .mailpoet_field_footer_text_size": _.partial(this.changeField, "styles.text.fontSize"),
"change #mailpoet_field_footer_link_color": _.partial(this.changeColorField, "styles.link.fontColor"),
"change #mailpoet_field_footer_link_underline": function(event) {
'change .mailpoet_field_footer_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
'change .mailpoet_field_footer_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
'change .mailpoet_field_footer_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
'change #mailpoet_field_footer_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
'change #mailpoet_field_footer_link_underline': function(event) {
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
"change .mailpoet_field_footer_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"change .mailpoet_field_footer_alignment": _.partial(this.changeField, "styles.text.textAlign"),
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_footer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'change .mailpoet_field_footer_alignment': _.partial(this.changeField, 'styles.text.textAlign'),
'click .mailpoet_done_editing': 'close'
};
},
templateContext: function() {

View File

@ -7,7 +7,7 @@ define([
'underscore'
], function(App, BaseBlock, _) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -37,7 +37,7 @@ define([
});
Module.HeaderBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_header_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_header_block mailpoet_droppable_block',
getTemplate: function() { return templates.headerBlock; },
modelEvents: _.extend({
'change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration': 'render'
@ -78,16 +78,16 @@ define([
getTemplate: function() { return templates.headerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_header_text_color": _.partial(this.changeColorField, "styles.text.fontColor"),
"change .mailpoet_field_header_text_font_family": _.partial(this.changeField, "styles.text.fontFamily"),
"change .mailpoet_field_header_text_size": _.partial(this.changeField, "styles.text.fontSize"),
"change #mailpoet_field_header_link_color": _.partial(this.changeColorField, "styles.link.fontColor"),
"change #mailpoet_field_header_link_underline": function(event) {
'change .mailpoet_field_header_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
'change .mailpoet_field_header_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
'change .mailpoet_field_header_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
'change #mailpoet_field_header_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
'change #mailpoet_field_header_link_underline': function(event) {
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
"change .mailpoet_field_header_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"change .mailpoet_field_header_alignment": _.partial(this.changeField, "styles.text.textAlign"),
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_header_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'change .mailpoet_field_header_alignment': _.partial(this.changeField, 'styles.text.textAlign'),
'click .mailpoet_done_editing': 'close'
};
},
templateContext: function() {

View File

@ -8,7 +8,7 @@ define([
'mailpoet'
], function(App, BaseBlock, _, MailPoet) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock,
@ -34,7 +34,7 @@ define([
});
Module.ImageBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_image_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_image_block mailpoet_droppable_block',
getTemplate: function() { return templates.imageBlock; },
onDragSubstituteBy: function() { return Module.ImageWidgetView; },
templateContext: function() {
@ -75,13 +75,13 @@ define([
getTemplate: function() { return templates.imageBlockSettings; },
events: function() {
return {
"input .mailpoet_field_image_link": _.partial(this.changeField, "link"),
"input .mailpoet_field_image_address": 'changeAddress',
"input .mailpoet_field_image_alt_text": _.partial(this.changeField, "alt"),
"change .mailpoet_field_image_full_width": _.partial(this.changeBoolCheckboxField, "fullWidth"),
"change .mailpoet_field_image_alignment": _.partial(this.changeField, "styles.block.textAlign"),
"click .mailpoet_field_image_select_another_image": "showMediaManager",
"click .mailpoet_done_editing": "close"
'input .mailpoet_field_image_link': _.partial(this.changeField, 'link'),
'input .mailpoet_field_image_address': 'changeAddress',
'input .mailpoet_field_image_alt_text': _.partial(this.changeField, 'alt'),
'change .mailpoet_field_image_full_width': _.partial(this.changeBoolCheckboxField, 'fullWidth'),
'change .mailpoet_field_image_alignment': _.partial(this.changeField, 'styles.block.textAlign'),
'click .mailpoet_field_image_select_another_image': 'showMediaManager',
'click .mailpoet_done_editing': 'close'
};
},
initialize: function(options) {
@ -177,7 +177,7 @@ define([
var handlers = {
content: {
'embed': 'embedContent',
embed: 'embedContent',
'edit-selection': 'editSelectionContent'
},
toolbar: {
@ -331,7 +331,7 @@ define([
height: mainSize.height + 'px',
width: mainSize.width + 'px',
src: mainSize.url,
alt: (attachment.get('alt') !== "" && attachment.get('alt') !== undefined) ? attachment.get('alt') : attachment.get('title')
alt: (attachment.get('alt') !== '' && attachment.get('alt') !== undefined) ? attachment.get('alt') : attachment.get('title')
});
// Rerender settings view due to changes from outside of settings view
that.render();

View File

@ -37,7 +37,7 @@ define([
DividerBlock
) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -176,7 +176,7 @@ define([
});
Module.PostsBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_posts_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_posts_block mailpoet_droppable_block',
getTemplate: function() { return templates.postsBlock; },
modelEvents: {}, // Forcefully disable all events
regions: _.extend({
@ -296,7 +296,7 @@ define([
this.blockModel = options.blockModel;
},
events: {
'scroll': 'onPostsScroll'
scroll: 'onPostsScroll'
},
onPostsScroll: function(event) {
var $postsBox = jQuery(event.target);
@ -326,10 +326,10 @@ define([
this.$('.mailpoet_post_scroll_container').scrollTop(0);
}
},
'loadingMorePosts': function() {
loadingMorePosts: function() {
this.$('.mailpoet_post_selection_loading').css('visibility', 'visible');
},
'morePostsLoaded': function() {
morePostsLoaded: function() {
this.$('.mailpoet_post_selection_loading').css('visibility', 'hidden');
}
},
@ -462,25 +462,25 @@ define([
getTemplate: function() { return templates.displayOptionsPostsBlockSettings; },
events: function() {
return {
"click .mailpoet_posts_select_button": 'showButtonSettings',
"click .mailpoet_posts_select_divider": 'showDividerSettings',
"change .mailpoet_posts_read_more_type": 'changeReadMoreType',
"change .mailpoet_posts_display_type": 'changeDisplayType',
"change .mailpoet_posts_title_format": 'changeTitleFormat',
"change .mailpoet_posts_title_as_links": _.partial(this.changeBoolField, 'titleIsLink'),
"change .mailpoet_posts_show_divider": _.partial(this.changeBoolField, 'showDivider'),
"input .mailpoet_posts_show_amount": _.partial(this.changeField, "amount"),
"change .mailpoet_posts_content_type": _.partial(this.changeField, "contentType"),
"change .mailpoet_posts_include_or_exclude": _.partial(this.changeField, "inclusionType"),
"change .mailpoet_posts_title_alignment": _.partial(this.changeField, "titleAlignment"),
"change .mailpoet_posts_image_full_width": _.partial(this.changeBoolField, "imageFullWidth"),
"change .mailpoet_posts_featured_image_position": _.partial(this.changeField, "featuredImagePosition"),
"change .mailpoet_posts_show_author": _.partial(this.changeField, "showAuthor"),
"input .mailpoet_posts_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
"change .mailpoet_posts_show_categories": _.partial(this.changeField, "showCategories"),
"input .mailpoet_posts_categories": _.partial(this.changeField, "categoriesPrecededBy"),
"input .mailpoet_posts_read_more_text": _.partial(this.changeField, "readMoreText"),
"change .mailpoet_posts_sort_by": _.partial(this.changeField, "sortBy")
'click .mailpoet_posts_select_button': 'showButtonSettings',
'click .mailpoet_posts_select_divider': 'showDividerSettings',
'change .mailpoet_posts_read_more_type': 'changeReadMoreType',
'change .mailpoet_posts_display_type': 'changeDisplayType',
'change .mailpoet_posts_title_format': 'changeTitleFormat',
'change .mailpoet_posts_title_as_links': _.partial(this.changeBoolField, 'titleIsLink'),
'change .mailpoet_posts_show_divider': _.partial(this.changeBoolField, 'showDivider'),
'input .mailpoet_posts_show_amount': _.partial(this.changeField, 'amount'),
'change .mailpoet_posts_content_type': _.partial(this.changeField, 'contentType'),
'change .mailpoet_posts_include_or_exclude': _.partial(this.changeField, 'inclusionType'),
'change .mailpoet_posts_title_alignment': _.partial(this.changeField, 'titleAlignment'),
'change .mailpoet_posts_image_full_width': _.partial(this.changeBoolField, 'imageFullWidth'),
'change .mailpoet_posts_featured_image_position': _.partial(this.changeField, 'featuredImagePosition'),
'change .mailpoet_posts_show_author': _.partial(this.changeField, 'showAuthor'),
'input .mailpoet_posts_author_preceded_by': _.partial(this.changeField, 'authorPrecededBy'),
'change .mailpoet_posts_show_categories': _.partial(this.changeField, 'showCategories'),
'input .mailpoet_posts_categories': _.partial(this.changeField, 'categoriesPrecededBy'),
'input .mailpoet_posts_read_more_text': _.partial(this.changeField, 'readMoreText'),
'change .mailpoet_posts_sort_by': _.partial(this.changeField, 'sortBy')
};
},
templateContext: function() {

View File

@ -11,7 +11,7 @@ define([
'jquery'
], function(App, BaseBlock, Backbone, Marionette, SuperModel, _, jQuery) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock,
@ -87,7 +87,7 @@ define([
tagName: 'span',
getTemplate: function() { return templates.socialIconBlock; },
modelEvents: {
'change': 'render'
change: 'render'
},
templateContext: function() {
var allIconSets = App.getAvailableStyles().get('socialIconSets');
@ -138,7 +138,7 @@ define([
},
events: function() {
return {
"click .mailpoet_done_editing": "close"
'click .mailpoet_done_editing': 'close'
};
},
initialize: function() {
@ -158,11 +158,11 @@ define([
getTemplate: function() { return templates.socialSettingsIcon; },
events: function() {
return {
"click .mailpoet_delete_block": "deleteIcon",
"change .mailpoet_social_icon_field_type": _.partial(this.changeField, "iconType"),
"input .mailpoet_social_icon_field_image": _.partial(this.changeField, "image"),
"input .mailpoet_social_icon_field_link": this.changeLink,
"input .mailpoet_social_icon_field_text": _.partial(this.changeField, "text")
'click .mailpoet_delete_block': 'deleteIcon',
'change .mailpoet_social_icon_field_type': _.partial(this.changeField, 'iconType'),
'input .mailpoet_social_icon_field_image': _.partial(this.changeField, 'image'),
'input .mailpoet_social_icon_field_link': this.changeLink,
'input .mailpoet_social_icon_field_text': _.partial(this.changeField, 'text')
};
},
modelEvents: {
@ -214,7 +214,7 @@ define([
SocialBlockSettingsIconSelectorView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsIconSelector; },
regions: {
'icons': '#mailpoet_social_icon_selector_contents'
icons: '#mailpoet_social_icon_selector_contents'
},
events: {
'click .mailpoet_add_social_icon': 'addSocialIcon'
@ -237,7 +237,7 @@ define([
SocialBlockSettingsStylesView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsStyles; },
modelEvents: {
'change': 'render'
change: 'render'
},
events: {
'click .mailpoet_social_icon_set': 'changeSocialIconSet'

View File

@ -7,7 +7,7 @@ define([
'underscore'
], function(App, BaseBlock, _) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -27,7 +27,7 @@ define([
});
Module.SpacerBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_spacer_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_spacer_block mailpoet_droppable_block',
getTemplate: function() { return templates.spacerBlock; },
behaviors: _.defaults({
ResizableBehavior: {
@ -69,8 +69,8 @@ define([
getTemplate: function() { return templates.spacerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_spacer_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_spacer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'click .mailpoet_done_editing': 'close'
};
}
});

View File

@ -7,7 +7,7 @@ define([
'underscore'
], function(App, BaseBlock, _) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -22,17 +22,17 @@ define([
});
Module.TextBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_text_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_text_block mailpoet_droppable_block',
getTemplate: function() { return templates.textBlock; },
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'), // Prevent rerendering on model change due to text editor redrawing
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
TextEditorBehavior: {
toolbar1: "formatselect bold italic forecolor | link unlink",
toolbar2: "alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_shortcodes",
validElements: "p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]",
invalidElements: "script",
toolbar1: 'formatselect bold italic forecolor | link unlink',
toolbar2: 'alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_shortcodes',
validElements: 'p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]',
invalidElements: 'script',
blockFormats: 'Heading 1=h1;Heading 2=h2;Heading 3=h3;Paragraph=p',
plugins: "link lists code textcolor colorpicker mailpoet_shortcodes paste",
plugins: 'link lists code textcolor colorpicker mailpoet_shortcodes paste',
configurationFilter: function(originalSettings) {
return _.extend({}, originalSettings, {
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),

View File

@ -4,7 +4,7 @@ define([
'underscore',
'mailpoet'
], function(App, SuperModel, _, MailPoet) {
"use strict";
'use strict';
var Module = {};
@ -34,14 +34,14 @@ define([
if (type in Module._blockTypes) {
return Module._blockTypes[type].blockModel;
} else {
throw "Block type not supported: " + type;
throw 'Block type not supported: ' + type;
}
};
Module.getBlockTypeView = function(type) {
if (type in Module._blockTypes) {
return Module._blockTypes[type].blockView;
} else {
throw "Block type not supported: " + type;
throw 'Block type not supported: ' + type;
}
};

View File

@ -6,7 +6,7 @@ define([
'jquery'
], function(App, Backbone, Marionette, _, jQuery) {
"use strict";
'use strict';
var Module = {};
@ -19,8 +19,8 @@ define([
},
events: function() {
return {
'keyup .mailpoet_input_title': _.partial(this.changeField, "subject"),
'keyup .mailpoet_input_preheader': _.partial(this.changeField, "preheader")
'keyup .mailpoet_input_title': _.partial(this.changeField, 'subject'),
'keyup .mailpoet_input_preheader': _.partial(this.changeField, 'preheader')
};
},
changeField: function(field, event) {
@ -33,7 +33,7 @@ define([
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
tooltipId: 'tooltip-designer-subject-line-ti',
tooltip: MailPoet.I18n.t('helpTooltipDesignerSubjectLine'),
place: "right"
place: 'right'
});
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-preheader'), {
tooltipId: 'tooltip-designer-preheader-ti',

View File

@ -22,7 +22,7 @@ define([
html2canvas
) {
"use strict";
'use strict';
var Module = {},
saveTimeout;
@ -65,15 +65,6 @@ define([
});
};
// For getting a promise after triggering save event
Module.saveAndProvidePromise = function(saveResult) {
var result = saveResult;
var promise = Module.save();
if (saveResult !== undefined) {
result.promise = promise;
}
};
Module.getThumbnail = function(element, options) {
var promise = html2canvas(element, options || {});
@ -82,8 +73,8 @@ define([
// Removes 1px left transparent border from resulting canvas.
var oldContext = oldCanvas.getContext('2d'),
newCanvas = document.createElement("canvas"),
newContext = newCanvas.getContext("2d"),
newCanvas = document.createElement('canvas'),
newContext = newCanvas.getContext('2d'),
leftBorderWidth = 1;
newCanvas.width = oldCanvas.width;
@ -169,7 +160,7 @@ define([
},
save: function() {
this.hideOptionContents();
App.getChannel().trigger('save');
App.getChannel().request('save');
},
beforeSave: function() {
// TODO: Add a loading animation instead
@ -289,7 +280,10 @@ define([
next: function() {
this.hideOptionContents();
if(!this.$('.mailpoet_save_next').hasClass('button-disabled')) {
window.location.href = App.getConfig().get('urls.send');
Module._cancelAutosave();
Module.save().done(function(response) {
window.location.href = App.getConfig().get('urls.send');
});
}
},
validateNewsletter: function(jsonObject) {
@ -300,8 +294,8 @@ define([
var contents = JSON.stringify(jsonObject);
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent') &&
contents.indexOf("[link:subscription_unsubscribe_url]") < 0 &&
contents.indexOf("[link:subscription_unsubscribe]") < 0) {
contents.indexOf('[link:subscription_unsubscribe_url]') < 0 &&
contents.indexOf('[link:subscription_unsubscribe]') < 0) {
this.showValidationError(MailPoet.I18n.t('unsubscribeLinkMissing'));
return;
}
@ -326,15 +320,21 @@ define([
// may be requested
var AUTOSAVE_DELAY_DURATION = 1000;
// Cancel save timer if another change happens before it completes
if (saveTimeout) clearTimeout(saveTimeout);
Module._cancelAutosave();
saveTimeout = setTimeout(function() {
App.getChannel().trigger('save');
clearTimeout(saveTimeout);
saveTimeout = undefined;
App.getChannel().request('save').always(function() {
Module._cancelAutosave();
});
}, AUTOSAVE_DELAY_DURATION);
};
Module._cancelAutosave = function() {
if (!saveTimeout) return;
clearTimeout(saveTimeout);
saveTimeout = undefined;
};
Module.beforeExitWithUnsavedChanges = function(e) {
if (saveTimeout) {
var message = MailPoet.I18n.t('unsavedChangesWillBeLost');
@ -350,12 +350,12 @@ define([
App.on('before:start', function(App, options) {
var Application = App;
Application.save = Module.saveAndProvidePromise;
Application.save = Module.save;
Application.getChannel().on('autoSave', Module.autoSave);
window.onbeforeunload = Module.beforeExitWithUnsavedChanges;
Application.getChannel().on('save', function(saveResult) { Application.save(saveResult); });
Application.getChannel().reply('save', Application.save);
});
App.on('start', function(App, options) {

View File

@ -20,7 +20,7 @@ define([
StickyKit
) {
"use strict";
'use strict';
var Module = {};
@ -69,7 +69,7 @@ define([
'slideUp',
{
duration: 250,
easing: "easeOut",
easing: 'easeOut',
complete: function() {
$openRegion.addClass('closed');
}.bind(this)
@ -81,7 +81,7 @@ define([
'slideDown',
{
duration: 250,
easing: "easeIn",
easing: 'easeIn',
complete: function() {
$targetRegion.removeClass('closed');
}
@ -180,40 +180,40 @@ define([
},
events: function() {
return {
"change #mailpoet_text_font_color": _.partial(this.changeColorField, 'text.fontColor'),
"change #mailpoet_text_font_family": function(event) {
'change #mailpoet_text_font_color': _.partial(this.changeColorField, 'text.fontColor'),
'change #mailpoet_text_font_family': function(event) {
this.model.set('text.fontFamily', event.target.value);
},
"change #mailpoet_text_font_size": function(event) {
'change #mailpoet_text_font_size': function(event) {
this.model.set('text.fontSize', event.target.value);
},
"change #mailpoet_h1_font_color": _.partial(this.changeColorField, 'h1.fontColor'),
"change #mailpoet_h1_font_family": function(event) {
'change #mailpoet_h1_font_color': _.partial(this.changeColorField, 'h1.fontColor'),
'change #mailpoet_h1_font_family': function(event) {
this.model.set('h1.fontFamily', event.target.value);
},
"change #mailpoet_h1_font_size": function(event) {
'change #mailpoet_h1_font_size': function(event) {
this.model.set('h1.fontSize', event.target.value);
},
"change #mailpoet_h2_font_color": _.partial(this.changeColorField, 'h2.fontColor'),
"change #mailpoet_h2_font_family": function(event) {
'change #mailpoet_h2_font_color': _.partial(this.changeColorField, 'h2.fontColor'),
'change #mailpoet_h2_font_family': function(event) {
this.model.set('h2.fontFamily', event.target.value);
},
"change #mailpoet_h2_font_size": function(event) {
'change #mailpoet_h2_font_size': function(event) {
this.model.set('h2.fontSize', event.target.value);
},
"change #mailpoet_h3_font_color": _.partial(this.changeColorField, 'h3.fontColor'),
"change #mailpoet_h3_font_family": function(event) {
'change #mailpoet_h3_font_color': _.partial(this.changeColorField, 'h3.fontColor'),
'change #mailpoet_h3_font_family': function(event) {
this.model.set('h3.fontFamily', event.target.value);
},
"change #mailpoet_h3_font_size": function(event) {
'change #mailpoet_h3_font_size': function(event) {
this.model.set('h3.fontSize', event.target.value);
},
"change #mailpoet_a_font_color": _.partial(this.changeColorField, 'link.fontColor'),
"change #mailpoet_a_font_underline": function(event) {
'change #mailpoet_a_font_color': _.partial(this.changeColorField, 'link.fontColor'),
'change #mailpoet_a_font_underline': function(event) {
this.model.set('link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
"change #mailpoet_newsletter_background_color": _.partial(this.changeColorField, 'wrapper.backgroundColor'),
"change #mailpoet_background_color": _.partial(this.changeColorField, 'body.backgroundColor')
'change #mailpoet_newsletter_background_color': _.partial(this.changeColorField, 'wrapper.backgroundColor'),
'change #mailpoet_background_color': _.partial(this.changeColorField, 'body.backgroundColor')
};
},
templateContext: function() {
@ -321,10 +321,7 @@ define([
MailPoet.Modal.loading(true);
// save before sending
var saveResult = {promise: null};
App.getChannel().trigger('save', saveResult);
saveResult.promise.always(function() {
App.getChannel().request('save').always(function() {
CommunicationComponent.previewNewsletter(data).always(function() {
MailPoet.Modal.loading(false);
}).done(function(response) {

View File

@ -4,7 +4,7 @@ define([
'backbone.supermodel'
], function(App, Marionette, SuperModel) {
"use strict";
'use strict';
var Module = {};
@ -49,7 +49,7 @@ define([
Module.StylesView = Marionette.View.extend({
getTemplate: function() { return templates.styles; },
modelEvents: {
'change': 'render'
change: 'render'
},
serializeData: function() {
return this.model.toJSON();

View File

@ -46,8 +46,8 @@ tinymce.PluginManager.add('mailpoet_shortcodes', function(editor, url) {
// Open window
editor.windowManager.open({
height: parseInt(editor.getParam("plugin_mailpoet_shortcodes_height", 400)),
width: parseInt(editor.getParam("plugin_mailpoet_shortcodes_width", 450)),
height: parseInt(editor.getParam('plugin_mailpoet_shortcodes_height', 400)),
width: parseInt(editor.getParam('plugin_mailpoet_shortcodes_width', 450)),
autoScroll: true,
title: editor.settings.mailpoet_shortcodes_window_title,
body: shortcodes,

View File

@ -41,7 +41,7 @@ define(
render: function () {
const steps = this.state.steps.map((step, index) => {
const stepClasses = classNames(
{ 'mailpoet_current': (this.props.step === step.name) }
{ mailpoet_current: (this.props.step === step.name) }
);
let label = step.label;

View File

@ -69,7 +69,7 @@ const _QueueMixin = {
}
const progressClasses = classNames(
'mailpoet_progress',
{ 'mailpoet_progress_complete': newsletter.queue.status === 'completed' }
{ mailpoet_progress_complete: newsletter.queue.status === 'completed' }
);
// calculate percentage done
@ -84,8 +84,8 @@ const _QueueMixin = {
<span>
{
MailPoet.I18n.t('newsletterQueueCompleted')
.replace("%$1d", newsletter.queue.count_processed)
.replace("%$2d", newsletter.queue.count_total)
.replace('%$1d', newsletter.queue.count_processed)
.replace('%$2d', newsletter.queue.count_total)
}
</span>
);
@ -120,7 +120,7 @@ const _QueueMixin = {
percentage = MailPoet.I18n.t('noSubscribers');
} else {
progress_bar_width = percentage;
percentage += "%";
percentage += '%';
}
return (
@ -128,7 +128,7 @@ const _QueueMixin = {
<div className={ progressClasses }>
<span
className="mailpoet_progress_bar"
style={ { width: progress_bar_width + "%" } }
style={ { width: progress_bar_width + '%' } }
></span>
<span className="mailpoet_progress_label">
{ percentage }
@ -239,7 +239,7 @@ const _StatisticsMixin = {
<div>
<span className="mailpoet_stats_text">
{ percentage_opened_display }%,
{ " " }
{ ' ' }
{ percentage_clicked_display }%
<span className="mailpoet_stat_hidden">
, { percentage_unsubscribed_display }%
@ -327,7 +327,7 @@ const _MailerMixin = {
MailPoet.I18n.t('mailerCheckSettingsNotice'),
/\[link\](.*?)\[\/link\]/g,
match => (
<a href={`?page=mailpoet-settings#mta`}>{ match }</a>
<a href={'?page=mailpoet-settings#mta'} key="check-sending">{ match }</a>
)
);
if (state.meta.mta_log.error.operation === 'send') {

View File

@ -5,18 +5,18 @@ const timeFormat = window.mailpoet_time_format || 'H:i';
// welcome emails
const _timeDelayValues = {
'immediate': MailPoet.I18n.t('delayImmediately'),
'hours': MailPoet.I18n.t('delayHoursAfter'),
'days': MailPoet.I18n.t('delayDaysAfter'),
'weeks': MailPoet.I18n.t('delayWeeksAfter'),
immediate: MailPoet.I18n.t('delayImmediately'),
hours: MailPoet.I18n.t('delayHoursAfter'),
days: MailPoet.I18n.t('delayDaysAfter'),
weeks: MailPoet.I18n.t('delayWeeksAfter'),
};
const _intervalValues = {
'daily': MailPoet.I18n.t('daily'),
'weekly': MailPoet.I18n.t('weekly'),
'monthly': MailPoet.I18n.t('monthly'),
'nthWeekDay': MailPoet.I18n.t('monthlyEvery'),
'immediately': MailPoet.I18n.t('immediately'),
daily: MailPoet.I18n.t('daily'),
weekly: MailPoet.I18n.t('weekly'),
monthly: MailPoet.I18n.t('monthly'),
nthWeekDay: MailPoet.I18n.t('monthlyEvery'),
immediately: MailPoet.I18n.t('immediately'),
};
// notification emails
@ -60,7 +60,7 @@ const _monthDayValues = _.object(
if (labels[day] !== undefined) {
label = labels[day];
} else {
label = MailPoet.I18n.t('nth').replace("%$1d", day + 1);
label = MailPoet.I18n.t('nth').replace('%$1d', day + 1);
}
return [day + 1, label];
}
@ -68,10 +68,10 @@ const _monthDayValues = _.object(
);
const _nthWeekDayValues = {
'1': MailPoet.I18n.t('first'),
'2': MailPoet.I18n.t('second'),
'3': MailPoet.I18n.t('third'),
'L': MailPoet.I18n.t('last'),
1: MailPoet.I18n.t('first'),
2: MailPoet.I18n.t('second'),
3: MailPoet.I18n.t('third'),
L: MailPoet.I18n.t('last'),
};
export { _timeDelayValues as timeDelayValues };

View File

@ -119,7 +119,7 @@ define(
MailPoet.trackEvent('Emails > Welcome email activated', {
'MailPoet Free version': window.mailpoet_version,
'List type': opts.event,
'Delay': opts.afterTimeNumber + ' ' + opts.afterTimeType,
Delay: opts.afterTimeNumber + ' ' + opts.afterTimeType,
});
} else if (response.data.type === 'notification') {
MailPoet.Notice.success(
@ -127,7 +127,7 @@ define(
);
MailPoet.trackEvent('Emails > Post notifications activated', {
'MailPoet Free version': window.mailpoet_version,
'Frequency': opts.intervalType,
Frequency: opts.intervalType,
});
}
}).fail(this._showError);

View File

@ -195,7 +195,7 @@ define(
});
const DateTime = React.createClass({
_DATE_TIME_SEPARATOR: " ",
_DATE_TIME_SEPARATOR: ' ',
getInitialState: function () {
return this._buildStateFromProps(this.props);
},

View File

@ -122,7 +122,7 @@ define(
MailPoet.I18n.t('mailpoetGuideTemplateTitle'),
description:
MailPoet.I18n.t('mailpoetGuideTemplateDescription'),
readonly: "1",
readonly: '1',
},
];
}
@ -179,7 +179,7 @@ define(
window.confirm(
(
MailPoet.I18n.t('confirmTemplateDeletion')
).replace("%$1s", template.name)
).replace('%$1s', template.name)
)
) {
MailPoet.Ajax.post({
@ -263,7 +263,7 @@ define(
{MailPoet.I18n.t('select')}
</a>
</div>
{ (template.readonly === "1") ? false : deleteLink }
{ (template.readonly === '1') ? false : deleteLink }
</li>
);
});
@ -271,7 +271,7 @@ define(
const boxClasses = classNames(
'mailpoet_boxes',
'clearfix',
{ 'mailpoet_boxes_loading': this.state.loading }
{ mailpoet_boxes_loading: this.state.loading }
);
return (

View File

@ -53,10 +53,10 @@ define(
render: function () {
let types = [
{
'id': 'standard',
'title': MailPoet.I18n.t('regularNewsletterTypeTitle'),
'description': MailPoet.I18n.t('regularNewsletterTypeDescription'),
'action': function () {
id: 'standard',
title: MailPoet.I18n.t('regularNewsletterTypeTitle'),
description: MailPoet.I18n.t('regularNewsletterTypeDescription'),
action: function () {
return (
<a className="button button-primary" onClick={ this.createNewsletter.bind(null, 'standard') }>
{MailPoet.I18n.t('create')}
@ -65,10 +65,10 @@ define(
}.bind(this)(),
},
{
'id': 'welcome',
'title': MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
'description': MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
'action': function () {
id: 'welcome',
title: MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
description: MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
action: function () {
return (
<div>
<a href="?page=mailpoet-premium" target="_blank">
@ -79,10 +79,10 @@ define(
}(),
},
{
'id': 'notification',
'title': MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
'description': MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
'action': function () {
id: 'notification',
title: MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
description: MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
action: function () {
return (
<a className="button button-primary" onClick={ this.setupNewsletter.bind(null, 'notification') }>
{MailPoet.I18n.t('setUp')}

View File

@ -16,8 +16,8 @@ const availableSegments = _.filter(
const events = {
name: 'event',
values: {
'segment': MailPoet.I18n.t('onSubscriptionToList'),
'user': MailPoet.I18n.t('onWPUserRegistration'),
segment: MailPoet.I18n.t('onSubscriptionToList'),
user: MailPoet.I18n.t('onWPUserRegistration'),
},
};

View File

@ -1,5 +1,5 @@
define('notice', ['mailpoet', 'jquery'], function(mp, jQuery) {
"use strict";
'use strict';
/*==================================================================================================
MailPoet Notice:
@ -124,7 +124,7 @@ define('notice', ['mailpoet', 'jquery'], function(mp, jQuery) {
if (
this.options.id !== null
&&
jQuery('[data-id="'+this.options.id+'"').length > 0
jQuery('[data-id="'+this.options.id+'"]').length > 0
) {
this.updateNotice();
} else {

View File

@ -32,6 +32,9 @@ define(
},
onCreate: function () {
MailPoet.Notice.success(MailPoet.I18n.t('segmentAdded'));
MailPoet.trackEvent('Lists > Add new', {
'MailPoet Free version': window.mailpoet_version,
});
},
};

View File

@ -15,9 +15,9 @@ define(
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
'api_version': window.mailpoet_api_version,
'endpoint': 'setup',
'action': 'reset'
api_version: window.mailpoet_api_version,
endpoint: 'setup',
action: 'reset'
}).always(function () {
MailPoet.Modal.loading(false);
}).done(function () {

View File

@ -43,10 +43,10 @@ define(
label: MailPoet.I18n.t('status'),
type: 'select',
values: {
'subscribed': MailPoet.I18n.t('subscribed'),
'unconfirmed': MailPoet.I18n.t('unconfirmed'),
'unsubscribed': MailPoet.I18n.t('unsubscribed'),
'bounced': MailPoet.I18n.t('bounced'),
subscribed: MailPoet.I18n.t('subscribed'),
unconfirmed: MailPoet.I18n.t('unconfirmed'),
unsubscribed: MailPoet.I18n.t('unsubscribed'),
bounced: MailPoet.I18n.t('bounced'),
},
filter: function (subscriber, value) {
if (~~(subscriber.wp_user_id) > 0 && value === 'unconfirmed') {
@ -144,6 +144,9 @@ define(
},
onCreate: function () {
MailPoet.Notice.success(MailPoet.I18n.t('subscriberAdded'));
MailPoet.trackEvent('Subscribers > Add new', {
'MailPoet Free version': window.mailpoet_version,
});
},
};

View File

@ -13,7 +13,7 @@ define(
Handlebars,
select2
) {
if (!jQuery("#mailpoet_subscribers_export").length) {
if (!jQuery('#mailpoet_subscribers_export').length) {
return;
}
jQuery(document).ready(function () {
@ -27,11 +27,11 @@ define(
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribers_export_template(exportData));
// define reusable variables
var segmentsContainerElement = jQuery("#export_lists"),
subscriberFieldsContainerElement = jQuery("#export_columns"),
var segmentsContainerElement = jQuery('#export_lists'),
subscriberFieldsContainerElement = jQuery('#export_columns'),
exportConfirmedOptionElement = jQuery(':radio[name="option_confirmed"]'),
groupBySegmentOptionElement = jQuery(':checkbox[name="option_group_by_list"]'),
nextStepButton = jQuery("a.mailpoet_export_process"),
nextStepButton = jQuery('a.mailpoet_export_process'),
renderSegmentsAndFields = function (container, data) {
if (container.data('select2')) {
container
@ -107,7 +107,7 @@ define(
'first_name',
'last_name',
'status'
]).trigger("change");
]).trigger('change');
exportConfirmedOptionElement.change(function () {
var selectedSegments = segmentsContainerElement.val();
@ -137,16 +137,17 @@ define(
return;
}
MailPoet.Modal.loading(true);
var exportFormat = jQuery(':radio[name="option_format"]:checked').val();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'ImportExport',
action: 'processExport',
data: JSON.stringify({
'export_confirmed_option': exportData.exportConfirmedOption,
'export_format_option': jQuery(':radio[name="option_format"]:checked').val(),
'group_by_segment_option': (groupBySegmentOptionElement.is(":visible")) ? groupBySegmentOptionElement.prop('checked') : false,
'segments': (exportData.segments) ? segmentsContainerElement.val() : false,
'subscriber_fields': subscriberFieldsContainerElement.val()
export_confirmed_option: exportData.exportConfirmedOption,
export_format_option: exportFormat,
group_by_segment_option: (groupBySegmentOptionElement.is(':visible')) ? groupBySegmentOptionElement.prop('checked') : false,
segments: (exportData.segments) ? segmentsContainerElement.val() : false,
subscriber_fields: subscriberFieldsContainerElement.val()
})
}).always(function(response) {
MailPoet.Modal.loading(false);
@ -157,6 +158,12 @@ define(
.replace('[/link]', '</a>');
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
window.location.href = response.data.exportFileURL;
MailPoet.trackEvent('Subscribers export completed', {
'Total exported': response.data.totalExported,
'Only confirmed?': exportData.exportConfirmedOption,
'File Format': exportFormat,
'MailPoet Free version': window.mailpoet_version
});
}).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(

View File

@ -30,9 +30,9 @@ define(
router = new (Backbone.Router.extend({
routes: {
'': 'home',
'step1': 'step1',
'step2': 'step2',
'step3': 'step3'
step1: 'step1',
step2: 'step2',
step3: 'step3'
},
home: function () {
this.navigate('step1', {trigger: true});
@ -112,7 +112,7 @@ define(
* Paste
*/
pasteInputElement
.attr('value', pasteInputPlaceholderElement).css('color', "#999")
.attr('value', pasteInputPlaceholderElement).css('color', '#999')
.focus(function () {
if (jQuery(this).val() === pasteInputPlaceholderElement) {
jQuery(this).attr('value', '').css('color', '#222');
@ -120,7 +120,7 @@ define(
})
.blur(function () {
if (jQuery(this).val() === '') {
jQuery(this).attr('value', pasteInputPlaceholderElement).css('color', "#999");
jQuery(this).attr('value', pasteInputPlaceholderElement).css('color', '#999');
}
})
.keyup(function () {
@ -141,7 +141,7 @@ define(
// delay loading indicator for 10ms or else it's just too fast :)
MailPoet.Modal.loading(true);
setTimeout(function () {
Papa.parse(pasteInputElement.val(), parseCSV());
Papa.parse(pasteInputElement.val(), parseCSV(false));
}, 10);
});
@ -168,7 +168,7 @@ define(
MailPoet.Modal.loading(true);
setTimeout(function () {
uploadElement.parse({
config: parseCSV()
config: parseCSV(true)
})
}, 10);
}
@ -238,6 +238,10 @@ define(
MailPoet.Modal.loading(false);
}).done(function(response) {
importData.step1 = response.data;
MailPoet.trackEvent('Subscribers import started', {
source: 'MailChimp',
'MailPoet Free version': window.mailpoet_version
});
router.navigate('step2', {trigger: true});
}).fail(function(response) {
if (response.errors.length > 0) {
@ -289,7 +293,7 @@ define(
element.closest('table a').addClass(disabled);
}
function parseCSV() {
function parseCSV(isFile) {
var processedSubscribers = [],
parsedEmails = [],
duplicateEmails = [],
@ -378,7 +382,7 @@ define(
processedSubscribers[0] = rowData;
}
}
else if (rowData[emailColumnPosition] !== "") {
else if (rowData[emailColumnPosition] !== '') {
var email = detectAndCleanupEmail(rowData[emailColumnPosition]);
if (_.has(parsedEmails, email)) {
duplicateEmails.push(email);
@ -407,14 +411,18 @@ define(
// since we assume that the header line is always present, we need
// to detect the header by checking if it contains a valid e-mail address
importData.step1 = {
'header': (!emailRegex.test(
header: (!emailRegex.test(
processedSubscribers[0][emailColumnPosition])
) ? processedSubscribers.shift() : null,
'subscribers': processedSubscribers,
'subscribersCount': processedSubscribers.length,
'duplicate': duplicateEmails,
'invalid': invalidEmails
subscribers: processedSubscribers,
subscribersCount: processedSubscribers.length,
duplicate: duplicateEmails,
invalid: invalidEmails
};
MailPoet.trackEvent('Subscribers import started', {
source: isFile ? 'file upload' : 'pasted data',
'MailPoet Free version': window.mailpoet_version
});
router.navigate('step2', {trigger: true});
}
else {
@ -512,7 +520,7 @@ define(
var details = jQuery('.mailpoet_subscribers_data_parse_results_details');
jQuery(details).toggle();
this.text =
(jQuery(details).is(":visible"))
(jQuery(details).is(':visible'))
? MailPoet.I18n.t('hideDetails')
: MailPoet.I18n.t('showDetails');
});
@ -592,9 +600,9 @@ define(
}
}).done(function(response) {
mailpoetSegments.push({
'id': response.data.id,
'name': response.data.name,
'subscriberCount': 0
id: response.data.id,
name: response.data.name,
subscriberCount: 0
});
var selected_values = segmentSelectElement.val();
@ -626,7 +634,7 @@ define(
// register partial template that will contain subscribers data
Handlebars.registerPartial(
"subscribers_data_template_partial",
'subscribers_data_template_partial',
subscribersDataTemplatePartial
);
@ -670,7 +678,7 @@ define(
&& displayedColumnsIds.indexOf(columnId) === -1)
? columnId
: 'ignore';
displayedColumns[i] = {'column_id': columnId};
displayedColumns[i] = {column_id: columnId};
displayedColumnsIds.push(columnId);
}
return options.fn(displayedColumns);
@ -747,17 +755,17 @@ define(
data: data
}).done(function(response) {
var new_column_data = {
'id': response.data.id,
'name': response.data.name,
'type': response.data.type,
'params': response.data.params,
'custom': true
id: response.data.id,
name: response.data.name,
type: response.data.type,
params: response.data.params,
custom: true
};
// if this is the first custom column, create an "optgroup"
if (mailpoetColumnsSelect2.length === 2) {
mailpoetColumnsSelect2.push({
'name': MailPoet.I18n.t('userColumns'),
'children': []
name: MailPoet.I18n.t('userColumns'),
children: []
});
}
mailpoetColumnsSelect2[2].children.push(new_column_data);
@ -974,10 +982,10 @@ define(
timestamp = Date.now() / 1000,
subscribers = [],
importResults = {
'created': 0,
'updated': 0,
'errors': [],
'segments': []
created: 0,
updated: 0,
errors: [],
segments: []
},
splitSubscribers = function (subscribers, size) {
return subscribers.reduce(function (res, item, index) {
@ -1070,6 +1078,12 @@ define(
MailPoet.Notice.error(_.flatten(importData.step2.errors));
}
MailPoet.trackEvent('Subscribers import finished', {
'Subscribers created': importData.step2.created,
'Subscribers updated': importData.step2.updated,
'MailPoet Free version': window.mailpoet_version
});
// display statistics
var subscribersDataImportResultsTemplate =
Handlebars
@ -1118,4 +1132,4 @@ define(
Backbone.history.start();
}
});
});
});

View File

@ -88,7 +88,7 @@ const messages = {
<div>
<p>{MailPoet.I18n.t('bouncedSubscribersHelp')}</p>
<p>
<a href={ `admin.php?page=mailpoet-premium` } className="button-primary">
<a href={ 'admin.php?page=mailpoet-premium' } className="button-primary">
{MailPoet.I18n.t('bouncedSubscribersPremiumButtonText')}
</a>
</p>

View File

@ -21,28 +21,6 @@ modules:
user: ''
password: ''
dump: tests/_data/dump.sql
WPLoader:
wpRootFolder: /wp-core
dbName: wordpress
dbHost: mysql
dbUser: wordpress
dbPassword: wordpress
wpDebug: false
tablePrefix: wp_
domain: wordpress
plugins: ['mailpoet/mailpoet.php']
activatePlugins: ['mailpoet/mailpoet.php']
WPWebDriver:
host: chrome
url: 'http://wordpress'
browser: chrome
port: 4444
window_size: '1024x768'
restart: true
wait: 0
adminUsername: admin
adminPassword: password
adminPath: /wp-admin
coverage:
enabled: true
whitelist:

View File

@ -20,7 +20,7 @@
},
"require-dev": {
"codeception/aspect-mock": "^2.0",
"codeception/codeception": "2.2.11",
"codeception/codeception": "2.3.5",
"codeception/verify": "^0.3.3",
"consolidation/robo": "^1.0.5",
"henrikbjorn/lurker": "^1.2",

17
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "f24637851f65aaddf31f499e9512a62a",
"content-hash": "3c6a5b45c2c80ffa51e3faa28d218aba",
"packages": [
{
"name": "cerdic/css-tidy",
@ -951,28 +951,28 @@
},
{
"name": "codeception/codeception",
"version": "2.2.11",
"version": "2.3.5",
"source": {
"type": "git",
"url": "https://github.com/Codeception/Codeception.git",
"reference": "a8681b416921ae282ccca2c485d75a3ed6756080"
"reference": "e807cd458eb9f7ae7464f33ad835a2f54aa73194"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/a8681b416921ae282ccca2c485d75a3ed6756080",
"reference": "a8681b416921ae282ccca2c485d75a3ed6756080",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/e807cd458eb9f7ae7464f33ad835a2f54aa73194",
"reference": "e807cd458eb9f7ae7464f33ad835a2f54aa73194",
"shasum": ""
},
"require": {
"behat/gherkin": "~4.4.0",
"ext-json": "*",
"ext-mbstring": "*",
"facebook/webdriver": ">=1.0.1 <2.0",
"facebook/webdriver": ">=1.1.3 <2.0",
"guzzlehttp/guzzle": ">=4.1.4 <7.0",
"guzzlehttp/psr7": "~1.0",
"php": ">=5.4.0 <8.0",
"phpunit/php-code-coverage": ">=2.2.4 <6.0",
"phpunit/phpunit": ">4.8.20 <6.0",
"phpunit/phpunit": ">4.8.20 <7.0",
"phpunit/phpunit-mock-objects": ">2.3 <5.0",
"sebastian/comparator": ">1.1 <3.0",
"sebastian/diff": "^1.4",
@ -997,6 +997,7 @@
"php-amqplib/php-amqplib": "~2.4",
"predis/predis": "^1.0",
"squizlabs/php_codesniffer": "~2.0",
"symfony/process": ">=2.7 <4.0",
"vlucas/phpdotenv": "^2.4.0"
},
"suggest": {
@ -1041,7 +1042,7 @@
"functional testing",
"unit testing"
],
"time": "2017-05-11T21:07:05+00:00"
"time": "2017-08-10T20:28:02+00:00"
},
{
"name": "codeception/verify",

View File

@ -1,11 +1,14 @@
<?php
namespace MailPoet\API;
use MailPoet\Config\AccessControl;
if(!defined('ABSPATH')) exit;
class API {
static function JSON() {
return new \MailPoet\API\JSON\API();
static function JSON(AccessControl $access_control) {
return new \MailPoet\API\JSON\API($access_control);
}
static function MP($version) {

View File

@ -1,7 +1,7 @@
<?php
namespace MailPoet\API\JSON;
use MailPoet\Config\Env;
use MailPoet\Config\AccessControl;
use MailPoet\Util\Helpers;
use MailPoet\Util\Security;
use MailPoet\WP\Hooks;
@ -19,9 +19,11 @@ class API {
private $_available_api_versions = array(
'v1'
);
private $access_control;
const CURRENT_VERSION = 'v1';
function __construct() {
function __construct(AccessControl $access_control) {
$this->access_control = $access_control;
foreach($this->_available_api_versions as $available_api_version) {
$this->addEndpointNamespace(
sprintf('%s\%s', __NAMESPACE__, $available_api_version),
@ -130,17 +132,11 @@ class API {
// 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->_request_method, $permissions) === false ||
$permissions[$this->_request_method] !== Access::ALL
) {
if($this->checkPermissions() === false) {
$error_message = __('You do not have the required permissions.', 'mailpoet');
$error_response = $this->createErrorResponse(Error::FORBIDDEN, $error_message, Response::STATUS_FORBIDDEN);
return $error_response;
}
if(!$this->validatePermissions($this->_request_method, $endpoint->permissions)) {
$error_message = __('You do not have the required permissions.', 'mailpoet');
$error_response = $this->createErrorResponse(Error::FORBIDDEN, $error_message, Response::STATUS_FORBIDDEN);
return $error_response;
}
$response = $endpoint->{$this->_request_method}($this->_request_data);
return $response;
} catch(\Exception $e) {
@ -150,8 +146,11 @@ class API {
}
}
function checkPermissions() {
return current_user_can(Env::$required_permission);
function validatePermissions($request_method, $permissions) {
// validate method permission if defined, otherwise validate global permission
return(!empty($permissions['methods'][$request_method])) ?
$this->access_control->validatePermission($permissions['methods'][$request_method]) :
$this->access_control->validatePermission($permissions['global']);
}
function checkToken() {

View File

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

View File

@ -1,11 +1,16 @@
<?php
namespace MailPoet\API\JSON;
use MailPoet\Config\AccessControl;
if(!defined('ABSPATH')) exit;
abstract class Endpoint {
public $permissions = array();
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS,
'methods' => array()
);
function successResponse(
$data = array(), $meta = array(), $status = Response::STATUS_OK
@ -18,7 +23,7 @@ abstract class Endpoint {
) {
if(empty($errors)) {
$errors = array(
Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet')
Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet')
);
}
return new ErrorResponse($errors, $meta, $status);

View File

@ -1,12 +1,18 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\Config\AccessControl;
use MailPoet\WP\Posts as WPPosts;
if(!defined('ABSPATH')) exit;
class AutomatedLatestContent extends APIEndpoint {
public $ALC;
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
);
function __construct() {
$this->ALC = new \MailPoet\Newsletter\AutomatedLatestContent();

View File

@ -1,12 +1,19 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Models\CustomField;
if(!defined('ABSPATH')) exit;
class CustomFields extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_FORMS
);
function getAll() {
$collection = CustomField::orderByAsc('created_at')->findMany();
$custom_fields = array_map(function($custom_field) {

View File

@ -1,17 +1,23 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Form\Renderer as FormRenderer;
use MailPoet\Form\Util;
use MailPoet\Listing;
use MailPoet\Models\Form;
use MailPoet\Models\StatisticsForms;
use MailPoet\Form\Renderer as FormRenderer;
use MailPoet\Listing;
use MailPoet\Form\Util;
if(!defined('ABSPATH')) exit;
class Forms extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_FORMS
);
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form = Form::findOne($id);

View File

@ -1,13 +1,19 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\Subscribers\ImportExport\Import\MailChimp;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\Config\AccessControl;
use MailPoet\Models\Segment;
use MailPoet\Subscribers\ImportExport\Import\MailChimp;
if(!defined('ABSPATH')) exit;
class ImportExport extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_SUBSCRIBERS
);
function getMailChimpLists($data) {
try {
$mailChimp = new MailChimp($data['api_key']);

View File

@ -1,18 +1,24 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\Config\AccessControl;
if(!defined('ABSPATH')) exit;
class MP2Migrator extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS
);
public function __construct() {
$this->MP2Migrator = new \MailPoet\Config\MP2Migrator();
}
/**
* Import end point
*
*
* @param object $data
* @return object
*/
@ -26,10 +32,10 @@ class MP2Migrator extends APIEndpoint {
));
}
}
/**
* Stop import end point
*
*
* @param object $data
* @return object
*/
@ -43,10 +49,10 @@ class MP2Migrator extends APIEndpoint {
));
}
}
/**
* Skip import end point
*
*
* @param object $data
* @return object
*/
@ -60,5 +66,5 @@ class MP2Migrator extends APIEndpoint {
));
}
}
}

View File

@ -1,12 +1,19 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Mailer\MailerLog;
if(!defined('ABSPATH')) exit;
class Mailer extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
);
function send($data = array()) {
try {
$mailer = new \MailPoet\Mailer\Mailer(

View File

@ -1,13 +1,19 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Models\NewsletterTemplate;
if(!defined('ABSPATH')) exit;
class NewsletterTemplates extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
);
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$template = NewsletterTemplate::findOne($id);

View File

@ -1,16 +1,19 @@
<?php
namespace MailPoet\API\JSON\v1;
use Carbon\Carbon;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Listing;
use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterOption;
use MailPoet\Models\NewsletterOptionField;
use MailPoet\Models\NewsletterSegment;
use MailPoet\Models\NewsletterTemplate;
use MailPoet\Models\SendingQueue;
use MailPoet\Models\Setting;
use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterTemplate;
use MailPoet\Models\NewsletterSegment;
use MailPoet\Models\NewsletterOptionField;
use MailPoet\Models\NewsletterOption;
use MailPoet\Models\Subscriber;
use MailPoet\Newsletter\Renderer\Renderer;
use MailPoet\Newsletter\Scheduler\Scheduler;
@ -22,6 +25,10 @@ if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-includes/pluggable.php');
class Newsletters extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
);
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$newsletter = Newsletter::findOne($id);
@ -134,7 +141,7 @@ class Newsletters extends APIEndpoint {
}
$id = (isset($data['id'])) ? (int)$data['id'] : false;
$newsletter = Newsletter::findOne($id);
$newsletter = Newsletter::filter('filterWithOptions')->findOne($id);
if($newsletter === false) {
return $this->errorResponse(array(
@ -147,11 +154,22 @@ class Newsletters extends APIEndpoint {
if(!empty($errors)) {
return $this->errorResponse($errors);
} else {
return $this->successResponse(
Newsletter::findOne($newsletter->id)->asArray()
);
}
// if there are past due notifications, reschedule them for the next send date
if($newsletter->type === Newsletter::TYPE_NOTIFICATION && $status === Newsletter::STATUS_ACTIVE) {
$next_run_date = Scheduler::getNextRunDate($newsletter->schedule);
$newsletter->queue()
->whereLte('scheduled_at', Carbon::createFromTimestamp(current_time('timestamp')))
->where('status', SendingQueue::STATUS_SCHEDULED)
->findResultSet()
->set('scheduled_at', $next_run_date)
->save();
}
return $this->successResponse(
Newsletter::findOne($newsletter->id)->asArray()
);
}
function restore($data = array()) {

View File

@ -1,15 +1,21 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Models\Segment;
use MailPoet\Config\AccessControl;
use MailPoet\Listing;
use MailPoet\Models\Segment;
use MailPoet\Segments\WP;
if(!defined('ABSPATH')) exit;
class Segments extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_SEGMENTS
);
function get($data = array()) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$segment = Segment::findOne($id);

View File

@ -1,18 +1,24 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Mailer\Mailer;
use MailPoet\Models\Newsletter;
use MailPoet\Models\SendingQueue as SendingQueueModel;
use MailPoet\Models\Subscriber;
use MailPoet\Newsletter\Scheduler\Scheduler;
use MailPoet\Models\SendingQueue as SendingQueueModel;
use MailPoet\Util\Helpers;
if(!defined('ABSPATH')) exit;
class SendingQueue extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
);
function add($data = array()) {
$newsletter_id = (isset($data['newsletter_id'])
? (int)$data['newsletter_id']

View File

@ -1,11 +1,12 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Config\Installer;
use MailPoet\Services\Bridge;
use MailPoet\Util\License\License;
use MailPoet\WP\DateTime;
if(!defined('ABSPATH')) exit;
@ -13,6 +14,9 @@ if(!defined('ABSPATH')) exit;
class Services extends APIEndpoint {
public $bridge;
public $date_time;
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS
);
function __construct() {
$this->bridge = new Bridge();
@ -40,9 +44,9 @@ class Services extends APIEndpoint {
$state = !empty($result['state']) ? $result['state'] : null;
$success_message = null;
if($state == Bridge::PREMIUM_KEY_VALID) {
if($state == Bridge::KEY_VALID) {
$success_message = __('Your MailPoet Sending Service key has been successfully validated.', 'mailpoet');
} elseif($state == Bridge::PREMIUM_KEY_EXPIRING) {
} elseif($state == Bridge::KEY_EXPIRING) {
$success_message = sprintf(
__('Your MailPoet Sending Service key expires on %s!', 'mailpoet'),
$this->date_time->formatDate(strtotime($result['data']['expire_at']))
@ -54,9 +58,12 @@ class Services extends APIEndpoint {
}
switch($state) {
case Bridge::PREMIUM_KEY_INVALID:
case Bridge::KEY_INVALID:
$error = __('Your MailPoet Sending Service key is invalid.', 'mailpoet');
break;
case Bridge::KEY_ALREADY_USED:
$error = __('Your MailPoet Sending Service key is already used on another site.', 'mailpoet');
break;
default:
$code = !empty($result['code']) ? $result['code'] : Bridge::CHECK_ERROR_UNKNOWN;
$error = sprintf(
@ -90,9 +97,9 @@ class Services extends APIEndpoint {
$state = !empty($result['state']) ? $result['state'] : null;
$success_message = null;
if($state == Bridge::PREMIUM_KEY_VALID) {
if($state == Bridge::KEY_VALID) {
$success_message = __('Your Premium key has been successfully validated.', 'mailpoet');
} elseif($state == Bridge::PREMIUM_KEY_EXPIRING) {
} elseif($state == Bridge::KEY_EXPIRING) {
$success_message = sprintf(
__('Your Premium key expires on %s.', 'mailpoet'),
$this->date_time->formatDate(strtotime($result['data']['expire_at']))
@ -107,10 +114,10 @@ class Services extends APIEndpoint {
}
switch($state) {
case Bridge::PREMIUM_KEY_INVALID:
case Bridge::KEY_INVALID:
$error = __('Your Premium key is invalid.', 'mailpoet');
break;
case Bridge::PREMIUM_KEY_ALREADY_USED:
case Bridge::KEY_ALREADY_USED:
$error = __('Your Premium key is already used on another site.', 'mailpoet');
break;
default:

View File

@ -1,24 +1,31 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Models\Setting;
use MailPoet\Services\Bridge;
if(!defined('ABSPATH')) exit;
class Settings extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS
);
function get() {
return $this->successResponse(Setting::getAll());
}
function set($settings = array()) {
if(empty($settings)) {
return $this->badRequest(array(
APIError::BAD_REQUEST =>
__('You have not specified any settings to be saved.', 'mailpoet')
));
return $this->badRequest(
array(
APIError::BAD_REQUEST =>
__('You have not specified any settings to be saved.', 'mailpoet')
));
} else {
foreach($settings as $name => $value) {
Setting::setValue($name, $value);

View File

@ -1,13 +1,19 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\Config\AccessControl;
use MailPoet\Config\Activator;
use MailPoet\WP\Hooks;
if(!defined('ABSPATH')) exit;
class Setup extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS
);
function reset() {
try {
$activator = new Activator();

View File

@ -1,21 +1,22 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\API\JSON\Access as APIAccess;
use MailPoet\Form\Util\FieldNameObfuscator;
use MailPoet\Config\AccessControl;
use MailPoet\Listing;
use MailPoet\Models\Subscriber;
use MailPoet\Form\Util\FieldNameObfuscator;
use MailPoet\Models\Form;
use MailPoet\Models\StatisticsForms;
use MailPoet\Models\Subscriber;
if(!defined('ABSPATH')) exit;
class Subscribers extends APIEndpoint {
public $permissions = array(
'subscribe' => APIAccess::ALL
'global' => AccessControl::PERMISSION_MANAGE_SUBSCRIBERS,
'methods' => array('subscribe' => AccessControl::NO_ACCESS_RESTRICTION)
);
function get($data = array()) {

View File

@ -0,0 +1,104 @@
<?php
namespace MailPoet\Config;
use MailPoet\WP\Hooks as WPHooks;
if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-includes/pluggable.php');
class AccessControl {
const PERMISSION_ACCESS_PLUGIN_ADMIN = 'access_plugin_admin';
const PERMISSION_MANAGE_SETTINGS = 'manage_settings';
const PERMISSION_MANAGE_EMAILS = 'manage_emails';
const PERMISSION_MANAGE_SUBSCRIBERS = 'manage_subscribers';
const PERMISSION_MANAGE_FORMS = 'manage_forms';
const PERMISSION_MANAGE_SEGMENTS = 'manage_segments';
const PERMISSION_UPDATE_PLUGIN = 'update_plugin';
const NO_ACCESS_RESTRICTION = 'no_access_restriction';
public $permissions;
public $current_user_roles;
public $user_capabilities;
function __construct() {
$this->permissions = $this->getDefaultPermissions();
$this->user_roles = $this->getUserRoles();
$this->user_capabilities = $this->getUserCapabilities();
}
private function getDefaultPermissions() {
return array(
self::PERMISSION_ACCESS_PLUGIN_ADMIN => WPHooks::applyFilters(
'mailpoet_permission_access_plugin_admin',
array(
'administrator',
'editor'
)
),
self::PERMISSION_MANAGE_SETTINGS => WPHooks::applyFilters(
'mailpoet_permission_manage_settings',
array(
'administrator'
)
),
self::PERMISSION_MANAGE_EMAILS => WPHooks::applyFilters(
'mailpoet_permission_manage_emails',
array(
'administrator',
'editor'
)
),
self::PERMISSION_MANAGE_SUBSCRIBERS => WPHooks::applyFilters(
'mailpoet_permission_manage_subscribers',
array(
'administrator'
)
),
self::PERMISSION_MANAGE_FORMS => WPHooks::applyFilters(
'mailpoet_permission_manage_forms',
array(
'administrator'
)
),
self::PERMISSION_MANAGE_SEGMENTS => WPHooks::applyFilters(
'mailpoet_permission_manage_segments',
array(
'administrator'
)
),
self::PERMISSION_UPDATE_PLUGIN => WPHooks::applyFilters(
'mailpoet_permission_update_plugin',
array(
'administrator'
)
),
);
}
function getUserRoles() {
$user = wp_get_current_user();
return $user->roles;
}
function getUserCapabilities() {
$user = wp_get_current_user();
return array_keys($user->allcaps);
}
function getUserFirstCapability() {
return (!empty($this->user_capabilities)) ?
$this->user_capabilities[0] :
null;
}
function validatePermission($permission) {
if($permission === self::NO_ACCESS_RESTRICTION) return true;
if(empty($this->permissions[$permission])) return false;
$permitted_roles = array_intersect(
$this->user_roles,
$this->permissions[$permission]
);
return (!empty($permitted_roles));
}
}

View File

@ -1,10 +1,11 @@
<?php
namespace MailPoet\Config;
if(!defined('ABSPATH')) exit;
class Activator {
static function activate() {
function activate() {
$migrator = new Migrator();
$migrator->up();
@ -14,8 +15,8 @@ class Activator {
update_option('mailpoet_db_version', Env::$version);
}
static function deactivate() {
function deactivate() {
$migrator = new Migrator();
$migrator->down();
}
}
}

View File

@ -1,12 +1,11 @@
<?php
namespace MailPoet\Config;
use MailPoet\Models\Setting;
use MailPoet\Util\Url;
class Changelog {
function __construct() {
}
function init() {
$doing_ajax = (bool)(defined('DOING_AJAX') && DOING_AJAX);

View File

@ -1,4 +1,5 @@
<?php
namespace MailPoet\Config;
if(!defined('ABSPATH')) exit;
@ -31,7 +32,6 @@ class Env {
static $db_collation;
static $db_charset_collate;
static $db_timezone_offset;
static $required_permission = 'manage_options';
static function init($file, $version) {
global $wpdb;

View File

@ -13,17 +13,18 @@ if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
class Initializer {
const UNABLE_TO_CONNECT = 'Unable to connect to the database (the database is unable to open a file or folder), the connection is likely not configured correctly. Please read our [link] Knowledge Base article [/link] for steps how to resolve it.';
const SOLVE_DB_ISSUE_URL = 'http://beta.docs.mailpoet.com/article/200-solving-database-connection-issues';
protected $plugin_initialized = false;
private $access_control;
function __construct($params = array(
'file' => '',
'version' => '1.0.0'
)) {
Env::init($params['file'], $params['version']);
$this->access_control = new AccessControl();
}
function init() {
@ -135,7 +136,11 @@ class Initializer {
// if current db version and plugin version differ
if(version_compare($current_db_version, Env::$version) !== 0) {
Activator::activate();
if(!$this->access_control->validatePermission(AccessControl::PERMISSION_UPDATE_PLUGIN)) {
throw new \Exception(__('You do not have permission to activate/deactivate MailPoet plugin.', 'mailpoet'));
}
$activator = new Activator();
$activator->activate();
}
}
@ -185,7 +190,7 @@ class Initializer {
}
function setupMenu() {
$menu = new Menu($this->renderer, Env::$assets_url);
$menu = new Menu($this->renderer, Env::$assets_url, $this->access_control);
$menu->init();
}
@ -218,11 +223,11 @@ class Initializer {
}
function setupJSONAPI() {
API\API::JSON()->init();
API\API::JSON($this->access_control)->init();
}
function setupRouter() {
$router = new Router\Router();
$router = new Router\Router($this->access_control);
$router->init();
}
@ -246,7 +251,7 @@ class Initializer {
function handleFailedInitialization($exception) {
// Check if we are able to add pages at this point
if(function_exists('wp_get_current_user')) {
Menu::addErrorPage();
Menu::addErrorPage($this->access_control);
}
return WPNotice::displayError($exception);
}

View File

@ -187,8 +187,9 @@ class MP2Migrator {
*
*/
private function eraseMP3Data() {
Activator::deactivate();
Activator::activate();
$activator = new Activator();
$activator->deactivate();
$activator->activate();
$this->deleteSegments();
$this->resetMigrationCounters();

View File

@ -1,4 +1,5 @@
<?php
namespace MailPoet\Config;
use MailPoet\Cron\CronTrigger;
@ -25,9 +26,18 @@ use MailPoet\WP\Readme;
if(!defined('ABSPATH')) exit;
class Menu {
function __construct($renderer, $assets_url) {
const MAIN_PAGE_SLUG = 'mailpoet-newsletters';
public $renderer;
public $assets_url;
private $access_control;
private $subscribers_over_limit;
function __construct($renderer, $assets_url, AccessControl $access_control) {
$this->renderer = $renderer;
$this->assets_url = $assets_url;
$this->access_control = $access_control;
$this->user_capability = $this->access_control->getUserFirstCapability();
$subscribers_feature = new SubscribersFeature();
$this->subscribers_over_limit = $subscribers_feature->check();
$this->checkMailPoetAPIKey();
@ -45,134 +55,204 @@ class Menu {
}
function setup() {
if(!$this->access_control->validatePermission(AccessControl::PERMISSION_ACCESS_PLUGIN_ADMIN)) return;
if(self::isOnMailPoetAdminPage()) {
do_action('mailpoet_conflict_resolver_styles');
do_action('mailpoet_conflict_resolver_scripts');
}
$main_page_slug = 'mailpoet-newsletters';
// Main page
add_menu_page(
'MailPoet',
'MailPoet',
Env::$required_permission,
$main_page_slug,
$this->user_capability,
self::MAIN_PAGE_SLUG,
null,
$this->assets_url . '/img/menu_icon.png',
30
);
$newsletters_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Emails', 'mailpoet')),
__('Emails', 'mailpoet'),
Env::$required_permission,
$main_page_slug,
array(
$this,
'newsletters'
)
);
// Emails page
if($this->access_control->validatePermission(AccessControl::PERMISSION_MANAGE_EMAILS)) {
$newsletters_page = add_submenu_page(
self::MAIN_PAGE_SLUG,
$this->setPageTitle(__('Emails', 'mailpoet')),
__('Emails', 'mailpoet'),
$this->user_capability,
self::MAIN_PAGE_SLUG,
array(
$this,
'newsletters'
)
);
// add limit per page to screen options
add_action('load-' . $newsletters_page, function() {
add_screen_option('per_page', array(
'label' => _x(
'Number of newsletters per page',
'newsletters per page (screen options)',
'mailpoet'
),
'option' => 'mailpoet_newsletters_per_page'
));
});
// add limit per page to screen options
add_action('load-' . $newsletters_page, function() {
add_screen_option('per_page', array(
'label' => _x(
'Number of newsletters per page',
'newsletters per page (screen options)',
'mailpoet'
),
'option' => 'mailpoet_newsletters_per_page'
));
});
$forms_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Forms', 'mailpoet')),
__('Forms', 'mailpoet'),
Env::$required_permission,
'mailpoet-forms',
array(
$this,
'forms'
)
);
// add limit per page to screen options
add_action('load-' . $forms_page, function() {
add_screen_option('per_page', array(
'label' => _x(
'Number of forms per page',
'forms per page (screen options)',
'mailpoet'
),
'option' => 'mailpoet_forms_per_page'
));
});
// newsletter editor
add_submenu_page(
true,
$this->setPageTitle(__('Newsletter', 'mailpoet')),
__('Newsletter Editor', 'mailpoet'),
$this->user_capability,
'mailpoet-newsletter-editor',
array(
$this,
'newletterEditor'
)
);
}
$subscribers_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Subscribers', 'mailpoet')),
__('Subscribers', 'mailpoet'),
Env::$required_permission,
'mailpoet-subscribers',
array(
$this,
'subscribers'
)
);
// add limit per page to screen options
add_action('load-' . $subscribers_page, function() {
add_screen_option('per_page', array(
'label' => _x(
'Number of subscribers per page',
'subscribers per page (screen options)',
'mailpoet'
),
'option' => 'mailpoet_subscribers_per_page'
));
});
// Forms page
if($this->access_control->validatePermission(AccessControl::PERMISSION_MANAGE_FORMS)) {
$forms_page = add_submenu_page(
self::MAIN_PAGE_SLUG,
$this->setPageTitle(__('Forms', 'mailpoet')),
__('Forms', 'mailpoet'),
$this->user_capability,
'mailpoet-forms',
array(
$this,
'forms'
)
);
$segments_page = add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Lists', 'mailpoet')),
__('Lists', 'mailpoet'),
Env::$required_permission,
'mailpoet-segments',
array(
$this,
'segments'
)
);
// add limit per page to screen options
add_action('load-' . $forms_page, function() {
add_screen_option('per_page', array(
'label' => _x(
'Number of forms per page',
'forms per page (screen options)',
'mailpoet'
),
'option' => 'mailpoet_forms_per_page'
));
});
// add limit per page to screen options
add_action('load-' . $segments_page, function() {
add_screen_option('per_page', array(
'label' => _x(
'Number of segments per page',
'segments per page (screen options)',
'mailpoet'
),
'option' => 'mailpoet_segments_per_page'
));
});
// form editor
add_submenu_page(
true,
$this->setPageTitle(__('Form Editor', 'mailpoet')),
__('Form Editor', 'mailpoet'),
$this->user_capability,
'mailpoet-form-editor',
array(
$this,
'formEditor'
)
);
}
// Subscribers page
if($this->access_control->validatePermission(AccessControl::PERMISSION_MANAGE_SUBSCRIBERS)) {
$subscribers_page = add_submenu_page(
self::MAIN_PAGE_SLUG,
$this->setPageTitle(__('Subscribers', 'mailpoet')),
__('Subscribers', 'mailpoet'),
$this->user_capability,
'mailpoet-subscribers',
array(
$this,
'subscribers'
)
);
// add limit per page to screen options
add_action('load-' . $subscribers_page, function() {
add_screen_option('per_page', array(
'label' => _x(
'Number of subscribers per page',
'subscribers per page (screen options)',
'mailpoet'
),
'option' => 'mailpoet_subscribers_per_page'
));
});
// import
add_submenu_page(
'admin.php?page=mailpoet-subscribers',
$this->setPageTitle(__('Import', 'mailpoet')),
__('Import', 'mailpoet'),
$this->user_capability,
'mailpoet-import',
array(
$this,
'import'
)
);
// export
add_submenu_page(
true,
$this->setPageTitle(__('Export', 'mailpoet')),
__('Export', 'mailpoet'),
$this->user_capability,
'mailpoet-export',
array(
$this,
'export'
)
);
}
// Segments page
if($this->access_control->validatePermission(AccessControl::PERMISSION_MANAGE_SEGMENTS)) {
$segments_page = add_submenu_page(
self::MAIN_PAGE_SLUG,
$this->setPageTitle(__('Lists', 'mailpoet')),
__('Lists', 'mailpoet'),
$this->user_capability,
'mailpoet-segments',
array(
$this,
'segments'
)
);
// add limit per page to screen options
add_action('load-' . $segments_page, function() {
add_screen_option('per_page', array(
'label' => _x(
'Number of segments per page',
'segments per page (screen options)',
'mailpoet'
),
'option' => 'mailpoet_segments_per_page'
));
});
}
// Settings page
if($this->access_control->validatePermission(AccessControl::PERMISSION_MANAGE_SETTINGS)) {
add_submenu_page(
self::MAIN_PAGE_SLUG,
$this->setPageTitle(__('Settings', 'mailpoet')),
__('Settings', 'mailpoet'),
$this->user_capability,
'mailpoet-settings',
array(
$this,
'settings'
)
);
}
// Help page
add_submenu_page(
$main_page_slug,
$this->setPageTitle(__('Settings', 'mailpoet')),
__('Settings', 'mailpoet'),
Env::$required_permission,
'mailpoet-settings',
array(
$this,
'settings'
)
);
add_submenu_page(
$main_page_slug,
self::MAIN_PAGE_SLUG,
$this->setPageTitle(__('Help', 'mailpoet')),
__('Help', 'mailpoet'),
Env::$required_permission,
$this->user_capability,
'mailpoet-help',
array(
$this,
@ -180,12 +260,13 @@ class Menu {
)
);
// Premium page
// Only show this page in menu if the Premium plugin is not activated
add_submenu_page(
License::getLicense() ? true : $main_page_slug,
License::getLicense() ? true : self::MAIN_PAGE_SLUG,
$this->setPageTitle(__('Premium', 'mailpoet')),
__('Premium', 'mailpoet'),
Env::$required_permission,
$this->user_capability,
'mailpoet-premium',
array(
$this,
@ -193,35 +274,12 @@ class Menu {
)
);
add_submenu_page(
'admin.php?page=mailpoet-subscribers',
$this->setPageTitle(__('Import', 'mailpoet')),
__('Import', 'mailpoet'),
Env::$required_permission,
'mailpoet-import',
array(
$this,
'import'
)
);
add_submenu_page(
true,
$this->setPageTitle(__('Export', 'mailpoet')),
__('Export', 'mailpoet'),
Env::$required_permission,
'mailpoet-export',
array(
$this,
'export'
)
);
// Welcome page
add_submenu_page(
true,
$this->setPageTitle(__('Welcome', 'mailpoet')),
__('Welcome', 'mailpoet'),
Env::$required_permission,
$this->user_capability,
'mailpoet-welcome',
array(
$this,
@ -229,23 +287,12 @@ class Menu {
)
);
add_submenu_page(
true,
$this->setPageTitle(__('Migration', 'mailpoet')),
'',
Env::$required_permission,
'mailpoet-migration',
array(
$this,
'migration'
)
);
// Update page
add_submenu_page(
true,
$this->setPageTitle(__('Update', 'mailpoet')),
__('Update', 'mailpoet'),
Env::$required_permission,
$this->user_capability,
'mailpoet-update',
array(
$this,
@ -253,27 +300,16 @@ class Menu {
)
);
// Migration page
add_submenu_page(
true,
$this->setPageTitle(__('Form Editor', 'mailpoet')),
__('Form Editor', 'mailpoet'),
Env::$required_permission,
'mailpoet-form-editor',
$this->setPageTitle(__('Migration', 'mailpoet')),
'',
$this->user_capability,
'mailpoet-migration',
array(
$this,
'formEditor'
)
);
add_submenu_page(
true,
$this->setPageTitle(__('Newsletter', 'mailpoet')),
__('Newsletter Editor', 'mailpoet'),
Env::$required_permission,
'mailpoet-newsletter-editor',
array(
$this,
'newletterEditor'
'migration'
)
);
}
@ -293,20 +329,20 @@ class Menu {
or
strpos($redirect_url, 'mailpoet') === false
) {
$redirect_url = admin_url('admin.php?page=mailpoet-newsletters');
$redirect_url = admin_url('admin.php?page=' . self::MAIN_PAGE_SLUG);
}
$data = array(
'settings' => Setting::getAll(),
'current_user' => wp_get_current_user(),
'redirect_url' => $redirect_url,
'sub_menu' => 'mailpoet-newsletters'
'sub_menu' => self::MAIN_PAGE_SLUG
);
$this->displayPage('welcome.html', $data);
}
function migration() {
$mp2_migrator = new MP2Migrator();
$mp2_migrator = new MP2Migrator($this->access_control);
$mp2_migrator->init();
$data = array(
'log_file_url' => $mp2_migrator->log_file_url,
@ -328,14 +364,14 @@ class Menu {
or
strpos($redirect_url, 'mailpoet') === false
) {
$redirect_url = admin_url('admin.php?page=mailpoet-newsletters');
$redirect_url = admin_url('admin.php?page=' . self::MAIN_PAGE_SLUG);
}
$data = array(
'settings' => Setting::getAll(),
'current_user' => wp_get_current_user(),
'redirect_url' => $redirect_url,
'sub_menu' => 'mailpoet-newsletters'
'sub_menu' => self::MAIN_PAGE_SLUG
);
$readme_file = Env::$path . '/readme.txt';
@ -352,7 +388,7 @@ class Menu {
function premium() {
$data = array(
'subscriber_count' => Subscriber::getTotalSubscribers(),
'sub_menu' => 'mailpoet-newsletters'
'sub_menu' => self::MAIN_PAGE_SLUG
);
$this->displayPage('premium.html', $data);
@ -505,7 +541,7 @@ class Menu {
'shortcodes' => ShortcodesHelper::getShortcodes(),
'settings' => Setting::getAll(),
'current_wp_user' => Subscriber::getCurrentWPUser(),
'sub_menu' => 'mailpoet-newsletters'
'sub_menu' => self::MAIN_PAGE_SLUG
);
wp_enqueue_media();
wp_enqueue_script('tinymce-wplink', includes_url('js/tinymce/plugins/wplink/plugin.js'));
@ -597,13 +633,13 @@ class Menu {
* This error page is used when the initialization is failed
* to display admin notices only
*/
static function addErrorPage() {
static function addErrorPage(AccessControl $access_control) {
if(!self::isOnMailPoetAdminPage()) {
return false;
}
// Check if page already exists
if(get_plugin_page_hook($_REQUEST['page'], '')
|| get_plugin_page_hook($_REQUEST['page'], 'mailpoet-newsletters')
|| get_plugin_page_hook($_REQUEST['page'], self::MAIN_PAGE_SLUG)
) {
return false;
}
@ -611,9 +647,12 @@ class Menu {
true,
'MailPoet',
'MailPoet',
Env::$required_permission,
$access_control->getUserFirstCapability(),
$_REQUEST['page'],
array(__CLASS__, 'errorPageCallback')
array(
__CLASS__,
'errorPageCallback'
)
);
}
@ -624,19 +663,17 @@ class Menu {
function checkMailPoetAPIKey(ServicesChecker $checker = null) {
if(self::isOnMailPoetAdminPage()) {
$show_notices = isset($_REQUEST['page'])
&& stripos($_REQUEST['page'], 'mailpoet-newsletters') === false;
&& stripos($_REQUEST['page'], self::MAIN_PAGE_SLUG) === false;
$checker = $checker ?: new ServicesChecker();
$this->mp_api_key_valid = $checker->isMailPoetAPIKeyValid($show_notices);
}
}
function checkPremiumKey(ServicesChecker $checker = null) {
if(self::isOnMailPoetAdminPage()) {
$show_notices = isset($_REQUEST['page'])
&& stripos($_REQUEST['page'], 'mailpoet-newsletters') === false;
$checker = $checker ?: new ServicesChecker();
$this->premium_key_valid = $checker->isPremiumKeyValid($show_notices);
}
$show_notices = isset($_SERVER['SCRIPT_NAME'])
&& stripos($_SERVER['SCRIPT_NAME'], 'plugins.php') !== false;
$checker = $checker ?: new ServicesChecker();
$this->premium_key_valid = $checker->isPremiumKeyValid($show_notices);
}
private function getLimitPerPage($model = null) {

View File

@ -22,7 +22,7 @@ class ServicesChecker {
if(!$mss_key_specified
|| empty($mss_key['state'])
|| $mss_key['state'] == Bridge::PREMIUM_KEY_INVALID
|| $mss_key['state'] == Bridge::KEY_INVALID
) {
if($display_error_notice) {
$error = Helpers::replaceLinkTags(
@ -33,7 +33,7 @@ class ServicesChecker {
WPNotice::displayError($error);
}
return false;
} elseif($mss_key['state'] == Bridge::PREMIUM_KEY_EXPIRING
} elseif($mss_key['state'] == Bridge::KEY_EXPIRING
&& !empty($mss_key['data']['expire_at'])
) {
if($display_error_notice) {
@ -48,7 +48,7 @@ class ServicesChecker {
WPNotice::displayWarning($error);
}
return true;
} elseif($mss_key['state'] == Bridge::PREMIUM_KEY_VALID) {
} elseif($mss_key['state'] == Bridge::KEY_VALID) {
return true;
}
@ -66,19 +66,27 @@ class ServicesChecker {
if(!$premium_key_specified
|| empty($premium_key['state'])
|| $premium_key['state'] === Bridge::PREMIUM_KEY_INVALID
|| $premium_key['state'] === Bridge::PREMIUM_KEY_ALREADY_USED
|| $premium_key['state'] === Bridge::KEY_INVALID
|| $premium_key['state'] === Bridge::KEY_ALREADY_USED
) {
if($display_error_notice) {
$error_string = __('[link1]Register[/link1] your copy of the MailPoet Premium plugin to receive access to automatic upgrades and support. Need a license key? [link2]Purchase one now.[/link2]', 'mailpoet');
$error = Helpers::replaceLinkTags(
__('Warning! Your License Key is either invalid or expired. [link]Renew your License now[/link] to enjoy automatic updates and Premium support.', 'mailpoet'),
'https://account.mailpoet.com',
array('target' => '_blank')
$error_string,
'admin.php?page=mailpoet-settings#premium',
array(),
'link1'
);
WPNotice::displayError($error);
$error = Helpers::replaceLinkTags(
$error,
'admin.php?page=mailpoet-premium',
array(),
'link2'
);
WPNotice::displayWarning($error);
}
return false;
} elseif($premium_key['state'] === Bridge::PREMIUM_KEY_EXPIRING
} elseif($premium_key['state'] === Bridge::KEY_EXPIRING
&& !empty($premium_key['data']['expire_at'])
) {
if($display_error_notice) {
@ -93,7 +101,7 @@ class ServicesChecker {
WPNotice::displayWarning($error);
}
return true;
} elseif($premium_key['state'] === Bridge::PREMIUM_KEY_VALID) {
} elseif($premium_key['state'] === Bridge::KEY_VALID) {
return true;
}

View File

@ -12,7 +12,6 @@ class Shortcodes {
function init() {
// form widget shortcode
add_shortcode('mailpoet_form', array($this, 'formWidget'));
add_shortcode('wysija_form', array($this, 'formWidget'));
// subscribers count shortcode
add_shortcode('mailpoet_subscribers_count', array(

View File

@ -1,5 +1,7 @@
<?php
namespace MailPoet\Config;
use MailPoet\Models\Form;
if(!defined('ABSPATH')) exit;
@ -113,10 +115,20 @@ class Widget {
'is_rtl' => (function_exists('is_rtl') ? (bool)is_rtl() : false)
));
$ajaxFailedErrorMessage = __('An error has happened while performing a request, please try again later.');
$ajax_failed_error_message = __('An error has happened while performing a request, please try again later.');
$inline_script = <<<EOL
function initMailpoetTranslation() {
if(typeof MailPoet !== 'undefined') {
MailPoet.I18n.add('ajaxFailedErrorMessage', '%s')
} else {
setTimeout(initMailpoetTranslation, 250);
}
}
setTimeout(initMailpoetTranslation, 250);
EOL;
wp_add_inline_script(
'mailpoet_public',
sprintf('MailPoet.I18n.add("ajaxFailedErrorMessage", "%s")', $ajaxFailedErrorMessage),
sprintf($inline_script, $ajax_failed_error_message),
'after'
);
}

View File

@ -8,6 +8,9 @@ if(!defined('ABSPATH')) exit;
class Posts {
static function extractAndSave($rendered_newsletter, $newsletter) {
if($newsletter->type !== NewsletterModel::TYPE_NOTIFICATION_HISTORY) {
return false;
}
preg_match_all(
'/data-post-id="(\d+)"/ism',
$rendered_newsletter['html'],
@ -16,9 +19,7 @@ class Posts {
if(!count($matched_posts_ids)) {
return false;
}
$newsletter_id = ($newsletter->type === NewsletterModel::TYPE_NOTIFICATION_HISTORY) ?
$newsletter->parent_id :
$newsletter->id;
$newsletter_id = $newsletter->parent_id; // parent post notification
foreach($matched_posts_ids as $post_id) {
$newsletter_post = NewsletterPost::create();
$newsletter_post->newsletter_id = $newsletter_id;
@ -27,4 +28,4 @@ class Posts {
}
return true;
}
}
}

View File

@ -15,7 +15,7 @@ class Renderer {
$styles = new Util\Styles(static::getStyles($form));
$html = '<style type="text/css">';
$html .= '.mailpoet_hp_email_label{position: absolute;left: -999em;}';// move honeypot field out of the sight
$html .= '.mailpoet_hp_email_label{position: absolute;left: -999em;}'; // move honeypot field out of sight
$html .= $styles->render($prefix);
$html .= '</style>';
@ -38,11 +38,13 @@ class Renderer {
}
}
static function renderBlocks($blocks = array()) {
// this is a honeypot for spambots
$html = '<label class="mailpoet_hp_email_label">Please leave this field empty<input type="email" name="data[email]"></label>';
static function renderBlocks($blocks = array(), $honeypot_enabled = true) {
// add honeypot for spambots
$html = ($honeypot_enabled) ?
'<label class="mailpoet_hp_email_label">' . __('Please leave this field empty', 'mailpoet') . '<input type="email" name="data[email]"></label>' :
'';
foreach($blocks as $key => $block) {
$html .= static::renderBlock($block)."\n";
$html .= static::renderBlock($block) . PHP_EOL;
}
return $html;

View File

@ -3,7 +3,7 @@
namespace MailPoet\Form;
use MailPoet\API\JSON\API;
use MailPoet\Config\Renderer;
use MailPoet\Config\Renderer as ConfigRenderer;
use MailPoet\Form\Renderer as FormRenderer;
use MailPoet\Models\Form;
use MailPoet\Util\Security;
@ -174,7 +174,7 @@ class Widget extends \WP_Widget {
$data['api_version'] = API::CURRENT_VERSION;
// render form
$renderer = new Renderer();
$renderer = new ConfigRenderer();
try {
$output = $renderer->render('form/widget.html', $data);
$output = do_shortcode($output);

View File

@ -488,7 +488,10 @@ class Subscriber extends Model {
unset($data['segments']);
}
$data = self::setRequiredFieldsDefaultValues($data);
// if new subscriber, make sure that required fields are set
if(!$subscriber) {
$data = self::setRequiredFieldsDefaultValues($data);
}
// get custom fields
list($data, $custom_fields) = self::extractCustomFieldsFromFromObject($data);

View File

@ -23,11 +23,8 @@ class Renderer {
$parent = Newsletter::findOne($newsletter_id);
$newer_than_timestamp = $parent->created_at;
}
} else if($preview) {
$newsletter_id = false;
$newer_than_timestamp = false;
} else {
$newsletter_id = $newsletter['id'];
$newsletter_id = false;
$newer_than_timestamp = false;
}
$this->ALC = new \MailPoet\Newsletter\AutomatedLatestContent(

View File

@ -176,6 +176,18 @@ class Scheduler {
return $next_run_date;
}
static function getPreviousRunDate($schedule, $from_timestamp = false) {
$from_timestamp = ($from_timestamp) ? $from_timestamp : current_time('timestamp');
try {
$schedule = \Cron\CronExpression::factory($schedule);
$previous_run_date = $schedule->getPreviousRunDate(Carbon::createFromTimestamp($from_timestamp))
->format('Y-m-d H:i:s');
} catch(\Exception $e) {
$previous_run_date = false;
}
return $previous_run_date;
}
static function getNewsletters($type) {
return Newsletter::getPublished()
->filter('filterType', $type)

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Router\Endpoints;
use MailPoet\Config\AccessControl;
use MailPoet\Cron\CronHelper;
use MailPoet\Cron\Daemon;
@ -17,6 +19,9 @@ class CronDaemon {
self::ACTION_PING_RESPONSE
);
public $data;
public $permissions = array(
'global' => AccessControl::NO_ACCESS_RESTRICTION
);
function __construct($data) {
$this->data = $data;

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Router\Endpoints;
use MailPoet\Config\AccessControl;
use MailPoet\Subscription as UserSubscription;
if(!defined('ABSPATH')) exit;
@ -16,6 +18,9 @@ class Subscription {
self::ACTION_UNSUBSCRIBE
);
public $data;
public $permissions = array(
'global' => AccessControl::NO_ACCESS_RESTRICTION
);
function __construct($data) {
$this->data = $data;

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Router\Endpoints;
use MailPoet\Config\AccessControl;
use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterLink;
use MailPoet\Models\SendingQueue;
@ -20,6 +22,9 @@ class Track {
self::ACTION_OPEN
);
public $data;
public $permissions = array(
'global' => AccessControl::NO_ACCESS_RESTRICTION
);
function __construct($data) {
$this->data = $this->_processTrackData($data);
@ -38,8 +43,8 @@ class Track {
function _processTrackData($data) {
$data = (object)Links::transformUrlDataObject($data);
if(empty($data->queue_id) ||
empty($data->subscriber_id) ||
empty($data->subscriber_token)
empty($data->subscriber_id) ||
empty($data->subscriber_token)
) {
return false;
}

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