277 lines
13 KiB
PHP
277 lines
13 KiB
PHP
<?php
|
|
/**
|
|
* Controls Page
|
|
*
|
|
* @package Igny8Bridge
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
// Include layout header
|
|
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-header.php';
|
|
|
|
// Get settings
|
|
$available_post_types = igny8_get_supported_post_types();
|
|
$enabled_post_types = igny8_get_enabled_post_types();
|
|
$available_taxonomies = igny8_get_supported_taxonomies();
|
|
$enabled_taxonomies = igny8_get_enabled_taxonomies();
|
|
$control_mode = igny8_get_control_mode();
|
|
$woocommerce_enabled = (int) get_option('igny8_enable_woocommerce', class_exists('WooCommerce') ? 1 : 0);
|
|
$woocommerce_detected = class_exists('WooCommerce');
|
|
$available_modules = igny8_get_available_modules();
|
|
$enabled_modules = igny8_get_enabled_modules();
|
|
$default_post_status = get_option('igny8_default_post_status', 'draft');
|
|
?>
|
|
|
|
<div class="igny8-page-header">
|
|
<h1><?php _e('Controls', 'igny8-bridge'); ?></h1>
|
|
<p><?php _e('Configure which content types to sync and how IGNY8 manages your content', 'igny8-bridge'); ?></p>
|
|
</div>
|
|
|
|
<form method="post" action="options.php">
|
|
<?php settings_fields('igny8_bridge_controls'); ?>
|
|
|
|
<div class="igny8-grid igny8-grid-2">
|
|
<!-- Post Types -->
|
|
<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('Post Types to Sync', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<?php foreach ($available_post_types as $slug => $label) : ?>
|
|
<div class="igny8-form-group" style="margin-bottom: 12px;">
|
|
<label style="display: flex; align-items: center; cursor: pointer;">
|
|
<input
|
|
type="checkbox"
|
|
name="igny8_enabled_post_types[]"
|
|
value="<?php echo esc_attr($slug); ?>"
|
|
<?php checked(in_array($slug, $enabled_post_types, true)); ?>
|
|
style="margin-right: 8px;"
|
|
/>
|
|
<?php echo esc_html($label); ?>
|
|
</label>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<p class="igny8-form-help">
|
|
<?php _e('Select the content types IGNY8 should manage automatically.', 'igny8-bridge'); ?>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Taxonomies -->
|
|
<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="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/>
|
|
</svg>
|
|
<?php _e('Taxonomies to Sync', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<?php foreach ($available_taxonomies as $slug => $label) : ?>
|
|
<div class="igny8-form-group" style="margin-bottom: 12px;">
|
|
<label style="display: flex; align-items: center; cursor: pointer;">
|
|
<input
|
|
type="checkbox"
|
|
name="igny8_enabled_taxonomies[]"
|
|
value="<?php echo esc_attr($slug); ?>"
|
|
<?php checked(in_array($slug, $enabled_taxonomies, true)); ?>
|
|
style="margin-right: 8px;"
|
|
/>
|
|
<?php echo esc_html($label); ?>
|
|
</label>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<p class="igny8-form-help">
|
|
<?php _e('Select which taxonomies to sync with IGNY8.', 'igny8-bridge'); ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Control Mode -->
|
|
<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 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/>
|
|
</svg>
|
|
<?php _e('Control Mode', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<div style="display: grid; gap: 16px;">
|
|
<label style="display: flex; align-items: flex-start; cursor: pointer; padding: 16px; border: 2px solid var(--igny8-stroke); border-radius: var(--igny8-radius-base); transition: all 0.2s;"
|
|
class="<?php echo $control_mode === 'mirror' ? 'igny8-control-mode-selected' : ''; ?>">
|
|
<input
|
|
type="radio"
|
|
name="igny8_control_mode"
|
|
value="mirror"
|
|
<?php checked($control_mode, 'mirror'); ?>
|
|
style="margin-right: 12px; margin-top: 4px;"
|
|
/>
|
|
<div>
|
|
<strong style="font-size: 16px; display: block; margin-bottom: 4px;">
|
|
<?php _e('Mirror Mode', 'igny8-bridge'); ?>
|
|
</strong>
|
|
<span style="color: var(--igny8-text-dim); font-size: 14px;">
|
|
<?php _e('IGNY8 is the source of truth; WordPress reflects changes only. Content is read-only in WordPress.', 'igny8-bridge'); ?>
|
|
</span>
|
|
</div>
|
|
</label>
|
|
|
|
<label style="display: flex; align-items: flex-start; cursor: pointer; padding: 16px; border: 2px solid var(--igny8-stroke); border-radius: var(--igny8-radius-base); transition: all 0.2s;"
|
|
class="<?php echo $control_mode === 'hybrid' ? 'igny8-control-mode-selected' : ''; ?>">
|
|
<input
|
|
type="radio"
|
|
name="igny8_control_mode"
|
|
value="hybrid"
|
|
<?php checked($control_mode, 'hybrid'); ?>
|
|
style="margin-right: 12px; margin-top: 4px;"
|
|
/>
|
|
<div>
|
|
<strong style="font-size: 16px; display: block; margin-bottom: 4px;">
|
|
<?php _e('Hybrid Mode', 'igny8-bridge'); ?>
|
|
</strong>
|
|
<span style="color: var(--igny8-text-dim); font-size: 14px;">
|
|
<?php _e('Allow editors to update content in WordPress and sync changes back to IGNY8. Two-way synchronization.', 'igny8-bridge'); ?>
|
|
</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="igny8-grid igny8-grid-2">
|
|
<!-- Modules -->
|
|
<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="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/>
|
|
</svg>
|
|
<?php _e('IGNY8 Modules', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<?php foreach ($available_modules as $module_key => $module_label) : ?>
|
|
<div class="igny8-form-group" style="margin-bottom: 12px;">
|
|
<label style="display: flex; align-items: center; cursor: pointer;">
|
|
<input
|
|
type="checkbox"
|
|
name="igny8_enabled_modules[]"
|
|
value="<?php echo esc_attr($module_key); ?>"
|
|
<?php checked(in_array($module_key, $enabled_modules, true)); ?>
|
|
style="margin-right: 8px;"
|
|
/>
|
|
<?php echo esc_html($module_label); ?>
|
|
</label>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<p class="igny8-form-help">
|
|
<?php _e('Disable modules temporarily if a feature is not ready in the SaaS app.', 'igny8-bridge'); ?>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Default Post Status -->
|
|
<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('Default Post Status', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<div style="display: grid; gap: 12px; margin-bottom: 16px;">
|
|
<label style="display: flex; align-items: flex-start; cursor: pointer;">
|
|
<input
|
|
type="radio"
|
|
name="igny8_default_post_status"
|
|
value="draft"
|
|
<?php checked($default_post_status, 'draft'); ?>
|
|
style="margin-right: 8px; margin-top: 4px;"
|
|
/>
|
|
<div>
|
|
<strong><?php _e('Draft', 'igny8-bridge'); ?></strong>
|
|
<span style="display: block; color: var(--igny8-text-dim); font-size: 13px;">
|
|
<?php _e('Save content as draft for review before publishing.', 'igny8-bridge'); ?>
|
|
</span>
|
|
</div>
|
|
</label>
|
|
|
|
<label style="display: flex; align-items: flex-start; cursor: pointer;">
|
|
<input
|
|
type="radio"
|
|
name="igny8_default_post_status"
|
|
value="publish"
|
|
<?php checked($default_post_status, 'publish'); ?>
|
|
style="margin-right: 8px; margin-top: 4px;"
|
|
/>
|
|
<div>
|
|
<strong><?php _e('Publish', 'igny8-bridge'); ?></strong>
|
|
<span style="display: block; color: var(--igny8-text-dim); font-size: 13px;">
|
|
<?php _e('Publish content immediately when received from IGNY8.', 'igny8-bridge'); ?>
|
|
</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
|
|
<p class="igny8-form-help">
|
|
<?php _e('Choose whether content published from IGNY8 should be saved as draft or published immediately in WordPress.', 'igny8-bridge'); ?>
|
|
</p>
|
|
|
|
<?php if ($woocommerce_detected): ?>
|
|
<div style="margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--igny8-stroke);">
|
|
<label style="display: flex; align-items: center; cursor: pointer;">
|
|
<input
|
|
type="checkbox"
|
|
name="igny8_enable_woocommerce"
|
|
value="1"
|
|
<?php checked($woocommerce_enabled, 1); ?>
|
|
style="margin-right: 8px;"
|
|
/>
|
|
<strong><?php _e('Sync WooCommerce products and categories', 'igny8-bridge'); ?></strong>
|
|
</label>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="igny8-alert igny8-alert-warning" style="margin-top: 20px;">
|
|
<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('WooCommerce is not installed. Install WooCommerce to sync products.', 'igny8-bridge'); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</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 Controls', 'igny8-bridge'); ?>
|
|
</button>
|
|
</form>
|
|
|
|
<style>
|
|
.igny8-control-mode-selected {
|
|
border-color: var(--igny8-primary) !important;
|
|
background: var(--igny8-primary-subtle) !important;
|
|
}
|
|
</style>
|
|
|
|
<?php
|
|
// Include layout footer
|
|
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-footer.php';
|
|
?>
|