PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / trunk
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity vtrunk
3.3.8 trunk 1.0 1.1.0 1.10.0 1.11.0 1.11.1 1.12.0 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 1.6.1 All 66 releases
logtivity / views / settings.php

settings.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity trunk, at views/settings.php

423 lines 18.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @package Logtivity
5 * @contact logtivity.io, hello@logtivity.io
6 * @copyright 2024-2026 Logtivity. All rights reserved
7 * @license https://www.gnu.org/licenses/gpl.html GNU/GPL
8 *
9 * This file is part of Logtivity.
10 *
11 * Logtivity is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * Logtivity is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with Logtivity. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25 /**
26 * @var string $fileName
27 * @var array $vars
28 * @var array $value
29 * @var string $key
30 * @var array $options
31 */
32
33 $api = new Logtivity_Api();
34 $apiKey = $api->getApiKey();
35 $latestResponse = $api->getLatestResponse();
36 $status = $api->getConnectionStatus();
37
38 echo logtivity_view('_admin-header', compact('options'));
39 ?>
40
41 <div class="postbox logtivity-settings">
42 <div class="inside">
43 <h1 style="padding-top: 20px;">Settings</h1>
44
45 <?php if (logtivity_has_site_url_changed()): ?>
46 <div class="logtivity-notice logtivity-notice-danger">
47 <h2>We've detected a change in your site URL.</h2>
48 <div>
49 As a precaution, we've stopped logging. To start recording
50 logs, again click the 'Update Settings' button below.
51 </div>
52 </div>
53 <?php endif;
54
55 if (logtivity_is_production() == false) : ?>
56 <div class="logtivity-notice logtivity-notice-warning">
57 <h2>This site is not sending logs to the production application.</h2>
58 <div>
59 See your dashboard at
60 <a target="_blank"
61 href="<?php echo logtivity_get_app_url(); ?>">
62 <?php esc_html_e('Logtivity dashboard', 'logtivity'); ?>
63 </a>
64 </div>
65 </div>
66 <?php endif; ?>
67
68 <form action="<?php echo admin_url('admin-ajax.php'); ?>?action=logtivity_update_settings" method="post">
69
70 <?php wp_nonce_field('logtivity_update_settings', 'logtivity_update_settings') ?>
71
72 <table class="form-table">
73 <tbody>
74 <tr class="user-user-login-wrap">
75 <th scope="row">
76 <label for="logtivity_site_api_key">Site API Key</label>
77 <?php if (has_filter('logtivity_site_api_key')): ?>
78 <div class="logtivity-constant">This option has been set in code.</div>
79 <?php endif ?>
80 </th>
81
82 <td>
83 <input id="logtivity_site_api_key"
84 name="logtivity_site_api_key"
85 type="text"
86 <?php echo has_filter('logtivity_site_api_key') ? 'readonly' : ''; ?>
87 value="<?php echo sanitize_text_field($apiKey); ?>"
88 class="regular-text">
89 <p>
90 Status:
91 <?php
92 switch ($status) {
93 case 'success':
94 echo '<span style="color: #4caf50; font-weight: bold;">Connected</span>';
95 break;
96
97 case 'paused':
98 echo '<span style="color: #dbbf24; font-weight: bold;">Logging is paused</span>';
99 echo '<br>' . $api->getConnectionMessage();
100 break;
101
102 case 'staging':
103 echo '<span style="color: #dbbf24; font-weight: bold;">' . $api->getConnectionMessage() . '</span>';
104 break;
105
106 case 'fail':
107 echo '<span style="color: #ff3232; font-weight: bold;">' . $api->getConnectionMessage() . '</span>';
108 break;
109
110 default:
111 if ($apiKey) {
112 echo '<span style="color: #ffdd32; font-weight: bold;">Unknown error</span>';
113 } else {
114 echo '<span style="font-weight: bold;">Enter this site\'s API Key</span>';
115 }
116 break;
117 }
118 ?>
119 </p>
120 </td>
121
122 <td style="vertical-align: top;">
123 <span class="description">
124 You can find this value by logging into your account
125 and navigating to this site's settings page.
126 </span>
127 </td>
128 </tr>
129
130 <tr class="user-user-login-wrap">
131 <th scope="row">
132 <label for="logtivity_should_store_user_id">Store User ID</label>
133 <?php if (has_filter('logtivity_should_store_user_id')): ?>
134 <div class="logtivity-constant">This option has been set in code.</div>
135 <?php endif ?>
136 </th>
137
138 <td>
139 <input name="logtivity_should_store_user_id"
140 type="hidden"
141 value="0">
142
143 <input id="logtivity_should_store_user_id"
144 name="logtivity_should_store_user_id"
145 type="checkbox"
146 <?php echo $options['logtivity_should_store_user_id'] ? 'checked' : ''; ?>
147 <?php echo has_filter('logtivity_should_store_user_id') ? 'readonly' : ''; ?>
148 value="1"
149 class="regular-checkbox">
150 </td>
151
152 <td>
153 <span class="description">
154 If you check this box, when logging an action,
155 we will include the users User ID in the logged action.
156 </span>
157 </td>
158 </tr>
159
160 <tr class="user-user-login-wrap">
161 <th scope="row">
162 <label for="logtivity_should_log_profile_link">Store Users Profile Link</label>
163 <?php if (has_filter('logtivity_should_log_profile_link')): ?>
164 <div class="logtivity-constant">This option has been set in code.</div>
165 <?php endif ?>
166 </th>
167
168 <td>
169 <input name="logtivity_should_log_profile_link"
170 type="hidden"
171 value="0">
172
173 <input id="logtivity_should_log_profile_link"
174 name="logtivity_should_log_profile_link"
175 type="checkbox"
176 <?php echo $options['logtivity_should_log_profile_link'] ? 'checked' : ''; ?>
177 <?php echo has_filter('logtivity_should_log_profile_link') ? 'readonly' : ''; ?>
178 value="1"
179 class="regular-checkbox">
180 </td>
181
182 <td>
183 <span class="description">
184 If you check this box, when logging an action,
185 we will include the users profile link in the logged action.
186 </span>
187 </td>
188 </tr>
189
190 <tr class="user-user-login-wrap">
191 <th scope="row">
192 <label for="logtivity_should_log_username">Store Users Username</label>
193 <?php if (has_filter('logtivity_should_log_username')): ?>
194 <div class="logtivity-constant">This option has been set in code.</div>
195 <?php endif ?>
196 </th>
197
198 <td>
199 <input name="logtivity_should_log_username"
200 type="hidden"
201 value="0">
202
203 <input id="logtivity_should_log_username"
204 name="logtivity_should_log_username"
205 type="checkbox"
206 <?php echo has_filter('logtivity_should_log_username') ? 'readonly' : ''; ?>
207 <?php echo $options['logtivity_should_log_username'] ? 'checked' : ''; ?>
208 value="1"
209 class="regular-checkbox">
210 </td>
211
212 <td>
213 <span class="description">
214 If you check this box, when logging an action,
215 we will include the users username in the logged action.
216 </span>
217 </td>
218 </tr>
219
220 <tr class="user-user-login-wrap">
221 <th scope="row">
222 <label for="logtivity_should_store_ip">Store Users IP Address</label>
223 <?php if (has_filter('logtivity_should_store_ip')): ?>
224 <div class="logtivity-constant">This option has been set in code.</div>
225 <?php endif ?>
226 </th>
227
228 <td>
229 <input name="logtivity_should_store_ip"
230 type="hidden"
231 value="0">
232
233 <input id="logtivity_should_store_ip"
234 name="logtivity_should_store_ip"
235 type="checkbox"
236 <?php echo $options['logtivity_should_store_ip'] ? 'checked' : ''; ?>
237 <?php echo has_filter('logtivity_should_store_ip') ? 'readonly' : ''; ?>
238 value="1"
239 class="regular-checkbox">
240 </td>
241
242 <td>
243 <span class="description">
244 If you check this box, when logging an action,
245 we will include the users IP address in the logged action.
246 </span>
247 </td>
248 </tr>
249
250 <tr class="user-user-login-wrap">
251 <th scope="row">
252 <label for="logtivity_app_verify_url">
253 Verify Site URL
254 </label>
255 <?php if (has_filter('logtivity_app_verify_url')): ?>
256 <div class="logtivity-constant">This option has been set in code.</div>
257 <?php endif ?>
258 </th>
259
260 <td>
261 <input name="logtivity_app_verify_url"
262 type="hidden"
263 value="0">
264
265 <input id="logtivity_app_verify_url"
266 name="logtivity_app_verify_url"
267 type="checkbox"
268 <?php echo $options['logtivity_app_verify_url'] ? 'checked' : ''; ?>
269 <?php echo has_filter('logtivity_app_verify_url') ? 'readonly' : ''; ?>
270 value="1"
271 class="regular-checkbox">
272 </td>
273
274 <td>
275 <span class="description">
276 When messages are sent to Logtivity, the site URL will be checked
277 against the URL Logtivity has on file for this API Key. If they do
278 not match, logging will be paused.
279 </span>
280 </td>
281 </tr>
282
283 <tr class="user-user-login-wrap">
284 <th scope="row">
285 <label for="logtivity_enable_debug_mode">
286 Enable debug mode (recommended off by default)
287 </label>
288 <?php if (has_filter('logtivity_enable_debug_mode')): ?>
289 <div class="logtivity-constant">This option has been set in code.</div>
290 <?php endif ?>
291 </th>
292
293 <td>
294 <input name="logtivity_enable_debug_mode"
295 type="hidden"
296 value="0">
297
298 <input id="logtivity_enable_debug_mode"
299 name="logtivity_enable_debug_mode"
300 type="checkbox"
301 <?php echo $options['logtivity_enable_debug_mode'] ? 'checked' : ''; ?>
302 <?php echo has_filter('logtivity_enable_debug_mode') ? 'readonly' : ''; ?>
303 value="1"
304 class="regular-checkbox">
305 </td>
306
307 <td>
308 <span class="description">
309 This will log the latest response from the API.
310 This can be useful for debugging the result from an API call when storing a log.
311 We <strong>recommend setting this to off by default</strong> as this will allow
312 us to send logs asynchronously and not wait for a response from the API.
313 This will be more performant.
314 </span>
315 </td>
316 </tr>
317
318 <tr class="user-user-login-wrap">
319 <th scope="row">
320 <label for="logtivity_disable_individual_logs">Disable Individual Logs</label>
321 <?php if (has_filter('logtivity_disable_individual_logs')): ?>
322 <div class="logtivity-constant">This option has been set in code.</div>
323 <?php endif ?>
324 </th>
325 <td>
326 <textarea id="logtivity_disable_individual_logs"
327 name="logtivity_disable_individual_logs"
328 class="regular-checkbox"
329 style="width: 100%;"
330 <?php echo has_filter('logtivity_disable_individual_logs') ? 'readonly' : ''; ?>
331 rows="10"
332 placeholder="User Logged In&#10;User Created && subscriber"
333 ><?php echo esc_html($options['logtivity_disable_individual_logs']); ?></textarea>
334 </td>
335
336 <td>
337 <span class="description">
338 You can disable individual logged actions here by listing the action names, one per line.
339 <br>
340 <br>
341 To specify the context field as well,
342 separate the action and context keywords with an && symbol.
343 <br>
344 <br>
345 <?php
346 if (
347 isset($options['logtivity_enable_white_label_mode']) == false
348 || $options['logtivity_enable_white_label_mode'] != 1
349 ):
350 ?>
351 If you have multiple sites on Logtivity and would rather control disabled
352 logs globally you can go to the
353 <?php
354 echo sprintf(
355 '<a href="%s" target="_blank" rel="nofollow">%s</a>',
356 logtivity_get_app_url() . '/team-settings/activity-log-settings',
357 'Activity Log Settings page'
358 );
359 ?>
360 in your Logtivity dashboard.
361 <?php endif; ?>
362 </span>
363 </td>
364 </tr>
365 </tbody>
366 </table>
367
368 <p class="submit">
369 <input id="submit"
370 name="submit"
371 type="submit"
372 class="button button-primary"
373 value="Update Settings">
374 </p>
375 </form>
376
377 </div>
378 </div>
379
380 <?php if ($options['logtivity_enable_debug_mode']): ?>
381
382 <div class="postbox">
383 <div class="inside">
384
385 <h3>Latest Response</h3>
386
387 <?php
388 if ($latestResponse) :
389 $date = $latestResponse['date'] ?? null;
390 $code = $latestResponse['code'] ?? null;
391 $message = $latestResponse['message'] ?? null;
392 $body = $latestResponse['body'] ?? null;
393
394 if ($date) : ?>
395 <h4>Date: <?php echo $date; ?></h4>
396 <?php
397 endif;
398
399 if ($code || $message) : ?>
400 <h4>
401 Response: <?php echo sprintf('%s - %s', $code ?: 'NA', $message ?: 'No Message'); ?>
402 </h4>
403 <?php
404 endif;
405
406 if ($body) : ?>
407 <code style="display: block; padding: 20px; overflow-x: auto;">
408 <?php echo json_encode($body); ?>
409 </code>
410 <?php
411 endif;
412
413 else : ?>
414 <p>The latest logging response will appear here after an event has been logged.</p>
415
416 <?php endif ?>
417 </div>
418 </div>
419
420 <?php endif ?>
421
422 <?php echo logtivity_view('_admin-footer', compact('options')); ?>
423