video badges code review

This commit is contained in:
qfrery
2018-06-06 12:55:20 +01:00
parent 705241d330
commit d6f72087e9
8 changed files with 31 additions and 44 deletions

View File

@@ -2,7 +2,7 @@ $excellent-badge-color = #2993ab
$good-badge-color = #f0b849
$bad-badge-color = #d54e21
$green-badge-color = #55bd56
$cta-badge-color = #46b450
$video-guide-badge-color = #46b450
#newsletters_container
h2.nav-tab-wrapper
@@ -53,8 +53,8 @@ $cta-badge-color = #46b450
&_green
background: $green-badge-color
&_cta
background: $cta-badge-color
&_video
background: $video-guide-badge-color
line-height: 5em
padding: 7px 6px 7px 6px
text-decoration: none

View File

@@ -123,10 +123,7 @@ const NewsletterTypes = React.createClass({
];
const types = Hooks.applyFilters('mailpoet_newsletters_types', [...defaultTypes, ...this.getAutomaticEmails()], this);
let badgeClassName = 'mailpoet_badge mailpoet_badge_cta';
if (window.mailpoet_is_new_user === false) {
badgeClassName += ' mailpoet_badge_cta_grey';
}
const badgeClassName = (window.mailpoet_is_new_user === true) ? 'mailpoet_badge mailpoet_badge_video' : 'mailpoet_badge mailpoet_badge_video mailpoet_badge_video_grey';
return (
<div>

View File

@@ -384,7 +384,7 @@ class Menu {
$data['is_old_user'] = false;
if(!empty($data['settings']['installed_at'])) {
$installed_at = Carbon::createFromTimestamp(strtotime($data['settings']['installed_at']));
$current_time = Carbon::createFromTimestamp(WPFunctions::currentTime('timestamp'));
$current_time = Carbon::createFromTimestamp(WPFunctions::currentTime('timestamp'));
$data['is_new_user'] = $current_time->diffInDays($installed_at) <= 30;
$data['is_old_user'] = $current_time->diffInMonths($installed_at) >= 6;
$data['stop_call_for_rating'] = isset($data['settings']['stop_call_for_rating']) ? $data['settings']['stop_call_for_rating'] : false;
@@ -438,12 +438,7 @@ class Menu {
)
);
$data['is_new_user'] = true;
if(!empty($data['settings']['installed_at'])) {
$installed_at = Carbon::createFromTimestamp(strtotime($data['settings']['installed_at']));
$current_time = Carbon::createFromTimestamp(WPFunctions::currentTime('timestamp'));
$data['is_new_user'] = $current_time->diffInDays($installed_at) <= 30;
}
$data['is_new_user'] = $this->is_new_user();
$data = array_merge($data, Installer::getPremiumStatus());
@@ -548,13 +543,7 @@ class Menu {
$data['items_per_page'] = $this->getLimitPerPage('forms');
$data['segments'] = Segment::findArray();
$data['is_new_user'] = true;
$installed_at = Setting::getValue('installed_at');
if(!is_null($installed_at)) {
$installed_at = Carbon::createFromTimestamp(strtotime($installed_at));
$current_time = Carbon::createFromTimestamp(WPFunctions::currentTime('timestamp'));
$data['is_new_user'] = $current_time->diffInDays($installed_at) <= 30;
}
$data['is_new_user'] = $this->is_new_user();
$this->displayPage('forms.html', $data);
}
@@ -594,12 +583,7 @@ class Menu {
$data['automatic_emails'] = array();
$data['is_new_user'] = 'true';
if(!empty($data['settings']['installed_at'])) {
$installed_at = Carbon::createFromTimestamp(strtotime($data['settings']['installed_at']));
$current_time = Carbon::createFromTimestamp(WPFunctions::currentTime('timestamp'));
$data['is_new_user'] = $current_time->diffInDays($installed_at) <= 30 ? 'true' : 'false';
}
$data['is_new_user'] = $this->is_new_user();
wp_enqueue_script('jquery-ui');
wp_enqueue_script('jquery-ui-datepicker');
@@ -632,13 +616,7 @@ class Menu {
'sub_menu' => 'mailpoet-subscribers'
));
$data['is_new_user'] = true;
$installed_at = Setting::getValue('installed_at');
if(!is_null($installed_at)) {
$installed_at = Carbon::createFromTimestamp(strtotime($installed_at));
$current_time = Carbon::createFromTimestamp(WPFunctions::currentTime('timestamp'));
$data['is_new_user'] = $current_time->diffInDays($installed_at) <= 30;
}
$data['is_new_user'] = $this->is_new_user();
$this->displayPage('subscribers/importExport/import.html', $data);
}
@@ -778,4 +756,14 @@ class Menu {
$notice->displayWPNotice();
}
}
function is_new_user() {
$installed_at = Setting::getValue('installed_at');
if(is_null($installed_at)) {
return true;
}
$installed_at = Carbon::createFromTimestamp(strtotime($installed_at));
$current_time = Carbon::createFromTimestamp(WPFunctions::currentTime('timestamp'));
return $current_time->diffInDays($installed_at) <= 30;
}
}

