Files
igny8/plugins/wordpress/source/igny8-wp-bridge/admin/pages/data.php
2026-01-10 00:26:00 +00:00

149 lines
5.9 KiB
PHP

<?php
/**
* Data Page
*
* @package Igny8Bridge
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
// Include layout header
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-header.php';
// Get data statistics
$link_queue = get_option('igny8_link_queue', array());
$pending_links = array_filter($link_queue, function($item) {
return isset($item['status']) && $item['status'] === 'pending';
});
$total_links = count($link_queue);
$pending_count = count($pending_links);
$processed_count = $total_links - $pending_count;
?>
<div class="igny8-page-header">
<h1><?php _e('Data', 'igny8-bridge'); ?></h1>
<p><?php _e('View synced data, queues, and content status', 'igny8-bridge'); ?></p>
</div>
<!-- Statistics -->
<div class="igny8-grid igny8-grid-3">
<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="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/>
</svg>
<?php _e('Total Links', 'igny8-bridge'); ?>
</h2>
</div>
<div style="padding: 16px 0;">
<p style="font-size: 32px; font-weight: 700; margin: 0; color: var(--igny8-primary);">
<?php echo esc_html($total_links); ?>
</p>
</div>
</div>
<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="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<?php _e('Pending', 'igny8-bridge'); ?>
</h2>
</div>
<div style="padding: 16px 0;">
<p style="font-size: 32px; font-weight: 700; margin: 0; color: var(--igny8-warning);">
<?php echo esc_html($pending_count); ?>
</p>
</div>
</div>
<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 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<?php _e('Processed', 'igny8-bridge'); ?>
</h2>
</div>
<div style="padding: 16px 0;">
<p style="font-size: 32px; font-weight: 700; margin: 0; color: var(--igny8-success);">
<?php echo esc_html($processed_count); ?>
</p>
</div>
</div>
</div>
<!-- Link Queue -->
<?php if (!empty($link_queue)): ?>
<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="M4 6h16M4 10h16M4 14h16M4 18h16"/>
</svg>
<?php _e('Link Queue', 'igny8-bridge'); ?>
</h2>
</div>
<table class="igny8-table">
<thead>
<tr>
<th><?php _e('Post Title', 'igny8-bridge'); ?></th>
<th><?php _e('Target URL', 'igny8-bridge'); ?></th>
<th><?php _e('Anchor', 'igny8-bridge'); ?></th>
<th><?php _e('Status', 'igny8-bridge'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach (array_slice($link_queue, 0, 10) as $item): ?>
<tr>
<td>
<?php
$post = get_post($item['post_id'] ?? 0);
echo $post ? esc_html($post->post_title) : __('Unknown Post', 'igny8-bridge');
?>
</td>
<td>
<a href="<?php echo esc_url($item['target_url'] ?? '#'); ?>" target="_blank" style="color: var(--igny8-primary);">
<?php echo esc_html(isset($item['target_url']) ? parse_url($item['target_url'], PHP_URL_HOST) : '—'); ?>
</a>
</td>
<td><?php echo esc_html($item['anchor'] ?? '—'); ?></td>
<td>
<?php if (($item['status'] ?? '') === 'pending'): ?>
<span class="igny8-status igny8-status-disconnected"><?php _e('Pending', 'igny8-bridge'); ?></span>
<?php else: ?>
<span class="igny8-status igny8-status-connected"><?php _e('Processed', 'igny8-bridge'); ?></span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (count($link_queue) > 10): ?>
<p style="margin-top: 16px; color: var(--igny8-text-dim); font-size: 14px;">
<?php printf(__('Showing 10 of %d total items', 'igny8-bridge'), count($link_queue)); ?>
</p>
<?php endif; ?>
</div>
<?php else: ?>
<div class="igny8-alert igny8-alert-success">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<span><?php _e('No items in link queue. All links have been processed.', 'igny8-bridge'); ?></span>
</div>
<?php endif; ?>
<?php
// Include layout footer
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-footer.php';
?>