| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* E2pdf Notification Helper |
| 5 |
* |
| 6 |
* @copyright Copyright 2017 https://e2pdf.com |
| 7 |
* @license GPL v2 |
| 8 |
* @version 1 |
| 9 |
* @link https://e2pdf.com |
| 10 |
* @since 0.00.01 |
| 11 |
*/ |
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
die('Access denied.'); |
| 14 |
} |
| 15 |
|
| 16 |
class Model_E2pdf_Notification extends Model_E2pdf_Model { |
| 17 |
|
| 18 |
protected static $instance = NULL; |
| 19 |
|
| 20 |
const UPGRADE_URL = 'https://e2pdf.com'; |
| 21 |
|
| 22 |
/** |
| 23 |
* Add notification |
| 24 |
* |
| 25 |
* @param string $type - Notification type |
| 26 |
* @param string $text - Notification text |
| 27 |
*/ |
| 28 |
public function add_notification($type, $text) { |
| 29 |
$notifications = get_transient('e2pdf_notifications'); |
| 30 |
$notifications[] = array( |
| 31 |
'type' => $type, |
| 32 |
'text' => $text, |
| 33 |
); |
| 34 |
set_transient('e2pdf_notifications', $notifications); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Get notifications |
| 39 |
* |
| 40 |
* @return array - List of notifications |
| 41 |
*/ |
| 42 |
public function get_notifications() { |
| 43 |
$notifications = get_transient('e2pdf_notifications'); |
| 44 |
if (!get_option('e2pdf_hide_warnings')) { |
| 45 |
|
| 46 |
if (!is_array($notifications)) { |
| 47 |
$notifications = array(); |
| 48 |
} |
| 49 |
|
| 50 |
if ($this->helper->get('license')->get('status') == 'pre_expired') { |
| 51 |
array_unshift($notifications, array( |
| 52 |
'type' => 'notice', |
| 53 |
'text' => sprintf(__("Your E2Pdf License Key will expire at <strong>%s</strong>. Please renew it at <a target='_blank' href='%s'>%s</a>.", 'e2pdf'), $this->helper->get('license')->get('expire'), self::UPGRADE_URL, self::UPGRADE_URL) |
| 54 |
)); |
| 55 |
} |
| 56 |
|
| 57 |
if ($this->helper->get('license')->get('status') == 'expired') { |
| 58 |
array_unshift($notifications, array( |
| 59 |
'type' => 'error', |
| 60 |
'text' => sprintf(__("Your E2Pdf License Key has expired. Please renew it at <a target='_blank' href='%s'>%s</a>.", 'e2pdf'), self::UPGRADE_URL, self::UPGRADE_URL) |
| 61 |
)); |
| 62 |
} |
| 63 |
|
| 64 |
if ($this->helper->get('license')->get('type') == 'FREE') { |
| 65 |
array_unshift($notifications, array( |
| 66 |
'type' => 'notice', |
| 67 |
'text' => sprintf(__("You are using FREE license type. Up to 1 page and up to 1 template allowed. Please check <a target='_blank' href='%s'>%s</a> for upgrade options.", 'e2pdf'), self::UPGRADE_URL, self::UPGRADE_URL) |
| 68 |
)); |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
set_transient('e2pdf_notifications', array()); |
| 73 |
return $notifications; |
| 74 |
} |
| 75 |
|
| 76 |
} |
| 77 |
|