Rename method and variables for clarity

[MAILPOET-2624]
This commit is contained in:
Amine Ben hammou
2020-01-13 09:49:29 +01:00
committed by Jack Kitterhing
parent 5d59f53834
commit d2494469c0
6 changed files with 12 additions and 12 deletions

View File

@ -4,12 +4,12 @@ import Notice from 'notices/notice.jsx';
const SubscribersLimitNotice = () => {
if (!window.mailpoet_subscribers_limit_reached) return null;
const hasKey = window.mailpoet_has_api_key;
const hasValidApiKey = window.mailpoet_has_valid_api_key;
const title = MailPoet.I18n.t('subscribersLimitNoticeTitle')
.replace('[subscribersLimit]', window.mailpoet_subscribers_limit);
const youReachedTheLimit = MailPoet.I18n.t(hasKey ? 'yourPlanLimit' : 'freeVersionLimit')
const youReachedTheLimit = MailPoet.I18n.t(hasValidApiKey ? 'yourPlanLimit' : 'freeVersionLimit')
.replace('[subscribersLimit]', window.mailpoet_subscribers_limit);
const upgradeLink = hasKey
const upgradeLink = hasValidApiKey
? 'https://account.mailpoet.com/upgrade'
: `https://account.mailpoet.com/?s=${window.mailpoet_subscribers_count + 1}`;
const refreshSubscribers = async () => {
@ -38,7 +38,7 @@ const SubscribersLimitNotice = () => {
>
{MailPoet.I18n.t('upgradeNow')}
</a>
{hasKey && (
{hasValidApiKey && (
<>
{' '}
<button

View File

@ -97,7 +97,7 @@ class Newsletters {
$data['installed_days_ago'] = (int)$installedAtDateTime->diff(new \DateTime())->format('%a');
$data['subscribers_limit'] = $this->subscribers_feature->getSubscribersLimit();
$data['subscribers_limit_reached'] = $this->subscribers_feature->check();
$data['has_api_key'] = $this->subscribers_feature->hasAPIKey();
$data['has_valid_api_key'] = $this->subscribers_feature->hasValidApiKey();
$date_time = new DateTime();
$data['current_date'] = $date_time->getCurrentDate(DateTime::DEFAULT_DATE_FORMAT);

View File

@ -128,7 +128,7 @@ class Worker {
$unsubscribed = ($statistics->getUnsubscribeCount() * 100) / $statistics->getTotalSentCount();
$subject = $newsletter->getLatestQueue()->getNewsletterRenderedSubject();
$subscribers_count = $this->subscribers_repository->getTotalSubscribers();
$has_key = $this->subscribers_feature->hasAPIKey();
$has_valid_api_key = $this->subscribers_feature->hasValidApiKey();
$context = [
'subject' => $subject,
'preheader' => sprintf(_x(
@ -143,9 +143,9 @@ class Worker {
'clicked' => $clicked,
'opened' => $opened,
'subscribersLimitReached' => $this->subscribers_feature->check(),
'hasKey' => $has_key,
'hasValidApiKey' => $has_valid_api_key,
'subscribersLimit' => $this->subscribers_feature->getSubscribersLimit(),
'upgradeNowLink' => $has_key ? 'https://account.mailpoet.com/upgrade' : 'https://account.mailpoet.com/?s=' . ($subscribers_count + 1),
'upgradeNowLink' => $has_valid_api_key ? 'https://account.mailpoet.com/upgrade' : 'https://account.mailpoet.com/?s=' . ($subscribers_count + 1),
];
if ($link) {
$context['topLinkClicks'] = $link->getTotalClicksCount();

View File

@ -33,12 +33,12 @@ class Subscribers {
return $subscribers_count > $limit;
}
public function hasAPIKey() {
public function hasValidApiKey() {
return $this->hasValidMssKey() || $this->hasValidPremiumKey();
}
public function getSubscribersLimit() {
if (!$this->hasAPIKey()) {
if (!$this->hasValidApiKey()) {
return $this->getFreeSubscribersLimit();
}

View File

@ -8,7 +8,7 @@
<% if subscribersLimitReached %>
<%= __('Congratulations, you now have more than [subscribersLimit] subscribers!')|replace({'[subscribersLimit]': subscribersLimit}) %>
<% if hasKey %>
<% if hasValidApiKey %>
<%= __('Your plan is limited to [subscribersLimit] subscribers.')|replace({'[subscribersLimit]': subscribersLimit}) %>
<% else %>
<%= __('Our free version is limited to [subscribersLimit] subscribers.')|replace({'[subscribersLimit]': subscribersLimit}) %>

View File

@ -10,7 +10,7 @@
var mailpoet_display_nps_poll = <%= (sent_newsletters_count > 0 and settings.display_nps_poll) ? 'true' : 'false' %>;
var mailpoet_subscribers_limit = <%= subscribers_limit ? subscribers_limit : 'false' %>;
var mailpoet_subscribers_limit_reached = <%= subscribers_limit_reached ? 'true' : 'false' %>;
var mailpoet_has_api_key = <%= has_api_key ? 'true' : 'false' %>;
var mailpoet_has_valid_api_key = <%= has_valid_api_key ? 'true' : 'false' %>;
var mailpoet_segments = <%= json_encode(segments) %>;
var mailpoet_show_congratulate_after_first_newsletter = <%= show_congratulate_after_first_newsletter %>;
var mailpoet_installed_days_ago = <%= installed_days_ago %>;