View File

@@ -22,4 +22,4 @@ class Filters extends \Twig_Extension {
)
);
}
}
}

View File

@@ -12,7 +12,8 @@
</p>
</div>
<a class="mailpoet_badge mailpoet_badge_cta <% if(is_new_user == false) %>mailpoet_badge_cta_grey<% endif %>" href="https://beta.docs.mailpoet.com/article/236-video-guide-setting-up-forms" target="_blank">
<% set badgeClassName = (is_new_user == true) ? 'mailpoet_badge mailpoet_badge_video' : 'mailpoet_badge mailpoet_badge_video mailpoet_badge_video_grey' %>
<a class="<%= badgeClassName %>" href="https://beta.docs.mailpoet.com/article/236-video-guide-setting-up-forms" target="_blank">
<span class="dashicons dashicons-format-video"></span><%= __('See video guide') %>
</a>

View File

@@ -17,7 +17,8 @@
var mailpoet_tracking_enabled = <%= json_encode(tracking_enabled) %>;
var mailpoet_premium_active = <%= json_encode(premium_plugin_active) %>;
var mailpoet_automatic_emails = <%= json_encode(automatic_emails) %>;
var mailpoet_is_new_user = <%= is_new_user %>;
<% set newUser = (is_new_user == true) ? 'true' : 'false' %>
var mailpoet_is_new_user = <%= newUser %>;
</script>
<% endblock %>

View File

@@ -145,12 +145,11 @@
</ul>
<p class="mailpoet_sending_methods_help help">
<%= __("Need help to pick?") %>
<a class="mailpoet_badge mailpoet_badge_cta <% if(is_new_user == false) %>mailpoet_badge_cta_grey<% endif %>" href="https://beta.docs.mailpoet.com/article/235-video-guide-sending-options" target="_blank">
<span class="dashicons dashicons-format-video"></span><%= __('See video guide') %>
</a>
<%= __("[link]or check out the comparison table of sending methods[/link].")
|replaceLinkTags('http://beta.docs.mailpoet.com/article/181-comparison-table-of-sending-methods', {'target' : '_blank'})
<% set badgeClassName = (is_new_user == true) ? 'mailpoet_badge mailpoet_badge_video' : 'mailpoet_badge mailpoet_badge_video mailpoet_badge_video_grey' %>
<%= __('Need help to pick? [link1]%s See video guide[/link1] [link2]or check out the comparison table of sending methods[/link2].')
|format('<span class="dashicons dashicons-format-video"></span>')
|replaceLinkTags('https://beta.docs.mailpoet.com/article/235-video-guide-sending-options', {'class' : badgeClassName, 'target' : '_blank'}, 'link1')
|replaceLinkTags('http://beta.docs.mailpoet.com/article/181-comparison-table-of-sending-methods', {'target' : '_blank'}, 'link2')
|raw
%>
</p>

View File

@@ -22,7 +22,8 @@
</tbody>
</table>
<a class="mailpoet_badge mailpoet_badge_cta <% if(is_new_user == false) %>mailpoet_badge_cta_grey<% endif %>" href="https://beta.docs.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file" target="_blank">
<% set badgeClassName = (is_new_user == true) ? 'mailpoet_badge mailpoet_badge_video' : 'mailpoet_badge mailpoet_badge_video mailpoet_badge_video_grey' %>
<a class="<%= badgeClassName %>" href="https://beta.docs.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file" target="_blank">
<span class="dashicons dashicons-format-video"></span><%= __('See video guide') %>
</a>