Files
igny8/plugins/wordpress/source/igny8-wp-bridge/admin/pages/sync-old.php
2026-01-12 01:12:08 +00:00

170 lines
7.3 KiB
PHP

<?php
/**
* Sync Page
*
* @package Igny8Bridge
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
// Include layout header
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-header.php';
// Get sync settings
$connection_enabled = igny8_is_connection_enabled();
$last_site_sync = intval(get_option('igny8_last_site_sync', 0));
$last_taxonomy_sync = intval(get_option('igny8_last_taxonomy_sync', 0));
$last_keyword_sync = intval(get_option('igny8_last_keyword_sync', 0));
$last_writer_sync = intval(get_option('igny8_last_writer_sync', 0));
$next_site_sync = wp_next_scheduled('igny8_sync_site_data');
$date_format = get_option('date_format');
$time_format = get_option('time_format');
$last_site_sync_formatted = $last_site_sync ? date_i18n($date_format . ' ' . $time_format, $last_site_sync) : __('Never', 'igny8-bridge');
$last_taxonomy_sync_formatted = $last_taxonomy_sync ? date_i18n($date_format . ' ' . $time_format, $last_taxonomy_sync) : __('Never', 'igny8-bridge');
$last_keyword_sync_formatted = $last_keyword_sync ? date_i18n($date_format . ' ' . $time_format, $last_keyword_sync) : __('Never', 'igny8-bridge');
$last_writer_sync_formatted = $last_writer_sync ? date_i18n($date_format . ' ' . $time_format, $last_writer_sync) : __('Never', 'igny8-bridge');
$next_site_sync_formatted = $next_site_sync ? date_i18n($date_format . ' ' . $time_format, $next_site_sync) : __('Not scheduled', 'igny8-bridge');
?>
<div class="igny8-page-header">
<h1><?php _e('Sync', 'igny8-bridge'); ?></h1>
<p><?php _e('Configure automatic sync and monitor synchronization status', 'igny8-bridge'); ?></p>
</div>
<form method="post" action="options.php">
<?php settings_fields('igny8_bridge_connection'); ?>
<!-- Connection Enable/Disable -->
<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="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"/>
</svg>
<?php _e('Sync Status', 'igny8-bridge'); ?>
</h2>
</div>
<label style="display: flex; align-items: center; cursor: pointer; padding: 16px; background: var(--igny8-surface); border-radius: var(--igny8-radius-base);">
<input
type="checkbox"
name="igny8_connection_enabled"
value="1"
<?php checked($connection_enabled, 1); ?>
style="margin-right: 12px;"
/>
<div>
<strong style="font-size: 16px; display: block; margin-bottom: 4px;">
<?php _e('Enable IGNY8 Sync', 'igny8-bridge'); ?>
</strong>
<span style="color: var(--igny8-text-dim); font-size: 14px;">
<?php _e('Allow IGNY8 to sync content to this WordPress site. Disable this to pause syncing temporarily.', 'igny8-bridge'); ?>
</span>
</div>
</label>
</div>
<button type="submit" class="igny8-btn igny8-btn-primary">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
<?php _e('Save Sync Settings', 'igny8-bridge'); ?>
</button>
</form>
<!-- Sync History -->
<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('Sync History', 'igny8-bridge'); ?>
</h2>
</div>
<table class="igny8-table">
<thead>
<tr>
<th><?php _e('Sync Type', 'igny8-bridge'); ?></th>
<th><?php _e('Last Sync', 'igny8-bridge'); ?></th>
<th><?php _e('Status', 'igny8-bridge'); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><?php _e('Site Data', 'igny8-bridge'); ?></strong></td>
<td><?php echo esc_html($last_site_sync_formatted); ?></td>
<td>
<?php if ($last_site_sync): ?>
<span class="igny8-status igny8-status-connected">✓ <?php _e('Synced', 'igny8-bridge'); ?></span>
<?php else: ?>
<span class="igny8-status igny8-status-disconnected">— <?php _e('Never', 'igny8-bridge'); ?></span>
<?php endif; ?>
</td>
</tr>
<tr>
<td><strong><?php _e('Taxonomies', 'igny8-bridge'); ?></strong></td>
<td><?php echo esc_html($last_taxonomy_sync_formatted); ?></td>
<td>
<?php if ($last_taxonomy_sync): ?>
<span class="igny8-status igny8-status-connected">✓ <?php _e('Synced', 'igny8-bridge'); ?></span>
<?php else: ?>
<span class="igny8-status igny8-status-disconnected">— <?php _e('Never', 'igny8-bridge'); ?></span>
<?php endif; ?>
</td>
</tr>
<tr>
<td><strong><?php _e('Keywords', 'igny8-bridge'); ?></strong></td>
<td><?php echo esc_html($last_keyword_sync_formatted); ?></td>
<td>
<?php if ($last_keyword_sync): ?>
<span class="igny8-status igny8-status-connected">✓ <?php _e('Synced', 'igny8-bridge'); ?></span>
<?php else: ?>
<span class="igny8-status igny8-status-disconnected">— <?php _e('Never', 'igny8-bridge'); ?></span>
<?php endif; ?>
</td>
</tr>
<tr>
<td><strong><?php _e('Writers', 'igny8-bridge'); ?></strong></td>
<td><?php echo esc_html($last_writer_sync_formatted); ?></td>
<td>
<?php if ($last_writer_sync): ?>
<span class="igny8-status igny8-status-connected">✓ <?php _e('Synced', 'igny8-bridge'); ?></span>
<?php else: ?>
<span class="igny8-status igny8-status-disconnected">— <?php _e('Never', 'igny8-bridge'); ?></span>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Next Scheduled Sync -->
<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="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
<?php _e('Scheduled Syncs', 'igny8-bridge'); ?>
</h2>
</div>
<div class="igny8-form-group">
<label><?php _e('Next Site Data Sync', 'igny8-bridge'); ?></label>
<p style="margin: 0; font-size: 15px; font-weight: 600;">
<?php echo esc_html($next_site_sync_formatted); ?>
</p>
</div>
</div>
<?php
// Include layout footer
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-footer.php';
?>