From 4cc9b396934f8ef9d3f40f046dbfff8f11f0c892 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Sat, 18 Apr 2026 09:23:39 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20model=20picker=20shows=200=20image=20mod?= =?UTF-8?q?els=20=E2=80=94=20capability=20mismatch=20in=20field=20renderer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../fields/class-open-router-model-field.php | 38 +++++-------------- prautoblogger.php | 4 +- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/includes/admin/fields/class-open-router-model-field.php b/includes/admin/fields/class-open-router-model-field.php index 3efcba5..e939779 100644 --- a/includes/admin/fields/class-open-router-model-field.php +++ b/includes/admin/fields/class-open-router-model-field.php @@ -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 $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 - */ - 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. diff --git a/prautoblogger.php b/prautoblogger.php index e2628d3..5aca883 100644 --- a/prautoblogger.php +++ b/prautoblogger.php @@ -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__ ) );