Files
igny8/plugins/wordpress/source/igny8-wp-bridge/admin/pages/logs.php
2026-01-13 09:23:54 +00:00

109 lines
4.5 KiB
PHP

<?php
/**
* Logs Page
*
* @package Igny8Bridge
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
// Include layout header
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-header.php';
// Get logs
$webhook_logs = igny8_get_webhook_logs(array('limit' => 20));
?>
<div class="igny8-page-header">
<div style="display: flex; justify-content: space-between; align-items: flex-start; width: 100%;">
<div>
<h1><?php _e('Logs', 'igny8-bridge'); ?></h1>
<p><?php _e('Review webhook activity and troubleshoot sync issues', 'igny8-bridge'); ?></p>
</div>
<div style="text-align: right; font-size: 14px; color: rgba(255,255,255,0.9);">
<span style="display: block; font-weight: 500;">Plugin v<?php echo esc_html(IGNY8_BRIDGE_VERSION); ?></span>
<span style="display: block; opacity: 0.75; font-size: 13px;">PHP <?php echo esc_html(PHP_VERSION); ?></span>
</div>
</div>
</div>
<?php if (!empty($webhook_logs)): ?>
<div class="igny8-card">
<div class="igny8-card-header">
<h2>
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
<?php _e('Webhook Logs', 'igny8-bridge'); ?>
</h2>
</div>
<table class="igny8-table">
<thead>
<tr>
<th><?php _e('Timestamp', 'igny8-bridge'); ?></th>
<th><?php _e('Event', 'igny8-bridge'); ?></th>
<th><?php _e('Status', 'igny8-bridge'); ?></th>
<th><?php _e('Response Time', 'igny8-bridge'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($webhook_logs as $log): ?>
<tr>
<td>
<?php
$timestamp = isset($log['timestamp']) ? $log['timestamp'] : 0;
echo esc_html(date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $timestamp));
?>
</td>
<td>
<strong><?php echo esc_html($log['event'] ?? __('Unknown', 'igny8-bridge')); ?></strong>
</td>
<td>
<?php if (($log['status'] ?? '') === 'success'): ?>
<span class="igny8-status igny8-status-connected">✓ <?php _e('Success', 'igny8-bridge'); ?></span>
<?php else: ?>
<span class="igny8-status igny8-status-disconnected">✗ <?php _e('Failed', 'igny8-bridge'); ?></span>
<?php endif; ?>
</td>
<td>
<?php
$response_time = isset($log['response_time']) ? $log['response_time'] : 0;
echo esc_html(number_format($response_time, 2)) . 'ms';
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="igny8-alert igny8-alert-success" style="margin-top: 24px;">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<span>
<?php _e('For detailed API request/response logs, check', 'igny8-bridge'); ?>
<code>wp-content/debug.log</code>
</span>
</div>
<?php else: ?>
<div class="igny8-alert igny8-alert-warning">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<div>
<strong><?php _e('No Logs Available', 'igny8-bridge'); ?></strong>
<p><?php _e('No webhook activity has been recorded yet. Logs will appear here once IGNY8 starts sending content to your site.', 'igny8-bridge'); ?></p>
</div>
</div>
<?php endif; ?>
<?php
// Include layout footer
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-footer.php';
?>