PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 3.3.10
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v3.3.10
3.3.10 3.3.9 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 All 68 releases
← All changes | views/settings.php +90 -53 3.3.9 → 3.3.10 View file →
@@ -29,13 +29,14 @@
29 29 * @var string $key
30 30 * @var array $options
31 31 */
32 32
33 -$api = new Logtivity_Api();
34 -$apiKey = $api->getApiKey();
35 -$latestResponse = $api->getLatestResponse();
36 -$status = $api->getConnectionStatus();
33 +$api = new Logtivity_Api();
34 +$apiKey = $api->getApiKey();
35 +$connectionStatus = $api->getConnectionStatus();
36 +$debugLogEntries = (new Logtivity_Debug_Log())->recent();
37 37
38 +// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- logtivity_view() renders trusted plugin templates.
38 39 echo logtivity_view('_admin-header', compact('options'));
39 40 ?>
40 41
41 42 <div class="postbox logtivity-settings">
@@ -68,18 +69,19 @@
68 69 <?php elseif (logtivity_is_production() == false) : ?>
69 70 <div class="logtivity-notice logtivity-notice-warning">
70 71 <h2>This site is not sending logs to the production application.</h2>
71 72 <div>
72 - See your dashboard at
73 - <a target="_blank"
74 - href="<?php echo logtivity_get_app_url(); ?>">
75 - <?php esc_html_e('Logtivity dashboard', 'logtivity'); ?>
76 - </a>
73 + See your dashboard at
74 + <a target="_blank"
75 + rel="noopener noreferrer"
76 + href="<?php echo esc_url(logtivity_get_app_url()); ?>">
77 + <?php esc_html_e('Logtivity dashboard', 'logtivity'); ?>
78 + </a>
77 79 </div>
78 80 </div>
79 81 <?php endif; ?>
80 82
81 - <form action="<?php echo admin_url('admin-ajax.php'); ?>?action=logtivity_update_settings" method="post">
83 + <form action="<?php echo esc_url(admin_url('admin-ajax.php?action=logtivity_update_settings')); ?>" method="post">
82 84
83 85 <?php wp_nonce_field('logtivity_update_settings', 'logtivity_update_settings') ?>
84 86
85 87 <table class="form-table">
@@ -96,14 +98,14 @@
96 98 <input id="logtivity_site_api_key"
97 99 name="logtivity_site_api_key"
98 100 type="text"
99 101 <?php echo has_filter('logtivity_site_api_key') ? 'readonly' : ''; ?>
100 - value="<?php echo sanitize_text_field($apiKey); ?>"
102 + value="<?php echo esc_attr($apiKey); ?>"
101 103 class="regular-text">
102 104 <p>
103 105 Status:
104 106 <?php
105 - switch ($status) {
107 + switch ($connectionStatus) {
106 108 case 'success':
107 109 echo '<span style="color: #4caf50; font-weight: bold;">Connected</span>';
108 110 break;
109 111
@@ -108,17 +110,17 @@
108 110 break;
109 111
110 112 case 'paused':
111 113 echo '<span style="color: #dbbf24; font-weight: bold;">Logging is paused</span>';
112 - echo '<br>' . $api->getConnectionMessage();
114 + echo '<br>' . esc_html($api->getConnectionMessage());
113 115 break;
114 116
115 117 case 'staging':
116 - echo '<span style="color: #dbbf24; font-weight: bold;">' . $api->getConnectionMessage() . '</span>';
118 + echo '<span style="color: #dbbf24; font-weight: bold;">' . esc_html($api->getConnectionMessage()) . '</span>';
117 119 break;
118 120
119 121 case 'fail':
120 - echo '<span style="color: #ff3232; font-weight: bold;">' . $api->getConnectionMessage() . '</span>';
122 + echo '<span style="color: #ff3232; font-weight: bold;">' . esc_html($api->getConnectionMessage()) . '</span>';
121 123 break;
122 124
123 125 default:
124 126 if ($apiKey) {
@@ -318,13 +320,14 @@
318 320 </td>
319 321
320 322 <td>
321 323 <span class="description">
322 - This will log the latest response from the API.
323 - This can be useful for debugging the result from an API call when storing a log.
324 - We <strong>recommend setting this to off by default</strong> as this will allow
325 - us to send logs asynchronously and not wait for a response from the API.
326 - This will be more performant.
324 + This will record a history of request and response data for API calls
325 + to a debug log file (<code>wp-content/uploads/logtivity-logs/debug.log</code>),
326 + viewable below. Response details are only captured for calls that already
327 + wait for a response (periodic settings check-ins, roughly every 10 minutes);
328 + other calls are still sent without waiting and only the outgoing request is
329 + logged. Enabling this does not affect performance.
327 330 </span>
328 331 </td>
329 332 </tr>
330 333
@@ -363,12 +366,12 @@
363 366 ?>
364 367 If you have multiple sites on Logtivity and would rather control disabled
365 368 logs globally you can go to the
366 369 <?php
367 - echo sprintf(
370 + printf(
368 371 '<a href="%s" target="_blank" rel="nofollow">%s</a>',
369 - logtivity_get_app_url() . '/team-settings/activity-log-settings',
370 - 'Activity Log Settings page'
372 + esc_url(logtivity_get_app_url() . '/team-settings/activity-log-settings'),
373 + esc_html__('Activity Log Settings page', 'logtivity')
371 374 );
372 375 ?>
373 376 in your Logtivity dashboard.
374 377 <?php endif; ?>
@@ -394,42 +397,76 @@
394 397
395 398 <div class="postbox">
396 399 <div class="inside">
397 400
398 - <h3>Latest Response</h3>
401 + <h3>Debug Log</h3>
399 402
400 - <?php
401 - if ($latestResponse) :
402 - $date = $latestResponse['date'] ?? null;
403 - $code = $latestResponse['code'] ?? null;
404 - $message = $latestResponse['message'] ?? null;
405 - $body = $latestResponse['body'] ?? null;
403 + <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" style="display: inline-block; margin-bottom: 15px;">
404 + <input type="hidden" name="action" value="logtivity_clear_debug_log">
405 + <?php wp_nonce_field('logtivity_clear_debug_log', 'logtivity_clear_debug_log'); ?>
406 + <input id="logtivity-clear-debug-log"
407 + type="submit"
408 + class="button"
409 + value="Clear Debug Log"
410 + onclick="return confirm('Are you sure you want to clear the debug log?');">
411 + </form>
406 412
407 - if ($date) : ?>
408 - <h4>Date: <?php echo $date; ?></h4>
409 - <?php
410 - endif;
413 + <?php if ($debugLogEntries) : ?>
414 + <a id="logtivity-download-debug-log"
415 + class="button"
416 + style="margin-bottom: 15px;"
417 + href="<?php
418 + echo esc_url(wp_nonce_url(
419 + admin_url('admin-post.php?action=logtivity_download_debug_log'),
420 + 'logtivity_download_debug_log',
421 + 'logtivity_download_debug_log'
422 + ));
423 + ?>">
424 + Download Debug Log
425 + </a>
426 + <?php endif; ?>
411 427
412 - if ($code || $message) : ?>
413 - <h4>
414 - Response: <?php echo sprintf('%s - %s', $code ?: 'NA', $message ?: 'No Message'); ?>
415 - </h4>
416 - <?php
417 - endif;
418 -
419 - if ($body) : ?>
420 - <code style="display: block; padding: 20px; overflow-x: auto;">
421 - <?php echo json_encode($body); ?>
422 - </code>
423 - <?php
424 - endif;
425 -
426 - else : ?>
427 - <p>The latest logging response will appear here after an event has been logged.</p>
428 -
429 - <?php endif ?>
428 + <?php if ($debugLogEntries) : ?>
429 + <?php foreach ($debugLogEntries as $entry) : ?>
430 + <div style="border-bottom: 1px solid #ddd; padding: 10px 0;">
431 + <h4>
432 + <?php echo esc_html($entry['timestamp'] ?? ''); ?>
433 + &mdash;
434 + <?php echo esc_html($entry['method'] ?? ''); ?>
435 + <?php echo esc_html($entry['endpoint'] ?? ''); ?>
436 + </h4>
437 + <?php $responseCode = $entry['response_code'] ?? null; ?>
438 + <h4>
439 + Response:
440 + <?php
441 + echo $responseCode === null
442 + ? 'not captured (sent without waiting for a response)'
443 + : esc_html(sprintf(
444 + '%s - %s (%sms)',
445 + $responseCode,
446 + $entry['response_message'] ?? 'No Message',
447 + $entry['response_time_ms'] ?? 'NA'
448 + ));
449 + ?>
450 + </h4>
451 + <code style="display: block; padding: 20px; overflow-x: auto;">
452 + Request: <?php echo esc_html(wp_json_encode($entry['request_body'] ?? null)); ?>
453 + </code>
454 + <?php if ($responseCode !== null) : ?>
455 + <code style="display: block; padding: 20px; overflow-x: auto;">
456 + Response: <?php echo esc_html(wp_json_encode($entry['response_body'] ?? null)); ?>
457 + </code>
458 + <?php endif; ?>
459 + </div>
460 + <?php endforeach; ?>
461 + <?php else : ?>
462 + <p>The debug log will appear here after an API call has been made.</p>
463 + <?php endif; ?>
430 464 </div>
431 465 </div>
432 466
433 467 <?php endif ?>
434 468
435 -<?php echo logtivity_view('_admin-footer', compact('options')); ?>
469 +<?php
470 +// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- logtivity_view() renders trusted plugin templates.
471 +echo logtivity_view('_admin-footer', compact('options'));
472 +?>