| 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 object $log |
| 27 |
*/ |
| 28 |
?> |
| 29 |
<div class="logtivity-modal-strip"> |
| 30 |
<h2 id="logtivity-log-modal-title" class="title">Overview</h2> |
| 31 |
<button type="button" class="notice-dismiss js-logtivity-notice-dismiss"> |
| 32 |
<span class="screen-reader-text">Dismiss this modal.</span> |
| 33 |
</button> |
| 34 |
</div> |
| 35 |
|
| 36 |
<table style="margin-top: 0;" class="form-table logtivity-table"> |
| 37 |
<tbody> |
| 38 |
<tr> |
| 39 |
<th scope="row">Action</th> |
| 40 |
<td><?php echo sanitize_text_field($log->action) ?></td> |
| 41 |
</tr> |
| 42 |
<?php if ($log->context): ?> |
| 43 |
<tr> |
| 44 |
<th scope="row">Context</th> |
| 45 |
<td><?php echo sanitize_text_field($log->context) ?></td> |
| 46 |
</tr> |
| 47 |
<?php endif ?> |
| 48 |
<?php if ($log->action_user_id): ?> |
| 49 |
<tr> |
| 50 |
<th scope="row">User ID</th> |
| 51 |
<td><?php echo sanitize_text_field($log->action_user_id) ?></td> |
| 52 |
</tr> |
| 53 |
<?php endif ?> |
| 54 |
<?php if ($log->action_username): ?> |
| 55 |
<tr> |
| 56 |
<th scope="row">Username</th> |
| 57 |
<td><?php echo sanitize_text_field($log->action_username) ?></td> |
| 58 |
</tr> |
| 59 |
<?php |
| 60 |
endif; |
| 61 |
|
| 62 |
if ($log->action_user_meta) : |
| 63 |
foreach (json_decode($log->action_user_meta) as $key => $value) : |
| 64 |
?> |
| 65 |
<tr> |
| 66 |
<th scope="row"><?php echo sanitize_text_field(ucfirst(str_replace('_', ' ', $key))) ?></th> |
| 67 |
<td> |
| 68 |
<?php |
| 69 |
if (is_array($value)) : |
| 70 |
?> |
| 71 |
<pre class="mb-0"><?php var_export($value) ?></pre> |
| 72 |
<?php |
| 73 |
elseif (substr($value, 0, 4) === 'http') : |
| 74 |
?> |
| 75 |
<a target="_blank" |
| 76 |
rel="noopener noreferrer" |
| 77 |
href="<?php echo sanitize_text_field($value) ?>"> |
| 78 |
<?php echo sanitize_text_field($value) ?> |
| 79 |
</a> |
| 80 |
<?php |
| 81 |
else : |
| 82 |
echo sanitize_text_field($value); |
| 83 |
endif; |
| 84 |
?> |
| 85 |
</td> |
| 86 |
</tr> |
| 87 |
<?php |
| 88 |
endforeach; |
| 89 |
endif; |
| 90 |
|
| 91 |
if ($log->ip_address) : ?> |
| 92 |
<tr> |
| 93 |
<th scope="row">IP</th> |
| 94 |
<td><?php echo sanitize_text_field($log->ip_address) ?></td> |
| 95 |
</tr> |
| 96 |
<?php endif ?> |
| 97 |
<tr> |
| 98 |
<th scope="row">Date</th> |
| 99 |
<td> |
| 100 |
<?php echo logtivity_datetime($log->occurred_at); ?> |
| 101 |
</td> |
| 102 |
</tr> |
| 103 |
</tbody> |
| 104 |
</table> |
| 105 |
|
| 106 |
<?php |
| 107 |
$meta = json_decode($log->meta, true); |
| 108 |
if ($meta) : |
| 109 |
?> |
| 110 |
<div class="logtivity-modal-strip light small"> |
| 111 |
<h3 class="hndle">Meta</h3> |
| 112 |
</div> |
| 113 |
|
| 114 |
<table style="margin-top: 0;" class="form-table logtivity-table"> |
| 115 |
<tbody> |
| 116 |
<?php |
| 117 |
foreach ($meta as $key => $value) : |
| 118 |
?> |
| 119 |
<tr> |
| 120 |
<th scope="row"> |
| 121 |
<?php if (isset($value['key'])) : ?> |
| 122 |
<strong><?php echo sanitize_text_field($value['key']) ?></strong> |
| 123 |
<?php else : ?> |
| 124 |
<strong><?php echo sanitize_text_field($key) ?></strong> |
| 125 |
<?php endif ?> |
| 126 |
</th> |
| 127 |
|
| 128 |
<td> |
| 129 |
<?php |
| 130 |
$value = (isset($value['key']) && !isset($value['value'])) ? '' : ($value['value'] ?? ''); |
| 131 |
|
| 132 |
if (is_array($value) || is_object($value)) : |
| 133 |
?> |
| 134 |
<pre><?php var_export($value) ?></pre> |
| 135 |
<?php |
| 136 |
elseif (preg_match('#^https?://#', ltrim($value))) : |
| 137 |
?> |
| 138 |
<a target="_blank" |
| 139 |
rel="noopener noreferrer" |
| 140 |
href="<?php echo sanitize_text_field($value) ?>"> |
| 141 |
Visit Link |
| 142 |
<i class="ml-1 small fas fa-external-link-alt"></i> |
| 143 |
</a> |
| 144 |
<?php |
| 145 |
else : |
| 146 |
echo sanitize_text_field($value); |
| 147 |
endif; |
| 148 |
?> |
| 149 |
</td> |
| 150 |
</tr> |
| 151 |
|
| 152 |
<?php endforeach; ?> |
| 153 |
</tbody> |
| 154 |
</table> |
| 155 |
<?php |
| 156 |
endif; |
| 157 |
|