Merge pull request #1575 from mailpoet/email-notifications-fix

New subscriber emails notifications fixes [MAILPOET-1952][MAILPOET-1600]
This commit is contained in:
M. Shull
2018-10-22 13:23:11 -04:00
committed by GitHub
3 changed files with 10 additions and 7 deletions

View File

@ -12,8 +12,7 @@
|replaceLinkTags(link_settings) |replaceLinkTags(link_settings)
) %></small> ) %></small>
<# date('-1hour') is here to get today's date, this is the only way that worked for me #> <% if 'now'|date('Y-m-d') < '2018-11-30'|date('Y-m-d') %>
<% if date('-1hour') < date('2018-11-12') %>
<p> <p>
<small> <small>
<%= __('PS. MailPoet annual plans are nearly half price for a limited time. <%= __('PS. MailPoet annual plans are nearly half price for a limited time.

View File

@ -10,8 +10,7 @@
<%= __('You can disable these emails in your MailPoet Settings.') %> <%= __('You can disable these emails in your MailPoet Settings.') %>
<%= link_settings %> <%= link_settings %>
<# date('-1hour') is here to get today's date, this is the only way that worked for me #> <% if 'now'|date('Y-m-d') < '2018-11-30'|date('Y-m-d') %>
<% if date('-1hour') < date('2018-11-12') %>
<%= __('PS. MailPoet annual plans are nearly half price for a limited time. Find out more in the Premium page in your admin.') %> <%= __('PS. MailPoet annual plans are nearly half price for a limited time. Find out more in the Premium page in your admin.') %>
<%= link_premium %> <%= link_premium %>
<% endif %> <% endif %>

View File

@ -65,6 +65,7 @@
$(function() { $(function() {
// on form submission // on form submission
$('#mailpoet_settings_form').on('submit', function() { $('#mailpoet_settings_form').on('submit', function() {
var errorFound = false;
// Check if filled emails are valid // Check if filled emails are valid
var invalidEmails = $.map($('#mailpoet_settings_form')[0].elements, function(el) { var invalidEmails = $.map($('#mailpoet_settings_form')[0].elements, function(el) {
return el.type === 'email' && el.value && !window.mailpoet_email_regex.test(el.value) ? el.value : null; return el.type === 'email' && el.value && !window.mailpoet_email_regex.test(el.value) ? el.value : null;
@ -74,7 +75,7 @@
"<%= __('Invalid email addresses: ') | escape('js') %>" + invalidEmails.join(', '), "<%= __('Invalid email addresses: ') | escape('js') %>" + invalidEmails.join(', '),
{ scroll: true } { scroll: true }
); );
return false; errorFound = true;
} }
// if reCAPTCHA is enabled but keys are emty, show error // if reCAPTCHA is enabled but keys are emty, show error
var enabled = $('input[name="re_captcha[enabled]"]:checked').val(), var enabled = $('input[name="re_captcha[enabled]"]:checked').val(),
@ -83,7 +84,7 @@
if (enabled && (site_key == '' || secret_key == '')) { if (enabled && (site_key == '' || secret_key == '')) {
$('#settings_re_captcha_tokens_error').show(); $('#settings_re_captcha_tokens_error').show();
window.location.href = '#advanced'; window.location.href = '#advanced';
return false; errorFound = true;
} else { } else {
$('#settings_re_captcha_tokens_error').hide(); $('#settings_re_captcha_tokens_error').hide();
} }
@ -93,10 +94,14 @@
if (notifications_enabled && address == '') { if (notifications_enabled && address == '') {
$('#settings_subscriber_email_notification_error').show(); $('#settings_subscriber_email_notification_error').show();
window.location.href = '#basics'; window.location.href = '#basics';
return false; errorFound = true;
} else { } else {
$('#settings_subscriber_email_notification_error').hide(); $('#settings_subscriber_email_notification_error').hide();
} }
// stop processing if an error was found
if (errorFound) {
return false;
}
// if we're setting up a sending method, try to activate it // if we're setting up a sending method, try to activate it
if ($('.mailpoet_mta_setup_save').is(':visible')) { if ($('.mailpoet_mta_setup_save').is(':visible')) {
$('.mailpoet_mta_setup_save').trigger('click'); $('.mailpoet_mta_setup_save').trigger('click');