9.6 KiB
Site ID and Sync Settings Fix
Issues Addressed
1. ❌ "Site ID not set" Error in WordPress Plugin
Problem: Plugin showed "X Site ID not set" error preventing sync operations
Root Cause:
- Plugin was taking the first site from
/system/sites/API response - User has multiple sites (Home & Garden, Salman Sadiq, etc.)
- Wrong site was being selected
Solution:
- Match site by domain name instead of taking first result
- Added fallback to first site if no domain match
- Added manual Site ID input field if auto-detection fails
2. ✅ Taxonomy Selection Impact Verified
Question: Does the "Taxonomies to Sync" checkbox selection have actual impact?
Answer: YES! The taxonomy selection is fully functional:
Code Reference: data/site-collection.php (lines 318-325)
// Get enabled taxonomies from settings
if (function_exists('igny8_get_enabled_taxonomies')) {
$enabled_taxonomies = igny8_get_enabled_taxonomies();
if (!empty($enabled_taxonomies)) {
$tracked_taxonomies = $enabled_taxonomies;
}
}
foreach ($tracked_taxonomies as $taxonomy) {
if (!taxonomy_exists($taxonomy)) {
continue;
}
// Only syncs enabled taxonomies
}
✅ Only checked taxonomies will be collected and synced
When Selection Matters:
- ✅ "Collect & Send Site Data" button - respects selections
- ✅ Cron jobs (automatic syncs) - respects selections
- ✅ Manual syncs from WP Admin - respects selections
3. ✅ Post Type Selection Impact Verified
Question: Does the "Post Types to Sync" checkbox selection have actual impact?
Answer: YES! The post type selection is fully functional:
Code Reference: data/site-collection.php (lines 302-315)
foreach ((array) $settings['post_types'] as $post_type) {
if (!post_type_exists($post_type) || !igny8_is_post_type_enabled($post_type)) {
continue; // Skips disabled post types
}
$posts = igny8_fetch_wordpress_posts($post_type, ...);
// Only fetches enabled post types
}
✅ Only checked post types will be collected and synced
When Selection Matters:
- ✅ "Collect & Send Site Data" button - respects selections
- ✅ Cron jobs (automatic syncs) - respects selections
- ✅ Manual syncs from WP Admin - respects selections
4. ✅ App "Sync Now" Button Impact Verified
Question: Does the "Sync Now" button on Content Types page respect plugin settings?
Answer: PARTIALLY - It respects integration config, but uses backend-stored settings:
How It Works:
- Frontend calls:
/v1/integration/integrations/{id}/sync/ - Backend reads integration's
config_json.content_types - Syncs based on what's enabled in the integration record
Important Notes:
- ✅ The "Sync Now" button syncs FROM WordPress TO IGNY8
- ✅ It uses the settings stored in the integration config (backend database)
- ⚠️ If you change plugin settings, you need to send site structure first:
- Click "Collect & Send Site Data" in plugin
- This updates the integration config in the backend
- Then "Sync Now" will use the new settings
Workflow:
Plugin Settings Changed
↓
Click "Collect & Send Site Data" (updates backend config)
↓
Click "Sync Now" in App (uses updated config)
↓
Syncs with new settings
Changes Made
File 1: admin/class-admin.php
Change 1: Site ID Detection by Domain
// Before (line 278-283)
$site_response = $api->get('/system/sites/');
if ($site_response['success'] && !empty($site_response['results'])) {
$site = $site_response['results'][0]; // Takes first
update_option('igny8_site_id', $site['id']);
}
// After (line 278-299)
$site_response = $api->get('/system/sites/');
if ($site_response['success'] && !empty($site_response['results'])) {
$current_site_url = get_site_url();
$current_domain = parse_url($current_site_url, PHP_URL_HOST);
// Try to find matching site by domain
$matched_site = null;
foreach ($site_response['results'] as $site) {
if (!empty($site['domain'])) {
$site_domain = parse_url($site['domain'], PHP_URL_HOST);
if ($site_domain === $current_domain) {
$matched_site = $site;
break;
}
}
}
// Use matched site or fallback to first
if ($matched_site) {
update_option('igny8_site_id', $matched_site['id']);
error_log('IGNY8: Matched site by domain: ' . $matched_site['name']);
} else {
$site = $site_response['results'][0];
update_option('igny8_site_id', $site['id']);
error_log('IGNY8: No domain match, using first site');
}
}
Change 2: Allow Manual Site ID (line 63-68)
// Added sanitization for manual site ID entry
register_setting('igny8_settings', 'igny8_site_id', array(
'type' => 'integer',
'sanitize_callback' => 'absint'
));
File 2: admin/settings.php
Change: Manual Site ID Input Field (line 210-232)
<?php if ($site_id) : ?>
<tr>
<th scope="row"><?php _e('Site ID', 'igny8-bridge'); ?></th>
<td>
<?php echo esc_html($site_id); ?>
<p class="description">
<?php _e('Auto-detected from your IGNY8 account.', 'igny8-bridge'); ?>
</p>
</td>
</tr>
<?php else : ?>
<tr>
<th scope="row">
<label for="igny8_site_id_manual"><?php _e('Site ID (Manual)', 'igny8-bridge'); ?></label>
</th>
<td>
<input
type="number"
id="igny8_site_id_manual"
name="igny8_site_id"
value=""
class="regular-text"
/>
<p class="description">
<?php _e('If auto-detection failed, manually enter your IGNY8 Site ID here.', 'igny8-bridge'); ?>
</p>
</td>
</tr>
<?php endif; ?>
How to Deploy
Step 1: Upload Updated Files to homeg8.com
Upload these 2 files via FTP/SFTP to wp-content/plugins/igny8-wp-plugin/:
- ✅
admin/class-admin.php(Site ID domain matching) - ✅
admin/settings.php(Manual Site ID field)
Step 2: Reconnect the Plugin
Option A: Automatic (Recommended)
- Go to WordPress Admin → Settings → IGNY8 Bridge
- Click "Revoke API Key" button
- Re-enter your email, password, and API key
- Click "Connect to IGNY8"
- Plugin should now detect Site ID correctly by matching "homeg8.com" domain
Option B: Manual (If Auto-detection Still Fails)
- Go to IGNY8 app and find your Site ID:
- Navigate to Sites → Home & Garden Site
- Check the URL:
https://app.igny8.com/sites/5/... - Site ID is
5
- Go to WordPress Admin → Settings → IGNY8 Bridge
- Scroll to "Connection Status" section
- If "Site ID not set", you'll see a manual input field
- Enter
5(or your site ID) - Click "Save Connection Settings"
Step 3: Verify Fix
-
Check Site ID:
- Settings → IGNY8 Bridge
- "Connection Status" section should show "Site ID: 5"
-
Test Sync Operations:
- Should no longer show "X Site ID not set" error
- Click "Collect & Send Site Data" - should work
- Click "Sync Posts to IGNY8" - should work
-
Check App Frontend:
- Go to IGNY8 App → Sites → Home & Garden → Settings → Content Types
- Click "Sync Now"
- Should see content being synced
Testing Checklist
Plugin Side (WordPress Admin)
- Site ID is correctly detected and displayed
- "Collect & Send Site Data" button works (no Site ID error)
- "Sync Posts to IGNY8" button works
- "Sync Taxonomies" button works
- Taxonomy selections are saved correctly
- Post type selections are saved correctly
- Only selected taxonomies are synced
- Only selected post types are synced
App Side (IGNY8 Frontend)
- Site shows "Connected" status
- Content Types page shows correct counts
- "Sync Now" button triggers sync
- Synced content appears with correct counts
- Integration test connection succeeds
FAQ
Q: What if Site ID is still not detected?
A: Use the manual Site ID input:
- Find your Site ID in the app URL
- Enter it manually in the plugin settings
- Save settings
Q: Do I need to re-save taxonomy/post type selections?
A: No, existing selections are preserved. Only Site ID is affected.
Q: Will this affect existing synced content?
A: No, existing content is safe. This only fixes the Site ID detection.
Q: How do I find my Site ID?
A: Check the IGNY8 app URL when viewing your site:
- URL format:
https://app.igny8.com/sites/{SITE_ID}/... - Example:
https://app.igny8.com/sites/5/dashboard→ Site ID is5
Q: Does the "Sync Now" button in the app use my plugin settings immediately?
A: Not immediately. You need to:
- Change settings in plugin
- Click "Collect & Send Site Data" to update backend
- Then "Sync Now" will use new settings
Summary
✅ What's Fixed:
- Site ID now correctly detected by domain matching
- Manual Site ID input available as fallback
- Better logging for debugging
✅ What's Confirmed Working:
- Taxonomy selection affects sync (only checked taxonomies sync)
- Post type selection affects sync (only checked post types sync)
- "Collect & Send Site Data" respects selections
- "Sync Now" in app uses integration config
⚠️ Important Workflow:
Change Plugin Settings
↓
Click "Collect & Send Site Data" (updates backend)
↓
Click "Sync Now" in App (uses updated settings)
Support
If issues persist:
- Check WordPress debug log:
wp-content/debug.log - Check for error: "IGNY8: Matched site by domain: {site_name}"
- If no match found: "IGNY8: No domain match, using first site"
- Use manual Site ID input if auto-detection fails