PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.18
E2Pdf – Export Pdf Tool for WordPress v1.32.18
1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 1.08.09 All 71 releases
e2pdf / classes / model / e2pdf-notification.php

e2pdf-notification.php in E2Pdf – Export Pdf Tool for WordPress 1.32.18, at classes/model/e2pdf-notification.php

107 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * File: /model/e2pdf-notification.php
5 *
6 * @package E2Pdf
7 * @license GPLv3
8 * @link https://e2pdf.com
9 */
10 if (!defined('ABSPATH')) {
11 die('Access denied.');
12 }
13
14 class Model_E2pdf_Notification extends Model_E2pdf_Model {
15
16 // add notification
17 public function add_notification($type, $text) {
18
19 $notifications = get_transient('e2pdf_notifications');
20 if (!is_array($notifications)) {
21 $notifications = [];
22 }
23
24 $notifications[] = [
25 'type' => $type,
26 'text' => $text,
27 ];
28 set_transient('e2pdf_notifications', $notifications);
29 }
30
31 // get notifications
32 public function get_notifications() {
33
34 $notifications = get_transient('e2pdf_notifications');
35 if (!is_array($notifications)) {
36 $notifications = [];
37 }
38
39 if (!get_option('e2pdf_hide_warnings', '0')) {
40 if ($this->helper->get('license')->get('status') == 'pre_expired') {
41 /* translators: %s: License Key Expire Date */
42 $message = sprintf(__('Your E2Pdf License Key will expire at <strong>%s</strong>', 'e2pdf'), $this->helper->get('license')->get('expire'));
43 if (current_user_can('manage_options') || current_user_can('e2pdf_license')) {
44 $message .= ' | ' . sprintf('<a class="e2pdf-link" target="_blank" href="%s">%s »</a>', 'https://e2pdf.com/checkout/license/renew/' . get_option('e2pdf_license'), __('Renew License Key', 'e2pdf'));
45 }
46 array_unshift(
47 $notifications,
48 [
49 'type' => 'notice',
50 'text' => $message,
51 ]
52 );
53 }
54
55 if ($this->helper->get('license')->get('status') == 'expired') {
56 $message = __('Your E2Pdf License Key has expired', 'e2pdf');
57 if (current_user_can('manage_options') || current_user_can('e2pdf_license')) {
58 $message .= ' | ' . sprintf('<a class="e2pdf-link" target="_blank" href="%s">%s »</a>', 'https://e2pdf.com/checkout/license/renew/' . get_option('e2pdf_license'), __('Renew License Key', 'e2pdf'));
59 }
60 array_unshift(
61 $notifications,
62 [
63 'type' => 'error',
64 'text' => $message,
65 ]
66 );
67 }
68
69 if ($this->helper->get('license')->get('type') == 'FREE' && $this->helper->get('page') == 'e2pdf-templates') {
70 array_unshift(
71 $notifications,
72 [
73 'type' => 'notice',
74 'text' => sprintf(__('You are using E2Pdf FREE License Type', 'e2pdf') . ' | ' . __('Up to 1 Page and up to 1 Template allowed', 'e2pdf') . ' | <a class="e2pdf-link" target="_blank" href="%s">%s »</a>', 'https://e2pdf.com/price', __('Upgrade License Key', 'e2pdf')),
75 ]
76 );
77 }
78 }
79
80 if ($this->helper->get('license')->get('error')) {
81 foreach ($notifications as $key => $notify) {
82 if ($notify['type'] === 'error' && $notify['text'] === $this->helper->get('license')->get('error')) {
83 unset($notifications[$key]);
84 }
85 }
86 if ($this->helper->get('license')->get('error') === 'License Key does not match this site. Please correct License Key to continue usage.') {
87 $message = __('E2Pdf License Key does not match this site', 'e2pdf');
88 if (current_user_can('manage_options') || current_user_can('e2pdf_license')) {
89 $message .= ' | ' . sprintf('<a class="e2pdf-link" id="e2pdf-restore-license-key" href="javascript:void(0)" _wpnonce="%s">%s »</a>', wp_create_nonce('e2pdf_license'), __('Restore License Key', 'e2pdf'));
90 }
91 } else {
92 $message = $this->helper->get('license')->get('error');
93 }
94 array_unshift(
95 $notifications,
96 [
97 'type' => 'error',
98 'text' => $message,
99 ]
100 );
101 }
102
103 set_transient('e2pdf_notifications', []);
104 return $notifications;
105 }
106 }
107