1
This commit is contained in:
@@ -1,185 +0,0 @@
|
||||
# Phase 5 Implementation Summary
|
||||
|
||||
## Overview
|
||||
Phase 5 implementation adds Planner, Linker, and Optimizer module hooks to the WordPress bridge plugin.
|
||||
|
||||
## Implemented Features
|
||||
|
||||
### 5.1 Planner Briefs Display & Refresh Actions ✅
|
||||
|
||||
**Files Created:**
|
||||
- `admin/class-post-meta-boxes.php` - Meta boxes for post editor
|
||||
- `admin/assets/js/post-editor.js` - JavaScript for AJAX interactions
|
||||
|
||||
**Features:**
|
||||
- **Planner Brief Meta Box** in post editor sidebar
|
||||
- Displays cached brief with title, content, outline, keywords, and tone
|
||||
- Shows cache timestamp
|
||||
- "Fetch Brief" button to load from IGNY8 API
|
||||
- "Request Refresh" button to trigger Planner refresh
|
||||
|
||||
**API Endpoints Used:**
|
||||
- `GET /planner/tasks/{id}/brief/` - Fetch Planner brief (with fallback to Writer brief)
|
||||
- `POST /planner/tasks/{id}/refresh/` - Request Planner task refresh
|
||||
|
||||
**Meta Fields Added:**
|
||||
- `_igny8_task_brief` - Cached brief data
|
||||
- `_igny8_brief_cached_at` - Brief cache timestamp
|
||||
|
||||
**AJAX Handlers:**
|
||||
- `igny8_fetch_planner_brief` - Fetches and caches brief
|
||||
- `igny8_refresh_planner_task` - Requests Planner refresh
|
||||
|
||||
---
|
||||
|
||||
### 5.2 Link Graph Export ✅
|
||||
|
||||
**Files Created:**
|
||||
- `data/link-graph.php` - Link graph extraction and export
|
||||
|
||||
**Features:**
|
||||
- **Link Extraction** from post content
|
||||
- Extracts all internal links (anchor tags)
|
||||
- Captures source URL, target URL, and anchor text
|
||||
- Filters to only internal links (same domain)
|
||||
- Normalizes URLs for consistency
|
||||
|
||||
- **Link Graph Collection**
|
||||
- Processes all enabled post types
|
||||
- Extracts links from published posts
|
||||
- Configurable batch processing (max 1000 posts per run)
|
||||
|
||||
- **Automatic Export During Site Scans**
|
||||
- Integrated into `igny8_collect_site_data()`
|
||||
- Included in site data payload
|
||||
- Also sent separately to Linker module endpoint
|
||||
|
||||
**API Endpoints Used:**
|
||||
- `POST /linker/link-map/` - Send link graph to Linker module
|
||||
|
||||
**Functions:**
|
||||
- `igny8_extract_post_links($post_id)` - Extract links from single post
|
||||
- `igny8_extract_link_graph($post_ids)` - Extract links from multiple posts
|
||||
- `igny8_send_link_graph_to_igny8($site_id, $link_graph)` - Send to IGNY8 API
|
||||
|
||||
**Integration Points:**
|
||||
- `igny8_collect_site_data()` - Includes link graph in site data
|
||||
- `igny8_send_site_data_to_igny8()` - Sends link graph after site import
|
||||
- `igny8_perform_full_site_scan()` - Sends link graph during full scans
|
||||
|
||||
**Options Stored:**
|
||||
- `igny8_last_link_graph_sync` - Last sync timestamp
|
||||
- `igny8_last_link_graph_count` - Number of links sent
|
||||
|
||||
---
|
||||
|
||||
### 5.4 Optimizer Triggers ✅
|
||||
|
||||
**Features:**
|
||||
- **Optimizer Meta Box** in post editor sidebar
|
||||
- Displays current optimizer job ID and status
|
||||
- "Request Optimization" button to create new job
|
||||
- "Check Status" button to fetch latest job status
|
||||
- Shows score changes and recommendations when available
|
||||
|
||||
**API Endpoints Used:**
|
||||
- `POST /optimizer/jobs/` - Create optimizer job
|
||||
- `GET /optimizer/jobs/{id}/` - Get optimizer job status
|
||||
|
||||
**Meta Fields Added:**
|
||||
- `_igny8_optimizer_job_id` - Optimizer job ID
|
||||
- `_igny8_optimizer_status` - Job status (pending, processing, completed, failed)
|
||||
- `_igny8_optimizer_score_changes` - Score changes from optimization
|
||||
- `_igny8_optimizer_recommendations` - Optimization recommendations
|
||||
- `_igny8_optimizer_job_created_at` - Job creation timestamp
|
||||
|
||||
**AJAX Handlers:**
|
||||
- `igny8_create_optimizer_job` - Creates new optimizer job
|
||||
- `igny8_get_optimizer_status` - Fetches job status and updates meta
|
||||
|
||||
**Job Parameters:**
|
||||
- `post_id` - WordPress post ID
|
||||
- `task_id` - IGNY8 task ID
|
||||
- `job_type` - Type of job (default: 'audit')
|
||||
- `priority` - Job priority (default: 'normal')
|
||||
|
||||
---
|
||||
|
||||
## Module Toggle Support
|
||||
|
||||
All Phase 5 features respect the module toggle settings:
|
||||
- **Planner** module must be enabled for brief fetching/refresh
|
||||
- **Linker** module must be enabled for link graph export
|
||||
- **Optimizer** module must be enabled for optimizer jobs
|
||||
|
||||
Features also check `igny8_is_connection_enabled()` to ensure sync operations are active.
|
||||
|
||||
---
|
||||
|
||||
## UI/UX Features
|
||||
|
||||
### Post Editor Meta Boxes
|
||||
- Clean, organized display in sidebar
|
||||
- Real-time AJAX updates
|
||||
- Success/error message display
|
||||
- Auto-refresh after operations
|
||||
- Disabled state when connection is off
|
||||
|
||||
### JavaScript Enhancements
|
||||
- Loading states on buttons
|
||||
- Confirmation dialogs for destructive actions
|
||||
- Error handling and user feedback
|
||||
- Non-blocking AJAX requests
|
||||
|
||||
---
|
||||
|
||||
## Integration with Existing Code
|
||||
|
||||
### Modified Files:
|
||||
- `igny8-bridge.php` - Added meta boxes class loading
|
||||
- `includes/functions.php` - Added optimizer meta field registrations
|
||||
- `data/site-collection.php` - Integrated link graph extraction
|
||||
|
||||
### New Dependencies:
|
||||
- None (uses existing Igny8API class)
|
||||
|
||||
---
|
||||
|
||||
## Testing Checklist
|
||||
|
||||
- [ ] Planner brief displays correctly in post editor
|
||||
- [ ] Fetch brief button works and caches data
|
||||
- [ ] Request refresh button triggers Planner refresh
|
||||
- [ ] Link graph extraction works on posts with links
|
||||
- [ ] Link graph is included in site scans
|
||||
- [ ] Link graph is sent to Linker endpoint
|
||||
- [ ] Optimizer job creation works
|
||||
- [ ] Optimizer status check works
|
||||
- [ ] All features respect module toggles
|
||||
- [ ] All features respect connection enabled toggle
|
||||
- [ ] Meta boxes only show for posts with task IDs
|
||||
- [ ] Error handling works correctly
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
|
||||
1. **Link Graph Processing**: Currently limited to 1000 posts per run to prevent timeouts. Can be increased or made configurable.
|
||||
|
||||
2. **Brief Caching**: Briefs are cached in post meta to reduce API calls. Cache can be refreshed manually.
|
||||
|
||||
3. **Optimizer Jobs**: Jobs are created asynchronously. Status must be checked manually or via webhook (Phase 6).
|
||||
|
||||
4. **Module Dependencies**: All features check module enablement before executing.
|
||||
|
||||
5. **Connection Toggle**: All features respect the master connection toggle added earlier.
|
||||
|
||||
---
|
||||
|
||||
## Next Steps (Phase 6)
|
||||
|
||||
Phase 5.3 (Accept link recommendations via webhook) is deferred to Phase 6, which will implement:
|
||||
- REST endpoint `/wp-json/igny8/v1/event` with shared secret
|
||||
- Webhook handler for link recommendations
|
||||
- Link insertion queue system
|
||||
|
||||
@@ -1,298 +0,0 @@
|
||||
# Phase 6 Implementation Summary
|
||||
|
||||
## Overview
|
||||
Phase 6 implementation adds webhook support and remote control capabilities, allowing IGNY8 SaaS to send events to WordPress.
|
||||
|
||||
## Implemented Features
|
||||
|
||||
### 6.1 REST Route Registration with Shared Secret ✅
|
||||
|
||||
**Files Created:**
|
||||
- `includes/class-igny8-webhooks.php` - Main webhook handler class
|
||||
|
||||
**Features:**
|
||||
- **REST Endpoint**: `/wp-json/igny8/v1/event` (POST)
|
||||
- **Shared Secret Authentication**: HMAC-SHA256 signature verification
|
||||
- **Connection Check**: All webhook handlers verify `igny8_is_connection_enabled()` before processing
|
||||
|
||||
**Security:**
|
||||
- Webhook secret stored in WordPress options (auto-generated on first use)
|
||||
- Signature verification via `X-IGNY8-Signature` header
|
||||
- Secret can be regenerated from settings page
|
||||
- Failed authentication attempts are logged
|
||||
|
||||
**Functions:**
|
||||
- `igny8_get_webhook_secret()` - Get or generate webhook secret
|
||||
- `igny8_regenerate_webhook_secret()` - Regenerate secret
|
||||
|
||||
---
|
||||
|
||||
### 6.2 SaaS Event Handlers ✅
|
||||
|
||||
**Event Types Supported:**
|
||||
|
||||
#### 1. Task Published (`task_published`, `task_completed`)
|
||||
- Creates or updates WordPress post from IGNY8 task
|
||||
- Fetches full task data from Writer API
|
||||
- Respects enabled post types
|
||||
- Updates post status if task is completed
|
||||
|
||||
#### 2. Link Recommendation (`link_recommendation`, `insert_link`)
|
||||
- Queues link insertion for processing
|
||||
- Validates required parameters (post_id, target_url, anchor)
|
||||
- Respects Linker module toggle
|
||||
- Processes links asynchronously via cron
|
||||
|
||||
#### 3. Optimizer Request (`optimizer_request`, `optimizer_job_completed`)
|
||||
- Updates optimizer job status
|
||||
- Stores score changes and recommendations
|
||||
- Updates post meta with optimizer data
|
||||
- Respects Optimizer module toggle
|
||||
|
||||
**Event Handler Flow:**
|
||||
1. Verify connection is enabled
|
||||
2. Verify module is enabled (if applicable)
|
||||
3. Validate event data
|
||||
4. Process event
|
||||
5. Log activity
|
||||
6. Return unified JSON response
|
||||
|
||||
---
|
||||
|
||||
### 6.3 Webhook Activity Logging ✅
|
||||
|
||||
**Files Created:**
|
||||
- `includes/class-igny8-webhook-logs.php` - Logging functions
|
||||
|
||||
**Features:**
|
||||
- **Log Storage**: WordPress options (last 500 logs)
|
||||
- **Log Fields**:
|
||||
- Event type
|
||||
- Event data
|
||||
- IP address
|
||||
- User agent
|
||||
- Status (received, processed, failed)
|
||||
- Response data
|
||||
- Timestamps (received_at, processed_at)
|
||||
- Error messages
|
||||
|
||||
**Functions:**
|
||||
- `igny8_log_webhook_activity()` - Log webhook receipt
|
||||
- `igny8_update_webhook_log()` - Update log with processing result
|
||||
- `igny8_get_webhook_logs()` - Retrieve logs with filtering
|
||||
- `igny8_clear_old_webhook_logs()` - Cleanup old logs
|
||||
|
||||
**UI Display:**
|
||||
- Recent webhook activity table in settings page
|
||||
- Shows last 10 webhook events
|
||||
- Displays event type, status, and timestamp
|
||||
|
||||
---
|
||||
|
||||
### Link Queue System ✅
|
||||
|
||||
**Files Created:**
|
||||
- `includes/class-igny8-link-queue.php` - Link insertion queue
|
||||
|
||||
**Features:**
|
||||
- **Queue Storage**: WordPress options
|
||||
- **Queue Processing**: Cron-based (processes 10 items per run)
|
||||
- **Retry Logic**: Up to 3 attempts per link
|
||||
- **Status Tracking**: pending, completed, failed
|
||||
|
||||
**Link Insertion Logic:**
|
||||
1. Finds anchor text in post content
|
||||
2. Wraps anchor with link tag
|
||||
3. Avoids duplicate links
|
||||
4. Falls back to appending link if anchor not found
|
||||
|
||||
**Queue Management:**
|
||||
- Automatic processing via cron
|
||||
- Manual trigger available
|
||||
- Queue size limit (1000 items)
|
||||
- Status tracking per item
|
||||
|
||||
---
|
||||
|
||||
## Connection Checks
|
||||
|
||||
**All handlers check connection status:**
|
||||
|
||||
✅ **Webhook Handler** (`verify_webhook_secret`)
|
||||
- Checks `igny8_is_connection_enabled()` before allowing webhook
|
||||
|
||||
✅ **Event Handlers** (`handle_webhook`, `handle_task_published`, etc.)
|
||||
- Double-checks connection enabled before processing
|
||||
- Returns error if connection disabled
|
||||
|
||||
✅ **Link Queue** (`igny8_queue_link_insertion`, `igny8_process_link_queue`)
|
||||
- Checks connection enabled before queuing/processing
|
||||
|
||||
✅ **REST API Endpoints** (existing endpoints)
|
||||
- Updated to check connection enabled
|
||||
- Returns 403 if connection disabled
|
||||
|
||||
---
|
||||
|
||||
## Settings UI Enhancements
|
||||
|
||||
**New Sections Added:**
|
||||
|
||||
1. **Webhook Configuration**
|
||||
- Webhook URL display with copy button
|
||||
- Webhook secret display with copy button
|
||||
- Regenerate secret button
|
||||
|
||||
2. **Link Queue**
|
||||
- Shows pending links count
|
||||
- Displays queue table (last 10 items)
|
||||
- Shows post ID, anchor, target URL, status
|
||||
|
||||
3. **Recent Webhook Activity**
|
||||
- Shows last 10 webhook events
|
||||
- Displays event type, status, timestamp
|
||||
- Color-coded status badges
|
||||
|
||||
---
|
||||
|
||||
## Security Features
|
||||
|
||||
1. **HMAC Signature Verification**
|
||||
- Uses SHA-256 HMAC
|
||||
- Compares request body signature
|
||||
- Prevents replay attacks
|
||||
|
||||
2. **Connection Toggle Protection**
|
||||
- All endpoints check connection status
|
||||
- Webhooks rejected if connection disabled
|
||||
- Clear error messages
|
||||
|
||||
3. **Module Toggle Respect**
|
||||
- Events only processed if module enabled
|
||||
- Graceful error responses
|
||||
|
||||
4. **Input Validation**
|
||||
- All parameters sanitized
|
||||
- Required fields validated
|
||||
- Type checking
|
||||
|
||||
---
|
||||
|
||||
## API Response Format
|
||||
|
||||
All webhook responses follow unified JSON format:
|
||||
|
||||
**Success:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Event processed",
|
||||
"data": { ... }
|
||||
}
|
||||
```
|
||||
|
||||
**Error:**
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": "Error message",
|
||||
"code": "error_code"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Integration Points
|
||||
|
||||
### Modified Files:
|
||||
- `igny8-bridge.php` - Added webhook classes loading
|
||||
- `includes/functions.php` - Added webhook secret functions
|
||||
- `includes/class-igny8-rest-api.php` - Added connection checks
|
||||
- `admin/settings.php` - Added webhook UI sections
|
||||
- `admin/class-admin.php` - Added secret regeneration handler
|
||||
|
||||
### New Dependencies:
|
||||
- None (uses existing WordPress functions)
|
||||
|
||||
---
|
||||
|
||||
## Testing Checklist
|
||||
|
||||
- [ ] Webhook endpoint accessible at `/wp-json/igny8/v1/event`
|
||||
- [ ] Signature verification works correctly
|
||||
- [ ] Invalid signatures are rejected
|
||||
- [ ] Connection disabled blocks webhooks
|
||||
- [ ] Task published event creates/updates posts
|
||||
- [ ] Link recommendation queues links
|
||||
- [ ] Link queue processes links correctly
|
||||
- [ ] Optimizer events update post meta
|
||||
- [ ] Webhook logs are created and updated
|
||||
- [ ] Settings UI displays webhook info
|
||||
- [ ] Secret regeneration works
|
||||
- [ ] All events respect module toggles
|
||||
- [ ] All events respect connection toggle
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
|
||||
1. **Webhook Secret**: Auto-generated on first use. Must be configured in IGNY8 SaaS app.
|
||||
|
||||
2. **Link Queue**: Processes 10 items per cron run to prevent timeouts. Can be adjusted.
|
||||
|
||||
3. **Log Retention**: Keeps last 500 logs. Older logs can be cleared manually.
|
||||
|
||||
4. **Signature Header**: IGNY8 SaaS must send `X-IGNY8-Signature` header with HMAC-SHA256 signature of request body.
|
||||
|
||||
5. **Connection Toggle**: All webhook handlers check connection status before processing. This ensures no data is processed when connection is disabled.
|
||||
|
||||
6. **Module Toggles**: Each event type checks if its module is enabled before processing.
|
||||
|
||||
---
|
||||
|
||||
## Webhook Payload Examples
|
||||
|
||||
### Task Published
|
||||
```json
|
||||
{
|
||||
"event": "task_published",
|
||||
"data": {
|
||||
"task_id": 123,
|
||||
"status": "completed"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Link Recommendation
|
||||
```json
|
||||
{
|
||||
"event": "link_recommendation",
|
||||
"data": {
|
||||
"post_id": 456,
|
||||
"target_url": "https://example.com/page",
|
||||
"anchor": "example link",
|
||||
"priority": "normal"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Optimizer Request
|
||||
```json
|
||||
{
|
||||
"event": "optimizer_job_completed",
|
||||
"data": {
|
||||
"post_id": 456,
|
||||
"job_id": 789,
|
||||
"status": "completed",
|
||||
"score_changes": { ... },
|
||||
"recommendations": [ ... ]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
Phase 6 is complete. All webhook functionality is implemented with proper security, logging, and connection checks.
|
||||
|
||||
@@ -1,249 +0,0 @@
|
||||
# Status Sync & Content ID Documentation
|
||||
|
||||
**Last Updated**: 2025-10-17
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This document explains how the plugin handles status synchronization and content_id tracking between IGNY8 and WordPress.
|
||||
|
||||
---
|
||||
|
||||
## Status Mapping
|
||||
|
||||
### IGNY8 → WordPress
|
||||
|
||||
When content arrives from IGNY8, status is mapped as follows:
|
||||
|
||||
| IGNY8 Status | WordPress Status | Description |
|
||||
|--------------|------------------|-------------|
|
||||
| `completed` | `publish` | Content is published |
|
||||
| `draft` | `draft` | Content is draft |
|
||||
| `pending` | `pending` | Content pending review |
|
||||
| `scheduled` | `future` | Content scheduled |
|
||||
| `archived` | `trash` | Content archived |
|
||||
|
||||
### WordPress → IGNY8
|
||||
|
||||
When WordPress post status changes, it's mapped back to IGNY8:
|
||||
|
||||
| WordPress Status | IGNY8 Status | Description |
|
||||
|------------------|--------------|-------------|
|
||||
| `publish` | `completed` | Post is published |
|
||||
| `draft` | `draft` | Post is draft |
|
||||
| `pending` | `pending` | Post pending review |
|
||||
| `private` | `completed` | Post is private (published) |
|
||||
| `trash` | `archived` | Post is deleted |
|
||||
| `future` | `scheduled` | Post is scheduled |
|
||||
|
||||
---
|
||||
|
||||
## Content ID Tracking
|
||||
|
||||
### Storage
|
||||
|
||||
The plugin stores IGNY8 `content_id` in post meta:
|
||||
- **Meta Key**: `_igny8_content_id`
|
||||
- **Type**: Integer
|
||||
- **REST API**: Available via `/wp-json/wp/v2/posts?meta_key=_igny8_content_id&meta_value=123`
|
||||
|
||||
### Task ID Tracking
|
||||
|
||||
The plugin also stores IGNY8 `task_id`:
|
||||
- **Meta Key**: `_igny8_task_id`
|
||||
- **Type**: Integer
|
||||
- **REST API**: Available via `/wp-json/wp/v2/posts?meta_key=_igny8_task_id&meta_value=456`
|
||||
|
||||
---
|
||||
|
||||
## Response to IGNY8
|
||||
|
||||
When content is created/updated in WordPress, the plugin responds to IGNY8 with:
|
||||
|
||||
```json
|
||||
{
|
||||
"assigned_post_id": 123,
|
||||
"post_url": "https://example.com/post/",
|
||||
"wordpress_status": "publish",
|
||||
"status": "completed",
|
||||
"synced_at": "2025-10-17 12:00:00",
|
||||
"post_type": "post",
|
||||
"content_type": "post",
|
||||
"content_id": 789
|
||||
}
|
||||
```
|
||||
|
||||
### Response Fields
|
||||
|
||||
- **`assigned_post_id`**: WordPress post ID
|
||||
- **`post_url`**: Full URL to the post
|
||||
- **`wordpress_status`**: Actual WordPress status (publish/pending/draft)
|
||||
- **`status`**: IGNY8 mapped status (completed/pending/draft)
|
||||
- **`synced_at`**: Timestamp of sync
|
||||
- **`post_type`**: WordPress post type
|
||||
- **`content_type`**: IGNY8 content type
|
||||
- **`content_id`**: IGNY8 content ID (if provided)
|
||||
|
||||
---
|
||||
|
||||
## REST API Endpoints
|
||||
|
||||
The plugin provides REST API endpoints for IGNY8 to query WordPress:
|
||||
|
||||
### 1. Get Post by Content ID
|
||||
|
||||
**Endpoint**: `GET /wp-json/igny8/v1/post-by-content-id/{content_id}`
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"post_id": 123,
|
||||
"title": "Post Title",
|
||||
"status": "publish",
|
||||
"wordpress_status": "publish",
|
||||
"igny8_status": "completed",
|
||||
"url": "https://example.com/post/",
|
||||
"post_type": "post",
|
||||
"content_id": 789,
|
||||
"task_id": 456,
|
||||
"last_synced": "2025-10-17 12:00:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Get Post by Task ID
|
||||
|
||||
**Endpoint**: `GET /wp-json/igny8/v1/post-by-task-id/{task_id}`
|
||||
|
||||
**Response**: Same format as above
|
||||
|
||||
### 3. Get Post Status by Content ID
|
||||
|
||||
**Endpoint**: `GET /wp-json/igny8/v1/post-status/{content_id}`
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"post_id": 123,
|
||||
"wordpress_status": "publish",
|
||||
"igny8_status": "completed",
|
||||
"status_mapping": {
|
||||
"publish": "completed",
|
||||
"draft": "draft",
|
||||
"pending": "pending",
|
||||
"private": "completed",
|
||||
"trash": "archived",
|
||||
"future": "scheduled"
|
||||
},
|
||||
"content_id": 789,
|
||||
"url": "https://example.com/post/",
|
||||
"last_synced": "2025-10-17 12:00:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Status Flow
|
||||
|
||||
### When Content Arrives from IGNY8
|
||||
|
||||
1. **Receive** content with `content_type`, `status`, `content_id`, `task_id`
|
||||
2. **Map** IGNY8 status to WordPress status
|
||||
3. **Create** WordPress post with mapped status
|
||||
4. **Store** `content_id` and `task_id` in post meta
|
||||
5. **Respond** to IGNY8 with:
|
||||
- WordPress post ID
|
||||
- WordPress actual status
|
||||
- IGNY8 mapped status
|
||||
- Post URL
|
||||
- Content ID
|
||||
|
||||
### When WordPress Status Changes
|
||||
|
||||
1. **Detect** status change via `save_post` or `transition_post_status` hook
|
||||
2. **Get** `task_id` and `content_id` from post meta
|
||||
3. **Map** WordPress status to IGNY8 status
|
||||
4. **Update** IGNY8 task with:
|
||||
- WordPress actual status
|
||||
- IGNY8 mapped status
|
||||
- Post URL
|
||||
- Content ID (if available)
|
||||
- Sync timestamp
|
||||
|
||||
---
|
||||
|
||||
## Available Meta Fields
|
||||
|
||||
All fields are available for IGNY8 to read via REST API:
|
||||
|
||||
- `_igny8_task_id` - IGNY8 task ID
|
||||
- `_igny8_content_id` - IGNY8 content ID
|
||||
- `_igny8_cluster_id` - IGNY8 cluster ID
|
||||
- `_igny8_sector_id` - IGNY8 sector ID
|
||||
- `_igny8_keyword_ids` - Array of keyword IDs
|
||||
- `_igny8_wordpress_status` - WordPress post status
|
||||
- `_igny8_last_synced` - Last sync timestamp
|
||||
|
||||
---
|
||||
|
||||
## Query Examples
|
||||
|
||||
### Via WordPress REST API
|
||||
|
||||
```bash
|
||||
# Get post by content_id
|
||||
GET /wp-json/wp/v2/posts?meta_key=_igny8_content_id&meta_value=123
|
||||
|
||||
# Get post by task_id
|
||||
GET /wp-json/wp/v2/posts?meta_key=_igny8_task_id&meta_value=456
|
||||
|
||||
# Get all IGNY8 posts
|
||||
GET /wp-json/wp/v2/posts?meta_key=_igny8_task_id
|
||||
```
|
||||
|
||||
### Via IGNY8 REST API Endpoints
|
||||
|
||||
```bash
|
||||
# Get post by content_id (with status info)
|
||||
GET /wp-json/igny8/v1/post-by-content-id/123
|
||||
|
||||
# Get post status only
|
||||
GET /wp-json/igny8/v1/post-status/123
|
||||
|
||||
# Get post by task_id
|
||||
GET /wp-json/igny8/v1/post-by-task-id/456
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Authentication
|
||||
|
||||
REST API endpoints require:
|
||||
- IGNY8 API authentication (access token)
|
||||
- Authorization header: `Bearer {access_token}`
|
||||
|
||||
Or internal use when IGNY8 is connected.
|
||||
|
||||
---
|
||||
|
||||
## Status Flags Available
|
||||
|
||||
✅ **Task ID** - Stored and queryable
|
||||
✅ **Content ID** - Stored and queryable
|
||||
✅ **WordPress Status** - Stored and sent to IGNY8
|
||||
✅ **IGNY8 Status** - Mapped and sent to IGNY8
|
||||
✅ **Post Type** - Stored and sent to IGNY8
|
||||
✅ **Content Type** - Stored and sent to IGNY8
|
||||
✅ **Sync Timestamp** - Stored and sent to IGNY8
|
||||
✅ **Post URL** - Sent to IGNY8
|
||||
|
||||
---
|
||||
|
||||
**All status information is available for IGNY8 to read and query!**
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
# Style Guide - IGNY8 WordPress Bridge
|
||||
|
||||
**Last Updated**: 2025-10-17
|
||||
|
||||
---
|
||||
|
||||
## CSS Architecture
|
||||
|
||||
### No Inline CSS Policy
|
||||
|
||||
✅ **All styles are in `admin/assets/css/admin.css`**
|
||||
❌ **No inline `style=""` attributes**
|
||||
❌ **No `<style>` tags in PHP files**
|
||||
|
||||
### Global Design Updates
|
||||
|
||||
To update the design globally, **only edit**:
|
||||
- `admin/assets/css/admin.css` - All admin styles
|
||||
|
||||
---
|
||||
|
||||
## CSS Class Naming Convention
|
||||
|
||||
|
||||
### Prefix
|
||||
All classes use `igny8-` prefix to avoid conflicts.
|
||||
|
||||
### Naming Pattern
|
||||
```
|
||||
igny8-{component}-{element}-{modifier}
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
#### Containers
|
||||
- `.igny8-settings-container` - Main container
|
||||
- `.igny8-settings-card` - Card component
|
||||
- `.igny8-sync-actions` - Button group container
|
||||
|
||||
#### Status Indicators
|
||||
- `.igny8-status-connected` - Connected status
|
||||
- `.igny8-status-disconnected` - Disconnected status
|
||||
- `.igny8-test-result` - Test result container
|
||||
- `.igny8-test-result .igny8-success` - Success message
|
||||
- `.igny8-test-result .igny8-error` - Error message
|
||||
- `.igny8-test-result .igny8-loading` - Loading message
|
||||
|
||||
#### Sync Operations
|
||||
- `.igny8-sync-status` - Sync status container
|
||||
- `.igny8-sync-status-success` - Success state
|
||||
- `.igny8-sync-status-error` - Error state
|
||||
- `.igny8-sync-status-loading` - Loading state
|
||||
|
||||
#### Statistics
|
||||
- `.igny8-stats-grid` - Statistics grid
|
||||
- `.igny8-stat-item` - Individual stat item
|
||||
- `.igny8-stat-label` - Stat label
|
||||
- `.igny8-stat-value` - Stat value
|
||||
|
||||
#### Buttons
|
||||
- `.igny8-button-group` - Button group container
|
||||
- `.igny8-loading` - Loading state modifier
|
||||
|
||||
#### Messages
|
||||
- `.igny8-message` - Base message class
|
||||
- `.igny8-message-success` - Success message
|
||||
- `.igny8-message-error` - Error message
|
||||
- `.igny8-message-info` - Info message
|
||||
- `.igny8-message-warning` - Warning message
|
||||
|
||||
#### Tables
|
||||
- `.igny8-table` - Table component
|
||||
- `.igny8-table th` - Table header
|
||||
- `.igny8-table td` - Table cell
|
||||
|
||||
#### Loading
|
||||
- `.igny8-spinner` - Loading spinner
|
||||
- `.igny8-loading` - Loading state
|
||||
|
||||
---
|
||||
|
||||
## Color Scheme
|
||||
|
||||
All colors are defined in CSS for easy updates:
|
||||
|
||||
### Status Colors
|
||||
- **Success**: `#46b450` (green)
|
||||
- **Error**: `#dc3232` (red)
|
||||
- **Info**: `#2271b1` (blue)
|
||||
- **Warning**: `#f0b849` (amber)
|
||||
|
||||
### Background Colors
|
||||
- **Success BG**: `#d4edda` / `#f0f8f0`
|
||||
- **Error BG**: `#f8d7da` / `#fff5f5`
|
||||
- **Info BG**: `#d1ecf1` / `#f0f6fc`
|
||||
- **Warning BG**: `#fffbf0`
|
||||
|
||||
### Border Colors
|
||||
- **Default**: `#ccd0d4`
|
||||
- **Light**: `#ddd` / `#eee`
|
||||
|
||||
---
|
||||
|
||||
## Responsive Breakpoints
|
||||
|
||||
```css
|
||||
@media (max-width: 782px) {
|
||||
/* Mobile styles */
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Update Design
|
||||
|
||||
### Change Colors Globally
|
||||
|
||||
Edit `admin/assets/css/admin.css`:
|
||||
|
||||
```css
|
||||
/* Status Colors */
|
||||
.igny8-status-connected {
|
||||
color: #YOUR_COLOR; /* Change here */
|
||||
}
|
||||
```
|
||||
|
||||
### Change Layout
|
||||
|
||||
Edit container classes in `admin.css`:
|
||||
|
||||
```css
|
||||
.igny8-settings-container {
|
||||
max-width: YOUR_WIDTH; /* Change here */
|
||||
}
|
||||
```
|
||||
|
||||
### Add New Styles
|
||||
|
||||
1. Add CSS class to `admin/assets/css/admin.css`
|
||||
2. Use class in PHP/HTML (no inline styles)
|
||||
3. Follow naming convention: `igny8-{component}-{element}`
|
||||
|
||||
---
|
||||
|
||||
## JavaScript Class Usage
|
||||
|
||||
JavaScript adds/removes CSS classes (no inline styles):
|
||||
|
||||
```javascript
|
||||
// ✅ Good - Uses CSS classes
|
||||
$element.addClass('igny8-loading');
|
||||
$element.addClass('igny8-sync-status-success');
|
||||
|
||||
// ❌ Bad - Inline styles
|
||||
$element.css('color', 'green');
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
admin/assets/css/
|
||||
└── admin.css ← ALL styles here
|
||||
|
||||
admin/assets/js/
|
||||
└── admin.js ← Uses CSS classes only
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Checklist for New Features
|
||||
|
||||
When adding new UI elements:
|
||||
|
||||
- [ ] Define CSS classes in `admin.css`
|
||||
- [ ] Use classes in PHP/HTML (no `style=""`)
|
||||
- [ ] Use classes in JavaScript (no `.css()`)
|
||||
- [ ] Follow naming convention
|
||||
- [ ] Add responsive styles if needed
|
||||
- [ ] Test on mobile/tablet
|
||||
|
||||
---
|
||||
|
||||
**Remember**: All design changes = Edit `admin.css` only! 🎨
|
||||
|
||||
@@ -1,430 +0,0 @@
|
||||
# IGNY8 WordPress Bridge – Verification Report (Phases 1-5)
|
||||
|
||||
**Date:** Generated automatically
|
||||
**Scope:** Verification of implementation plan phases 1-5
|
||||
|
||||
---
|
||||
|
||||
## Phase 1 – Foundations ✅ **COMPLETE**
|
||||
|
||||
### 1.1 Harden Credential Storage
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `includes/functions.php` (lines 20-111)
|
||||
- `igny8_encrypt_value()` - AES-256-CBC encryption
|
||||
- `igny8_decrypt_value()` - Decryption with fallback
|
||||
- `igny8_store_secure_option()` - Secure storage wrapper
|
||||
- `igny8_get_secure_option()` - Secure retrieval wrapper
|
||||
|
||||
- `includes/class-igny8-api.php` (lines 106-150)
|
||||
- `refresh_token()` method implements token refresh tracking
|
||||
- Stores `igny8_token_refreshed_at` and `igny8_access_token_issued` timestamps
|
||||
|
||||
**Verification:**
|
||||
- ✅ Option encryption using OpenSSL AES-256-CBC
|
||||
- ✅ Token refresh tracking with timestamps
|
||||
- ✅ Secure option storage/retrieval functions
|
||||
|
||||
---
|
||||
|
||||
### 1.2 Build Diagnostics Card
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `admin/settings.php` (lines 139-214)
|
||||
|
||||
**Features Implemented:**
|
||||
- ✅ Access Token Age display (with human-readable time)
|
||||
- ✅ Last API Health Check timestamp
|
||||
- ✅ Last Site Data Sync timestamp
|
||||
- ✅ Last Full Site Scan timestamp
|
||||
- ✅ Last Semantic Map timestamp (with summary)
|
||||
- ✅ Last Taxonomy Sync timestamp
|
||||
- ✅ Last Keyword Sync timestamp
|
||||
- ✅ Last Writer Sync timestamp
|
||||
- ✅ Next Scheduled Site Scan display
|
||||
|
||||
**Note:** Health check uses `/planner/keywords/?page_size=1` as fallback (per plan note)
|
||||
|
||||
---
|
||||
|
||||
### 1.3 Add Control Model + Post-Type/Woo Toggles
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `admin/settings.php` (lines 229-330)
|
||||
|
||||
**Features Implemented:**
|
||||
- ✅ Post Types to Sync (checkbox list with all supported types)
|
||||
- ✅ IGNY8 Modules toggle (Sites, Planner, Writer, Linker, Optimizer)
|
||||
- ✅ Control Mode radio buttons (Mirror/Hybrid)
|
||||
- ✅ WooCommerce Data toggle (with detection)
|
||||
|
||||
**Supporting Functions:**
|
||||
- `includes/functions.php`:
|
||||
- `igny8_get_supported_post_types()` (lines 118-134)
|
||||
- `igny8_get_enabled_post_types()` (lines 141-149)
|
||||
- `igny8_get_control_mode()` (lines 156-159)
|
||||
- `igny8_get_available_modules()` (lines 166-181)
|
||||
- `igny8_get_enabled_modules()` (lines 188-196)
|
||||
|
||||
---
|
||||
|
||||
## Phase 2 – Automatic Taxonomy & Keyword Sync ✅ **COMPLETE**
|
||||
|
||||
### 2.1 Scheduled Fetch of Sectors/Clusters
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `sync/taxonomy-sync.php`:
|
||||
- `igny8_sync_igny8_sectors_to_wp()` (lines 80-134)
|
||||
- `igny8_sync_igny8_clusters_to_wp()` (lines 142-237)
|
||||
- `igny8_cron_sync_taxonomies()` (lines 244-253)
|
||||
|
||||
**Scheduling:**
|
||||
- `includes/functions.php` (line 490-492): Scheduled `twicedaily`
|
||||
|
||||
**API Endpoints Used:**
|
||||
- ✅ `/planner/sites/{id}/sectors/` (GET)
|
||||
- ✅ `/planner/sites/{id}/clusters/` (GET)
|
||||
|
||||
**Features:**
|
||||
- ✅ Populates `igny8_sectors` taxonomy
|
||||
- ✅ Populates `igny8_clusters` taxonomy
|
||||
- ✅ Stores `_igny8_sector_id` and `_igny8_cluster_id` term meta
|
||||
- ✅ Respects module toggle (skips if Planner disabled)
|
||||
|
||||
---
|
||||
|
||||
### 2.2 Pull Planner Keywords Per Cluster
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `sync/taxonomy-sync.php`:
|
||||
- `igny8_sync_keywords_from_planner()` (lines 260-351)
|
||||
- `igny8_cron_sync_keywords()` (lines 358-364)
|
||||
|
||||
**Scheduling:**
|
||||
- `includes/functions.php` (line 495-497): Scheduled `daily`
|
||||
|
||||
**API Endpoints Used:**
|
||||
- ✅ `/planner/keywords/?cluster_id={id}&page_size=500` (GET)
|
||||
|
||||
**Features:**
|
||||
- ✅ Fetches keywords per cluster
|
||||
- ✅ Stores `_igny8_keyword_ids` in term meta (cluster level)
|
||||
- ✅ Stores `_igny8_keyword_ids` in post meta (post level)
|
||||
- ✅ Respects module toggle (skips if Planner disabled)
|
||||
|
||||
---
|
||||
|
||||
### 2.3 Render Read-Only Badges
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `admin/class-admin-columns.php`:
|
||||
- `render_sectors_column()` (lines 121-133)
|
||||
- `render_clusters_column()` (lines 140-152)
|
||||
- `render_source_column()` (lines 102-114)
|
||||
|
||||
**Features:**
|
||||
- ✅ Displays sectors as badges in post list table
|
||||
- ✅ Displays clusters as badges in post list table
|
||||
- ✅ Shows IGNY8/WP source badge
|
||||
- ✅ Read-only display (no editing in list view)
|
||||
|
||||
**Note:** Editor side panels would require additional meta box implementation (not explicitly required in plan)
|
||||
|
||||
---
|
||||
|
||||
## Phase 3 – Writer Module Integration ✅ **MOSTLY COMPLETE**
|
||||
|
||||
### 3.1 Cron/Webhook to Fetch Tasks
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `sync/igny8-to-wp.php`:
|
||||
- `igny8_sync_igny8_tasks_to_wp()` (lines 265-441)
|
||||
- `igny8_cron_sync_from_igny8()` (lines 756-795)
|
||||
|
||||
**Scheduling:**
|
||||
- `includes/functions.php` (line 485-487): Scheduled `hourly`
|
||||
|
||||
**API Endpoints Used:**
|
||||
- ✅ `/writer/tasks/?site_id={id}&status={status}` (GET)
|
||||
|
||||
**Features:**
|
||||
- ✅ Fetches tasks with filters (status, cluster_id)
|
||||
- ✅ Creates new WordPress posts from tasks
|
||||
- ✅ Updates existing posts if task already linked
|
||||
- ✅ Respects enabled post types
|
||||
- ✅ Respects module toggle (skips if Writer disabled)
|
||||
|
||||
---
|
||||
|
||||
### 3.2 Hook save_post / transition_post_status
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `sync/post-sync.php`:
|
||||
- `igny8_sync_post_status_to_igny8()` (lines 22-78)
|
||||
- `igny8_sync_post_status_transition()` (lines 137-169)
|
||||
|
||||
**Hooks Registered:**
|
||||
- `sync/hooks.php` (lines 23, 28):
|
||||
- ✅ `save_post` → `igny8_sync_post_status_to_igny8`
|
||||
- ✅ `transition_post_status` → `igny8_sync_post_status_transition`
|
||||
|
||||
**API Endpoints Used:**
|
||||
- ✅ `/writer/tasks/{id}/` (PUT)
|
||||
|
||||
**Features:**
|
||||
- ✅ Pushes WordPress post status to IGNY8
|
||||
- ✅ Pushes post URL to IGNY8
|
||||
- ✅ Maps WordPress status to IGNY8 status
|
||||
- ✅ Only syncs IGNY8-managed posts
|
||||
- ✅ Skips autosaves and revisions
|
||||
|
||||
---
|
||||
|
||||
### 3.3 Store Briefs/Outlines on Post Meta
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `sync/igny8-to-wp.php`:
|
||||
- `igny8_cache_task_brief()` (lines 49-64)
|
||||
|
||||
**API Endpoints Used:**
|
||||
- ✅ `/writer/tasks/{id}/brief/` (GET)
|
||||
|
||||
**Features:**
|
||||
- ✅ Fetches brief from IGNY8 API
|
||||
- ✅ Stores in `_igny8_task_brief` post meta
|
||||
- ✅ Stores cache timestamp in `_igny8_brief_cached_at`
|
||||
- ✅ Called automatically when posts are created/updated
|
||||
|
||||
---
|
||||
|
||||
### 3.4 Queue Visualization
|
||||
**Status:** ⚠️ **PARTIALLY IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `admin/settings.php` (lines 365-377): Basic stats display
|
||||
|
||||
**Implemented:**
|
||||
- ✅ Sync statistics section in settings
|
||||
- ✅ Synced posts count (via AJAX)
|
||||
- ✅ Last sync timestamp
|
||||
|
||||
**Missing:**
|
||||
- ❌ Detailed queue counts (pending, processing, failed)
|
||||
- ❌ Failure logs/visualization
|
||||
- ❌ Queue status widget
|
||||
|
||||
**Recommendation:** Add detailed queue tracking table or widget showing:
|
||||
- Pending syncs
|
||||
- Failed syncs with error messages
|
||||
- Processing status
|
||||
|
||||
---
|
||||
|
||||
## Phase 4 – Sites Module & Semantic Mapping ✅ **COMPLETE**
|
||||
|
||||
### 4.1 Incremental + Full Site-Data Collectors
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `data/site-collection.php`:
|
||||
- `igny8_collect_site_data()` (lines 277-364) - Full collection
|
||||
- `igny8_sync_incremental_site_data()` (lines 411-498) - Incremental sync
|
||||
- `igny8_fetch_wordpress_posts()` (lines 23-99)
|
||||
- `igny8_fetch_all_taxonomy_terms()` (lines 254-270)
|
||||
|
||||
**Features:**
|
||||
- ✅ Honors post type toggles (`igny8_is_post_type_enabled()`)
|
||||
- ✅ Honors WooCommerce toggle
|
||||
- ✅ Honors module toggle (skips if Sites disabled)
|
||||
- ✅ Incremental mode (only changed posts since last sync)
|
||||
- ✅ Full mode (all posts)
|
||||
- ✅ Collects posts, taxonomies, terms
|
||||
- ✅ Collects WooCommerce products (if enabled)
|
||||
|
||||
---
|
||||
|
||||
### 4.2 Schedule Automatic Submission
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `data/site-collection.php`:
|
||||
- `igny8_send_site_data_to_igny8()` (lines 372-403)
|
||||
- `igny8_perform_full_site_scan()` (lines 507-535)
|
||||
|
||||
**Scheduling:**
|
||||
- `includes/functions.php`:
|
||||
- Line 475-477: Daily incremental sync (`igny8_sync_site_data`)
|
||||
- Line 480-482: Daily full scan check (`igny8_full_site_scan` - runs max once per week)
|
||||
|
||||
**API Endpoints Used:**
|
||||
- ✅ `/system/sites/{id}/import/` (POST) - Full import
|
||||
- ✅ `/system/sites/{id}/sync/` (POST) - Incremental sync
|
||||
|
||||
**Features:**
|
||||
- ✅ Automatic daily incremental sync
|
||||
- ✅ Automatic weekly full scan (throttled)
|
||||
- ✅ Manual trigger available via settings page
|
||||
|
||||
---
|
||||
|
||||
### 4.3 Track Semantic Map Metadata
|
||||
**Status:** ✅ **IMPLEMENTED**
|
||||
|
||||
**Location:**
|
||||
- `data/semantic-mapping.php`:
|
||||
- `igny8_map_site_to_semantic_strategy()` (lines 24-101)
|
||||
|
||||
**API Endpoints Used:**
|
||||
- ✅ `/planner/sites/{id}/semantic-map/` (POST)
|
||||
|
||||
**Tracking:**
|
||||
- `data/site-collection.php` (lines 526-531):
|
||||
- ✅ Stores `igny8_last_semantic_map` timestamp
|
||||
- ✅ Stores `igny8_last_semantic_map_summary` (sectors count, keywords count)
|
||||
|
||||
**Display:**
|
||||
- `admin/settings.php` (lines 171-187): Shows semantic map summary in diagnostics
|
||||
|
||||
---
|
||||
|
||||
## Phase 5 – Planner, Linker, Optimizer Hooks ❌ **NOT IMPLEMENTED**
|
||||
|
||||
### 5.1 Display Planner Briefs/Tasks Per Post
|
||||
**Status:** ❌ **NOT IMPLEMENTED**
|
||||
|
||||
**Required:**
|
||||
- Display Planner briefs/tasks per post in editor
|
||||
- Allow "request refresh" actions
|
||||
|
||||
**API Endpoints (from plan):**
|
||||
- `/planner/tasks/{id}/brief/` (GET)
|
||||
- `/planner/tasks/{id}/refresh/` (POST)
|
||||
|
||||
**Current State:**
|
||||
- ✅ Briefs are cached in post meta (`_igny8_task_brief`)
|
||||
- ❌ No UI to display briefs in post editor
|
||||
- ❌ No "request refresh" action/button
|
||||
- ❌ No Planner task display per post
|
||||
|
||||
**Recommendation:** Implement:
|
||||
1. Meta box in post editor showing cached brief
|
||||
2. Button to fetch fresh brief from `/planner/tasks/{id}/brief/`
|
||||
3. Button to trigger refresh via `/planner/tasks/{id}/refresh/`
|
||||
|
||||
---
|
||||
|
||||
### 5.2 Export WP Link Graph During Site Scans
|
||||
**Status:** ❌ **NOT IMPLEMENTED**
|
||||
|
||||
**Required:**
|
||||
- Export WordPress internal link graph during site scans
|
||||
- Send to `/linker/link-map/` (POST)
|
||||
|
||||
**Current State:**
|
||||
- ❌ No link graph extraction
|
||||
- ❌ No link graph export to IGNY8
|
||||
- ❌ Not integrated into site scan process
|
||||
|
||||
**Recommendation:** Implement:
|
||||
1. Function to extract internal links from posts (source_url, target_url, anchor)
|
||||
2. Include link graph in `igny8_collect_site_data()` output
|
||||
3. Send link graph to `/linker/link-map/` during full site scans
|
||||
|
||||
---
|
||||
|
||||
### 5.3 Accept Link Recommendations Via Webhook
|
||||
**Status:** ❌ **NOT IMPLEMENTED** (This is Phase 6)
|
||||
|
||||
**Note:** This requirement is listed in Phase 5 but implementation belongs to Phase 6 (Webhooks & Remote Control). The REST endpoint `/wp-json/igny8/v1/event` is not yet implemented.
|
||||
|
||||
**Required (for Phase 6):**
|
||||
- REST endpoint `/wp-json/igny8/v1/event` with shared secret
|
||||
- Handler for `action: "insert_link"` events
|
||||
- Queue link insertions
|
||||
|
||||
---
|
||||
|
||||
### 5.4 Expose Optimizer Triggers
|
||||
**Status:** ❌ **NOT IMPLEMENTED**
|
||||
|
||||
**Required:**
|
||||
- Expose optimizer triggers (metrics requests, re-optimization)
|
||||
- Endpoints: `/optimizer/jobs/` (POST), `/optimizer/jobs/{id}/` (GET)
|
||||
|
||||
**Current State:**
|
||||
- ✅ Optimizer module is listed in available modules
|
||||
- ❌ No functions to create optimizer jobs
|
||||
- ❌ No functions to fetch optimizer job status
|
||||
- ❌ No UI to trigger optimizer actions
|
||||
|
||||
**Recommendation:** Implement:
|
||||
1. Function `igny8_create_optimizer_job($post_id, $job_type, $priority)`
|
||||
2. Function `igny8_get_optimizer_job_status($job_id)`
|
||||
3. UI in post editor or settings to trigger optimization
|
||||
4. Display optimizer scores/recommendations
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
| Phase | Status | Completion |
|
||||
|-------|--------|------------|
|
||||
| **Phase 1** | ✅ Complete | 100% |
|
||||
| **Phase 2** | ✅ Complete | 100% |
|
||||
| **Phase 3** | ⚠️ Mostly Complete | 90% (missing detailed queue visualization) |
|
||||
| **Phase 4** | ✅ Complete | 100% |
|
||||
| **Phase 5** | ❌ Not Implemented | 0% |
|
||||
|
||||
**Overall Completion (Phases 1-5):** ~78%
|
||||
|
||||
---
|
||||
|
||||
## Recommendations
|
||||
|
||||
### High Priority (Phase 5)
|
||||
1. **Implement Planner briefs display** (5.1)
|
||||
- Add meta box in post editor
|
||||
- Add refresh action buttons
|
||||
- Display cached briefs
|
||||
|
||||
2. **Implement link graph export** (5.2)
|
||||
- Extract internal links from posts
|
||||
- Include in site scan data
|
||||
- Send to `/linker/link-map/` endpoint
|
||||
|
||||
3. **Implement optimizer triggers** (5.4)
|
||||
- Create optimizer job functions
|
||||
- Add UI to trigger optimization
|
||||
- Display optimizer results
|
||||
|
||||
### Medium Priority
|
||||
4. **Enhance queue visualization** (3.4)
|
||||
- Add detailed queue status table
|
||||
- Show failure logs
|
||||
- Add retry mechanisms
|
||||
|
||||
### Low Priority
|
||||
5. **Phase 6 preparation** (5.3)
|
||||
- Plan webhook endpoint structure
|
||||
- Design shared secret authentication
|
||||
- Plan link insertion queue system
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
|
||||
- All implemented phases follow the plan specifications correctly
|
||||
- API endpoints are used as specified in the plan
|
||||
- Module toggles and post type filters are respected throughout
|
||||
- Cron scheduling is properly configured
|
||||
- Token refresh and credential security are properly implemented
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": ".."
|
||||
},
|
||||
{
|
||||
"path": "../../../igny8-app/igny8"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
# IGNY8 SaaS – Missing / Pending API Endpoints
|
||||
|
||||
These endpoints are referenced in the WordPress bridge plan but are not currently available (or confirmed) in the SaaS API set. The SaaS team should implement or confirm them so the bridge can automate end-to-end flows.
|
||||
|
||||
| ID | Purpose | Proposed Endpoint | Method | Payload / Notes |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| M1 | Pull recommended WordPress integration settings (post types, module toggles) after authentication | `/system/sites/{id}/settings/` | GET | Returns flags such as `enable_products`, `allow_wp_edits`, feature rollouts. |
|
||||
| M2 | Lightweight health check for diagnostics panel | `/system/ping/` | GET | Responds with `{success:true, time, version}` so WP can show “connected” without hitting data-heavy routes. |
|
||||
| M3 | Retrieve writer brief/outlines linked to a task | `/writer/tasks/{id}/brief/` | GET | Should return structured brief content, tone, keywords, outline items. |
|
||||
| M4 | Trigger planner refresh for a post/cluster from WP | `/planner/tasks/{id}/refresh/` | POST | Body includes `wordpress_post_id`, reason (`"reoptimize"`), optional notes. |
|
||||
| M5 | Upload WordPress internal link graph for Linker module | `/linker/link-map/` | POST | Payload: list of `{source_url, target_url, anchor}` records plus site ID. Should accept batches. |
|
||||
| M6 | Push Linker recommendations back to WordPress | **Webhook to WP** | POST | SaaS calls WP endpoint with `{action:"insert_link", post_id, anchor, target_url}`. Requires ability to configure per-site shared secret. |
|
||||
| M7 | Create Optimizer job (e.g., re-audit a post) initiated from WP | `/optimizer/jobs/` | POST | Body: `{post_id, task_id, job_type, priority}` returning job ID + status. |
|
||||
| M8 | Fetch Optimizer job status/results for UI | `/optimizer/jobs/{id}/` | GET | Response should include `status`, `score_changes`, `recommendations`. |
|
||||
| M9 | Report per-site sync status back to WP for monitoring | `/system/sites/{id}/status/` | GET | Returns last processed webhook, queued jobs, outstanding recommendations. |
|
||||
| M10 | Notify WP when a new Writer task is ready (to avoid polling) | **Webhook to WP** | POST | Payload: `{task_id, cluster_id, title, status}`; WP responds 200 and enqueues ingestion. Provide retry/backoff headers. |
|
||||
|
||||
## Webhook Security Requirements
|
||||
1. SaaS must send `X-IGNY8-Signature` (HMAC-SHA256 over body using shared secret).
|
||||
2. Includes `X-IGNY8-Timestamp` to prevent replay.
|
||||
3. WordPress bridge will validate signature before enqueuing actions.
|
||||
|
||||
## Next Steps for SaaS Team
|
||||
1. Confirm which endpoints already exist (rename if different) and document response schemas.
|
||||
2. Implement missing endpoints/webhooks and expose them via API documentation.
|
||||
3. Provide sample payloads + Postman collection so WP bridge devs can test without full app context.
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
# IGNY8 WordPress Bridge – Implementation Plan
|
||||
|
||||
## Objectives
|
||||
- Keep WordPress as a lightweight publishing edge while IGNY8 SaaS remains the control plane.
|
||||
- Automate all sync flows once the site connects (no repeated manual buttons).
|
||||
- Provide hooks for Sites, Planner, Writer, Linker, and Optimizer modules using the endpoints defined in `WORDPRESS-PLUGIN-INTEGRATION.md`.
|
||||
|
||||
## Assumptions
|
||||
1. Existing IGNY8 REST API endpoints (auth, sites, planner, writer) follow the unified response format.
|
||||
2. WordPress environment runs PHP ≥ 7.4 with REST API enabled and (optionally) WooCommerce.
|
||||
3. SaaS app can call back into WordPress via authenticated REST endpoints/webhooks.
|
||||
|
||||
## Work Breakdown
|
||||
|
||||
### Phase 1 – Foundations
|
||||
| Step | WordPress Tasks | IGNY8 API Usage |
|
||||
| --- | --- | --- |
|
||||
| 1.1 | Harden credential storage (option encryption, refresh tracking) | `/auth/login/`, `/auth/refresh/` |
|
||||
| 1.2 | Build diagnostics card (ping, last sync, token age) | `/system/ping/` (or `/planner/keywords/?page_size=1` as health check) |
|
||||
| 1.3 | Add “control model” + post-type/Woo toggles on settings page | `GET /system/sites/{id}/` (to pull recommended defaults) |
|
||||
|
||||
### Phase 2 – Automatic Taxonomy & Keyword Sync
|
||||
| Step | WordPress Tasks | IGNY8 API Usage |
|
||||
| --- | --- | --- |
|
||||
| 2.1 | Scheduled fetch of sectors/clusters; populate `igny8_sectors`, `igny8_clusters` | `/planner/sectors/`, `/planner/clusters/` |
|
||||
| 2.2 | Pull Planner keywords per cluster and store `_igny8_keyword_ids` meta | `/planner/keywords/?cluster_id=` |
|
||||
| 2.3 | Render read-only badges in list tables and editor side panels | — (local data) |
|
||||
|
||||
### Phase 3 – Writer Module Integration
|
||||
| Step | WordPress Tasks | IGNY8 API Usage |
|
||||
| --- | --- | --- |
|
||||
| 3.1 | Cron or webhook to fetch new/updated tasks and create posts | `/writer/tasks/?site_id=&status=` |
|
||||
| 3.2 | Hook `save_post` / `transition_post_status` to push status & URLs | `/writer/tasks/{id}/` (PUT) |
|
||||
| 3.3 | Store briefs/outlines on post meta for editors | `/writer/tasks/{id}/brief/` |
|
||||
| 3.4 | Queue visualization (counts, failures) in settings page | — (local logs) |
|
||||
|
||||
### Phase 4 – Sites Module & Semantic Mapping
|
||||
| Step | WordPress Tasks | IGNY8 API Usage |
|
||||
| --- | --- | --- |
|
||||
| 4.1 | Implement incremental + full site-data collectors honoring toggles | — (WP data) |
|
||||
| 4.2 | Schedule automatic submission of site payloads | `/system/sites/{id}/import/` (full) |
|
||||
| 4.3 | Track semantic map metadata locally for reporting | `/planner/sites/{id}/semantic-map/` |
|
||||
|
||||
### Phase 5 – Planner, Linker, Optimizer Hooks
|
||||
| Step | WordPress Tasks | IGNY8 API Usage |
|
||||
| --- | --- | --- |
|
||||
| 5.1 | Display Planner briefs/tasks per post; allow “request refresh” actions | `/planner/tasks/{id}/brief/`, `/planner/tasks/{id}/refresh/` |
|
||||
| 5.2 | Export WP link graph during site scans | `/linker/link-map/` (POST) |
|
||||
| 5.3 | Accept link recommendations via webhook and queue insertions | SaaS → WP REST endpoint (new) |
|
||||
| 5.4 | Expose optimizer triggers (metrics requests, re-optimization) | `/optimizer/jobs/` (POST), `/optimizer/jobs/{id}/` |
|
||||
|
||||
### Phase 6 – Webhooks & Remote Control
|
||||
| Step | WordPress Tasks | IGNY8 API Usage |
|
||||
| --- | --- | --- |
|
||||
| 6.1 | Register REST routes (`/wp-json/igny8/v1/event`) with shared secret | — (incoming) |
|
||||
| 6.2 | Handle SaaS events: task published, link recommendation, optimizer request | SaaS posts payloads; responses follow unified JSON |
|
||||
| 6.3 | Persist webhook activity logs (custom table or option) | — |
|
||||
|
||||
### Phase 7 – Automation & Monitoring
|
||||
| Step | WordPress Tasks | IGNY8 API Usage |
|
||||
| --- | --- | --- |
|
||||
| 7.1 | WP-CLI commands (`wp igny8 sync posts`, `sync site`) to mirror SaaS automation | Same endpoints as UI |
|
||||
| 7.2 | Admin notices + status widget for sync health (error counts, tokens) | `/system/sites/{id}/status/` (if available) |
|
||||
| 7.3 | Structured logging (maybe `wp_igny8_logs` table) for audits | — |
|
||||
|
||||
## Deliverables
|
||||
1. Updated plugin code implementing all phases.
|
||||
2. Settings UI redesign with automatic operations (no manual sync buttons post-setup).
|
||||
3. REST endpoints + cron jobs documented for SaaS team.
|
||||
4. Test plan covering happy path, token expiry, webhook retries.
|
||||
|
||||
## Timeline (Rough)
|
||||
| Phase | Est. Effort | Notes |
|
||||
| --- | --- | --- |
|
||||
| 1 | 2–3 days | Mostly admin UI + auth refactor |
|
||||
| 2 | 3 days | Taxonomies + keywords + scheduling |
|
||||
| 3 | 3–4 days | Writer hooks + automatic task ingestion |
|
||||
| 4 | 2 days | Site data automation |
|
||||
| 5 | 4 days | Requires close coordination with SaaS teams |
|
||||
| 6 | 2 days | REST/webhook security |
|
||||
| 7 | 1–2 days | Tooling & monitoring |
|
||||
|
||||
Effort assumes endpoints already exist; see `docs/missing-saas-api-endpoints.md` for gaps.
|
||||
|
||||
Reference in New Issue
Block a user