fix: model picker shows 0 image models — capability mismatch in field renderer
The field renderer still checked for the old 'cloudflare_image' capability but the setting was changed to 'image_generation'. Updated to resolve model name/price from the shared get_image_models() list. Bumped to v0.2.5 to bust browser JS/CSS cache. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,40 +23,20 @@ class PRAutoBlogger_OpenRouter_Model_Field {
|
||||
* @param string $value Current model id (e.g. 'google/gemini-2.5-flash-lite').
|
||||
* @param array<string, mixed> $args Field definition from settings fields.
|
||||
*/
|
||||
/**
|
||||
* Static Cloudflare Workers AI model definitions.
|
||||
*
|
||||
* These don't come from an API registry — Cloudflare has only two FLUX
|
||||
* models and pricing is stable. Costs are per-image at 1024×632 (default).
|
||||
*
|
||||
* @var array<string, array{name: string, cost_per_image: string}>
|
||||
*/
|
||||
private const CLOUDFLARE_MODELS = [
|
||||
'flux-1-schnell' => [
|
||||
'name' => 'FLUX.1 [schnell]',
|
||||
'provider' => 'Cloudflare',
|
||||
'cost_per_image' => '$0.0007',
|
||||
'description' => 'Fast + cheap, 4 inference steps',
|
||||
],
|
||||
'flux-1-dev' => [
|
||||
'name' => 'FLUX.1 [dev]',
|
||||
'provider' => 'Cloudflare',
|
||||
'cost_per_image' => '$0.0028',
|
||||
'description' => 'Higher quality, ~4× cost, 20 steps',
|
||||
],
|
||||
];
|
||||
|
||||
public static function render( string $id, string $value, array $args ): void {
|
||||
$capability = $args['capability'] ?? 'text→text';
|
||||
$display_name = $value ?: __( '— Select a model —', 'prautoblogger' );
|
||||
$display_price = '';
|
||||
|
||||
if ( 'cloudflare_image' === $capability ) {
|
||||
// Resolve from static Cloudflare model list.
|
||||
$cf_model = self::CLOUDFLARE_MODELS[ $value ] ?? null;
|
||||
if ( null !== $cf_model ) {
|
||||
$display_name = $cf_model['name'];
|
||||
$display_price = $cf_model['cost_per_image'] . '/image';
|
||||
if ( 'image_generation' === $capability ) {
|
||||
// Resolve from the static image model list defined in settings.
|
||||
$image_models = PRAutoBlogger_Settings_Fields_Extended::get_image_models();
|
||||
foreach ( $image_models as $im ) {
|
||||
if ( ( $im['id'] ?? '' ) === $value ) {
|
||||
$display_name = $im['name'] ?? $value;
|
||||
$display_price = '$' . number_format( (float) ( $im['cost_per_image'] ?? 0 ), 4 ) . '/image';
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Resolve from the OpenRouter model registry cache.
|
||||
|
||||
@@ -8,7 +8,7 @@ declare(strict_types=1);
|
||||
* Plugin Name: PRAutoBlogger
|
||||
* Plugin URI: https://peptiderepo.com/prautoblogger
|
||||
* Description: Monitors social media for trending topics, generates SEO-friendly blog posts using AI, and publishes them on a daily schedule with full cost tracking and self-improvement metrics.
|
||||
* Version: 0.2.4
|
||||
* Version: 0.2.5
|
||||
* Requires at least: 6.0
|
||||
* Requires PHP: 7.4
|
||||
* Author: PeptideRepo
|
||||
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
| and limits without magic strings.
|
||||
*/
|
||||
|
||||
define( 'PRAUTOBLOGGER_VERSION', '0.2.4' );
|
||||
define( 'PRAUTOBLOGGER_VERSION', '0.2.5' );
|
||||
define( 'PRAUTOBLOGGER_DB_VERSION', '1.1.0' );
|
||||
define( 'PRAUTOBLOGGER_PLUGIN_FILE', __FILE__ );
|
||||
define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
|
||||
Reference in New Issue
Block a user