| 1 |
<?php |
| 2 |
/** |
| 3 |
* Activity Log - Logs Tab. |
| 4 |
* |
| 5 |
* @package King_Addons |
| 6 |
*/ |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
$activity_log = \King_Addons\Activity_Log::instance(); |
| 13 |
$event_keys = $activity_log->get_event_keys(); |
| 14 |
$is_pro = $activity_log->is_pro(); |
| 15 |
|
| 16 |
// Get all users for filter |
| 17 |
$users = get_users(['fields' => ['ID', 'user_login']]); |
| 18 |
?> |
| 19 |
|
| 20 |
<!-- Controls Bar --> |
| 21 |
<div class="ka-al-controls"> |
| 22 |
<div class="ka-al-search"> |
| 23 |
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" viewBox="0 0 24 24" |
| 24 |
stroke="currentColor" stroke-width="2"> |
| 25 |
<path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /> |
| 26 |
</svg> |
| 27 |
<input type="text" id="ka-al-search" placeholder="<?php esc_attr_e('Search events...', 'king-addons'); ?>"> |
| 28 |
</div> |
| 29 |
|
| 30 |
<div class="ka-al-filters"> |
| 31 |
<select id="ka-al-filter-event" class="ka-al-select"> |
| 32 |
<option value=""><?php esc_html_e('All Events', 'king-addons'); ?></option> |
| 33 |
<?php foreach ($event_keys as $key): ?> |
| 34 |
<option value="<?php echo esc_attr($key); ?>"> |
| 35 |
<?php echo esc_html(\King_Addons\Activity_Log_Event_Types::get_label($key)); ?> |
| 36 |
</option> |
| 37 |
<?php endforeach; ?> |
| 38 |
</select> |
| 39 |
|
| 40 |
<select id="ka-al-filter-severity" class="ka-al-select"> |
| 41 |
<option value=""><?php esc_html_e('All Severities', 'king-addons'); ?></option> |
| 42 |
<?php foreach (\King_Addons\Activity_Log_Event_Types::get_severity_labels() as $sev => $label): ?> |
| 43 |
<option value="<?php echo esc_attr($sev); ?>"><?php echo esc_html($label); ?></option> |
| 44 |
<?php endforeach; ?> |
| 45 |
</select> |
| 46 |
|
| 47 |
<select id="ka-al-filter-user" class="ka-al-select"> |
| 48 |
<option value=""><?php esc_html_e('All Users', 'king-addons'); ?></option> |
| 49 |
<?php foreach ($users as $user): ?> |
| 50 |
<option value="<?php echo esc_attr($user->ID); ?>"> |
| 51 |
<?php echo esc_html($user->user_login); ?> |
| 52 |
</option> |
| 53 |
<?php endforeach; ?> |
| 54 |
</select> |
| 55 |
|
| 56 |
<input type="date" id="ka-al-filter-date-from" class="ka-al-date" |
| 57 |
placeholder="<?php esc_attr_e('From', 'king-addons'); ?>"> |
| 58 |
<input type="date" id="ka-al-filter-date-to" class="ka-al-date" |
| 59 |
placeholder="<?php esc_attr_e('To', 'king-addons'); ?>"> |
| 60 |
|
| 61 |
<button type="button" id="ka-al-filter-apply" class="ka-al-btn ka-al-btn-primary"> |
| 62 |
<?php esc_html_e('Apply', 'king-addons'); ?> |
| 63 |
</button> |
| 64 |
|
| 65 |
<button type="button" id="ka-al-filter-reset" class="ka-al-btn ka-al-btn-secondary"> |
| 66 |
<?php esc_html_e('Reset', 'king-addons'); ?> |
| 67 |
</button> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
|
| 71 |
<!-- Logs Table --> |
| 72 |
<div class="ka-al-table-wrap"> |
| 73 |
<table class="ka-al-table" id="ka-al-table"> |
| 74 |
<thead> |
| 75 |
<tr> |
| 76 |
<th><?php esc_html_e('Time', 'king-addons'); ?></th> |
| 77 |
<th><?php esc_html_e('Event', 'king-addons'); ?></th> |
| 78 |
<th><?php esc_html_e('Severity', 'king-addons'); ?></th> |
| 79 |
<th><?php esc_html_e('User', 'king-addons'); ?></th> |
| 80 |
<th><?php esc_html_e('Object', 'king-addons'); ?></th> |
| 81 |
<th><?php esc_html_e('IP', 'king-addons'); ?></th> |
| 82 |
<th><?php esc_html_e('Actions', 'king-addons'); ?></th> |
| 83 |
</tr> |
| 84 |
</thead> |
| 85 |
<tbody id="ka-al-table-body"> |
| 86 |
<tr class="ka-al-loading"> |
| 87 |
<td colspan="7"> |
| 88 |
<div class="ka-al-spinner"></div> |
| 89 |
<?php esc_html_e('Loading events...', 'king-addons'); ?> |
| 90 |
</td> |
| 91 |
</tr> |
| 92 |
</tbody> |
| 93 |
</table> |
| 94 |
</div> |
| 95 |
|
| 96 |
<!-- Pagination --> |
| 97 |
<div class="ka-al-pagination" id="ka-al-pagination"> |
| 98 |
<span class="ka-al-pagination-info"></span> |
| 99 |
<div class="ka-al-pagination-controls"> |
| 100 |
<button type="button" class="ka-al-page-btn" data-page="prev" disabled> |
| 101 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" |
| 102 |
stroke="currentColor" stroke-width="2"> |
| 103 |
<path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" /> |
| 104 |
</svg> |
| 105 |
</button> |
| 106 |
<span class="ka-al-page-numbers"></span> |
| 107 |
<button type="button" class="ka-al-page-btn" data-page="next" disabled> |
| 108 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" |
| 109 |
stroke="currentColor" stroke-width="2"> |
| 110 |
<path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" /> |
| 111 |
</svg> |
| 112 |
</button> |
| 113 |
</div> |
| 114 |
</div> |