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:
@@ -259,5 +259,13 @@ class PRAutoBlogger_Settings_Fields_Extended {
|
||||
'description' => __( 'When the provider rejects an image prompt as NSFW, retry once with a generic fallback scene built from the article title. Disable to fail fast if the filter gets trigger-happy.', 'prautoblogger' ),
|
||||
),
|
||||
);
|
||||
array(
|
||||
'id' => 'prautoblogger_runware_model_catalog',
|
||||
'label' => __( 'Runware Model Catalog', 'prautoblogger' ),
|
||||
'type' => 'runware_catalog_sync',
|
||||
'section' => 'prautoblogger_images',
|
||||
'description' => __( 'Live model catalog sync status and on-demand refresh.', 'prautoblogger' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user