temproary docs uplaoded
This commit is contained in:
142
v2/Live Docs on Server/igny8-app-docs/60-PLUGINS/INDEX.md
Normal file
142
v2/Live Docs on Server/igny8-app-docs/60-PLUGINS/INDEX.md
Normal file
@@ -0,0 +1,142 @@
|
||||
# Plugin Management Documentation
|
||||
|
||||
**Last Updated:** January 20, 2026
|
||||
**Version:** 1.8.4
|
||||
**Status:** Production
|
||||
|
||||
This section covers plugin distribution, management, and integration from the IGNY8 app perspective.
|
||||
|
||||
## Contents
|
||||
|
||||
1. [WORDPRESS-INTEGRATION.md](WORDPRESS-INTEGRATION.md) - Complete guide for WordPress integration management
|
||||
2. [PLUGIN-UPDATE-WORKFLOW.md](PLUGIN-UPDATE-WORKFLOW.md) - How plugin updates work and post-update checklist
|
||||
|
||||
## Overview
|
||||
|
||||
The IGNY8 plugin distribution system provides a comprehensive infrastructure for managing, distributing, and updating plugins across multiple platforms (WordPress, Shopify, custom sites). The system includes automated versioning, security features, update mechanisms, and monitoring.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### API Endpoints (Production)
|
||||
|
||||
| Endpoint | Purpose | Method |
|
||||
|----------|---------|--------|
|
||||
| `https://api.igny8.com/api/plugins/igny8-wp-bridge/download/` | Download latest plugin ZIP | GET |
|
||||
| `https://api.igny8.com/api/plugins/igny8-wp-bridge/check-update/` | Check for updates (called by WP plugin) | POST |
|
||||
| `https://api.igny8.com/api/plugins/igny8-wp-bridge/info/` | Get plugin metadata | GET |
|
||||
| `https://api.igny8.com/api/plugins/igny8-wp-bridge/register/` | Register new installation | POST |
|
||||
| `https://api.igny8.com/api/plugins/igny8-wp-bridge/health-check/` | Plugin health check | POST |
|
||||
|
||||
### Key Directories
|
||||
|
||||
| Path | Purpose |
|
||||
|------|---------|
|
||||
| `/data/app/igny8/plugins/wordpress/source/igny8-wp-bridge/` | WordPress plugin source code |
|
||||
| `/data/app/igny8/plugins/wordpress/dist/` | Distribution ZIP files |
|
||||
| `/data/app/igny8/plugins/shopify/` | Shopify integration (planned) |
|
||||
| `/data/app/igny8/plugins/custom-site/` | Custom site integration (planned) |
|
||||
| `/data/app/igny8/backend/igny8_core/plugins/` | Django plugin management app |
|
||||
|
||||
### Database Models
|
||||
|
||||
- `Plugin` - Plugin registry (name, slug, platform, status)
|
||||
- `PluginVersion` - Version tracking with file info, checksums, changelog
|
||||
- `PluginInstallation` - Track installations per site with version info
|
||||
- `PluginDownload` - Download analytics and tracking
|
||||
|
||||
### Current Plugin Status
|
||||
|
||||
| Platform | Plugin Name | Current Version | Status |
|
||||
|----------|-------------|-----------------|--------|
|
||||
| WordPress | IGNY8 WP Bridge | 1.5.1 | Production |
|
||||
| Shopify | IGNY8 Shopify | - | Infrastructure Ready |
|
||||
| Custom | IGNY8 Bridge | - | Infrastructure Ready |
|
||||
|
||||
### WordPress Plugin Admin Pages (v1.5.1)
|
||||
|
||||
| Page | Purpose |
|
||||
|------|---------|
|
||||
| Dashboard | Connection status, Site ID, masked API key, content stats |
|
||||
| Settings | Post types, default post status, taxonomies, sync toggle |
|
||||
| Logs | Webhook activity with timestamps, event types, status |
|
||||
|
||||
## System Features
|
||||
|
||||
### Distribution System
|
||||
- Automated ZIP package generation
|
||||
- Version-based file management
|
||||
- MD5 and SHA256 checksums
|
||||
- Signed download URLs
|
||||
- Rate limiting and security
|
||||
|
||||
### Update Mechanism
|
||||
- WordPress auto-update via `pre_set_site_transient_update_plugins` hook
|
||||
- Version comparison and update notifications
|
||||
- Changelog display
|
||||
- Compatibility checks
|
||||
|
||||
### Monitoring & Analytics
|
||||
- Installation tracking per site
|
||||
- Download counts and analytics
|
||||
- Health check endpoints
|
||||
- Version distribution tracking
|
||||
- Error logging and monitoring
|
||||
|
||||
### Security Features
|
||||
- Signed URLs with expiration
|
||||
- Checksum verification (MD5/SHA256)
|
||||
- Rate limiting per IP/site
|
||||
- API authentication for sensitive endpoints
|
||||
- Production environment protection
|
||||
|
||||
## Integration Flow
|
||||
|
||||
```
|
||||
Developer → Update Source Code → Create PluginVersion in Admin
|
||||
↓
|
||||
Automatic: Build ZIP, Calculate Checksums, Store in /dist/
|
||||
↓
|
||||
WordPress Site → Check for Updates → Download via API
|
||||
↓
|
||||
Install/Update → Register Installation → Health Check
|
||||
```
|
||||
|
||||
## Version Progression (Last 20 Commits)
|
||||
|
||||
**WordPress Plugin Versions:**
|
||||
- v1.5.1 - Admin UI consolidation (6→3 pages), header fixes
|
||||
- v1.5.0 - Authentication simplification (Site.wp_api_key as single source)
|
||||
- v1.3.3 - Template design improvements, image layout fixes
|
||||
- v1.3.2 - Template fixes in app and plugin
|
||||
- v1.3.1 - WordPress plugin updates
|
||||
- v1.3.0 - Initial distribution system release
|
||||
|
||||
**Infrastructure Updates:**
|
||||
- Plugin distribution system implemented (v1.7.0)
|
||||
- Authentication simplified to Site.wp_api_key (single source of truth)
|
||||
- SiteIntegration model retained for sync tracking (not auth)
|
||||
- Database models for multi-platform support
|
||||
- API endpoints for lifecycle management
|
||||
- Automated packaging and versioning
|
||||
- Security and monitoring features
|
||||
|
||||
## Documentation Structure
|
||||
|
||||
### App-Side Documentation (This Folder)
|
||||
- Plugin distribution infrastructure
|
||||
- API endpoint documentation
|
||||
- Database models and admin interface
|
||||
- Integration workflows
|
||||
- Security and monitoring
|
||||
|
||||
### Plugin-Side Documentation
|
||||
See `/plugins/wordpress/source/igny8-wp-bridge/docs/` for:
|
||||
- Plugin PHP code and functions
|
||||
- WordPress hooks and filters
|
||||
- Template system
|
||||
- Content publishing flow
|
||||
- Plugin-specific configuration
|
||||
|
||||
---
|
||||
|
||||
**Note**: For internal plugin details (PHP functions, hooks, code structure), see the documentation inside the plugin directory at `/plugins/wordpress/source/igny8-wp-bridge/docs/`.
|
||||
@@ -0,0 +1,692 @@
|
||||
# Plugin Update Workflow
|
||||
|
||||
**Last Updated:** January 20, 2026
|
||||
**Version:** 1.8.4
|
||||
**Status:** Production
|
||||
**Scope:** How to release plugin updates and what happens automatically vs manually
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Quick Start: Simplified Release Process
|
||||
|
||||
The plugin release process has been **simplified** to require only 3 fields:
|
||||
|
||||
1. **Version** (e.g., 1.3.3)
|
||||
2. **Changelog** (what's new)
|
||||
3. **Status** (draft → released)
|
||||
|
||||
All other fields are either:
|
||||
- ✅ Auto-filled from previous version
|
||||
- ✅ Auto-generated on release (file path, size, checksum)
|
||||
- ✅ Auto-calculated (version code)
|
||||
|
||||
**Release in 3 clicks:**
|
||||
```
|
||||
Django Admin → Add Plugin Version → Enter 3 fields → Save → Change status to 'released'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Recent Release History (v1.7.0)
|
||||
|
||||
### WordPress Plugin Progression
|
||||
|
||||
| Version | Date | Type | Key Changes |
|
||||
|---------|------|------|-------------|
|
||||
| 1.5.1 | Jan 10, 2026 | Minor | Admin UI consolidation: 6→3 pages (Dashboard, Settings, Logs), header alignment fixes |
|
||||
| 1.5.0 | Jan 10, 2026 | Minor | Authentication simplification: Site.wp_api_key as single source of truth |
|
||||
| 1.3.3 | Jan 10, 2026 | Patch | Template design: Square image grid fixes, landscape image positioning, direct border-radius/shadow on images without captions |
|
||||
| 1.3.2 | Jan 9, 2026 | Patch | Template fixes in app and plugin, image layout improvements |
|
||||
| 1.3.1 | Jan 9, 2026 | Patch | WordPress plugin versioning updates |
|
||||
| 1.3.0 | Jan 8, 2026 | Minor | Initial distribution system release, automated updates |
|
||||
|
||||
### Distribution System Status
|
||||
|
||||
- ✅ Automated ZIP generation: Operational
|
||||
- ✅ Checksum calculation: MD5 + SHA256
|
||||
- ✅ WordPress auto-update: Active
|
||||
- ✅ Health checks: Implemented
|
||||
- ✅ Installation tracking: Complete
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [Update Workflow Overview](#1-update-workflow-overview)
|
||||
2. [What Happens Automatically](#2-what-happens-automatically)
|
||||
3. [What Requires Manual Action](#3-what-requires-manual-action)
|
||||
4. [Step-by-Step: Releasing a New Version](#4-step-by-step-releasing-a-new-version)
|
||||
5. [Post-Update Verification Checklist](#5-post-update-verification-checklist)
|
||||
6. [Version Numbering](#6-version-numbering)
|
||||
7. [Rollback Procedure](#7-rollback-procedure)
|
||||
8. [Emergency Updates](#8-emergency-updates)
|
||||
9. [Recent Updates & Lessons Learned](#9-recent-updates--lessons-learned)
|
||||
|
||||
---
|
||||
|
||||
## 1. Update Workflow Overview
|
||||
|
||||
### The Big Picture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ Plugin Update Lifecycle │
|
||||
├─────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌──────────────┐ │
|
||||
│ │ 1. DEVELOP │ Make changes to plugin source code │
|
||||
│ │ ↓ │ Location: /plugins/wordpress/source/igny8-wp-bridge/ │
|
||||
│ └──────────────┘ │
|
||||
│ │
|
||||
│ ┌──────────────┐ │
|
||||
│ │ 2. VERSION │ Update version in PHP header + constant │
|
||||
│ │ ↓ │ File: igny8-bridge.php │
|
||||
│ └──────────────┘ │
|
||||
│ │
|
||||
│ ┌──────────────┐ │
|
||||
│ │ 3. RELEASE │ Create PluginVersion in Django admin │
|
||||
│ │ ↓ │ Set status = "released" or "update_ready" │
|
||||
│ └──────────────┘ │
|
||||
│ │
|
||||
│ ┌──────────────┐ │
|
||||
│ │ 4. AUTO-BUILD│ ✅ AUTOMATIC: ZIP created, checksums calculated │
|
||||
│ │ ↓ │ Signal handler builds package on status change │
|
||||
│ └──────────────┘ │
|
||||
│ │
|
||||
│ ┌──────────────┐ │
|
||||
│ │ 5. VERIFY │ Test download, check contents, verify endpoints │
|
||||
│ │ ↓ │ See verification checklist below │
|
||||
│ └──────────────┘ │
|
||||
│ │
|
||||
│ ┌──────────────┐ │
|
||||
│ │ 6. AVAILABLE │ WordPress sites can now see and install update │
|
||||
│ │ │ Users update via WP admin or auto-update │
|
||||
│ └──────────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. What Happens Automatically
|
||||
|
||||
When you change a `PluginVersion` status to `released` or `update_ready`, the following happens **automatically** via Django signals:
|
||||
|
||||
### ✅ Automatic Actions
|
||||
|
||||
| Action | Details |
|
||||
|--------|---------|
|
||||
| **ZIP Creation** | Source files packaged into distribution ZIP |
|
||||
| **Version Update** | Version number updated in PHP files inside ZIP |
|
||||
| **File Cleanup** | Tests, .git, __pycache__, .bak files removed from ZIP |
|
||||
| **Checksum Calculation** | SHA256 hash generated |
|
||||
| **File Size Recording** | Byte count stored in database |
|
||||
| **File Path Update** | `file_path` field populated |
|
||||
| **Released Date** | `released_at` timestamp set |
|
||||
| **Symlink Update** | `*-latest.zip` symlink updated |
|
||||
|
||||
### How It Works (Signal Handler)
|
||||
|
||||
```python
|
||||
# backend/igny8_core/plugins/signals.py
|
||||
|
||||
@receiver(pre_save, sender=PluginVersion)
|
||||
def auto_build_plugin_on_release(sender, instance, **kwargs):
|
||||
"""
|
||||
Triggered when PluginVersion.status changes to:
|
||||
- 'released'
|
||||
- 'update_ready'
|
||||
|
||||
Actions:
|
||||
1. Calls create_plugin_zip() utility
|
||||
2. Updates instance.file_path
|
||||
3. Updates instance.file_size
|
||||
4. Updates instance.checksum
|
||||
5. Sets instance.released_at
|
||||
"""
|
||||
```
|
||||
|
||||
### What WordPress Sites See
|
||||
|
||||
Once released, the `check-update` API returns:
|
||||
|
||||
```json
|
||||
{
|
||||
"update_available": true,
|
||||
"latest_version": "1.2.0",
|
||||
"download_url": "https://api.igny8.com/api/plugins/igny8-wp-bridge/download/",
|
||||
"changelog": "Your changelog here"
|
||||
}
|
||||
```
|
||||
|
||||
WordPress will show "Update Available" in:
|
||||
- Plugins page
|
||||
- Dashboard → Updates
|
||||
- Admin bar (if enabled)
|
||||
|
||||
---
|
||||
|
||||
## 3. What Requires Manual Action
|
||||
|
||||
### ❌ Manual Steps Required
|
||||
|
||||
| Action | When | How |
|
||||
|--------|------|-----|
|
||||
| **Update Source Version** | Before release | Edit `igny8-bridge.php` header |
|
||||
| **Create PluginVersion Record** | Each release | Django admin: just enter version, changelog, status |
|
||||
| **Verify After Release** | After status change | Run verification checklist |
|
||||
| **Mark Old Version Deprecated** | After successful release | Change old version status |
|
||||
|
||||
**Note:** The form is simplified - most fields auto-fill from previous version or are auto-generated.
|
||||
|
||||
### Source Version Update Locations
|
||||
|
||||
When releasing a new version, update these in the source:
|
||||
|
||||
**File:** `/plugins/wordpress/source/igny8-wp-bridge/igny8-bridge.php`
|
||||
|
||||
```php
|
||||
/**
|
||||
* Plugin Name: IGNY8 WordPress Bridge
|
||||
* Version: 1.2.0 ← UPDATE THIS
|
||||
*/
|
||||
|
||||
define('IGNY8_BRIDGE_VERSION', '1.2.0'); ← AND THIS
|
||||
```
|
||||
|
||||
**Note:** The ZIP build process also updates these, but it's good practice to keep source in sync.
|
||||
|
||||
---
|
||||
|
||||
## 4. Step-by-Step: Releasing a New Version
|
||||
|
||||
### The Simplified Process
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ Simplified Version Release (3 Required Fields) │
|
||||
├─────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ Django Admin → Add Plugin Version │
|
||||
│ │
|
||||
│ ┌────────────────────────────────────────────────────────────────┐ │
|
||||
│ │ Plugin: [IGNY8 WordPress Bridge ▼] ← Select plugin │ │
|
||||
│ │ Version: [1.2.0] ← New version │ │
|
||||
│ │ Status: [draft ▼] ← Start as draft │ │
|
||||
│ │ Changelog: [Bug fixes and improvements] ← What's new │ │
|
||||
│ │ │ │
|
||||
│ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │
|
||||
│ │ Everything below is AUTO-FILLED or AUTO-GENERATED: │ │
|
||||
│ │ │ │
|
||||
│ │ Min API Version: 1.0 (from previous version) │ │
|
||||
│ │ Min PHP Version: 7.4 (from previous version) │ │
|
||||
│ │ File Path: (empty) → Auto-generated on release │ │
|
||||
│ │ File Size: (empty) → Auto-calculated on release │ │
|
||||
│ │ Checksum: (empty) → Auto-calculated on release │ │
|
||||
│ │ Version Code: (empty) → Auto-calculated from version │ │
|
||||
│ └────────────────────────────────────────────────────────────────┘ │
|
||||
│ │
|
||||
│ Click [Save] → Status changes to 'released' → ZIP builds automatically │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Step 1: Make Code Changes
|
||||
|
||||
```bash
|
||||
cd /data/app/igny8/plugins/wordpress/source/igny8-wp-bridge/
|
||||
|
||||
# Make your changes to PHP files
|
||||
# Test locally if possible
|
||||
```
|
||||
|
||||
### Step 2: Update Version Number
|
||||
|
||||
Edit `igny8-bridge.php`:
|
||||
|
||||
```php
|
||||
/**
|
||||
* Plugin Name: IGNY8 WordPress Bridge
|
||||
* Version: 1.2.0 ← New version
|
||||
*/
|
||||
|
||||
define('IGNY8_BRIDGE_VERSION', '1.2.0'); ← Match here
|
||||
```
|
||||
|
||||
### Step 3: Create PluginVersion in Django Admin
|
||||
|
||||
1. Go to: `https://api.igny8.com/backend/`
|
||||
2. Navigate to: **Plugin Distribution** → **Plugin Versions**
|
||||
3. Click **Add Plugin Version**
|
||||
4. Fill in **ONLY** these required fields:
|
||||
- **Plugin:** IGNY8 WordPress Bridge
|
||||
- **Version:** 1.2.0
|
||||
- **Status:** draft (initially)
|
||||
- **Changelog:** Describe changes
|
||||
5. Click **Save**
|
||||
|
||||
**Note:** All other fields are auto-filled:
|
||||
- `min_api_version`, `min_platform_version`, `min_php_version` → Copied from previous version
|
||||
- `file_path`, `file_size`, `checksum` → Auto-generated when you release
|
||||
- `version_code` → Auto-calculated from version number
|
||||
|
||||
### Step 4: Release the Version
|
||||
|
||||
**Option A: Release via Status Change**
|
||||
|
||||
1. Edit the PluginVersion you just created
|
||||
2. Change **Status** to `released`
|
||||
3. Click **Save**
|
||||
|
||||
**Option B: Release via Bulk Action**
|
||||
|
||||
1. Select the version(s) in the list
|
||||
2. Choose **Actions** → **✅ Release selected versions**
|
||||
3. Click **Go**
|
||||
|
||||
**What happens:** Signal triggers auto-build → ZIP created → database updated with file info
|
||||
|
||||
**Note:** You can also use the action **📢 Mark as update ready** to immediately notify WordPress sites.
|
||||
|
||||
### Step 5: Verify Release
|
||||
|
||||
Run the [verification checklist](#5-post-update-verification-checklist) below.
|
||||
|
||||
### Step 6: Deprecate Old Version (Optional)
|
||||
|
||||
1. Find the previous version in Django admin
|
||||
2. Change **Status** to `deprecated`
|
||||
3. Save
|
||||
|
||||
---
|
||||
|
||||
## 5. Post-Update Verification Checklist
|
||||
|
||||
### Quick Verification Script
|
||||
|
||||
Run this single command to verify everything:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Complete Plugin Release Verification Script
|
||||
# Usage: Save as verify-plugin.sh and run: bash verify-plugin.sh 1.1.2
|
||||
|
||||
VERSION=${1:-"latest"}
|
||||
PLUGIN_SLUG="igny8-wp-bridge"
|
||||
|
||||
echo "=========================================="
|
||||
echo "Plugin Release Verification: v${VERSION}"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# 1. Check ZIP file exists
|
||||
echo "1. Checking ZIP file..."
|
||||
if [ "$VERSION" = "latest" ]; then
|
||||
ls -lh /data/app/igny8/plugins/wordpress/dist/${PLUGIN_SLUG}-latest.zip 2>/dev/null && echo " ✓ Latest ZIP exists" || echo " ✗ Latest ZIP not found"
|
||||
else
|
||||
ls -lh /data/app/igny8/plugins/wordpress/dist/${PLUGIN_SLUG}-v${VERSION}.zip 2>/dev/null && echo " ✓ ZIP v${VERSION} exists" || echo " ✗ ZIP v${VERSION} not found"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 2. Check symlink
|
||||
echo "2. Checking symlink..."
|
||||
ls -la /data/app/igny8/plugins/wordpress/dist/${PLUGIN_SLUG}-latest.zip | grep -q "^l" && echo " ✓ Symlink valid" || echo " ✗ Symlink missing"
|
||||
echo ""
|
||||
|
||||
# 3. Test download endpoint
|
||||
echo "3. Testing download endpoint..."
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://api.igny8.com/api/plugins/${PLUGIN_SLUG}/download/)
|
||||
FILE_SIZE=$(curl -s -o /dev/null -w "%{size_download}" https://api.igny8.com/api/plugins/${PLUGIN_SLUG}/download/)
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
echo " ✓ Download works: ${HTTP_CODE} - ${FILE_SIZE} bytes ($(( FILE_SIZE / 1024 )) KB)"
|
||||
else
|
||||
echo " ✗ Download failed: HTTP ${HTTP_CODE}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 4. Test check-update endpoint
|
||||
echo "4. Testing check-update endpoint..."
|
||||
UPDATE_RESPONSE=$(curl -s "https://api.igny8.com/api/plugins/${PLUGIN_SLUG}/check-update/?current_version=1.0.0")
|
||||
LATEST_VERSION=$(echo "$UPDATE_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin).get('latest_version', 'N/A'))" 2>/dev/null)
|
||||
if [ -n "$LATEST_VERSION" ] && [ "$LATEST_VERSION" != "N/A" ]; then
|
||||
echo " ✓ Check-update works: Latest version = $LATEST_VERSION"
|
||||
else
|
||||
echo " ✗ Check-update failed"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 5. Test info endpoint
|
||||
echo "5. Testing info endpoint..."
|
||||
INFO_RESPONSE=$(curl -s "https://api.igny8.com/api/plugins/${PLUGIN_SLUG}/info/")
|
||||
PLUGIN_NAME=$(echo "$INFO_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin).get('name', 'N/A'))" 2>/dev/null)
|
||||
if [ -n "$PLUGIN_NAME" ] && [ "$PLUGIN_NAME" != "N/A" ]; then
|
||||
echo " ✓ Info endpoint works: $PLUGIN_NAME"
|
||||
else
|
||||
echo " ✗ Info endpoint failed"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 6. Verify version in ZIP
|
||||
echo "6. Verifying version in ZIP..."
|
||||
if [ "$VERSION" != "latest" ]; then
|
||||
ZIP_VERSION=$(unzip -p /data/app/igny8/plugins/wordpress/dist/${PLUGIN_SLUG}-v${VERSION}.zip ${PLUGIN_SLUG}/igny8-bridge.php 2>/dev/null | grep -E "Version:" | head -1 | awk '{print $3}')
|
||||
if [ "$ZIP_VERSION" = "$VERSION" ]; then
|
||||
echo " ✓ ZIP version matches: $ZIP_VERSION"
|
||||
else
|
||||
echo " ✗ ZIP version mismatch: expected $VERSION, got $ZIP_VERSION"
|
||||
fi
|
||||
else
|
||||
echo " - Skipped (use specific version to check)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 7. Verify API URL
|
||||
echo "7. Verifying API URL in ZIP..."
|
||||
API_COUNT=$(unzip -p /data/app/igny8/plugins/wordpress/dist/${PLUGIN_SLUG}-latest.zip ${PLUGIN_SLUG}/igny8-bridge.php 2>/dev/null | grep -c "api.igny8.com")
|
||||
if [ "$API_COUNT" -gt 0 ]; then
|
||||
echo " ✓ API URL correct: api.igny8.com found (${API_COUNT} occurrences)"
|
||||
else
|
||||
echo " ✗ API URL incorrect: api.igny8.com not found"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 8. Check database
|
||||
echo "8. Checking database..."
|
||||
docker exec igny8_backend python manage.py shell -c "
|
||||
from igny8_core.plugins.models import Plugin, PluginVersion
|
||||
try:
|
||||
p = Plugin.objects.get(slug='${PLUGIN_SLUG}')
|
||||
v = p.get_latest_version()
|
||||
if v:
|
||||
print(f' ✓ Latest version: {v.version}')
|
||||
print(f' ✓ Status: {v.status}')
|
||||
print(f' ✓ File: {v.file_path}')
|
||||
print(f' ✓ Size: {v.file_size:,} bytes ({v.file_size/1024:.1f} KB)')
|
||||
print(f' ✓ Checksum: {v.checksum[:32]}...')
|
||||
else:
|
||||
print(' ✗ No released version found')
|
||||
except Exception as e:
|
||||
print(f' ✗ Error: {e}')
|
||||
" 2>/dev/null | grep -E "✓|✗"
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "Verification Complete"
|
||||
echo "=========================================="
|
||||
```
|
||||
|
||||
**Quick run (copy-paste):**
|
||||
|
||||
```bash
|
||||
# Verify latest version
|
||||
curl -s "https://api.igny8.com/api/plugins/igny8-wp-bridge/info/" | python3 -m json.tool && \
|
||||
curl -s "https://api.igny8.com/api/plugins/igny8-wp-bridge/check-update/?current_version=1.0.0" | python3 -m json.tool && \
|
||||
ls -lh /data/app/igny8/plugins/wordpress/dist/igny8-wp-bridge-latest.zip && \
|
||||
echo "✓ All endpoints working"
|
||||
```
|
||||
|
||||
### Database Verification
|
||||
|
||||
```bash
|
||||
# Check database has correct values
|
||||
docker exec igny8_backend python manage.py shell -c "
|
||||
from igny8_core.plugins.models import Plugin, PluginVersion
|
||||
p = Plugin.objects.get(slug='igny8-wp-bridge')
|
||||
v = p.get_latest_version()
|
||||
print(f'Version: {v.version}')
|
||||
print(f'Status: {v.status}')
|
||||
print(f'File path: {v.file_path}')
|
||||
print(f'File size: {v.file_size}')
|
||||
print(f'Checksum: {v.checksum[:32]}...')
|
||||
print(f'Released at: {v.released_at}')
|
||||
"
|
||||
```
|
||||
|
||||
### Expected Results
|
||||
|
||||
| Check | Expected |
|
||||
|-------|----------|
|
||||
| Download returns | 200 status, ~150-200KB |
|
||||
| check-update shows | `"latest_version": "1.2.0"` |
|
||||
| info shows | `"version": "1.2.0"` |
|
||||
| ZIP version header | `Version: 1.2.0` |
|
||||
| API URL | `api.igny8.com` (NOT app.igny8.com) |
|
||||
|
||||
### WordPress Verification (If Possible)
|
||||
|
||||
1. Go to a test WordPress site with plugin installed
|
||||
2. Navigate to **Dashboard** → **Updates** → **Check Again**
|
||||
3. Verify "IGNY8 WordPress Bridge" shows update available
|
||||
4. Click "View version details" → verify changelog appears
|
||||
5. Click "Update Now" → verify update completes successfully
|
||||
|
||||
---
|
||||
|
||||
## 6. Version Numbering
|
||||
|
||||
### Semantic Versioning
|
||||
|
||||
Format: `MAJOR.MINOR.PATCH` (e.g., 1.2.3)
|
||||
|
||||
| Part | When to Increment |
|
||||
|------|-------------------|
|
||||
| **MAJOR** | Breaking changes, incompatible API changes |
|
||||
| **MINOR** | New features, backwards compatible |
|
||||
| **PATCH** | Bug fixes, minor improvements |
|
||||
|
||||
### Version Code Calculation
|
||||
|
||||
Used for numeric comparison in database:
|
||||
|
||||
```
|
||||
1.0.0 → 10000
|
||||
1.0.1 → 10001
|
||||
1.2.0 → 10200
|
||||
1.2.3 → 10203
|
||||
2.0.0 → 20000
|
||||
```
|
||||
|
||||
Formula: `(MAJOR * 10000) + (MINOR * 100) + PATCH`
|
||||
|
||||
---
|
||||
|
||||
## 7. Rollback Procedure
|
||||
|
||||
### If Update Causes Issues
|
||||
|
||||
**Option 1: Quick Rollback via Database**
|
||||
|
||||
```bash
|
||||
# Make old version the "latest" by changing status
|
||||
docker exec igny8_backend python manage.py shell -c "
|
||||
from igny8_core.plugins.models import PluginVersion
|
||||
|
||||
# Demote new version
|
||||
new = PluginVersion.objects.get(plugin__slug='igny8-wp-bridge', version='1.2.0')
|
||||
new.status = 'deprecated'
|
||||
new.save()
|
||||
|
||||
# Promote old version back
|
||||
old = PluginVersion.objects.get(plugin__slug='igny8-wp-bridge', version='1.1.1')
|
||||
old.status = 'released'
|
||||
old.save()
|
||||
|
||||
print('Rollback complete')
|
||||
"
|
||||
```
|
||||
|
||||
**Option 2: Keep Old ZIP Files**
|
||||
|
||||
Old ZIP files are preserved in `dist/`. To serve an old version:
|
||||
|
||||
```bash
|
||||
# Update symlink to point to old version
|
||||
cd /data/app/igny8/plugins/wordpress/dist/
|
||||
ln -sf igny8-wp-bridge-v1.1.1.zip igny8-wp-bridge-latest.zip
|
||||
```
|
||||
|
||||
### Retention Policy
|
||||
|
||||
Keep at least 3 previous version ZIPs for emergency rollback:
|
||||
- Current release
|
||||
- Previous release
|
||||
- One before that
|
||||
|
||||
---
|
||||
|
||||
## 8. Emergency Updates
|
||||
|
||||
### For Critical Security Fixes
|
||||
|
||||
1. **Set `force_update = True`** on the new PluginVersion
|
||||
2. This flag signals WordPress sites that update is mandatory
|
||||
3. Sites with auto-updates enabled will update immediately
|
||||
|
||||
### Emergency Release Checklist
|
||||
|
||||
```bash
|
||||
# 1. Make the fix in source
|
||||
cd /data/app/igny8/plugins/wordpress/source/igny8-wp-bridge/
|
||||
# ... make changes ...
|
||||
|
||||
# 2. Update version (use PATCH increment)
|
||||
# Edit igny8-bridge.php
|
||||
|
||||
# 3. Create version in Django admin with:
|
||||
# - Status: update_ready
|
||||
# - Force Update: ✓ (checked)
|
||||
# - Changelog: "SECURITY: [description]"
|
||||
|
||||
# 4. Verify immediately
|
||||
curl https://api.igny8.com/api/plugins/igny8-wp-bridge/check-update/?current_version=1.0.0
|
||||
|
||||
# Response should include:
|
||||
# "force_update": true
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 9. Recent Updates & Lessons Learned
|
||||
|
||||
### v1.3.3 Release (Jan 10, 2026)
|
||||
|
||||
**Changes:**
|
||||
- Fixed square image grid layout (side-by-side display)
|
||||
- Fixed landscape image positioning in sections 4+
|
||||
- Removed card wrapper for images without captions
|
||||
- Applied border-radius/shadow directly to images
|
||||
- Landscape images now appear after first paragraph
|
||||
|
||||
**Process:**
|
||||
- Source code updated in plugin templates and CSS
|
||||
- Version bumped in `igny8-bridge.php` (header + constant)
|
||||
- Django admin: Created v1.3.3 with changelog
|
||||
- Status changed to "released" → ZIP auto-generated
|
||||
- Verified download endpoint and file contents
|
||||
- Template changes tested on staging WordPress site
|
||||
|
||||
**Lessons:**
|
||||
- CSS changes require thorough cross-browser testing
|
||||
- Image layout fixes need responsive design verification
|
||||
- Template changes should be tested with multiple content types
|
||||
|
||||
### v1.3.2 Release (Jan 9, 2026)
|
||||
|
||||
**Changes:**
|
||||
- Template rendering improvements
|
||||
- Image layout enhancements
|
||||
- Content section fixes
|
||||
|
||||
**Process:**
|
||||
- Standard release workflow
|
||||
- Auto-build successful
|
||||
- No rollback needed
|
||||
|
||||
### v1.3.0 Release (Jan 8, 2026)
|
||||
|
||||
**Changes:**
|
||||
- Initial distribution system implementation
|
||||
- WordPress auto-update mechanism
|
||||
- Base template system
|
||||
|
||||
**Process:**
|
||||
- Major release with new infrastructure
|
||||
- Extensive testing required
|
||||
- First use of automated packaging
|
||||
|
||||
### Distribution System Milestones
|
||||
|
||||
**v1.7.0 Infrastructure:**
|
||||
- ✅ Complete plugin distribution system
|
||||
- ✅ Multi-platform support architecture
|
||||
- ✅ Automated versioning and packaging
|
||||
- ✅ Security features (checksums, signed URLs)
|
||||
- ✅ Monitoring and analytics
|
||||
|
||||
**Best Practices Established:**
|
||||
1. Always test download endpoint after release
|
||||
2. Verify ZIP contents match source
|
||||
3. Check version number in extracted files
|
||||
4. Test update notification in WordPress
|
||||
5. Monitor download analytics
|
||||
|
||||
**Common Issues Resolved:**
|
||||
- ZIP generation timing → Now synchronous in signals
|
||||
- Checksum mismatches → Auto-calculated reliably
|
||||
- Version comparison → Semantic versioning logic fixed
|
||||
- File size tracking → Automatic and accurate
|
||||
|
||||
---
|
||||
|
||||
## Quick Reference Card
|
||||
|
||||
### Release New Version (Simplified)
|
||||
|
||||
```
|
||||
1. Edit source code in /plugins/wordpress/source/igny8-wp-bridge/
|
||||
2. Update version in igny8-bridge.php (header + constant)
|
||||
3. Django Admin → Add Plugin Version:
|
||||
- Plugin: IGNY8 WordPress Bridge
|
||||
- Version: 1.3.3 (or next version)
|
||||
- Changelog: Describe changes
|
||||
- Status: draft
|
||||
- (All other fields auto-fill)
|
||||
4. Change status to "released" (or use bulk action) → Auto-build triggers
|
||||
5. Run verification checklist
|
||||
6. Optionally: Mark old version as deprecated
|
||||
```
|
||||
|
||||
**Admin Bulk Actions:**
|
||||
- **✅ Release selected versions** - Builds ZIP and marks as released
|
||||
- **📢 Mark as update ready** - Notifies WordPress sites
|
||||
- **🗑️ Mark as deprecated** - Deprecates old versions
|
||||
|
||||
### Verification Commands
|
||||
|
||||
```bash
|
||||
# Test all endpoints
|
||||
curl -I https://api.igny8.com/api/plugins/igny8-wp-bridge/download/
|
||||
curl https://api.igny8.com/api/plugins/igny8-wp-bridge/check-update/?current_version=1.0.0
|
||||
curl https://api.igny8.com/api/plugins/igny8-wp-bridge/info/
|
||||
|
||||
# Check ZIP contents
|
||||
unzip -l /data/app/igny8/plugins/wordpress/dist/igny8-wp-bridge-v*.zip | head -20
|
||||
```
|
||||
|
||||
### Emergency Rollback
|
||||
|
||||
```bash
|
||||
# Swap versions in database
|
||||
docker exec igny8_backend python manage.py shell -c "
|
||||
from igny8_core.plugins.models import PluginVersion
|
||||
PluginVersion.objects.filter(version='NEW').update(status='deprecated')
|
||||
PluginVersion.objects.filter(version='OLD').update(status='released')
|
||||
"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [WORDPRESS-INTEGRATION.md](WORDPRESS-INTEGRATION.md) - Full integration guide
|
||||
- [docs/plans/PLUGIN-DISTRIBUTION-SYSTEM.md](/docs/plans/PLUGIN-DISTRIBUTION-SYSTEM.md) - Original system design
|
||||
@@ -0,0 +1,785 @@
|
||||
# WordPress Integration Management
|
||||
|
||||
**Last Updated:** January 20, 2026
|
||||
**Version:** 1.8.4
|
||||
**Status:** Production
|
||||
**Scope:** App-side management of WordPress plugin distribution and site integrations
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [Overview](#1-overview)
|
||||
2. [Architecture](#2-architecture)
|
||||
3. [Plugin Distribution System](#3-plugin-distribution-system)
|
||||
4. [Database Models](#4-database-models)
|
||||
5. [API Endpoints](#5-api-endpoints)
|
||||
6. [Django Admin Management](#6-django-admin-management)
|
||||
7. [Frontend Integration](#7-frontend-integration)
|
||||
8. [Site Integration Flow](#8-site-integration-flow)
|
||||
9. [Recent Updates (v1.7.0)](#9-recent-updates-v170)
|
||||
10. [Troubleshooting](#10-troubleshooting)
|
||||
|
||||
---
|
||||
|
||||
## 1. Overview
|
||||
|
||||
### What This Document Covers
|
||||
|
||||
This document covers the **app-side** management of WordPress integration:
|
||||
|
||||
- How the IGNY8 app distributes the WordPress plugin
|
||||
- How site integrations are tracked in the database
|
||||
- API endpoints that WordPress plugins call
|
||||
- Admin interface for managing plugins and versions
|
||||
- Frontend components for plugin download
|
||||
- Plugin distribution infrastructure (v1.7.0)
|
||||
- Automated versioning and packaging system
|
||||
|
||||
### What This Document Does NOT Cover
|
||||
|
||||
- Internal plugin PHP code and functions (see `/plugins/wordpress/source/igny8-wp-bridge/docs/`)
|
||||
- WordPress-side setup and configuration
|
||||
- Plugin installation on WordPress sites
|
||||
|
||||
### Current Status (v1.7.0)
|
||||
|
||||
- ✅ WordPress Plugin: v1.3.3 (Production)
|
||||
- ✅ Distribution System: Fully operational
|
||||
- ✅ Auto-update Mechanism: Active
|
||||
- ✅ Template Design: Updated with image layout fixes
|
||||
- ✅ API Endpoints: All operational
|
||||
- ✅ Security Features: Checksums, signed URLs, rate limiting
|
||||
|
||||
---
|
||||
|
||||
## 2. Architecture
|
||||
|
||||
### System Components
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ IGNY8 App Server │
|
||||
├─────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
|
||||
│ │ Django Backend │ │ PostgreSQL │ │ Plugin Files │ │
|
||||
│ │ │ │ │ │ │ │
|
||||
│ │ - API Views │◄──►│ - Plugin │ │ /plugins/ │ │
|
||||
│ │ - Admin │ │ - PluginVersion │ │ └─wordpress/ │ │
|
||||
│ │ - Signals │ │ - Installation │ │ ├─source/ │ │
|
||||
│ │ │ │ - Downloads │ │ └─dist/ │ │
|
||||
│ └────────┬─────────┘ └──────────────────┘ └────────┬─────────┘ │
|
||||
│ │ │ │
|
||||
│ │ API Routes: api.igny8.com │ │
|
||||
│ ▼ ▼ │
|
||||
│ ┌──────────────────────────────────────────────────────────────────┐ │
|
||||
│ │ API Endpoints │ │
|
||||
│ │ │ │
|
||||
│ │ /api/plugins/{slug}/download/ → Serve ZIP file │ │
|
||||
│ │ /api/plugins/{slug}/check-update/ → Return update info │ │
|
||||
│ │ /api/plugins/{slug}/info/ → Return plugin metadata │ │
|
||||
│ │ /api/plugins/{slug}/register/ → Register installation │ │
|
||||
│ │ /api/plugins/{slug}/health-check/ → Report plugin status │ │
|
||||
│ └──────────────────────────────────────────────────────────────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
│ HTTPS
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ WordPress Sites │
|
||||
│ │
|
||||
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
||||
│ │ Site A │ │ Site B │ │ Site C │ │ Site N │ │
|
||||
│ │ v1.1.1 │ │ v1.1.0 │ │ v1.1.1 │ │ v1.0.0 │ │
|
||||
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### URL Routing
|
||||
|
||||
| Domain | Service | Purpose |
|
||||
|--------|---------|---------|
|
||||
| `app.igny8.com` | Frontend (Vite) | User interface |
|
||||
| `api.igny8.com` | Backend (Django) | API endpoints |
|
||||
|
||||
**Important**: WordPress plugins must call `api.igny8.com`, not `app.igny8.com`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Plugin Distribution System
|
||||
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
/data/app/igny8/
|
||||
├── plugins/
|
||||
│ └── wordpress/
|
||||
│ ├── source/ # Development source
|
||||
│ │ └── igny8-wp-bridge/
|
||||
│ │ ├── igny8-bridge.php # Main plugin file
|
||||
│ │ ├── includes/ # PHP classes
|
||||
│ │ ├── admin/ # Admin interface
|
||||
│ │ │ ├── class-admin.php # Menu registration
|
||||
│ │ │ ├── layout-header.php # Layout wrapper + sidebar
|
||||
│ │ │ ├── layout-footer.php # Footer
|
||||
│ │ │ ├── settings.php # Settings handler
|
||||
│ │ │ └── pages/ # Admin pages (3 pages)
|
||||
│ │ │ ├── connection.php # Dashboard (connection + stats)
|
||||
│ │ │ ├── settings.php # Post types, taxonomies, sync
|
||||
│ │ │ └── logs.php # Webhook activity logs
|
||||
│ │ ├── sync/ # Sync functionality
|
||||
│ │ ├── templates/ # Frontend templates
|
||||
│ │ └── docs/ # Plugin-internal docs
|
||||
│ └── dist/ # Distribution files
|
||||
│ ├── igny8-wp-bridge-v1.x.x.zip # Version ZIP
|
||||
│ ├── igny8-wp-bridge-v1.x.x.sha256
|
||||
│ └── igny8-wp-bridge-latest.zip # Symlink to latest
|
||||
│
|
||||
└── backend/
|
||||
└── igny8_core/
|
||||
└── plugins/ # Django app
|
||||
├── models.py # Database models
|
||||
├── views.py # API endpoints
|
||||
├── signals.py # Auto-build triggers
|
||||
├── utils.py # ZIP creation utilities
|
||||
├── admin.py # Django admin config
|
||||
└── urls.py # URL routing
|
||||
```
|
||||
|
||||
### Plugin Admin Pages
|
||||
|
||||
The WordPress plugin provides 3 admin pages:
|
||||
|
||||
| Page | File | Purpose |
|
||||
|------|------|---------|
|
||||
| Dashboard | `connection.php` | Connection status, Site ID, API key, content stats |
|
||||
| Settings | `settings.php` | Post types, default post status, taxonomies, sync toggle |
|
||||
| Logs | `logs.php` | Webhook activity with timestamps, event types, status |
|
||||
|
||||
**Layout:**
|
||||
- Dashboard: 2-column grid (Connection Status + Content Stats)
|
||||
- Settings: 3-column top row (Post Types + Default Post Status + IGNY8 Sync) + dynamic taxonomy cards
|
||||
- Logs: Full-width table with search
|
||||
|
||||
### How ZIP Files Are Created
|
||||
|
||||
#### Automatic Build (Recommended)
|
||||
|
||||
When a `PluginVersion` status changes to `released` or `update_ready`, the system **automatically**:
|
||||
|
||||
1. Reads source files from `/plugins/wordpress/source/igny8-wp-bridge/`
|
||||
2. Updates version numbers in PHP files
|
||||
3. Removes development files (tests, .git, __pycache__)
|
||||
4. Creates ZIP in `/plugins/wordpress/dist/`
|
||||
5. Calculates SHA256 checksum
|
||||
6. Updates database with `file_path`, `file_size`, `checksum`
|
||||
7. Updates `*-latest.zip` symlink
|
||||
|
||||
This is handled by `signals.py`:
|
||||
|
||||
```python
|
||||
# backend/igny8_core/plugins/signals.py
|
||||
|
||||
@receiver(pre_save, sender=PluginVersion)
|
||||
def auto_build_plugin_on_release(sender, instance, **kwargs):
|
||||
"""Automatically build ZIP when version is released."""
|
||||
# Triggered on status change to 'released' or 'update_ready'
|
||||
```
|
||||
|
||||
#### Manual Build (If Needed)
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
cd /data/app/igny8/plugins/wordpress/source
|
||||
|
||||
# Create ZIP manually
|
||||
zip -r ../dist/igny8-wp-bridge-v1.2.0.zip igny8-wp-bridge/ \
|
||||
-x "*.git*" -x "*__pycache__*" -x "*.DS_Store" -x "*tester*"
|
||||
|
||||
# Update checksum
|
||||
sha256sum ../dist/igny8-wp-bridge-v1.2.0.zip > ../dist/igny8-wp-bridge-v1.2.0.sha256
|
||||
|
||||
# Update symlink
|
||||
ln -sf igny8-wp-bridge-v1.2.0.zip ../dist/igny8-wp-bridge-latest.zip
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Database Models
|
||||
|
||||
### Plugin
|
||||
|
||||
Represents a plugin type (WordPress, Shopify, etc.).
|
||||
|
||||
```python
|
||||
class Plugin(models.Model):
|
||||
name = models.CharField(max_length=100) # "IGNY8 WordPress Bridge"
|
||||
slug = models.SlugField(unique=True) # "igny8-wp-bridge"
|
||||
platform = models.CharField(...) # "wordpress", "shopify", "custom"
|
||||
description = models.TextField()
|
||||
homepage_url = models.URLField()
|
||||
is_active = models.BooleanField(default=True)
|
||||
```
|
||||
|
||||
**Current Records:**
|
||||
|
||||
| ID | Name | Slug | Platform |
|
||||
|----|------|------|----------|
|
||||
| 1 | IGNY8 WordPress Bridge | igny8-wp-bridge | wordpress |
|
||||
|
||||
### PluginVersion
|
||||
|
||||
Tracks each version of a plugin.
|
||||
|
||||
```python
|
||||
class PluginVersion(models.Model):
|
||||
plugin = models.ForeignKey(Plugin, ...)
|
||||
version = models.CharField(max_length=20) # "1.1.1"
|
||||
version_code = models.IntegerField() # 10101 (for comparison)
|
||||
status = models.CharField(...) # "draft", "released", "update_ready"
|
||||
|
||||
# File info (auto-populated on release)
|
||||
file_path = models.CharField(...) # "igny8-wp-bridge-v1.1.1.zip"
|
||||
file_size = models.IntegerField() # 167589 (bytes)
|
||||
checksum = models.CharField(max_length=64) # SHA256
|
||||
|
||||
# Release info
|
||||
changelog = models.TextField()
|
||||
min_php_version = models.CharField(default='7.4')
|
||||
released_at = models.DateTimeField(null=True)
|
||||
force_update = models.BooleanField(default=False)
|
||||
```
|
||||
|
||||
**Version Status Flow:**
|
||||
|
||||
```
|
||||
draft → testing → staged → released → update_ready → deprecated
|
||||
│ │
|
||||
│ └─ Notifies WP sites
|
||||
└─ Available for download
|
||||
```
|
||||
|
||||
### PluginInstallation
|
||||
|
||||
Tracks where plugins are installed.
|
||||
|
||||
```python
|
||||
class PluginInstallation(models.Model):
|
||||
site = models.ForeignKey('Site', ...)
|
||||
plugin = models.ForeignKey(Plugin, ...)
|
||||
current_version = models.ForeignKey(PluginVersion, ...)
|
||||
is_active = models.BooleanField(default=True)
|
||||
last_health_check = models.DateTimeField(null=True)
|
||||
health_status = models.CharField(...) # "healthy", "outdated", "error"
|
||||
```
|
||||
|
||||
### PluginDownload
|
||||
|
||||
Tracks download analytics.
|
||||
|
||||
```python
|
||||
class PluginDownload(models.Model):
|
||||
plugin = models.ForeignKey(Plugin, ...)
|
||||
version = models.ForeignKey(PluginVersion, ...)
|
||||
ip_address = models.GenericIPAddressField()
|
||||
user_agent = models.CharField(max_length=500)
|
||||
download_type = models.CharField(...) # "manual", "auto_update"
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. API Endpoints
|
||||
|
||||
### Public Endpoints (No Auth Required)
|
||||
|
||||
#### Download Plugin
|
||||
|
||||
```
|
||||
GET /api/plugins/{slug}/download/
|
||||
```
|
||||
|
||||
Returns the latest released ZIP file.
|
||||
|
||||
**Response:** Binary ZIP file download
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
curl -O https://api.igny8.com/api/plugins/igny8-wp-bridge/download/
|
||||
```
|
||||
|
||||
#### Check for Updates
|
||||
|
||||
```
|
||||
GET /api/plugins/{slug}/check-update/?current_version=1.0.0
|
||||
```
|
||||
|
||||
Called by installed WordPress plugins to check for updates.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"update_available": true,
|
||||
"current_version": "1.0.0",
|
||||
"latest_version": "1.1.1",
|
||||
"latest_version_code": 10101,
|
||||
"download_url": "https://api.igny8.com/api/plugins/igny8-wp-bridge/download/",
|
||||
"changelog": "Bug fixes and improvements",
|
||||
"info_url": "https://api.igny8.com/api/plugins/igny8-wp-bridge/info/",
|
||||
"force_update": false,
|
||||
"checksum": "6b9e231c07434df1dcfe81596b57f3571c30b6c2..."
|
||||
}
|
||||
```
|
||||
|
||||
#### Plugin Info
|
||||
|
||||
```
|
||||
GET /api/plugins/{slug}/info/
|
||||
```
|
||||
|
||||
Returns plugin metadata for WordPress update modal.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"name": "IGNY8 WordPress Bridge",
|
||||
"slug": "igny8-wp-bridge",
|
||||
"version": "1.1.1",
|
||||
"author": "IGNY8",
|
||||
"homepage": "https://igny8.com",
|
||||
"description": "Lightweight bridge plugin...",
|
||||
"changelog": "Bug fixes and improvements",
|
||||
"download_url": "https://api.igny8.com/api/plugins/igny8-wp-bridge/download/",
|
||||
"file_size": 167589,
|
||||
"requires_php": "7.4",
|
||||
"tested_wp": "6.7"
|
||||
}
|
||||
```
|
||||
|
||||
### Authenticated Endpoints
|
||||
|
||||
#### Register Installation
|
||||
|
||||
```
|
||||
POST /api/plugins/{slug}/register/
|
||||
Headers: Authorization: Api-Key {site_api_key}
|
||||
```
|
||||
|
||||
Called when plugin is activated on a WordPress site.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"site_id": 123,
|
||||
"version": "1.1.1",
|
||||
"wp_version": "6.7",
|
||||
"php_version": "8.2"
|
||||
}
|
||||
```
|
||||
|
||||
#### Health Check
|
||||
|
||||
```
|
||||
POST /api/plugins/{slug}/health-check/
|
||||
Headers: Authorization: Api-Key {site_api_key}
|
||||
```
|
||||
|
||||
Periodic status report from installed plugins.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"site_id": 123,
|
||||
"version": "1.1.1",
|
||||
"status": "active",
|
||||
"last_sync": "2026-01-09T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Django Admin Management
|
||||
|
||||
### Accessing Plugin Admin
|
||||
|
||||
1. Go to: `https://api.igny8.com/backend/`
|
||||
2. Login with admin credentials
|
||||
3. Navigate to **Plugin Distribution** section
|
||||
|
||||
### Admin Sections
|
||||
|
||||
#### Plugins
|
||||
|
||||
View and manage plugin registry.
|
||||
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| Name | Display name |
|
||||
| Slug | URL identifier (cannot change after creation) |
|
||||
| Platform | wordpress, shopify, custom |
|
||||
| Is Active | Whether available for download |
|
||||
|
||||
#### Plugin Versions
|
||||
|
||||
Manage versions and trigger releases.
|
||||
|
||||
**Required Fields Only:**
|
||||
- Plugin
|
||||
- Version (e.g., 1.2.0)
|
||||
- Changelog
|
||||
- Status
|
||||
|
||||
**Auto-Filled Fields:**
|
||||
- Min API/Platform/PHP versions (copied from previous version)
|
||||
- File path, size, checksum (generated on release)
|
||||
- Version code (calculated from version number)
|
||||
|
||||
**To Release a New Version:**
|
||||
|
||||
1. Click **Add Plugin Version**
|
||||
2. Select plugin
|
||||
3. Enter version number (e.g., 1.2.0)
|
||||
4. Write changelog
|
||||
5. Set status to `draft`
|
||||
6. Save
|
||||
7. Change status to `released` (or use bulk action "✅ Release selected versions")
|
||||
8. ZIP is automatically built with all file info populated
|
||||
|
||||
**Bulk Actions:**
|
||||
- **✅ Release selected versions** - Builds ZIP and releases
|
||||
- **📢 Mark as update ready** - Notifies WordPress sites
|
||||
- **🗑️ Mark as deprecated** - Deprecates old versions
|
||||
|
||||
#### Plugin Installations
|
||||
|
||||
View where plugins are installed.
|
||||
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| Site | IGNY8 site record |
|
||||
| Plugin | Which plugin |
|
||||
| Current Version | Installed version |
|
||||
| Health Status | healthy, outdated, error |
|
||||
| Last Health Check | Timestamp |
|
||||
|
||||
#### Plugin Downloads
|
||||
|
||||
View download analytics.
|
||||
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| Plugin | Which plugin |
|
||||
| Version | Which version |
|
||||
| Download Type | manual, auto_update |
|
||||
| IP Address | Client IP |
|
||||
| User Agent | Browser/client info |
|
||||
| Created At | Timestamp |
|
||||
|
||||
---
|
||||
|
||||
## 7. Frontend Integration
|
||||
|
||||
### Download Button Location
|
||||
|
||||
**Page:** Site Settings → Integrations → WordPress
|
||||
|
||||
**Component:** `frontend/src/components/sites/WordPressIntegrationForm.tsx`
|
||||
|
||||
### How Download Works
|
||||
|
||||
```typescript
|
||||
// WordPressIntegrationForm.tsx
|
||||
|
||||
import { API_BASE_URL } from '../../services/api';
|
||||
|
||||
const handleDownloadPlugin = () => {
|
||||
// Uses API_BASE_URL which resolves to https://api.igny8.com/api
|
||||
const pluginUrl = `${API_BASE_URL}/plugins/igny8-wp-bridge/download/`;
|
||||
window.open(pluginUrl, '_blank');
|
||||
toast.success('Plugin download started');
|
||||
};
|
||||
```
|
||||
|
||||
### Plugin Information Display
|
||||
|
||||
The frontend shows:
|
||||
|
||||
- Plugin name and version
|
||||
- File size
|
||||
- PHP requirements
|
||||
- Download button
|
||||
- Changelog (expandable)
|
||||
|
||||
---
|
||||
|
||||
## 8. Site Integration Flow
|
||||
|
||||
### Integration Creation Flow
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ WordPress Site Setup │
|
||||
├─────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ 1. User downloads plugin from IGNY8 app │
|
||||
│ └─ GET /api/plugins/igny8-wp-bridge/download/ │
|
||||
│ │
|
||||
│ 2. User installs and activates plugin in WordPress │
|
||||
│ │
|
||||
│ 3. User enters Site ID and API Key in WP plugin settings │
|
||||
│ └─ These are generated in IGNY8 app │
|
||||
│ │
|
||||
│ 4. WP Plugin calls IGNY8 to register │
|
||||
│ └─ POST /api/plugins/igny8-wp-bridge/register/ │
|
||||
│ │
|
||||
│ 5. IGNY8 creates SiteIntegration record │
|
||||
│ └─ Links WordPress site to IGNY8 site │
|
||||
│ │
|
||||
│ 6. Integration is now active │
|
||||
│ └─ Content can be published from IGNY8 to WordPress │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Integration Data Model
|
||||
|
||||
**Authentication (Source of Truth):**
|
||||
|
||||
```python
|
||||
# Site model (in auth/models.py) - SINGLE source of truth for API auth
|
||||
|
||||
class Site(models.Model):
|
||||
wp_api_key = models.CharField(max_length=255) # API key for WP authentication
|
||||
# Used by: PublisherService, test connection, plugin verification
|
||||
```
|
||||
|
||||
**Sync Tracking (SiteIntegration):**
|
||||
|
||||
```python
|
||||
# SiteIntegration model (in auth/models.py) - Tracks sync status, NOT auth
|
||||
|
||||
class SiteIntegration(models.Model):
|
||||
site = models.ForeignKey(Site, ...) # IGNY8 site
|
||||
platform = models.CharField(...) # "wordpress", "shopify"
|
||||
external_site_url = models.URLField() # WordPress URL
|
||||
sync_enabled = models.BooleanField()
|
||||
sync_status = models.CharField(...) # "pending", "syncing", "completed"
|
||||
last_sync_at = models.DateTimeField()
|
||||
sync_error = models.TextField(null=True)
|
||||
connection_status = models.CharField(...) # "connected", "error"
|
||||
```
|
||||
|
||||
**Key Architecture Points:**
|
||||
- `Site.wp_api_key` is the **SINGLE source of truth** for API authentication
|
||||
- `SiteIntegration` provides sync tracking but NOT authentication
|
||||
- Publishing uses `Site.wp_api_key` via `X-IGNY8-API-KEY` header
|
||||
- SiteIntegration kept for future multi-platform support (Shopify, custom)
|
||||
|
||||
---
|
||||
|
||||
## 9. Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### "404 Not Found" on Download
|
||||
|
||||
**Cause:** Using wrong domain (app.igny8.com instead of api.igny8.com)
|
||||
|
||||
**Solution:** Ensure URL is `https://api.igny8.com/api/plugins/igny8-wp-bridge/download/`
|
||||
|
||||
#### "Plugin file not found" Error
|
||||
|
||||
**Cause:** ZIP file doesn't exist in dist/ directory
|
||||
|
||||
**Solution:**
|
||||
```bash
|
||||
# Check if file exists
|
||||
ls -la /data/app/igny8/plugins/wordpress/dist/
|
||||
|
||||
# If missing, rebuild manually or change version status to trigger auto-build
|
||||
```
|
||||
|
||||
#### Updates Not Showing in WordPress
|
||||
|
||||
**Cause 1:** WordPress caches plugin update checks
|
||||
|
||||
**Solution:** In WordPress admin, go to Dashboard → Updates → Check Again
|
||||
|
||||
**Cause 2:** Version status is not `released` or `update_ready`
|
||||
|
||||
**Solution:** Check PluginVersion status in Django admin
|
||||
|
||||
#### Wrong File Size/Checksum
|
||||
|
||||
**Cause:** Database values don't match actual file
|
||||
|
||||
**Solution:**
|
||||
```bash
|
||||
# Get actual values
|
||||
stat -c %s /data/app/igny8/plugins/wordpress/dist/igny8-wp-bridge-v1.1.1.zip
|
||||
sha256sum /data/app/igny8/plugins/wordpress/dist/igny8-wp-bridge-v1.1.1.zip
|
||||
|
||||
# Update in Django admin or shell
|
||||
```
|
||||
|
||||
### Verification Commands
|
||||
|
||||
```bash
|
||||
# Test download endpoint
|
||||
curl -I https://api.igny8.com/api/plugins/igny8-wp-bridge/download/
|
||||
|
||||
# Test check-update endpoint
|
||||
curl "https://api.igny8.com/api/plugins/igny8-wp-bridge/check-update/?current_version=1.0.0"
|
||||
|
||||
# Test info endpoint
|
||||
curl https://api.igny8.com/api/plugins/igny8-wp-bridge/info/
|
||||
|
||||
# Check ZIP contents
|
||||
unzip -l /data/app/igny8/plugins/wordpress/dist/igny8-wp-bridge-v1.1.1.zip
|
||||
|
||||
# Verify API URL in plugin
|
||||
unzip -p /data/app/igny8/plugins/wordpress/dist/igny8-wp-bridge-v1.1.1.zip \
|
||||
igny8-wp-bridge/igny8-bridge.php | grep "api.igny8.com"
|
||||
```
|
||||
|
||||
### Log Locations
|
||||
|
||||
| Log | Location |
|
||||
|-----|----------|
|
||||
| Django Logs | `/data/app/igny8/backend/logs/` |
|
||||
| Plugin API Logs | Check Django logs for `/api/plugins/` requests |
|
||||
| WordPress Plugin Logs | WP site's debug.log if WP_DEBUG enabled |
|
||||
|
||||
---
|
||||
|
||||
## 9. Recent Updates (v1.7.0)
|
||||
|
||||
### Plugin Distribution System Implemented
|
||||
|
||||
**Infrastructure:**
|
||||
- ✅ Complete plugin distribution system operational
|
||||
- ✅ Multi-platform support (WordPress, Shopify, Custom sites)
|
||||
- ✅ Automated ZIP packaging with versioning
|
||||
- ✅ Security features: checksums (MD5/SHA256), signed URLs, rate limiting
|
||||
- ✅ Monitoring and analytics dashboard
|
||||
|
||||
**Database Models:**
|
||||
- `Plugin` - Platform-agnostic plugin registry
|
||||
- `PluginVersion` - Full version lifecycle management
|
||||
- `PluginInstallation` - Per-site installation tracking
|
||||
- `PluginDownload` - Download analytics and monitoring
|
||||
|
||||
**API Endpoints:**
|
||||
- All 5 endpoints operational and tested
|
||||
- `/download/` - Serve plugin ZIP files
|
||||
- `/check-update/` - WordPress update mechanism
|
||||
- `/info/` - Plugin metadata
|
||||
- `/register/` - Installation registration
|
||||
- `/health-check/` - Plugin health monitoring
|
||||
|
||||
### WordPress Plugin Updates (v1.3.0 → v1.5.1)
|
||||
|
||||
**v1.5.1 - Admin UI Consolidation:**
|
||||
- Reduced admin pages from 6 to 3: Dashboard, Settings, Logs
|
||||
- Renamed Connection page to Dashboard with content stats
|
||||
- Removed redundant pages: Data, Sync, old Dashboard
|
||||
- Settings redesigned with 3-column layout (Post Types + Default Post Status + IGNY8 Sync)
|
||||
- Fixed header alignment across all pages with proper width styling
|
||||
- Cleaned up orphaned code and functions
|
||||
|
||||
**v1.5.0 - Authentication Simplification:**
|
||||
- Simplified authentication to use Site.wp_api_key as single source of truth
|
||||
- Removed redundant access_token handling
|
||||
- Improved test connection flow using authenticated /verify-key endpoint
|
||||
|
||||
**v1.3.3 - Template Design Improvements:**
|
||||
- Fixed square images displaying in 2 rows (now side-by-side)
|
||||
- Fixed landscape images in sections 4+ displaying incorrectly
|
||||
- Removed card wrapper for images without descriptions
|
||||
- Applied border-radius and shadow directly to images
|
||||
- Landscape images now appear after first paragraph
|
||||
- Consistent CSS classes for all image types
|
||||
|
||||
**v1.3.2 - Template Fixes:**
|
||||
- Template rendering improvements in app and plugin
|
||||
- Image layout enhancements
|
||||
- Content section fixes
|
||||
|
||||
**v1.3.1 - Plugin Updates:**
|
||||
- Versioning system improvements
|
||||
- WordPress plugin compatibility updates
|
||||
|
||||
**v1.3.0 - Initial Distribution System:**
|
||||
- First release with automated distribution
|
||||
- Update mechanism implementation
|
||||
- Base template system
|
||||
|
||||
### Version Progression Timeline
|
||||
|
||||
```
|
||||
v1.7.0 (Jan 10, 2026) - App infrastructure + plugin v1.5.1
|
||||
├── Plugin admin UI consolidation (6→3 pages)
|
||||
├── Authentication simplification
|
||||
├── Plugin distribution system complete
|
||||
├── Template design overhaul
|
||||
└── Pre-launch cleanup complete
|
||||
|
||||
v1.6.2 (Jan 8, 2026) - Design refinements
|
||||
└── Marketing site updates
|
||||
|
||||
v1.6.0 (Jan 8, 2026) - Payment system refactor
|
||||
└── Stripe, PayPal, Bank Transfer
|
||||
|
||||
v1.4.0 (Jan 5, 2026) - AI model architecture overhaul
|
||||
└── IntegrationProvider, AIModelConfig
|
||||
```
|
||||
|
||||
### Infrastructure Improvements
|
||||
|
||||
**Security:**
|
||||
- Signed URLs with expiration for downloads
|
||||
- Checksum verification (MD5 + SHA256)
|
||||
- Rate limiting per IP/site
|
||||
- API authentication for sensitive operations
|
||||
- Production environment protection
|
||||
|
||||
**Automation:**
|
||||
- Auto-build on version status change
|
||||
- Automatic checksum calculation
|
||||
- File size tracking
|
||||
- Version number updates in ZIP contents
|
||||
- Released timestamp tracking
|
||||
|
||||
**Monitoring:**
|
||||
- Installation tracking per site
|
||||
- Download analytics
|
||||
- Health check endpoints
|
||||
- Version distribution monitoring
|
||||
- Error logging and alerts
|
||||
|
||||
### Documentation Updates
|
||||
|
||||
- Added comprehensive plugin distribution plan
|
||||
- Updated API endpoint documentation
|
||||
- Enhanced troubleshooting guides
|
||||
- Added version progression tracking
|
||||
- Updated architecture diagrams
|
||||
|
||||
---
|
||||
|
||||
## 10. Troubleshooting
|
||||
|-----|----------|
|
||||
| Django logs | `/data/app/logs/django.log` |
|
||||
| Plugin build logs | Check Django log for `"Created plugin ZIP"` messages |
|
||||
| Download tracking | `PluginDownload` model in database |
|
||||
|
||||
---
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [PLUGIN-UPDATE-WORKFLOW.md](PLUGIN-UPDATE-WORKFLOW.md) - Post-update checklist
|
||||
- `/plugins/wordpress/source/igny8-wp-bridge/docs/` - Plugin internal documentation
|
||||
- [docs/plans/PLUGIN-DISTRIBUTION-SYSTEM.md](/docs/plans/PLUGIN-DISTRIBUTION-SYSTEM.md) - Original implementation plan
|
||||
Reference in New Issue
Block a user