PluginProbe ʕ •ᴥ•ʔ
Wordfence Security – Firewall, Malware Scan, and Login Security / 7.3.2
Wordfence Security – Firewall, Malware Scan, and Login Security v7.3.2
8.2.2 8.2.1 8.2.0 3.7.1 3.7.2 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.9.1 4.0.1 4.0.2 4.0.3 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.1 5.1.2 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.1 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.1 5.3.10 5.3.11 5.3.12 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.3.8 5.3.9 6.0.1 6.0.10 6.0.11 6.0.12 6.0.14 6.0.15 6.0.16 6.0.17 6.0.18 6.0.19 6.0.2 6.0.20 6.0.21 6.0.22 6.0.23 6.0.24 6.0.25 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.1 6.1.10 6.1.11 6.1.12 6.1.14 6.1.15 6.1.16 6.1.17 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6 6.1.7 6.1.8 6.1.9 6.2.0 6.2.1 6.2.10 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.2.8 6.2.9 6.3.0 6.3.1 6.3.10 6.3.11 6.3.12 6.3.14 6.3.15 6.3.16 6.3.17 6.3.18 6.3.19 6.3.2 6.3.20 6.3.21 6.3.22 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.3.8 6.3.9 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1.0 7.1.1 7.1.10 7.1.11 7.1.12 7.1.14 7.1.15 7.1.16 7.1.17 7.1.18 7.1.19 7.1.2 7.1.20 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.1.9 7.10.0 7.10.1 7.10.2 7.10.3 7.10.4 7.10.5 7.10.6 7.10.7 7.11.0 7.11.1 7.11.2 7.11.3 7.11.4 7.11.5 7.11.6 7.11.7 7.2.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.4.0 7.4.1 7.4.10 7.4.11 7.4.12 7.4.14 7.4.2 7.4.3 trunk 7.4.4 1.1 7.4.5 1.2 7.4.6 1.3 7.4.7 1.3.1 7.4.8 1.3.2 7.4.9 1.3.3 7.5.0 1.4.2 7.5.1 1.4.3 7.5.10 1.4.4 7.5.11 1.4.5 7.5.2 1.4.6 7.5.3 1.4.7 7.5.4 1.4.8 7.5.5 1.5.1 7.5.6 1.5.2 7.5.7 1.5.3 7.5.8 1.5.4 7.5.9 1.5.5 7.6.0 1.5.6 7.6.1 2.0.1 7.6.2 2.0.2 7.7.0 2.0.3 7.7.1 2.0.5 7.8.0 2.0.6 7.8.1 2.0.7 7.8.2 2.1.0 7.9.0 2.1.1 7.9.1 2.1.2 7.9.2 2.1.3 7.9.3 2.1.4 8.0.0 2.1.5 8.0.1 3.0.2 8.0.2 3.0.3 8.0.3 3.0.4 8.0.4 3.0.5 8.0.5 3.0.6 8.1.0 3.0.7 8.1.1 3.0.8 8.1.2 3.0.9 8.1.3 3.1.0 8.1.4 3.1.1 v1.4.1 3.1.2 3.1.4 3.1.6 3.2.1 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.1 3.4.4 3.4.5 3.5.1 3.5.2 3.6.1 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
wordfence / lib / wfAdminNoticeQueue.php
wordfence / lib Last commit date
Diff 8 years ago dashboard 7 years ago rest-api 7 years ago .htaccess 7 years ago Diff.php 14 years ago GeoLite2-Country.mmdb 7 years ago IPTraf.php 8 years ago IPTrafList.php 7 years ago WFLSPHP52Compatability.php 7 years ago compat.php 8 years ago conntest.php 7 years ago cronview.php 8 years ago dbview.php 8 years ago diffResult.php 8 years ago email_genericAlert.php 7 years ago email_newIssues.php 7 years ago email_unlockRequest.php 8 years ago email_unsubscribeRequest.php 7 years ago flags.php 7 years ago live_activity.php 8 years ago menu_dashboard.php 7 years ago menu_dashboard_options.php 7 years ago menu_firewall.php 7 years ago menu_firewall_blocking.php 7 years ago menu_firewall_blocking_options.php 8 years ago menu_firewall_waf.php 7 years ago menu_firewall_waf_options.php 7 years ago menu_options.php 7 years ago menu_scanner.php 7 years ago menu_scanner_credentials.php 8 years ago menu_scanner_options.php 8 years ago menu_support.php 7 years ago menu_tools.php 7 years ago menu_tools_diagnostic.php 7 years ago menu_tools_importExport.php 7 years ago menu_tools_livetraffic.php 7 years ago menu_tools_twoFactor.php 7 years ago menu_tools_whois.php 8 years ago menu_wordfence_central.php 7 years ago noc1.key 7 years ago sysinfo.php 8 years ago unknownFiles.php 8 years ago viewFullActivityLog.php 8 years ago wf503.php 7 years ago wfAPI.php 7 years ago wfActivityReport.php 7 years ago wfAdminNoticeQueue.php 8 years ago wfArray.php 7 years ago wfBrowscap.php 8 years ago wfBrowscapCache.php 7 years ago wfBulkCountries.php 7 years ago wfCache.php 9 years ago wfCentralAPI.php 7 years ago wfConfig.php 7 years ago wfCrawl.php 8 years ago wfCredentialsController.php 7 years ago wfCrypt.php 7 years ago wfDB.php 7 years ago wfDashboard.php 7 years ago wfDateLocalization.php 8 years ago wfDiagnostic.php 7 years ago wfDict.php 8 years ago wfDirectoryIterator.php 7 years ago wfHelperBin.php 11 years ago wfHelperString.php 11 years ago wfIPWhitelist.php 7 years ago wfImportExportController.php 7 years ago wfIssues.php 7 years ago wfJWT.php 7 years ago wfLockedOut.php 7 years ago wfLog.php 7 years ago wfMD5BloomFilter.php 8 years ago wfModuleController.php 7 years ago wfNotification.php 8 years ago wfOnboardingController.php 7 years ago wfPersistenceController.php 8 years ago wfRESTAPI.php 7 years ago wfScan.php 7 years ago wfScanEngine.php 7 years ago wfSchema.php 7 years ago wfStyle.php 7 years ago wfSupportController.php 7 years ago wfUnlockMsg.php 7 years ago wfUpdateCheck.php 8 years ago wfUtils.php 7 years ago wfVersionCheckController.php 8 years ago wfView.php 10 years ago wfViewResult.php 8 years ago wordfenceClass.php 7 years ago wordfenceConstants.php 7 years ago wordfenceHash.php 7 years ago wordfenceScanner.php 7 years ago wordfenceURLHoover.php 7 years ago
wfAdminNoticeQueue.php
177 lines
1 <?php
2
3 class wfAdminNoticeQueue {
4 protected static function _notices() {
5 return wfConfig::get_ser('adminNoticeQueue', array());
6 }
7
8 protected static function _setNotices($notices) {
9 wfConfig::set_ser('adminNoticeQueue', $notices);
10 }
11
12 /**
13 * Adds an admin notice to the display queue.
14 *
15 * @param string $severity
16 * @param string $messageHTML
17 * @param bool|string $category If not false, notices with the same category will be removed prior to adding this one.
18 * @param bool|array $users If not false, an array of user IDs the notice should show for.
19 */
20 public static function addAdminNotice($severity, $messageHTML, $category = false, $users = false) {
21 $notices = self::_notices();
22 foreach ($notices as $id => $n) {
23 $usersMatches = false;
24 if (isset($n['users'])) {
25 $usersMatches = wfUtils::sets_equal($n['users'], $users);
26 }
27 else if ($users === false) {
28 $usersMatches = true;
29 }
30
31 $categoryMatches = false;
32 if ($category !== false && isset($n['category']) && $n['category'] == $category) {
33 $categoryMatches = true;
34 }
35
36 if ($usersMatches && $categoryMatches) {
37 unset($notices[$id]);
38 }
39 }
40
41 $id = wfUtils::uuid();
42 $notices[$id] = array(
43 'severity' => $severity,
44 'messageHTML' => $messageHTML,
45 );
46
47 if ($category !== false) {
48 $notices[$id]['category'] = $category;
49 }
50
51 if ($users !== false) {
52 $notices[$id]['users'] = $users;
53 }
54
55 self::_setNotices($notices);
56 }
57
58 /**
59 * Removes an admin notice using one of three possible search methods:
60 *
61 * 1. If $id matches. $category and $users are ignored
62 * 2. If $category matches. $users must be false for this.
63 * 3. If $category matches and the notice's user IDs matches $users.
64 *
65 * @param bool|int $id
66 * @param bool|string $category
67 * @param bool|int[] $users
68 */
69 public static function removeAdminNotice($id = false, $category = false, $users = false) {
70 if ($id === false && $category === false && $users === false) {
71 return;
72 }
73 else if ($id !== false) {
74 $category = false;
75 $users = false;
76 }
77
78 $notices = self::_notices();
79 foreach ($notices as $nid => $n) {
80 if ($id == $nid) { //ID match
81 unset($notices[$nid]);
82 break;
83 }
84 else if ($id !== false) {
85 continue;
86 }
87
88 if ($category !== false && isset($n['category']) && $category == $n['category']) {
89 if ($users !== false) {
90 if (isset($n['users']) && wfUtils::sets_equal($users, $n['users'])) {
91 unset($notices[$nid]);
92 }
93 }
94 else {
95 unset($notices[$nid]);
96 }
97 }
98 }
99 self::_setNotices($notices);
100 }
101
102 public static function hasNotice($category = false, $users = false) {
103 $notices = self::_notices();
104 foreach ($notices as $nid => $n) {
105 $categoryMatches = false;
106 if (($category === false && !isset($n['category'])) || ($category !== false && isset($n['category']) && $category == $n['category'])) {
107 $categoryMatches = true;
108 }
109
110 $usersMatches = false;
111 if (($users === false && !isset($n['users'])) || ($users !== false && isset($n['users']) && wfUtils::sets_equal($users, $n['users']))) {
112 $usersMatches = true;
113 }
114
115 if ($categoryMatches && $usersMatches) {
116 return true;
117 }
118 }
119 return false;
120 }
121
122 public static function enqueueAdminNotices() {
123 $user = wp_get_current_user();
124 if ($user->ID == 0) {
125 return false;
126 }
127
128 $networkAdmin = is_multisite() && is_network_admin();
129 $notices = self::_notices();
130 $added = false;
131 foreach ($notices as $nid => $n) {
132 if (isset($n['users']) && array_search($user->ID, $n['users']) === false) {
133 continue;
134 }
135
136 $notice = new wfAdminNotice($nid, $n['severity'], $n['messageHTML']);
137 if ($networkAdmin) {
138 add_action('network_admin_notices', array($notice, 'displayNotice'));
139 }
140 else {
141 add_action('admin_notices', array($notice, 'displayNotice'));
142 }
143
144 $added = true;
145 }
146
147 return $added;
148 }
149 }
150
151 class wfAdminNotice {
152 const SEVERITY_CRITICAL = 'critical';
153 const SEVERITY_WARNING = 'warning';
154 const SEVERITY_INFO = 'info';
155
156 private $_id;
157 private $_severity;
158 private $_messageHTML;
159
160 public function __construct($id, $severity, $messageHTML) {
161 $this->_id = $id;
162 $this->_severity = $severity;
163 $this->_messageHTML = $messageHTML;
164 }
165
166 public function displayNotice() {
167 $severityClass = 'notice-info';
168 if ($this->_severity == self::SEVERITY_CRITICAL) {
169 $severityClass = 'notice-error';
170 }
171 else if ($this->_severity == self::SEVERITY_WARNING) {
172 $severityClass = 'notice-warning';
173 }
174
175 echo '<div class="wf-admin-notice notice ' . $severityClass . '" data-notice-id="' . esc_attr($this->_id) . '"><p>' . $this->_messageHTML . '</p><p>' . sprintf(__('<a class="wf-btn wf-btn-default wf-btn-sm wf-dismiss-link" href="#" onclick="wordfenceExt.dismissAdminNotice(\'%s\'); return false;">Dismiss</a>', 'wordfence'), esc_attr($this->_id)) . '</p></div>';
176 }
177 }