feat: Live Runware model catalog sync — v0.15.0
Implements daily WP-Cron sync from Runware's /v1/models endpoint with 24h TTL caching, on-demand AJAX refresh button in PRAdmin (Images settings), smart fallback logic, and pricing merge from the authoritative cost table. ## Key additions: - class-runware-model-catalog.php: ~300 lines, fetches/normalizes/caches models, exposes sync()/get_models()/get_last_synced_at()/is_stale() public API - AJAX handler: prautoblogger_sync_runware_models_now with nonce + manage_options check - Daily cron registered on activation, unscheduled on deactivation - Caching strategy: <24h fresh → use cache; stale → sync; sync fails → fallback - Pricing merge: costs from class-runware-image-pricing.php injected on every sync - Fallback never returns empty array (hardcoded 15-model list) - Unit tests: sync success/failure, stale cache, fallback behavior, pricing merge ## File changes: - class-image-model-registry.php: refactored to delegate Runware to catalog, extracted get_runware_fallback_models() and get_openrouter_models() - class-settings-fields-extended.php: added runware_catalog_sync field type for status display + Sync button in Images settings section - class-prautoblogger.php: registered daily cron + AJAX hook - class-activator.php: schedule prautoblogger_sync_runware_models on activation - class-deactivator.php: unschedule on deactivation - class-ajax-handlers.php: added on_ajax_sync_runware_models_now() handler - class-runware-image-pricing.php: added @see cross-reference to catalog - ARCHITECTURE.md: updated Runware row in External API Integrations table - prautoblogger.php: version bump to 0.15.0 - CHANGELOG.md: detailed entry describing the fix and why it was necessary Fixes the pattern from v0.13.8 and v0.14.0 where hardcoded Runware model expansion without pricing class updates led to silent fallback-to-schnell bugs.
This commit is contained in:
@@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||
* Dependencies: None — pure calculation + option reads.
|
||||
*
|
||||
* @see class-runware-image-provider.php — Primary caller.
|
||||
* @see class-runware-model-catalog.php — Live model sync; authoritative pricing source.
|
||||
* @see class-open-router-image-pricing.php — Sibling pattern for OpenRouter.
|
||||
* @see admin/class-image-model-registry.php — Source of truth for model list; keep in sync.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user