| @@ -1,102 +1,156 @@ | ||
| 1 | -<div class="logtivity-modal-strip"> | |
| 2 | - <h2 class="title">Overview</h2> | |
| 3 | - <button type="button" class="notice-dismiss js-logtivity-notice-dismiss"><span class="screen-reader-text">Dismiss this modal.</span></button> | |
| 4 | -</div> | |
| 1 | +<?php | |
| 5 | 2 | |
| 6 | -<table style="margin-top: 0;" class="form-table logtivity-table"> | |
| 7 | - <tbody> | |
| 8 | - <tr> | |
| 9 | - <th>Action</th> | |
| 10 | - <td><?php echo sanitize_text_field($log->action) ?></td> | |
| 11 | - </tr> | |
| 12 | - <?php if ($log->context): ?> | |
| 13 | - <tr> | |
| 14 | - <th>Context</th> | |
| 15 | - <td><?php echo sanitize_text_field($log->context) ?></td> | |
| 16 | - </tr> | |
| 17 | - <?php endif ?> | |
| 18 | - <?php if ($log->action_user_id): ?> | |
| 19 | - <tr> | |
| 20 | - <th>User ID</th> | |
| 21 | - <td><?php echo sanitize_text_field($log->action_user_id) ?></td> | |
| 22 | - </tr> | |
| 23 | - <?php endif ?> | |
| 24 | - <?php if ($log->action_username): ?> | |
| 25 | - <tr> | |
| 26 | - <th>Username</th> | |
| 27 | - <td><?php echo sanitize_text_field($log->action_username) ?></td> | |
| 28 | - </tr> | |
| 29 | - <?php endif ?> | |
| 30 | - <?php if ($log->action_user_meta): ?> | |
| 31 | - <?php foreach (json_decode($log->action_user_meta) as $key => $value): ?> | |
| 32 | - <tr> | |
| 33 | - <th><?php echo sanitize_text_field(ucfirst( str_replace('_', ' ', $key) )) ?></th> | |
| 34 | - <td> | |
| 35 | - <?php if (is_array($value)): ?> | |
| 36 | - <pre class="mb-0"><?php var_export($value) ?></pre> | |
| 37 | - <?php else: ?> | |
| 38 | - <?php if (substr( $value, 0, 4 ) === "http"): ?> | |
| 39 | - <a target="_blank" rel="noopener noreferrer" href="<?php echo sanitize_text_field($value) ?>"><?php echo sanitize_text_field($value) ?></a> | |
| 40 | - <?php else: ?> | |
| 41 | - <?php echo sanitize_text_field($value) ?> | |
| 42 | - <?php endif ?> | |
| 43 | - <?php endif ?> | |
| 44 | - </td> | |
| 45 | - </tr> | |
| 46 | - <?php endforeach ?> | |
| 47 | - <?php endif; ?> | |
| 48 | - | |
| 49 | - <?php if ($log->ip_address): ?> | |
| 50 | - <tr> | |
| 51 | - <th>IP</th> | |
| 52 | - <td><?php echo sanitize_text_field($log->ip_address) ?></td> | |
| 53 | - </tr> | |
| 54 | - <?php endif ?> | |
| 55 | - <tr> | |
| 56 | - <th>Date</th> | |
| 57 | - <td> | |
| 58 | - <?php echo sanitize_text_field(date('M d Y', strtotime($log->occurred_at))) ?> <?php echo sanitize_text_field(date('H:i:s', strtotime($log->occurred_at))); ?> | |
| 59 | - </td> | |
| 60 | - </tr> | |
| 61 | - </tbody> | |
| 62 | -</table> | |
| 3 | +/** | |
| 4 | + * @package Logtivity | |
| 5 | + * @contact logtivity.io, [email protected] | |
| 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 | + */ | |
| 63 | 24 | |
| 64 | -<?php if ($log->meta): ?> | |
| 65 | - | |
| 66 | - <div class="logtivity-modal-strip light small"> | |
| 67 | - <h3 class="hndle">Meta</h3> | |
| 68 | - </div> | |
| 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> | |
| 69 | 35 | |
| 70 | - <table style="margin-top: 0;" class="form-table logtivity-table"> | |
| 71 | - <tbody> | |
| 72 | - <?php foreach (json_decode($log->meta, true) as $key => $value): ?> | |
| 73 | - | |
| 74 | - <tr> | |
| 75 | - <th> | |
| 76 | - <?php if (isset($value['key'])): ?> | |
| 77 | - <strong><?php echo sanitize_text_field($value['key']) ?></strong> | |
| 78 | - <?php else: ?> | |
| 79 | - <strong><?php echo sanitize_text_field($key) ?></strong> | |
| 80 | - <?php endif ?> | |
| 81 | - </th> | |
| 82 | - <td> | |
| 83 | - <?php if (isset($value['value'])): ?> | |
| 84 | - <?php $value = $value['value']; ?> | |
| 85 | - <?php endif; ?> | |
| 86 | - <?php if (is_array($value) || is_object($value)): ?> | |
| 87 | - <pre><?php var_export($value) ?></pre> | |
| 88 | - <?php else: ?> | |
| 89 | - <?php if (substr( $value, 0, 4 ) === "http"): ?> | |
| 90 | - <a target="_blank" rel="noopener noreferrer" href="<?php echo sanitize_text_field($value) ?>">Visit Link <i class="ml-1 small fas fa-external-link-alt"></i></a> | |
| 91 | - <?php else: ?> | |
| 92 | - <?php echo sanitize_text_field($value) ?> | |
| 93 | - <?php endif ?> | |
| 94 | - <?php endif ?> | |
| 95 | - </td> | |
| 96 | - </tr> | |
| 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; | |
| 97 | 61 | |
| 98 | - <?php endforeach ?> | |
| 99 | - </tbody> | |
| 100 | - </table> | |
| 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; | |
| 101 | 90 | |
| 102 | -<?php endif; ?> | |
| 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; | |