MainWP Integration
MainWP Dashboard (v4.5.2) is installed alongside Suma Management to provide WordPress multi-site management capabilities. The two systems coexist independently but share some data flows.
What MainWP Provides
| Capability | Description |
|---|---|
| Site connectivity | Connects to child sites via MainWP Child plugin |
| Plugin/theme updates | Detects and applies updates across all sites |
| Backup management | Scheduled and on-demand backups |
| Uptime monitoring | Basic uptime checking |
| Security scanning | Vulnerability detection |
| Site health | WordPress health score |
Relationship with Suma Management
┌──────────────────────┐ ┌──────────────────────┐
│ MainWP Dashboard │────▶│ Suma Management │
│ (site sync source) │ │ (enhanced tracking) │
└──────────────────────┘ └──────────────────────┘
│ │
│ Provides: │ Adds:
│ - Plugin lists │ - Cost tracking
│ - Theme versions │ - License management
│ - WP version │ - Pinecone vectors
│ - Connection status │ - Advanced reports
│ - PHP version │ - Harvest integration
│ │ - Order monitoring
└─────────────────────────────┘
Key Principle
MainWP is the source of truth for site connectivity and update data. Suma Management consumes this data but adds extensive tracking and management features that MainWP doesn't provide.
Data Flow
Site Update Sync
During Site_Update processing, data is pulled from MainWP:
class Site_Update {
/**
* Fetches current site data from MainWP child connection.
*
* @param int $site_id The Suma site ID.
* @return array Raw site data from MainWP.
*/
private function get_mainwp_data(int $site_id): array {
// MainWP stores its own site records
// Suma Management maps between the two via URL matching
$mainwp_site = $this->find_mainwp_site($site_id);
if (!$mainwp_site) {
return []; // Site not managed by MainWP
}
return [
'plugins' => $mainwp_site->plugins,
'themes' => $mainwp_site->themes,
'wp_version' => $mainwp_site->wp_version,
'php_version' => $mainwp_site->php_version,
'connected' => $mainwp_site->connected,
'last_sync' => $mainwp_site->last_sync,
];
}
}
Plugin Count Calculation
The plugin count displayed in Suma Management comes from MainWP's plugin inventory:
$plugins = json_decode($mainwp_data['plugins'], true);
$plugin_count = count($plugins);
$site->update(['plugin_count' => $plugin_count]);
MainWP REST API
MainWP provides its own REST API at /wp-json/mainwp/v1/:
| Endpoint | Method | Description |
|---|---|---|
/mainwp/v1/sites | GET | List all connected child sites |
/mainwp/v1/sites/{id} | GET | Get specific site details |
/mainwp/v1/sites/{id}/plugins | GET | List installed plugins |
/mainwp/v1/sites/{id}/themes | GET | List installed themes |
/mainwp/v1/updates | GET | Available updates across all sites |
Reconnection Cron
Child sites occasionally disconnect from MainWP (plugin updates, server changes, etc.). The reconnect-main-wp.php cron script handles automatic reconnection:
// cron/reconnect-main-wp.php
// Runs every 30 minutes
// Get disconnected sites from MainWP
$disconnected = MainWP_DB::instance()->get_disconnected_websites();
foreach ($disconnected as $site) {
try {
// Attempt reconnection
MainWP_Connect::reconnect($site->id);
error_log("[MainWP Reconnect] Reconnected: {$site->url}");
} catch (Exception $exception) {
error_log("[MainWP Reconnect] Failed: {$site->url} - " . $exception->getMessage());
}
}
Disconnected Site Reporting
The daily-disconnected-report.php cron sends a daily email listing all currently disconnected sites:
Subject: [Manage RG] Disconnected Sites Report - 2025-05-04
The following sites are currently disconnected from MainWP:
1. example.com - Last connected: 2025-05-02 14:30
2. shop.client.com - Last connected: 2025-05-01 08:15
Total disconnected: 2 of 52 managed sites
Please investigate and reconnect these sites.
Sites Not in MainWP
Not all sites tracked in Suma Management are connected via MainWP:
- BigCommerce sites — Not WordPress, can't run MainWP Child
- Static sites — No server-side plugin support
- Third-party hosted — No plugin install access
These sites are tracked manually in Suma Management and don't benefit from automatic plugin/theme sync.
Configuration
MainWP is configured through its own settings interface:
| Setting | Location |
|---|---|
| MainWP API key | MainWP → Settings → API |
| Child site connections | MainWP → Sites → Add New |
| Sync schedule | MainWP → Settings → Advanced |
| Extension licenses | MainWP → Extensions |
Troubleshooting
Site Shows Disconnected
- Check the child site's MainWP Child plugin is active
- Verify the child site is accessible (not in maintenance mode)
- Try manual reconnection from MainWP dashboard
- Check if site URL changed (SSL migration, domain change)
- Wait for automatic reconnection cron (runs every 30 minutes)
Stale Plugin Data
- Trigger manual sync in MainWP for the specific site
- Check
suma_cronqueue — the site may be pending update - Verify MainWP last sync timestamp isn't too old (> 24 hours)
MainWP vs Suma Management Conflicts
The two systems manage sites independently. If data appears inconsistent:
- MainWP is authoritative for plugin/theme lists
- Suma Management is authoritative for costs, licenses, and health checks
- Sync issues usually resolve after the next
site-updates.phpcron cycle