Files
piratepoet/lib/Util/Notices/DiscountsAnnouncement.php
Pavel Dohnal c0e252f42a Update the discount amount
[MAILPOET-1590]
2018-10-18 09:36:41 +02:00

45 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace MailPoet\Util\Notices;
use MailPoet\Models\Setting;
use MailPoet\Util\Helpers;
use MailPoet\WP\Notice as WPNotice;
class DiscountsAnnouncement {
const OPTION_NAME = 'mailpoet_display_discounts_announcement_q4_2018';
function enable() {
Setting::setValue(self::OPTION_NAME, true);
}
function disable() {
Setting::setValue(self::OPTION_NAME, false);
}
function init($should_display) {
$should_display = $should_display && (time() <= strtotime('2018-11-30 23:59:59'));
if($should_display && Setting::getValue(self::OPTION_NAME, true)) {
return $this->display();
}
}
private function display() {
$message = Helpers::replaceLinkTags(
__('<h3>Save on MailPoet Premium for a limited time. Discounts up to 50%</h3>
<p>Our annual sale is a good opportunity to get more detailed stats & great email deliverability. Dont miss out!</p>
[link]Visit the MailPoet Premium page[/link]', 'mailpoet'),
'admin.php?page=mailpoet-premium',
array('class' => 'button button-primary')
);
$message .= '<script>jQuery(function($) {$(document).on("click", ".mailpoet-dismissible-notice .notice-dismiss",function dismiss() {const type = $(this).closest(".mailpoet-dismissible-notice").data("notice");$.ajax(window.ajaxurl,{type: "POST",data: {action: "dismissed_notice_handler",type,}});});});</script>';
$extra_classes = 'mailpoet-dismissible-notice is-dismissible';
$data_notice_name = self::OPTION_NAME;
WPNotice::displaySuccess($message, $extra_classes, $data_notice_name);
return $message;
}
}