| 1 |
<?php |
| 2 |
/** |
| 3 |
* Activity Log - Dashboard 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 |
$kpis = $activity_log->get_kpis(); |
| 14 |
$top_events = $activity_log->get_top_events(); |
| 15 |
$top_users = $activity_log->get_top_users(); |
| 16 |
$is_pro = $activity_log->is_pro(); |
| 17 |
?> |
| 18 |
|
| 19 |
<!-- Bento KPI Cards --> |
| 20 |
<div class="ka-al-bento"> |
| 21 |
<div class="ka-al-bento-card"> |
| 22 |
<div class="ka-al-bento-icon ka-al-bento-icon--blue"> |
| 23 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" |
| 24 |
stroke="currentColor" stroke-width="2"> |
| 25 |
<path stroke-linecap="round" stroke-linejoin="round" |
| 26 |
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" /> |
| 27 |
</svg> |
| 28 |
</div> |
| 29 |
<div> |
| 30 |
<span class="ka-al-bento-value"><?php echo esc_html(number_format_i18n($kpis['events_24h'])); ?></span> |
| 31 |
<p class="ka-al-bento-desc"><?php esc_html_e('Events (24h)', 'king-addons'); ?></p> |
| 32 |
</div> |
| 33 |
</div> |
| 34 |
|
| 35 |
<div class="ka-al-bento-card"> |
| 36 |
<div class="ka-al-bento-icon ka-al-bento-icon--orange"> |
| 37 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" |
| 38 |
stroke="currentColor" stroke-width="2"> |
| 39 |
<path stroke-linecap="round" stroke-linejoin="round" |
| 40 |
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /> |
| 41 |
</svg> |
| 42 |
</div> |
| 43 |
<div> |
| 44 |
<span class="ka-al-bento-value"><?php echo esc_html(number_format_i18n($kpis['failed_logins'])); ?></span> |
| 45 |
<p class="ka-al-bento-desc"><?php esc_html_e('Failed Logins (24h)', 'king-addons'); ?></p> |
| 46 |
</div> |
| 47 |
</div> |
| 48 |
|
| 49 |
<div class="ka-al-bento-card"> |
| 50 |
<div class="ka-al-bento-icon ka-al-bento-icon--red"> |
| 51 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" |
| 52 |
stroke="currentColor" stroke-width="2"> |
| 53 |
<path stroke-linecap="round" stroke-linejoin="round" |
| 54 |
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /> |
| 55 |
</svg> |
| 56 |
</div> |
| 57 |
<div> |
| 58 |
<span class="ka-al-bento-value"><?php echo esc_html(number_format_i18n($kpis['critical_7d'])); ?></span> |
| 59 |
<p class="ka-al-bento-desc"><?php esc_html_e('Critical Events (7d)', 'king-addons'); ?></p> |
| 60 |
</div> |
| 61 |
</div> |
| 62 |
|
| 63 |
<div class="ka-al-bento-card"> |
| 64 |
<div class="ka-al-bento-icon ka-al-bento-icon--green"> |
| 65 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" |
| 66 |
stroke="currentColor" stroke-width="2"> |
| 67 |
<path stroke-linecap="round" stroke-linejoin="round" |
| 68 |
d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" /> |
| 69 |
</svg> |
| 70 |
</div> |
| 71 |
<div> |
| 72 |
<span class="ka-al-bento-value"><?php echo esc_html(number_format_i18n($kpis['unique_users'])); ?></span> |
| 73 |
<p class="ka-al-bento-desc"><?php esc_html_e('Active Users (7d)', 'king-addons'); ?></p> |
| 74 |
</div> |
| 75 |
</div> |
| 76 |
</div> |
| 77 |
|
| 78 |
<!-- Charts Section (Pro) --> |
| 79 |
<?php if (!$is_pro): ?> |
| 80 |
<div class="ka-al-pro-section"> |
| 81 |
<div class="ka-al-pro-card"> |
| 82 |
<div class="ka-al-pro-icon"> |
| 83 |
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="none" viewBox="0 0 24 24" |
| 84 |
stroke="currentColor" stroke-width="1.5"> |
| 85 |
<path stroke-linecap="round" stroke-linejoin="round" |
| 86 |
d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" /> |
| 87 |
</svg> |
| 88 |
</div> |
| 89 |
<h3><?php esc_html_e('Activity Charts & Analytics', 'king-addons'); ?></h3> |
| 90 |
<p><?php esc_html_e('Visualize activity trends, suspicious patterns, and audit insights with interactive charts.', 'king-addons'); ?> |
| 91 |
</p> |
| 92 |
<a href="https://kingaddons.com/pricing/?utm_source=kng-activity-log-charts&utm_medium=plugin&utm_campaign=kng" |
| 93 |
class="ka-al-pro-btn" target="_blank"> |
| 94 |
<?php esc_html_e('Upgrade to Pro', 'king-addons'); ?> |
| 95 |
</a> |
| 96 |
</div> |
| 97 |
</div> |
| 98 |
<?php endif; ?> |
| 99 |
|
| 100 |
<!-- Top Events & Users --> |
| 101 |
<div class="ka-al-dashboard-grid"> |
| 102 |
<div class="ka-al-card"> |
| 103 |
<div class="ka-al-card-header"> |
| 104 |
<h3><?php esc_html_e('Top Events (7 days)', 'king-addons'); ?></h3> |
| 105 |
</div> |
| 106 |
<div class="ka-al-card-body"> |
| 107 |
<?php if (empty($top_events)): ?> |
| 108 |
<p class="ka-al-empty"><?php esc_html_e('No events recorded yet.', 'king-addons'); ?></p> |
| 109 |
<?php else: ?> |
| 110 |
<table class="ka-al-mini-table"> |
| 111 |
<tbody> |
| 112 |
<?php foreach ($top_events as $event): ?> |
| 113 |
<tr> |
| 114 |
<td><?php echo esc_html(\King_Addons\Activity_Log_Event_Types::get_label($event->event_key)); ?> |
| 115 |
</td> |
| 116 |
<td class="ka-al-count"><?php echo esc_html(number_format_i18n($event->count)); ?></td> |
| 117 |
</tr> |
| 118 |
<?php endforeach; ?> |
| 119 |
</tbody> |
| 120 |
</table> |
| 121 |
<?php endif; ?> |
| 122 |
</div> |
| 123 |
</div> |
| 124 |
|
| 125 |
<div class="ka-al-card"> |
| 126 |
<div class="ka-al-card-header"> |
| 127 |
<h3><?php esc_html_e('Top Users (7 days)', 'king-addons'); ?></h3> |
| 128 |
</div> |
| 129 |
<div class="ka-al-card-body"> |
| 130 |
<?php if (empty($top_users)): ?> |
| 131 |
<p class="ka-al-empty"><?php esc_html_e('No user activity recorded yet.', 'king-addons'); ?></p> |
| 132 |
<?php else: ?> |
| 133 |
<table class="ka-al-mini-table"> |
| 134 |
<tbody> |
| 135 |
<?php foreach ($top_users as $user): ?> |
| 136 |
<tr> |
| 137 |
<td> |
| 138 |
<?php echo get_avatar($user->user_id, 28, '', '', ['class' => 'ka-al-avatar']); ?> |
| 139 |
<?php echo esc_html($user->user_login); ?> |
| 140 |
</td> |
| 141 |
<td class="ka-al-count"><?php echo esc_html(number_format_i18n($user->count)); ?></td> |
| 142 |
</tr> |
| 143 |
<?php endforeach; ?> |
| 144 |
</tbody> |
| 145 |
</table> |
| 146 |
<?php endif; ?> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
</div> |