294 lines
14 KiB
PHP
294 lines
14 KiB
PHP
<?php
|
|
/**
|
|
* Settings Page
|
|
* Configure post types, taxonomies, and sync settings
|
|
*
|
|
* @package Igny8Bridge
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
// Include layout header
|
|
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-header.php';
|
|
|
|
// Get all registered public post types
|
|
$all_post_types = get_post_types(array('public' => true), 'objects');
|
|
$excluded_post_types = array('attachment', 'revision', 'nav_menu_item', 'wp_block', 'wp_template', 'wp_template_part', 'wp_navigation');
|
|
$enabled_post_types = igny8_get_enabled_post_types();
|
|
$default_post_status = get_option('igny8_default_post_status', 'draft');
|
|
$sync_enabled = get_option('igny8_sync_enabled', 1);
|
|
|
|
// Get enabled taxonomies
|
|
$enabled_taxonomies = igny8_get_enabled_taxonomies();
|
|
|
|
// Filter out system post types
|
|
$public_post_types = array();
|
|
foreach ($all_post_types as $pt) {
|
|
if (!in_array($pt->name, $excluded_post_types, true)) {
|
|
$public_post_types[$pt->name] = $pt;
|
|
}
|
|
}
|
|
?>
|
|
|
|
<div class="igny8-page-header">
|
|
<div style="display: flex; justify-content: space-between; align-items: flex-start; width: 100%;">
|
|
<div>
|
|
<h1><?php _e('Settings', 'igny8-bridge'); ?></h1>
|
|
<p><?php _e('Configure post types, taxonomies, and sync settings', '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>
|
|
|
|
<form method="post" action="options.php" id="igny8-settings-form">
|
|
<?php settings_fields('igny8_bridge_controls'); ?>
|
|
|
|
<!-- Top Row: Post Types (1/3) + Default Settings (1/3) + IGNY8 Sync (1/3) -->
|
|
<div class="igny8-grid igny8-grid-3" style="margin-bottom: 24px;">
|
|
|
|
<!-- Post Types Card (1/3) -->
|
|
<div class="igny8-card">
|
|
<div class="igny8-card-header">
|
|
<h2>
|
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 20px; height: 20px;">
|
|
<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', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
<p style="margin-bottom: 16px; color: var(--igny8-text-dim); font-size: 13px;">
|
|
<?php _e('Enable post types to sync with IGNY8.', 'igny8-bridge'); ?>
|
|
</p>
|
|
|
|
<div style="display: grid; gap: 8px;">
|
|
<?php foreach ($public_post_types as $slug => $pt) :
|
|
$is_posts = ($slug === 'post');
|
|
$is_enabled = in_array($slug, $enabled_post_types, true);
|
|
?>
|
|
<label class="igny8-post-type-toggle" style="display: flex; align-items: center; cursor: pointer; padding: 10px 12px; border: 1px solid var(--igny8-stroke); border-radius: var(--igny8-radius-sm); background: var(--igny8-surface);">
|
|
<input
|
|
type="checkbox"
|
|
name="igny8_enabled_post_types[]"
|
|
value="<?php echo esc_attr($slug); ?>"
|
|
class="igny8-post-type-checkbox"
|
|
data-post-type="<?php echo esc_attr($slug); ?>"
|
|
<?php checked($is_enabled); ?>
|
|
style="margin-right: 10px;"
|
|
/>
|
|
<span style="flex: 1; font-weight: 500; font-size: 14px;">
|
|
<?php echo esc_html($pt->label); ?>
|
|
</span>
|
|
<?php if (!$is_posts) : ?>
|
|
<span class="igny8-badge igny8-badge-warning">
|
|
<?php _e('Coming Soon', 'igny8-bridge'); ?>
|
|
</span>
|
|
<?php else: ?>
|
|
<span style="color: var(--igny8-text-dim); font-size: 12px;"><?php echo esc_html($slug); ?></span>
|
|
<?php endif; ?>
|
|
</label>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Default Post Status Card (1/3) -->
|
|
<div class="igny8-card">
|
|
<div class="igny8-card-header">
|
|
<h2>
|
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 20px; height: 20px;">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
|
|
</svg>
|
|
<?php _e('Default Post Status', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
<p style="margin-bottom: 16px; color: var(--igny8-text-dim); font-size: 13px;">
|
|
<?php _e('Set default status for published content.', 'igny8-bridge'); ?>
|
|
</p>
|
|
|
|
<div style="display: grid; gap: 8px;">
|
|
<label style="display: flex; align-items: center; cursor: pointer; padding: 12px; border: 1px solid var(--igny8-stroke); border-radius: var(--igny8-radius-sm); <?php echo $default_post_status === 'draft' ? 'background: var(--igny8-primary-subtle); border-color: var(--igny8-primary);' : ''; ?>">
|
|
<input
|
|
type="radio"
|
|
name="igny8_default_post_status"
|
|
value="draft"
|
|
<?php checked($default_post_status, 'draft'); ?>
|
|
style="margin-right: 10px;"
|
|
/>
|
|
<div>
|
|
<strong style="font-size: 14px;"><?php _e('Draft', 'igny8-bridge'); ?></strong>
|
|
<span style="display: block; font-size: 12px; color: var(--igny8-text-dim);">
|
|
<?php _e('Review before publishing', 'igny8-bridge'); ?>
|
|
</span>
|
|
</div>
|
|
</label>
|
|
<label style="display: flex; align-items: center; cursor: pointer; padding: 12px; border: 1px solid var(--igny8-stroke); border-radius: var(--igny8-radius-sm); <?php echo $default_post_status === 'publish' ? 'background: var(--igny8-primary-subtle); border-color: var(--igny8-primary);' : ''; ?>">
|
|
<input
|
|
type="radio"
|
|
name="igny8_default_post_status"
|
|
value="publish"
|
|
<?php checked($default_post_status, 'publish'); ?>
|
|
style="margin-right: 10px;"
|
|
/>
|
|
<div>
|
|
<strong style="font-size: 14px;"><?php _e('Publish', 'igny8-bridge'); ?></strong>
|
|
<span style="display: block; font-size: 12px; color: var(--igny8-text-dim);">
|
|
<?php _e('Publish immediately', 'igny8-bridge'); ?>
|
|
</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- IGNY8 Sync Card (1/3) -->
|
|
<div class="igny8-card">
|
|
<div class="igny8-card-header">
|
|
<h2>
|
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 20px; height: 20px;">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
|
|
</svg>
|
|
<?php _e('IGNY8 Sync', 'igny8-bridge'); ?>
|
|
</h2>
|
|
</div>
|
|
<p style="margin-bottom: 16px; color: var(--igny8-text-dim); font-size: 13px;">
|
|
<?php _e('Control content publishing from IGNY8.', 'igny8-bridge'); ?>
|
|
</p>
|
|
|
|
<label style="display: flex; align-items: flex-start; cursor: pointer; padding: 14px; border: 1px solid var(--igny8-stroke); border-radius: var(--igny8-radius-sm); background: var(--igny8-surface);">
|
|
<input
|
|
type="checkbox"
|
|
name="igny8_sync_enabled"
|
|
value="1"
|
|
<?php checked($sync_enabled, 1); ?>
|
|
style="margin-right: 12px; margin-top: 2px; width: 18px; height: 18px;"
|
|
/>
|
|
<div>
|
|
<strong style="font-size: 14px; display: block;"><?php _e('Enable IGNY8 Sync', 'igny8-bridge'); ?></strong>
|
|
<span style="display: block; font-size: 12px; color: var(--igny8-text-dim); margin-top: 4px;">
|
|
<?php _e('Allow IGNY8 to publish content to this site', 'igny8-bridge'); ?>
|
|
</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Post Type Taxonomy Cards (dynamic, shown only for enabled post types) -->
|
|
<?php foreach ($public_post_types as $slug => $pt) :
|
|
$is_posts = ($slug === 'post');
|
|
$is_enabled = in_array($slug, $enabled_post_types, true);
|
|
$taxonomies = get_object_taxonomies($slug, 'objects');
|
|
|
|
// Filter out system taxonomies
|
|
$public_taxonomies = array();
|
|
foreach ($taxonomies as $tax) {
|
|
if ($tax->public && !in_array($tax->name, array('post_format', 'wp_theme'), true)) {
|
|
$public_taxonomies[$tax->name] = $tax;
|
|
}
|
|
}
|
|
|
|
// Skip if no public taxonomies
|
|
if (empty($public_taxonomies)) continue;
|
|
|
|
// Add IGNY8 taxonomies if they exist
|
|
if (taxonomy_exists('igny8_sectors')) {
|
|
$public_taxonomies['igny8_sectors'] = get_taxonomy('igny8_sectors');
|
|
}
|
|
if (taxonomy_exists('igny8_clusters')) {
|
|
$public_taxonomies['igny8_clusters'] = get_taxonomy('igny8_clusters');
|
|
}
|
|
?>
|
|
<div class="igny8-card igny8-taxonomy-card" data-post-type="<?php echo esc_attr($slug); ?>" style="margin-bottom: 24px; <?php echo $is_enabled ? '' : 'display: none;'; ?>">
|
|
<div class="igny8-card-header" style="display: flex; align-items: center; justify-content: space-between;">
|
|
<h2 style="display: flex; align-items: center; gap: 8px;">
|
|
<?php if ($slug === 'post') : ?>
|
|
<span style="font-size: 20px;">📝</span>
|
|
<?php elseif ($slug === 'product') : ?>
|
|
<span style="font-size: 20px;">📦</span>
|
|
<?php elseif ($slug === 'page') : ?>
|
|
<span style="font-size: 20px;">📄</span>
|
|
<?php else : ?>
|
|
<span style="font-size: 20px;">📁</span>
|
|
<?php endif; ?>
|
|
<?php echo esc_html(strtoupper($pt->label)); ?> <?php _e('Taxonomies', 'igny8-bridge'); ?>
|
|
</h2>
|
|
<?php if (!$is_posts) : ?>
|
|
<span class="igny8-badge igny8-badge-warning">
|
|
<?php _e('Coming Soon', 'igny8-bridge'); ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px;">
|
|
<?php foreach ($public_taxonomies as $tax_slug => $tax) :
|
|
$is_tax_enabled = in_array($tax_slug, $enabled_taxonomies, true);
|
|
?>
|
|
<label style="display: flex; align-items: center; cursor: pointer; padding: 10px 14px; border: 1px solid var(--igny8-stroke); border-radius: var(--igny8-radius-sm); background: var(--igny8-bg);">
|
|
<input
|
|
type="checkbox"
|
|
name="igny8_enabled_taxonomies[]"
|
|
value="<?php echo esc_attr($tax_slug); ?>"
|
|
<?php checked($is_tax_enabled); ?>
|
|
style="margin-right: 10px;"
|
|
/>
|
|
<span style="flex: 1; font-size: 14px;"><?php echo esc_html($tax->label); ?></span>
|
|
</label>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<button type="submit" class="igny8-btn igny8-btn-primary">
|
|
<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="M5 13l4 4L19 7"/>
|
|
</svg>
|
|
<?php _e('Save Settings', 'igny8-bridge'); ?>
|
|
</button>
|
|
</form>
|
|
|
|
<style>
|
|
.igny8-badge {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
border-radius: 4px;
|
|
}
|
|
.igny8-badge-warning {
|
|
background: #fef3c7;
|
|
color: #92400e;
|
|
}
|
|
.igny8-post-type-toggle:hover {
|
|
border-color: var(--igny8-primary);
|
|
}
|
|
.igny8-taxonomy-card {
|
|
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
jQuery(document).ready(function($) {
|
|
// Toggle taxonomy cards based on post type checkboxes
|
|
$('.igny8-post-type-checkbox').on('change', function() {
|
|
var postType = $(this).data('post-type');
|
|
var card = $('.igny8-taxonomy-card[data-post-type="' + postType + '"]');
|
|
|
|
if ($(this).is(':checked')) {
|
|
card.slideDown(200);
|
|
} else {
|
|
card.slideUp(200);
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<?php
|
|
// Include layout footer
|
|
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/layout-footer.php';
|
|
?>
|