Load/Save settings
- renamed all settings with dot syntax - refactored Menu->settings() - changed schema of settings table to allow longer setting name and value - added getAll() static method on Setting Model to fetch all settings (with proper unserialize of value)
This commit is contained in:
@ -51,7 +51,7 @@ function(
|
||||
return (
|
||||
<select
|
||||
ref="selection"
|
||||
id={ this.props.field.id || 'mailpoet_field_selection'}
|
||||
id={ this.props.field.id }
|
||||
placeholder={ this.props.field.placeholder }
|
||||
multiple={ this.props.field.multiple }
|
||||
onChange={ this.handleChange }
|
||||
|
@ -3,8 +3,10 @@ namespace MailPoet\Config;
|
||||
use \MailPoet\Models\Segment;
|
||||
use \MailPoet\Models\Setting;
|
||||
use \MailPoet\Settings\Hosts;
|
||||
use \MailPoet\Settings\Permissions;
|
||||
use \MailPoet\Settings\Pages;
|
||||
use \MailPoet\Util\Permissions;
|
||||
use \MailPoet\Util\DKIM;
|
||||
use \MailPoet\Util\Charsets;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
@ -95,10 +97,9 @@ class Menu {
|
||||
}
|
||||
|
||||
function settings() {
|
||||
// Flags (available features on WP install)
|
||||
// flags (available features on WP install)
|
||||
$flags = array();
|
||||
|
||||
// check if registration is enabled
|
||||
if(is_multisite()) {
|
||||
// get multisite registration option
|
||||
$registration = apply_filters(
|
||||
@ -115,44 +116,7 @@ class Menu {
|
||||
(bool)get_option('users_can_register', false);
|
||||
}
|
||||
|
||||
// Segments
|
||||
$segments = Segment::findArray();
|
||||
|
||||
// Settings
|
||||
$all_settings = Setting::findMany();
|
||||
$settings = array();
|
||||
foreach($all_settings as $setting) {
|
||||
$settings[$setting->name] = $setting->value;
|
||||
}
|
||||
|
||||
// Current user
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
// WP Pages
|
||||
$mailpoet_pages = get_posts(array('post_type' => 'mailpoet_page'));
|
||||
$pages = array_merge($mailpoet_pages, get_pages());
|
||||
foreach($pages as $key => $page) {
|
||||
// convert page object to array so that we can add some values
|
||||
$page = (array)$page;
|
||||
// get page's preview url
|
||||
$page['preview_url'] = get_permalink($page['ID']);
|
||||
// get page's edit url
|
||||
$page['edit_url'] = get_edit_post_link($page['ID']);
|
||||
// update page data
|
||||
$pages[$key] = $page;
|
||||
}
|
||||
|
||||
// Charsets
|
||||
$charsets = array(
|
||||
'UTF-8', 'UTF-7', 'BIG5', 'ISO-2022-JP',
|
||||
'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3',
|
||||
'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6',
|
||||
'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
|
||||
'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14',
|
||||
'ISO-8859-15', 'Windows-1251', 'Windows-1252'
|
||||
);
|
||||
|
||||
|
||||
$settings = Setting::getAll();
|
||||
|
||||
// dkim: check if public/private keys have been generated
|
||||
if(
|
||||
@ -171,12 +135,12 @@ class Menu {
|
||||
|
||||
$data = array(
|
||||
'settings' => $settings,
|
||||
'segments' => $segments,
|
||||
'pages' => $pages,
|
||||
'segments' => Segment::findArray(),
|
||||
'pages' => Pages::getAll(),
|
||||
'flags' => $flags,
|
||||
'charsets' => $charsets,
|
||||
'current_user' => $current_user,
|
||||
'permissions' => Permissions::get(),
|
||||
'charsets' => Charsets::getAll(),
|
||||
'current_user' => wp_get_current_user(),
|
||||
'permissions' => Permissions::getAll(),
|
||||
'hosts' => array(
|
||||
'web' => Hosts::getWebHosts(),
|
||||
'smtp' => Hosts::getSMTPHosts()
|
||||
|
@ -60,8 +60,8 @@ class Migrator {
|
||||
function settings() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'name varchar(20) NOT NULL,',
|
||||
'value varchar(255) NOT NULL,',
|
||||
'name varchar(50) NOT NULL,',
|
||||
'value mediumtext NOT NULL,',
|
||||
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||
'PRIMARY KEY (id),',
|
||||
|
@ -20,10 +20,29 @@ class Setting extends Model {
|
||||
if($setting === false) {
|
||||
return $default;
|
||||
} else {
|
||||
return $setting->value;
|
||||
if(is_serialized($setting->value)) {
|
||||
return unserialize($setting->value);
|
||||
} else {
|
||||
return $setting->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$settingsCollection = self::findMany();
|
||||
$settings = array();
|
||||
if(!empty($settingsCollection)) {
|
||||
foreach($settingsCollection as $setting) {
|
||||
$value = (is_serialized($setting->value)
|
||||
? unserialize($setting->value)
|
||||
: $setting->value
|
||||
);
|
||||
$settings[$setting->name] = $value;
|
||||
}
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
public static function createOrUpdate($model) {
|
||||
$exists = self::where('name', $model['name'])
|
||||
->find_one();
|
||||
|
14
lib/Router/Permissions.php
Normal file
14
lib/Router/Permissions.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace MailPoet\Router;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Permissions {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function set($permissions = array()) {
|
||||
$result = \MailPoet\Util\Permissions::set($permissions);
|
||||
wp_send_json($result);
|
||||
}
|
||||
}
|
@ -9,20 +9,24 @@ class Settings {
|
||||
}
|
||||
|
||||
function get() {
|
||||
$settings = Setting::find_array();
|
||||
$settings = Setting::getAll();
|
||||
wp_send_json($settings);
|
||||
}
|
||||
|
||||
function set($args) {
|
||||
$save = function($setting) {
|
||||
Setting::createOrUpdate($setting);
|
||||
};
|
||||
$results = array_map($save, $args);
|
||||
|
||||
wp_send_json(in_array(false, $results));
|
||||
}
|
||||
|
||||
function save($data = array()) {
|
||||
// TODO
|
||||
function set($settings = array()) {
|
||||
if(empty($settings)) {
|
||||
wp_send_json(false);
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
if(is_array($value)) {
|
||||
$value = serialize($value);
|
||||
}
|
||||
Setting::createOrUpdate(array(
|
||||
'name' => $name,
|
||||
'value' => $value
|
||||
));
|
||||
}
|
||||
wp_send_json(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
lib/Settings/Pages.php
Normal file
23
lib/Settings/Pages.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace MailPoet\Settings;
|
||||
|
||||
class Pages {
|
||||
|
||||
static function getAll() {
|
||||
$mailpoet_pages = get_posts(array(
|
||||
'post_type' => 'mailpoet_page'
|
||||
));
|
||||
|
||||
$pages = array_merge($mailpoet_pages, get_pages());
|
||||
|
||||
foreach($pages as $key => $page) {
|
||||
$page = (array)$page;
|
||||
$page['preview_url'] = get_permalink($page['ID']);
|
||||
$page['edit_url'] = get_edit_post_link($page['ID']);
|
||||
|
||||
$pages[$key] = $page;
|
||||
}
|
||||
|
||||
return $pages;
|
||||
}
|
||||
}
|
15
lib/Util/Charsets.php
Normal file
15
lib/Util/Charsets.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace MailPoet\Util;
|
||||
|
||||
class Charsets {
|
||||
static function getAll() {
|
||||
return array(
|
||||
'UTF-8', 'UTF-7', 'BIG5', 'ISO-2022-JP',
|
||||
'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3',
|
||||
'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6',
|
||||
'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
|
||||
'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14',
|
||||
'ISO-8859-15', 'Windows-1251', 'Windows-1252'
|
||||
);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace MailPoet\Settings;
|
||||
namespace MailPoet\Util;
|
||||
|
||||
class Permissions {
|
||||
static function getCapabilities() {
|
||||
@ -30,7 +30,7 @@ class Permissions {
|
||||
return $roles;
|
||||
}
|
||||
|
||||
static function get() {
|
||||
static function getAll() {
|
||||
$roles = static::getRoles();
|
||||
$capabilities = static::getCapabilities();
|
||||
|
||||
@ -67,28 +67,31 @@ class Permissions {
|
||||
}
|
||||
|
||||
static function set($permissions = array()) {
|
||||
if(!empty($permissions)) {
|
||||
foreach($permissions as $permission) {
|
||||
// ignore administrator & superadmin roles
|
||||
if(in_array(
|
||||
$permission['role'],
|
||||
array('administrator', 'superadmin'))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if(empty($permissions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// get role
|
||||
$role = get_role($permission['role']);
|
||||
if((bool)$permission['is_capable'] === true) {
|
||||
// add capability to role
|
||||
$role->add_cap($permission['capability']);
|
||||
} else {
|
||||
// remove capability to role
|
||||
if($role->has_cap($permission['capability'])) {
|
||||
$role->remove_cap($permission['capability']);
|
||||
}
|
||||
foreach($permissions as $permission) {
|
||||
// ignore administrator & superadmin roles
|
||||
if(in_array(
|
||||
$permission['role'],
|
||||
array('administrator', 'superadmin'))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// get role
|
||||
$role = get_role($permission['role']);
|
||||
if((bool)$permission['is_capable'] === true) {
|
||||
// add capability to role
|
||||
$role->add_cap($permission['capability']);
|
||||
} else {
|
||||
// remove capability to role
|
||||
if($role->has_cap($permission['capability'])) {
|
||||
$role->remove_cap($permission['capability']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -67,41 +67,14 @@
|
||||
e.preventDefault();
|
||||
|
||||
// serialize form data
|
||||
var data = $('#mailpoet_settings_form').serializeObject(),
|
||||
var settings_data = $('#mailpoet_settings_form').serializeObject(),
|
||||
permissions = $('.mailpoet_role_permission'),
|
||||
data_permissions = [],
|
||||
has_error = false;
|
||||
|
||||
// check if "subscribe in comments" is enabled
|
||||
if(parseInt(data.subscribe_on_comment) === 1) {
|
||||
if(data.subscribe_on_comment_lists === undefined) {
|
||||
$('#subscribe_on_comment_lists').next('.mailpoet_error').show();
|
||||
has_error = true;
|
||||
} else {
|
||||
$('#subscribe_on_comment_lists').next('.mailpoet_error').hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check if "subscribe in registration form" is enabled
|
||||
if(parseInt(data.subscribe_on_register) === 1) {
|
||||
if(data.subscribe_on_register_lists === undefined) {
|
||||
$('#subscribe_on_register_lists').next('.mailpoet_error').show();
|
||||
has_error = true;
|
||||
} else {
|
||||
$('#subscribe_on_register_lists').next('.mailpoet_error').hide();
|
||||
}
|
||||
}
|
||||
|
||||
// fail fast...
|
||||
if(has_error === true) {
|
||||
return false;
|
||||
}
|
||||
permissions_data = []
|
||||
|
||||
// format permissions
|
||||
for(var i = permissions.length - 1; i >= 0; i--) {
|
||||
var permission = $(permissions[i]);
|
||||
data_permissions.push({
|
||||
permissions_data.push({
|
||||
role: permission.data('role'),
|
||||
capability: permission.data('capability'),
|
||||
is_capable: (permission.is(':checked') ? 1 : 0)
|
||||
@ -109,28 +82,38 @@
|
||||
};
|
||||
|
||||
// show loading screen
|
||||
//MailPoet.Modal.loading(true);
|
||||
console.log(data);
|
||||
console.log(data_permissions);
|
||||
MailPoet.Modal.loading(true);
|
||||
|
||||
// // save permissions
|
||||
// mailpoet_post_wpi('settings_set_permissions.php', { permissions: data_permissions });
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'settings',
|
||||
action: 'set',
|
||||
data: settings_data
|
||||
}).done(function(response) {
|
||||
if(response === true) {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'permissions',
|
||||
action: 'set',
|
||||
data: permissions_data
|
||||
});
|
||||
|
||||
// // save settings
|
||||
// mailpoet_post_json('settings_set.php', data, function(response) {
|
||||
// if(response.success !== undefined && response.success === true) {
|
||||
// // display success message
|
||||
// MailPoet.Notice.success("<?php _e('Settings saved.'); ?>");
|
||||
// } else if(response.error !== undefined) {
|
||||
// MailPoet.Notice.error("<?php _e('Settings could not be saved.'); ?>");
|
||||
// }
|
||||
|
||||
// // hide loading screen
|
||||
// // MailPoet.Modal.loading(false);
|
||||
// }, function(error) {
|
||||
// // hide loading screen
|
||||
// // MailPoet.Modal.loading(false);
|
||||
// });
|
||||
MailPoet.Notice.success(
|
||||
"<%= __('Settings saved.') %>",
|
||||
{ scroll: true }
|
||||
);
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('Settings could not be saved.') %>",
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
MailPoet.Modal.loading(false);
|
||||
}).error(function(errors) {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('An error occurred. Check your settings.') %>",
|
||||
{ scroll: true }
|
||||
);
|
||||
MailPoet.Modal.loading(false);
|
||||
});
|
||||
});
|
||||
|
||||
// setup toggle checkboxes
|
||||
|
@ -54,8 +54,8 @@
|
||||
<p>
|
||||
<input type="text"
|
||||
id="settings[bounce_email]"
|
||||
name="bounce_email"
|
||||
value="<%= settings.bounce_email %>"
|
||||
name="bounce[address]"
|
||||
value="<%= settings.bounce.address %>"
|
||||
placeholder="bounce@mydomain.com"
|
||||
/>
|
||||
</p>
|
||||
@ -80,9 +80,9 @@
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="analytics"
|
||||
name="analytics[enabled]"
|
||||
value="1"
|
||||
<% if(settings.analytics) %>
|
||||
<% if(settings.analytics.enabled) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/><%= __('Yes') %>
|
||||
@ -91,9 +91,9 @@
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="analytics"
|
||||
name="analytics[enabled]"
|
||||
value=""
|
||||
<% if not(settings.analytics) %>
|
||||
<% if not(settings.analytics.enabled) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/><%= __('No') %>
|
||||
@ -104,7 +104,7 @@
|
||||
<!-- charset -->
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="settings[newsletter_charset]">
|
||||
<label for="settings[charset]">
|
||||
<%= __('Charset') %>
|
||||
<p class="description">
|
||||
<%= __('Squares or weird characters are displayed in your emails? Select the encoding for your language.') %>
|
||||
@ -113,11 +113,14 @@
|
||||
</th>
|
||||
<td>
|
||||
<p>
|
||||
<select id="settings[newsletter_charset]" name="newsletter_charset">
|
||||
<select
|
||||
id="settings[charset]"
|
||||
name="charset"
|
||||
>
|
||||
<% for charset in charsets %>
|
||||
<option
|
||||
value="<%= charset %>"
|
||||
<% if(settings.newsletter_charset == charset) %>
|
||||
<% if(settings.charset == charset) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= charset %></option>
|
||||
@ -141,9 +144,9 @@
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="debug"
|
||||
name="debug[enabled]"
|
||||
value="1"
|
||||
<% if(settings.debug) %>
|
||||
<% if(settings.debug.enabled) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/><%= __('Yes') %>
|
||||
@ -152,9 +155,9 @@
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="debug"
|
||||
name="debug[enabled]"
|
||||
value=""
|
||||
<% if not(settings.debug) %>
|
||||
<% if not(settings.debug.enabled) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/><%= __('No') %>
|
||||
|
@ -14,17 +14,17 @@
|
||||
<p>
|
||||
<input type="text"
|
||||
id="settings[notification_email]"
|
||||
name="notification_email"
|
||||
value="<%= settings.notification_email %>"
|
||||
name="notification[address]"
|
||||
value="<%= settings.notification.address %>"
|
||||
placeholder="notification@mydomain.com"
|
||||
class="regular-text" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="settings[notification_on_subscribe]">
|
||||
<input type="checkbox" id="settings[notification_on_subscribe]"
|
||||
name="notification_on_subscribe"
|
||||
name="notification[on_subscribe]"
|
||||
value="1"
|
||||
<% if(settings.notification_on_subscribe) %>checked="checked"<% endif %> />
|
||||
<% if(settings.notification.on_subscribe) %>checked="checked"<% endif %> />
|
||||
<%= __('When someone subscribes') %>
|
||||
</label>
|
||||
</p>
|
||||
@ -32,9 +32,9 @@
|
||||
<label for="settings[notification_on_unsubscribe]">
|
||||
<input type="checkbox"
|
||||
id="settings[notification_on_unsubscribe]"
|
||||
name="notification_on_unsubscribe"
|
||||
name="notification[on_unsubscribe]"
|
||||
value="1"
|
||||
<% if(settings.notification_on_unsubscribe) %>checked="checked"<% endif %> />
|
||||
<% if(settings.notification.on_unsubscribe) %>checked="checked"<% endif %> />
|
||||
<%= __('When someone unsubscribes') %>
|
||||
</label>
|
||||
</p>
|
||||
@ -42,9 +42,9 @@
|
||||
<label for="settings[notification_daily_report]">
|
||||
<input type="checkbox"
|
||||
id="settings[notification_daily_report]"
|
||||
name="notification_daily_report"
|
||||
name="notification[daily_report]"
|
||||
value="1"
|
||||
<% if(settings.notification_daily_report) %>checked="checked"<% endif %> />
|
||||
<% if(settings.notification.daily_report) %>checked="checked"<% endif %> />
|
||||
<%= __('Daily summary of emails sent') %>
|
||||
</label>
|
||||
</p>
|
||||
@ -53,13 +53,13 @@
|
||||
<label for="settings[from_name]"><%= __('From') %></label>
|
||||
<input type="text"
|
||||
id="settings[from_name]"
|
||||
name="from_name"
|
||||
value="<%= settings.from_name %>"
|
||||
name="sender[name]"
|
||||
value="<%= settings.sender.name %>"
|
||||
placeholder="<%= __('Your name') %>" />
|
||||
<input type="text"
|
||||
id="settings[from_email]"
|
||||
name="from_email"
|
||||
value="<%= settings.from_email %>"
|
||||
name="sender[address]"
|
||||
value="<%= settings.sender.address %>"
|
||||
placeholder="info@mydomain.com" />
|
||||
</p>
|
||||
<!-- email notification: reply_to name & email -->
|
||||
@ -67,13 +67,13 @@
|
||||
<label for="settings[notification_reply_name]"><%= __('Reply-to') %></label>
|
||||
<input type="text"
|
||||
id="settings[notification_reply_name]"
|
||||
name="notification_reply_name"
|
||||
value="<%= settings.notification_reply_name %>"
|
||||
name="notification[reply_to][name]"
|
||||
value="<%= settings.notification.reply_to.name %>"
|
||||
placeholder="<%= __('Your name') %>" />
|
||||
<input type="text"
|
||||
id="settings[notification_reply_email]"
|
||||
name="notification_reply_email"
|
||||
value="<%= settings.notification_reply_email %>"
|
||||
name="notification[reply_to][address]"
|
||||
value="<%= settings.notification.reply_to.address %>"
|
||||
placeholder="info@mydomain.com" />
|
||||
</p>
|
||||
</td>
|
||||
@ -89,17 +89,24 @@
|
||||
</th>
|
||||
<td>
|
||||
<p>
|
||||
<input data-toggle="mailpoet_subscribe_on_comment" type="checkbox" value="1" id="settings[subscribe_on_comment]" name="subscribe_on_comment" <% if(settings.subscribe_on_comment) %>checked="checked"<% endif %> />
|
||||
<input
|
||||
data-toggle="mailpoet_subscribe_on_comment"
|
||||
type="checkbox"
|
||||
value="1"
|
||||
id="settings[subscribe_on_comment]"
|
||||
name="subscribe[on_comment][enabled]"
|
||||
<% if(settings.subscribe.on_comment.enabled) %>checked="checked"<% endif %>
|
||||
/>
|
||||
</p>
|
||||
<div id="mailpoet_subscribe_on_comment">
|
||||
<p>
|
||||
<input
|
||||
type="text"
|
||||
id="settings[subscribe_on_comment_label]"
|
||||
name="subscribe_on_comment_label"
|
||||
name="subscribe[on_comment][label]"
|
||||
class="regular-text"
|
||||
<%if(settings.subscribe_on_comment_label) %>
|
||||
value="<%= settings.subscribe_on_comment_label %>"
|
||||
<%if(settings.subscribe.on_comment.label) %>
|
||||
value="<%= settings.subscribe.on_comment.label %>"
|
||||
<% else %>
|
||||
value="<%= __('Yes, add me to your mailing list.') %>"
|
||||
<% endif %>
|
||||
@ -108,22 +115,19 @@
|
||||
<p>
|
||||
<select
|
||||
id="mailpoet_subscribe_on_comment_lists"
|
||||
name="subscribe_on_comment_lists[]"
|
||||
name="subscribe[on_comment][lists][]"
|
||||
placeholder="<%= __('Choose a list') %>"
|
||||
multiple
|
||||
>
|
||||
<% for segment in segments %>
|
||||
<option
|
||||
value="<%= segment.id %>"
|
||||
<% if(segment.id in settings.subscribe_on_comment_lists) %>
|
||||
<% if(segment.id in settings.subscribe.on_comment.lists) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= segment.name %></option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
<span class="mailpoet_error">
|
||||
<%= __('Please select a list.') %>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -148,8 +152,8 @@
|
||||
type="checkbox"
|
||||
value="1"
|
||||
id="settings[subscribe_on_register]"
|
||||
name="subscribe_on_register"
|
||||
<% if(settings.subscribe_on_register) %>
|
||||
name="subscribe[on_register][enabled]"
|
||||
<% if(settings.subscribe.on_register.enabled) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/>
|
||||
@ -160,10 +164,10 @@
|
||||
<input
|
||||
type="text"
|
||||
id="settings[subscribe_on_register_label]"
|
||||
name="subscribe_on_register_label"
|
||||
name="subscribe[on_register][label]"
|
||||
class="regular-text"
|
||||
<%if(settings.subscribe_on_register_label) %>
|
||||
value="<%= settings.subscribe_on_register_label %>"
|
||||
<%if(settings.subscribe.on_register.label) %>
|
||||
value="<%= settings.subscribe.on_register.label %>"
|
||||
<% else %>
|
||||
value="<%= __('Yes, add me to your mailing list.') %>"
|
||||
<% endif %>
|
||||
@ -172,14 +176,14 @@
|
||||
<p>
|
||||
<select
|
||||
id="mailpoet_subscribe_on_register_lists"
|
||||
name="subscribe_on_register_lists[]"
|
||||
name="subscribe[on_register][lists][]"
|
||||
placeholder="<%= __('Choose a list') %>"
|
||||
multiple
|
||||
>
|
||||
<% for segment in segments %>
|
||||
<option
|
||||
value="<%= segment.id %>"
|
||||
<% if(segment.id in settings.subscribe_on_register_lists) %>
|
||||
<% if(segment.id in settings.subscribe.on_register.lists) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= segment.name %></option>
|
||||
@ -209,14 +213,14 @@
|
||||
<p>
|
||||
<select
|
||||
class="mailpoet_page_selection"
|
||||
name="subscription_edit_page"
|
||||
name="subscription[page]"
|
||||
>
|
||||
<% for page in pages %>
|
||||
<option
|
||||
value="<%= page.ID %>"
|
||||
data-preview-url="<%= page.preview_url|raw %>"
|
||||
data-edit-url="<%= page.edit_url|raw %>"
|
||||
<% if(page.ID == settings.subscription_edit_page) %>
|
||||
<% if(page.ID == settings.subscription.page) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= page.post_title %></option>
|
||||
@ -238,14 +242,14 @@
|
||||
<p>
|
||||
<select
|
||||
id="mailpoet_subscription_edit_lists"
|
||||
name="subscription_edit_lists[]"
|
||||
name="subscription[lists][]"
|
||||
placeholder="<%= __('Leave empty to show all lists') %>"
|
||||
multiple
|
||||
>
|
||||
<% for segment in segments %>
|
||||
<option
|
||||
value="<%= segment.id %>"
|
||||
<% if(segment.id in settings.subscription_edit_lists) %>
|
||||
<% if(segment.id in settings.subscription.lists) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= segment.name %></option>
|
||||
|
@ -14,21 +14,21 @@
|
||||
<input
|
||||
type="hidden"
|
||||
id="mta_method"
|
||||
name="mta_method"
|
||||
value="<%= settings.mta_method %>"
|
||||
name="mta[method]"
|
||||
value="<%= settings.mta.method %>"
|
||||
/>
|
||||
<!-- mta: sending frequency -->
|
||||
<input
|
||||
type="hidden"
|
||||
id="mta_frequency_emails"
|
||||
name="mta_frequency_emails"
|
||||
value="<%= settings.mta_frequency_emails %>"
|
||||
name="mta[frequency][emails]"
|
||||
value="<%= settings.mta.frequency.emails %>"
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
id="mta_frequency_interval"
|
||||
name="mta_frequency_interval"
|
||||
value="<%= settings.mta_frequency_interval %>"
|
||||
name="mta[frequency][interval]"
|
||||
value="<%= settings.mta.frequency.interval %>"
|
||||
/>
|
||||
<!-- dkim: public / private keys -->
|
||||
<input
|
||||
@ -52,7 +52,7 @@
|
||||
<ul class="mailpoet_sending_methods clearfix">
|
||||
<li
|
||||
data-method="mailpoet"
|
||||
<% if(settings.mta_method == 'mailpoet') %>class="mailpoet_active"<% endif %>
|
||||
<% if(settings.mta.method == 'mailpoet') %>class="mailpoet_active"<% endif %>
|
||||
>
|
||||
<h3>
|
||||
<img
|
||||
@ -81,7 +81,7 @@
|
||||
</li>
|
||||
<li
|
||||
data-method="website"
|
||||
<% if(settings.mta_method == 'website') %>class="mailpoet_active"<% endif %>
|
||||
<% if(settings.mta.method == 'website') %>class="mailpoet_active"<% endif %>
|
||||
>
|
||||
<h3><%= __('Your own website') %></h3>
|
||||
|
||||
@ -101,7 +101,7 @@
|
||||
</li>
|
||||
<li
|
||||
data-method="smtp"
|
||||
<% if(settings.mta_method == 'smtp') %>class="mailpoet_active"<% endif %>
|
||||
<% if(settings.mta.method == 'smtp') %>class="mailpoet_active"<% endif %>
|
||||
>
|
||||
<h3><%= __('Third party') %></h3>
|
||||
|
||||
@ -156,16 +156,16 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="mailpoet_account_key">
|
||||
<label for="mailpoet_api_key">
|
||||
<%= __('Your key') %>
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
id="mailpoet_account_key"
|
||||
id="mailpoet_api_key"
|
||||
size="40"
|
||||
name="account_key"
|
||||
name="api_key"
|
||||
value="<%= settings.api_key %>"
|
||||
/>
|
||||
</td>
|
||||
@ -193,11 +193,11 @@
|
||||
<p>
|
||||
<label>
|
||||
<input type="radio"
|
||||
name="mta_local_method"
|
||||
name="mta[local_method]"
|
||||
value="mail"
|
||||
<%
|
||||
if not(settings.mta_local_method)
|
||||
or (settings.mta_local_method == 'mail')
|
||||
if not(settings.mta.local_method)
|
||||
or (settings.mta.local_method == 'mail')
|
||||
%>checked="checked"<% endif %>
|
||||
/>PHP Mail
|
||||
</label>
|
||||
@ -207,10 +207,10 @@
|
||||
<p>
|
||||
<label>
|
||||
<input type="radio"
|
||||
name="mta_local_method"
|
||||
name="mta[local_method]"
|
||||
value="sendmail"
|
||||
<%
|
||||
if(settings.mta_local_method == 'sendmail')
|
||||
if(settings.mta.local_method == 'sendmail')
|
||||
%>checked="checked"<% endif %>
|
||||
/>Sendmail
|
||||
</label>
|
||||
@ -220,10 +220,10 @@
|
||||
<p>
|
||||
<label>
|
||||
<input type="radio"
|
||||
name="mta_local_method"
|
||||
name="mta[local_method]"
|
||||
value="wp_mail"
|
||||
<%
|
||||
if(settings.mta_local_method == 'wp_mail')
|
||||
if(settings.mta.local_method == 'wp_mail')
|
||||
%>checked="checked"<% endif %>
|
||||
/>WP Mail
|
||||
</label>
|
||||
@ -239,7 +239,10 @@
|
||||
<td>
|
||||
<p>
|
||||
<!-- sending frequency -->
|
||||
<select id="mailpoet_web_host" name="web_host">
|
||||
<select
|
||||
id="mailpoet_web_host"
|
||||
name="web_host"
|
||||
>
|
||||
<option value="auto">
|
||||
<%= __('Safe default values') %>
|
||||
</option>
|
||||
@ -329,13 +332,16 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="mailpoet_mta_provider">
|
||||
<label for="mailpoet_smtp_provider">
|
||||
<%= __('Provider') %>
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
<!-- smtp provider -->
|
||||
<select id="mailpoet_mta_provider" name="mta_provider">
|
||||
<select
|
||||
id="mailpoet_smtp_provider"
|
||||
name="smtp_provider"
|
||||
>
|
||||
<option data-interval="5" data-emails="100" value="manual">
|
||||
<%= __('Custom SMTP') %>
|
||||
</option>
|
||||
@ -346,7 +352,7 @@
|
||||
value="<%= host_key %>"
|
||||
data-emails="<%= host.emails %>"
|
||||
data-interval="<%= host.interval %>"
|
||||
<% if(settings.smtp_host == host_key) %>
|
||||
<% if(settings.smtp_provider == host_key) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= host.name %></option>
|
||||
@ -419,8 +425,8 @@
|
||||
<input
|
||||
type="text"
|
||||
id="settings[mta_smtp_host]"
|
||||
name="mta_smtp_host"
|
||||
value="<%= settings.mta.smtp_host %>" />
|
||||
name="mta[smtp][host]"
|
||||
value="<%= settings.mta.smtp.host %>" />
|
||||
</td>
|
||||
</tr>
|
||||
<!-- smtp: login -->
|
||||
@ -434,8 +440,8 @@
|
||||
<input
|
||||
type="text"
|
||||
id="settings[mta_smtp_login]"
|
||||
name="mta_smtp_login"
|
||||
value="<%= settings.mta.smtp_login %>"
|
||||
name="mta[smtp][login]"
|
||||
value="<%= settings.mta.smtp.login %>"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
@ -450,8 +456,8 @@
|
||||
<input
|
||||
type="password"
|
||||
id="settings[mta_smtp_password]"
|
||||
name="mta_smtp_password"
|
||||
value="<%= settings.mta.smtp_password %>"
|
||||
name="mta[smtp][password]"
|
||||
value="<%= settings.mta.smtp.password %>"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
@ -466,8 +472,8 @@
|
||||
<input
|
||||
type="text"
|
||||
id="settings[mta_smtp_port]"
|
||||
name="mta_smtp_port"
|
||||
value="<%= settings.mta.smtp_port %>"
|
||||
name="mta[smtp][port]"
|
||||
value="<%= settings.mta.smtp.port %>"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
@ -479,17 +485,17 @@
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
<select id="settings[mta_smtp_secure]" name="mta_smtp_secure">
|
||||
<select id="settings[mta_smtp_secure]" name="mta[smtp][secure]">
|
||||
<option value=""><%= __('No') %></option>
|
||||
<option
|
||||
value="ssl"
|
||||
<% if(settings.mta.smtp_secure == 'ssl') %>
|
||||
<% if(settings.mta.smtp.secure == 'ssl') %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
>SSL</option>
|
||||
<option
|
||||
value="tls"
|
||||
<% if(settings.mta.smtp_secure == 'tls') %>
|
||||
<% if(settings.mta.smtp.secure == 'tls') %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
>TLS</option>
|
||||
@ -511,8 +517,8 @@
|
||||
<input
|
||||
type="radio"
|
||||
value="1"
|
||||
name="mta_smtp_authenticate"
|
||||
<% if(settings.mta.smtp_authenticate) %>
|
||||
name="mta[smtp][authenticate]"
|
||||
<% if(settings.mta.smtp.authenticate) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/><%= __('Yes') %>
|
||||
@ -522,8 +528,8 @@
|
||||
<input
|
||||
type="radio"
|
||||
value=""
|
||||
name="mta_smtp_authenticate"
|
||||
<% if not(settings.mta.smtp_authenticate) %>
|
||||
name="mta[smtp][authenticate]"
|
||||
<% if not(settings.mta.smtp.authenticate) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/><%= __('No') %>
|
||||
@ -558,7 +564,7 @@
|
||||
type="checkbox"
|
||||
value="1"
|
||||
id="settings[dkim_enabled]"
|
||||
name="dkim_enabled"
|
||||
name="dkim[enabled]"
|
||||
<% if(settings.dkim.enabled) %>checked="checked"<% endif %>
|
||||
/>
|
||||
</p>
|
||||
@ -664,7 +670,7 @@
|
||||
});
|
||||
|
||||
// sending frequency update based on selected provider
|
||||
$('#mailpoet_mta_provider').on('change keyup', setProviderForm);
|
||||
$('#mailpoet_smtp_provider').on('change keyup', setProviderForm);
|
||||
$('#mailpoet_web_host').on('change keyup', renderHostSendingFrequency);
|
||||
|
||||
// update manual sending frequency when values are changed
|
||||
@ -697,7 +703,7 @@
|
||||
} else {
|
||||
if(
|
||||
method === 'mailpoet'
|
||||
&& $('#mailpoet_account_key').val().trim().length === 0
|
||||
&& $('#mailpoet_api_key').val().trim().length === 0
|
||||
) {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('You need to specify a MailPoet account key') %>"
|
||||
@ -740,7 +746,7 @@
|
||||
});
|
||||
|
||||
// render sending frequency form
|
||||
$('#mailpoet_mta_provider').trigger('change');
|
||||
$('#mailpoet_smtp_provider').trigger('change');
|
||||
$('#mailpoet_web_host').trigger('change');
|
||||
});
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
<input
|
||||
type="radio"
|
||||
class="mailpoet_signup_confirmation"
|
||||
name="signup_confirmation"
|
||||
name="signup_confirmation[enabled]"
|
||||
value="1"
|
||||
<% if not(settings.signup_confirmation) %>
|
||||
<% if(settings.signup_confirmation.enabled) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/><%= __('Yes') %>
|
||||
@ -29,9 +29,9 @@
|
||||
<input
|
||||
type="radio"
|
||||
class="mailpoet_signup_confirmation"
|
||||
name="signup_confirmation"
|
||||
name="signup_confirmation[enabled]"
|
||||
value=""
|
||||
<% if(settings.signup_confirmation) %>
|
||||
<% if not(settings.signup_confirmation.enabled) %>
|
||||
checked="checked"
|
||||
<% endif %>
|
||||
/><%= __('No') %>
|
||||
@ -55,15 +55,15 @@
|
||||
<input
|
||||
type="text"
|
||||
id="settings[signup_confirmation_from_name]"
|
||||
name="signup_confirmation_from_name"
|
||||
value="<%= settings.signup_confirmation_from_name %>"
|
||||
name="signup_confirmation[from][name]"
|
||||
value="<%= settings.signup_confirmation.from.name %>"
|
||||
placeholder="<%= __('Your name') %>"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
id="settings[signup_confirmation_from_email]"
|
||||
name="signup_confirmation_from_email"
|
||||
value="<%= settings.signup_confirmation_from_email %>"
|
||||
name="signup_confirmation[from][address]"
|
||||
value="<%= settings.signup_confirmation.from.address %>"
|
||||
placeholder="confirmation@mydomain.com"
|
||||
size="28"
|
||||
/>
|
||||
@ -82,15 +82,15 @@
|
||||
<input
|
||||
type="text"
|
||||
id="settings[signup_confirmation_reply_name]"
|
||||
name="signup_confirmation_reply_name"
|
||||
value="<%= settings.signup_confirmation_reply_name %>"
|
||||
name="signup_confirmation[reply_to][name]"
|
||||
value="<%= settings.signup_confirmation.reply_to.name %>"
|
||||
placeholder="<%= __('Your name') %>"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
id="settings[signup_confirmation_reply_email]"
|
||||
name="signup_confirmation_reply_email"
|
||||
value="<%= settings.signup_confirmation_reply_email %>"
|
||||
name="signup_confirmation[reply_to][address]"
|
||||
value="<%= settings.signup_confirmation.reply_to.address %>"
|
||||
placeholder="confirmation@mydomain.com"
|
||||
size="28"
|
||||
/>
|
||||
@ -109,9 +109,9 @@
|
||||
size="52"
|
||||
type="text"
|
||||
id="settings[signup_confirmation_email_subject]"
|
||||
name="signup_confirmation_email_subject"
|
||||
<% if(settings.signup_confirmation_email_subject) %>
|
||||
value="<%= settings.signup_confirmation_email_subject %>"
|
||||
name="signup_confirmation[subject]"
|
||||
<% if(settings.signup_confirmation.subject) %>
|
||||
value="<%= settings.signup_confirmation.subject %>"
|
||||
<% else %>
|
||||
value="<%=
|
||||
__('Confirm your subscription to %1$s')
|
||||
@ -136,9 +136,9 @@
|
||||
cols="50"
|
||||
rows="15"
|
||||
id="settings[signup_confirmation_email_body]"
|
||||
name="signup_confirmation_email_body"
|
||||
><% if(settings.signup_confirmation_email_body) %>
|
||||
<%=- settings.signup_confirmation_email_body -%>
|
||||
name="signup_confirmation[body]"
|
||||
><% if(settings.signup_confirmation.body) %>
|
||||
<%=- settings.signup_confirmation.body -%>
|
||||
<% else %>
|
||||
<%=- __("Hello!\n\nHurray! You've subscribed to our site.\nWe need you to activate your subscription to the list(s): [lists_to_confirm] by clicking the link below: \n\n[activation_link]Click here to confirm your subscription.[/activation_link]\n\nThank you,\n\nThe team!") -%>
|
||||
<% endif %></textarea>
|
||||
@ -158,14 +158,14 @@
|
||||
<p>
|
||||
<select
|
||||
class="mailpoet_page_selection"
|
||||
name="signup_confirmation_page"
|
||||
name="signup_confirmation[page]"
|
||||
>
|
||||
<% for page in pages %>
|
||||
<option
|
||||
value="<%= page.ID %>"
|
||||
data-preview-url="<%= page.preview_url|raw %>"
|
||||
data-edit-url="<%= page.edit_url|raw %>"
|
||||
<% if(page.ID == settings.signup_confirmation_page) %>
|
||||
<% if(page.ID == settings.signup_confirmation.page) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= page.post_title %></option>
|
||||
|
Reference in New Issue
Block a user