288 lines
15 KiB
PHP
288 lines
15 KiB
PHP
<?php
|
|
/**
|
|
* Dashboard Page (formerly Connection)
|
|
* Main plugin dashboard with connection status and content stats
|
|
*
|
|
* @package Igny8Bridge
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
// Include layout header
|
|
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-header.php';
|
|
|
|
// Get connection settings
|
|
$api_key = function_exists('igny8_get_secure_option') ? igny8_get_secure_option('igny8_api_key') : get_option('igny8_api_key');
|
|
$site_id = get_option('igny8_site_id', '');
|
|
$is_connected = !empty($api_key);
|
|
|
|
// Get content stats (from sync page)
|
|
global $wpdb;
|
|
$igny8_content_count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key = '_igny8_content_id'");
|
|
$igny8_content_count = $igny8_content_count ?: 0;
|
|
|
|
// Get IGNY8 taxonomy term counts
|
|
$clusters_count = 0;
|
|
$sectors_count = 0;
|
|
if (taxonomy_exists('igny8_clusters')) {
|
|
$clusters_count = wp_count_terms(array('taxonomy' => 'igny8_clusters', 'hide_empty' => false));
|
|
if (is_wp_error($clusters_count)) $clusters_count = 0;
|
|
}
|
|
if (taxonomy_exists('igny8_sectors')) {
|
|
$sectors_count = wp_count_terms(array('taxonomy' => 'igny8_sectors', 'hide_empty' => false));
|
|
if (is_wp_error($sectors_count)) $sectors_count = 0;
|
|
}
|
|
|
|
// Check for one-time success notification
|
|
$show_success = isset($_GET['connected']) && $_GET['connected'] === '1';
|
|
?>
|
|
|
|
<div class="igny8-page-header">
|
|
<div style="display: flex; justify-content: space-between; align-items: flex-start;">
|
|
<div>
|
|
<h1><?php _e('Dashboard', 'igny8-bridge'); ?></h1>
|
|
<p><?php _e('Manage your IGNY8 connection and monitor content', '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 (!$is_connected): ?>
|
|
<!-- Not Connected - Show Connection Form -->
|
|
<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('Connect to IGNY8', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<div class="igny8-status igny8-status-disconnected" style="margin-bottom: 24px;">
|
|
<span class="igny8-status-indicator"></span>
|
|
<?php _e('Not Connected', 'igny8-bridge'); ?>
|
|
</div>
|
|
|
|
<form method="post" action="">
|
|
<?php wp_nonce_field('igny8_settings_nonce'); ?>
|
|
|
|
<div class="igny8-form-group">
|
|
<label for="igny8_api_key">
|
|
<?php _e('API Key', 'igny8-bridge'); ?>
|
|
<span style="color: var(--igny8-danger);">*</span>
|
|
</label>
|
|
<input
|
|
type="text"
|
|
id="igny8_api_key"
|
|
name="igny8_api_key"
|
|
value=""
|
|
placeholder="<?php _e('igny8_site_5_1764575388582_u671q2e2mv', 'igny8-bridge'); ?>"
|
|
required
|
|
/>
|
|
<p class="igny8-form-help">
|
|
<?php printf(
|
|
__('Get your API key from the <a href="%s" target="_blank">IGNY8 app integrations page</a>. The API key format includes your site ID.', 'igny8-bridge'),
|
|
'https://app.igny8.com'
|
|
); ?>
|
|
</p>
|
|
</div>
|
|
|
|
<button type="submit" name="igny8_connect" 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="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('Connect to IGNY8', 'igny8-bridge'); ?>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- How to Connect Card -->
|
|
<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 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
</svg>
|
|
<?php _e('How to Connect', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
<ol style="padding-left: 20px; line-height: 1.8; font-size: 14px;">
|
|
<li><?php _e('Log in to your IGNY8 account', 'igny8-bridge'); ?></li>
|
|
<li><?php _e('Navigate to Settings → Integrations', 'igny8-bridge'); ?></li>
|
|
<li><?php _e('Find WordPress in the integrations list', 'igny8-bridge'); ?></li>
|
|
<li><?php _e('Click "Add Site" to generate a new API key', 'igny8-bridge'); ?></li>
|
|
<li><?php _e('Copy the API key and paste it above', 'igny8-bridge'); ?></li>
|
|
<li><?php _e('Click "Connect to IGNY8"', 'igny8-bridge'); ?></li>
|
|
</ol>
|
|
</div>
|
|
|
|
<?php else: ?>
|
|
<!-- Connected State -->
|
|
|
|
<?php if ($show_success): ?>
|
|
<!-- One-time Success Notification -->
|
|
<div class="igny8-alert igny8-alert-success" style="margin-bottom: 24px;">
|
|
<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>
|
|
<div>
|
|
<strong><?php _e('Connected Successfully', 'igny8-bridge'); ?></strong>
|
|
<p><?php _e('Your WordPress site is ready to publish content from IGNY8.', 'igny8-bridge'); ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Main Dashboard Grid -->
|
|
<div class="igny8-grid igny8-grid-2">
|
|
<!-- Connection Status Card (Left Half) -->
|
|
<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('Connection Status', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<div class="igny8-status igny8-status-connected" style="margin-bottom: 20px;">
|
|
<span class="igny8-status-indicator"></span>
|
|
<?php _e('Connected & Active', 'igny8-bridge'); ?>
|
|
</div>
|
|
|
|
<!-- Site ID -->
|
|
<div class="igny8-form-group" style="margin-bottom: 16px;">
|
|
<label style="font-size: 13px; color: var(--igny8-text-dim);"><?php _e('Site ID', 'igny8-bridge'); ?></label>
|
|
<code style="display: block; padding: 8px 12px; background: var(--igny8-surface); border-radius: var(--igny8-radius-base); font-size: 14px;">
|
|
<?php echo esc_html($site_id ?: __('Not set', 'igny8-bridge')); ?>
|
|
</code>
|
|
</div>
|
|
|
|
<!-- API Key (Masked) -->
|
|
<div class="igny8-form-group" style="margin-bottom: 20px;">
|
|
<label style="font-size: 13px; color: var(--igny8-text-dim);"><?php _e('API Key', 'igny8-bridge'); ?></label>
|
|
<div style="padding: 8px 12px; background: var(--igny8-surface); border: 1px solid var(--igny8-stroke); border-radius: var(--igny8-radius-base); font-family: monospace; font-size: 13px;">
|
|
<?php echo esc_html(substr($api_key, 0, 7) . '••••••••••' . substr($api_key, -6)); ?>
|
|
<span style="color: var(--igny8-success); font-weight: 600; margin-left: 8px;">✓ Verified</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Disconnect Section -->
|
|
<div style="padding-top: 16px; border-top: 1px solid var(--igny8-stroke);">
|
|
<form method="post" action="" style="display: flex; align-items: center; gap: 12px;">
|
|
<?php wp_nonce_field('igny8_revoke_api_key'); ?>
|
|
<button type="submit" name="igny8_revoke_api_key" class="igny8-btn igny8-btn-danger igny8-btn-sm"
|
|
onclick="return confirm('<?php _e('Are you sure you want to disconnect? This will stop all syncing with IGNY8.', 'igny8-bridge'); ?>');">
|
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 16px; height: 16px;">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
|
|
</svg>
|
|
<?php _e('Disconnect', 'igny8-bridge'); ?>
|
|
</button>
|
|
<span style="font-size: 12px; color: var(--igny8-text-dim);">
|
|
<?php _e('Your content will remain, but no new updates will sync.', 'igny8-bridge'); ?>
|
|
</span>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Content Stats Card (Right Half) -->
|
|
<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 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"/>
|
|
</svg>
|
|
<?php _e('Content Stats', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<!-- Vertically Stacked Stats -->
|
|
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
<div style="padding: 16px; background: var(--igny8-surface); border-radius: var(--igny8-radius-base); display: flex; justify-content: space-between; align-items: center;">
|
|
<span style="font-size: 14px; color: var(--igny8-text);"><?php _e('Published Posts', 'igny8-bridge'); ?></span>
|
|
<span style="font-size: 24px; font-weight: 700; color: var(--igny8-primary);"><?php echo esc_html($igny8_content_count); ?></span>
|
|
</div>
|
|
<div style="padding: 16px; background: var(--igny8-surface); border-radius: var(--igny8-radius-base); display: flex; justify-content: space-between; align-items: center;">
|
|
<span style="font-size: 14px; color: var(--igny8-text);"><?php _e('IGNY8 Clusters', 'igny8-bridge'); ?></span>
|
|
<span style="font-size: 24px; font-weight: 700; color: var(--igny8-primary);"><?php echo esc_html($clusters_count); ?></span>
|
|
</div>
|
|
<div style="padding: 16px; background: var(--igny8-surface); border-radius: var(--igny8-radius-base); display: flex; justify-content: space-between; align-items: center;">
|
|
<span style="font-size: 14px; color: var(--igny8-text);"><?php _e('IGNY8 Sectors', 'igny8-bridge'); ?></span>
|
|
<span style="font-size: 24px; font-weight: 700; color: var(--igny8-primary);"><?php echo esc_html($sectors_count); ?></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quick Actions Row -->
|
|
<div class="igny8-grid igny8-grid-3" style="margin-top: 24px;">
|
|
<!-- How to Publish Card -->
|
|
<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 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
</svg>
|
|
<?php _e('Publishing Content', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
<ol style="padding-left: 20px; line-height: 1.8; font-size: 14px; margin: 0;">
|
|
<li><?php _e('Create content in IGNY8 app', 'igny8-bridge'); ?></li>
|
|
<li><?php _e('Review and approve content', 'igny8-bridge'); ?></li>
|
|
<li><?php _e('Click "Publish to WordPress"', 'igny8-bridge'); ?></li>
|
|
<li><?php _e('Content appears on your site', 'igny8-bridge'); ?></li>
|
|
</ol>
|
|
</div>
|
|
|
|
<!-- Settings Card -->
|
|
<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="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
|
|
</svg>
|
|
<?php _e('Settings', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
<p style="font-size: 14px; color: var(--igny8-text-dim); margin-bottom: 16px;">
|
|
<?php _e('Configure post types and taxonomies', 'igny8-bridge'); ?>
|
|
</p>
|
|
<a href="<?php echo esc_url(admin_url('admin.php?page=igny8-settings')); ?>" class="igny8-btn igny8-btn-secondary">
|
|
<?php _e('Configure Settings', 'igny8-bridge'); ?>
|
|
</a>
|
|
</div>
|
|
|
|
<!-- View Logs Card -->
|
|
<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('View Logs', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
<p style="font-size: 14px; color: var(--igny8-text-dim); margin-bottom: 16px;">
|
|
<?php _e('Review sync history and troubleshoot', 'igny8-bridge'); ?>
|
|
</p>
|
|
<a href="<?php echo esc_url(admin_url('admin.php?page=igny8-logs')); ?>" class="igny8-btn igny8-btn-secondary">
|
|
<?php _e('View Logs', 'igny8-bridge'); ?>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
// Include layout footer
|
|
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-footer.php';
|
|
?>
|