PluginProbe ʕ •ᴥ•ʔ
Wordfence Security – Firewall, Malware Scan, and Login Security / 8.0.5
Wordfence Security – Firewall, Malware Scan, and Login Security v8.0.5
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 1 year ago audit-log 1 year ago dashboard 1 year ago rest-api 1 year ago .htaccess 7 years ago Diff.php 6 years ago GeoLite2-Country.mmdb 1 year ago IPTraf.php 1 year ago IPTrafList.php 1 year ago WFLSPHP52Compatability.php 6 years ago compat.php 8 years ago diffResult.php 1 year ago email_genericAlert.php 5 years ago email_newIssues.php 3 years ago email_unlockRequest.php 5 years ago email_unsubscribeRequest.php 4 years ago flags.php 7 years ago live_activity.php 4 years ago menu_dashboard.php 3 years ago menu_dashboard_options.php 3 years ago menu_firewall.php 3 years ago menu_firewall_blocking.php 4 years ago menu_firewall_blocking_options.php 3 years ago menu_firewall_waf.php 4 years ago menu_firewall_waf_options.php 3 years ago menu_install.php 3 years ago menu_options.php 1 year ago menu_scanner.php 2 years ago menu_scanner_credentials.php 1 year ago menu_scanner_options.php 3 years ago menu_support.php 1 year ago menu_tools.php 1 year ago menu_tools_auditlog.php 1 year ago menu_tools_diagnostic.php 1 year ago menu_tools_importExport.php 4 years ago menu_tools_livetraffic.php 2 years ago menu_tools_twoFactor.php 4 years ago menu_tools_whois.php 3 years ago menu_wordfence_central.php 3 years ago noc1.key 7 years ago sodium_compat_fast.php 2 years ago sysinfo.php 1 year ago viewFullActivityLog.php 4 years ago wf503.php 2 years ago wfAPI.php 1 year ago wfActivityReport.php 1 year ago wfAdminNoticeQueue.php 4 years ago wfAlerts.php 5 years ago wfArray.php 3 years ago wfAuditLog.php 1 year ago wfBrowscap.php 3 years ago wfBrowscapCache.php 7 years ago wfBulkCountries.php 2 years ago wfCache.php 3 years ago wfCentralAPI.php 1 year ago wfConfig.php 1 year ago wfCrawl.php 1 year ago wfCredentialsController.php 1 year ago wfCrypt.php 6 years ago wfCurlInterceptor.php 3 years ago wfDB.php 1 year ago wfDashboard.php 1 year ago wfDateLocalization.php 2 years ago wfDeactivationOption.php 3 years ago wfDiagnostic.php 1 year ago wfDict.php 8 years ago wfDirectoryIterator.php 7 years ago wfFileUtils.php 2 years ago wfHelperBin.php 11 years ago wfHelperString.php 1 year ago wfIPWhitelist.php 5 years ago wfImportExportController.php 5 years ago wfInaccessibleDirectoryException.php 2 years ago wfInvalidPathException.php 3 years ago wfIpLocation.php 3 years ago wfIpLocator.php 3 years ago wfIssues.php 1 year ago wfJWT.php 7 years ago wfLicense.php 3 years ago wfLockedOut.php 2 years ago wfLog.php 1 year ago wfMD5BloomFilter.php 8 years ago wfModuleController.php 7 years ago wfNotification.php 8 years ago wfOnboardingController.php 1 year ago wfPersistenceController.php 1 year ago wfRESTAPI.php 7 years ago wfScan.php 2 years ago wfScanEngine.php 1 year ago wfScanEntrypoint.php 3 years ago wfScanFile.php 1 year ago wfScanFileLink.php 3 years ago wfScanFileListItem.php 1 year ago wfScanFileProperties.php 1 year ago wfScanMonitor.php 2 years ago wfScanPath.php 3 years ago wfSchema.php 1 year ago wfStyle.php 1 year ago wfSupportController.php 1 year ago wfUnlockMsg.php 5 years ago wfUpdateCheck.php 1 year ago wfUtils.php 1 year ago wfVersionCheckController.php 3 years ago wfVersionSupport.php 1 year ago wfView.php 5 years ago wfViewResult.php 1 year ago wfWebsite.php 3 years ago wordfenceClass.php 1 year ago wordfenceConstants.php 1 year ago wordfenceHash.php 1 year ago wordfenceScanner.php 1 year ago wordfenceURLHoover.php 2 years ago
wfAdminNoticeQueue.php
195 lines
1 <?php
2
3 class wfAdminNoticeQueue {
4 protected static function _notices() {
5 return self::_purgeObsoleteNotices(wfConfig::get_ser('adminNoticeQueue', array()));
6 }
7
8 private static function _purgeObsoleteNotices($notices) {
9 $altered = false;
10 foreach ($notices as $id => $notice) {
11 if ($notice['category'] === 'php8') {
12 unset($notices[$id]);
13 $altered = true;
14 }
15 }
16 if ($altered)
17 self::_setNotices($notices);
18 return $notices;
19 }
20
21 protected static function _setNotices($notices) {
22 wfConfig::set_ser('adminNoticeQueue', $notices);
23 }
24
25 /**
26 * Adds an admin notice to the display queue.
27 *
28 * @param string $severity
29 * @param string $messageHTML
30 * @param bool|string $category If not false, notices with the same category will be removed prior to adding this one.
31 * @param bool|array $users If not false, an array of user IDs the notice should show for.
32 */
33 public static function addAdminNotice($severity, $messageHTML, $category = false, $users = false) {
34 $notices = self::_notices();
35 foreach ($notices as $id => $n) {
36 $usersMatches = false;
37 if (isset($n['users'])) {
38 $usersMatches = wfUtils::sets_equal($n['users'], $users);
39 }
40 else if ($users === false) {
41 $usersMatches = true;
42 }
43
44 $categoryMatches = false;
45 if ($category !== false && isset($n['category']) && $n['category'] == $category) {
46 $categoryMatches = true;
47 }
48
49 if ($usersMatches && $categoryMatches) {
50 unset($notices[$id]);
51 }
52 }
53
54 $id = wfUtils::uuid();
55 $notices[$id] = array(
56 'severity' => $severity,
57 'messageHTML' => $messageHTML,
58 );
59
60 if ($category !== false) {
61 $notices[$id]['category'] = $category;
62 }
63
64 if ($users !== false) {
65 $notices[$id]['users'] = $users;
66 }
67
68 self::_setNotices($notices);
69 }
70
71 /**
72 * Removes an admin notice using one of three possible search methods:
73 *
74 * 1. If $id matches. $category and $users are ignored
75 * 2. If $category matches. $users must be false for this.
76 * 3. If $category matches and the notice's user IDs matches $users.
77 *
78 * @param bool|int $id
79 * @param bool|string $category
80 * @param bool|int[] $users
81 */
82 public static function removeAdminNotice($id = false, $category = false, $users = false) {
83 if ($id === false && $category === false && $users === false) {
84 return;
85 }
86 else if ($id !== false) {
87 $category = false;
88 $users = false;
89 }
90
91 $notices = self::_notices();
92 $found = false;
93 foreach ($notices as $nid => $n) {
94 if ($id == $nid) { //ID match
95 unset($notices[$nid]);
96 $found=true;
97 break;
98 }
99 else if ($id !== false) {
100 continue;
101 }
102
103 if ($category !== false && isset($n['category']) && $category == $n['category']) {
104 if ($users !== false) {
105 if (isset($n['users']) && wfUtils::sets_equal($users, $n['users'])) {
106 unset($notices[$nid]);
107 $found=true;
108 }
109 }
110 else {
111 unset($notices[$nid]);
112 $found=true;
113 }
114 }
115 }
116 if($found)
117 self::_setNotices($notices);
118 }
119
120 public static function hasNotice($category = false, $users = false) {
121 $notices = self::_notices();
122 foreach ($notices as $nid => $n) {
123 $categoryMatches = false;
124 if (($category === false && !isset($n['category'])) || ($category !== false && isset($n['category']) && $category == $n['category'])) {
125 $categoryMatches = true;
126 }
127
128 $usersMatches = false;
129 if (($users === false && !isset($n['users'])) || ($users !== false && isset($n['users']) && wfUtils::sets_equal($users, $n['users']))) {
130 $usersMatches = true;
131 }
132
133 if ($categoryMatches && $usersMatches) {
134 return true;
135 }
136 }
137 return false;
138 }
139
140 public static function enqueueAdminNotices() {
141 $user = wp_get_current_user();
142 if ($user->ID == 0) {
143 return false;
144 }
145
146 $networkAdmin = is_multisite() && is_network_admin();
147 $notices = self::_notices();
148 $added = false;
149 foreach ($notices as $nid => $n) {
150 if (isset($n['users']) && array_search($user->ID, $n['users']) === false) {
151 continue;
152 }
153
154 $notice = new wfAdminNotice($nid, $n['severity'], $n['messageHTML']);
155 if ($networkAdmin) {
156 add_action('network_admin_notices', array($notice, 'displayNotice'));
157 }
158 else {
159 add_action('admin_notices', array($notice, 'displayNotice'));
160 }
161
162 $added = true;
163 }
164
165 return $added;
166 }
167 }
168
169 class wfAdminNotice {
170 const SEVERITY_CRITICAL = 'critical';
171 const SEVERITY_WARNING = 'warning';
172 const SEVERITY_INFO = 'info';
173
174 private $_id;
175 private $_severity;
176 private $_messageHTML;
177
178 public function __construct($id, $severity, $messageHTML) {
179 $this->_id = $id;
180 $this->_severity = $severity;
181 $this->_messageHTML = $messageHTML;
182 }
183
184 public function displayNotice() {
185 $severityClass = 'notice-info';
186 if ($this->_severity == self::SEVERITY_CRITICAL) {
187 $severityClass = 'notice-error';
188 }
189 else if ($this->_severity == self::SEVERITY_WARNING) {
190 $severityClass = 'notice-warning';
191 }
192
193 echo '<div class="wf-admin-notice notice ' . $severityClass . '" data-notice-id="' . esc_attr($this->_id) . '"><p>' . $this->_messageHTML . '</p><p><a class="wf-btn wf-btn-default wf-btn-sm wf-dismiss-link" href="#" onclick="wordfenceExt.dismissAdminNotice(\'' . esc_attr($this->_id) . '\'); return false;" role="button">' . esc_html__('Dismiss', 'wordfence') . '</a></p></div>';
194 }
195 }