# IGNY8 WordPress Bridge - Debug Setup Guide ## Quick Fix Summary ### Issue 1: API Key Not Showing After Reload ✅ FIXED - **Problem**: API key field was empty after reloading the page - **Fix**: Updated the form handler to detect placeholder asterisks and preserve the stored API key - **Result**: API key now properly shows as `********` when stored ### Issue 2: Test Connection Failing with 405 ✅ IMPROVED - **Problem**: Test connection returns HTTP 405 (Method Not Allowed) - **Fix**: Added comprehensive debugging and multiple endpoint fallback - **Result**: Now tests 3 different endpoints and shows detailed error messages ## Enable Debug Mode To see detailed API request/response logs, add these lines to your `wp-config.php` file (before `/* That's all, stop editing! */`): ```php // Enable WordPress debugging define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); // Enable IGNY8-specific debugging define('IGNY8_DEBUG', true); ``` ## View Debug Logs After enabling debug mode: 1. **Test the connection** in WordPress admin (Settings → IGNY8 API → Test Connection) 2. **Check the debug log** at: `wp-content/debug.log` 3. Look for lines starting with `IGNY8 DEBUG GET:` and `IGNY8 DEBUG RESPONSE:` ## What the Logs Will Show ``` IGNY8 DEBUG GET: https://api.igny8.com/api/v1/system/ping/ | Headers: {...} IGNY8 DEBUG RESPONSE: Status=405 | Body={"detail":"Method not allowed"} ``` ## Common 405 Error Causes 1. **Endpoint doesn't support GET method** - The SaaS API endpoint may only accept POST 2. **API key lacks permissions** - The API key doesn't have access to that endpoint 3. **Endpoint doesn't exist** - The URL path is incorrect or not implemented yet 4. **Firewall/WAF blocking** - Server-side security blocking the request ## Test Connection Endpoints (Tried in Order) The plugin now tests these endpoints automatically: 1. `/system/ping/` - Basic health check 2. `/planner/keywords/?page_size=1` - Keywords list (limited to 1 result) 3. `/system/sites/` - Sites list If **all three fail**, the error message will show the last failure with HTTP status code. ## Manual Testing with cURL Test the API from your server's command line: ```bash # Replace YOUR_API_KEY with your actual API key curl -v -H "Authorization: Bearer YOUR_API_KEY" "https://api.igny8.com/api/v1/system/ping/" ``` Expected success response (HTTP 200): ```json { "success": true, "data": { "status": "ok" } } ``` ## Next Steps for SaaS Team Based on the debug logs, the SaaS team should: 1. **Check which HTTP methods are allowed** for the tested endpoints 2. **Verify API key permissions** - Ensure the key has access to at least one endpoint 3. **Implement `/system/ping/` endpoint** if it doesn't exist (should return 200 OK) 4. **Check server logs** for incoming requests from the WordPress host 5. **Review WAF/firewall rules** that might be blocking requests ## Plugin Changes Made ### 1. `includes/class-igny8-api.php` - Added debug logging for all GET requests - Added HTTP status code to all responses - Improved error messages with status codes ### 2. `admin/class-admin.php` - Updated `test_connection()` to try multiple endpoints - Returns detailed error information including HTTP status - Detects API key placeholder to prevent overwriting stored key ### 3. `admin/assets/js/admin.js` - Shows HTTP status code in error messages - Logs full error details to browser console ### 4. `admin/settings.php` - Shows debug mode indicator when WP_DEBUG is enabled - Fixed API key field to show asterisks when key is stored ## Disable Debug Mode After troubleshooting, remove or comment out these lines from `wp-config.php`: ```php // define('WP_DEBUG', true); // define('WP_DEBUG_LOG', true); // define('IGNY8_DEBUG', true); ``` Keep `WP_DEBUG_DISPLAY` as `false` to prevent errors showing on the live site.