From 7d61c8c76d355a5ce0b9c58a9975b97309e760b4 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Sun, 19 Apr 2026 22:08:06 +0700 Subject: [PATCH] feat: add Image B toggle to disable second image generation (v0.4.6) New toggle in Images settings controls whether the source-data-based second image is generated. Disabling saves one image gen call + one LLM prompt rewrite per article. Defaults to enabled. Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 7 +++++++ includes/admin/class-settings-fields-extended.php | 10 +++++++++- includes/core/class-image-pipeline.php | 9 +++++++-- prautoblogger.php | 4 ++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed1a4c9..fd61398 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to PRAutoBlogger will be documented in this file. Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project uses [Semantic Versioning](https://semver.org/). +## [0.4.6] — 2026-04-19 + +### Added +- **Image B toggle.** New "Generate Second Image (B)" toggle in Images settings. + Disabling saves one image generation call + one LLM prompt rewrite per article. + Defaults to enabled for backwards compatibility. + ## [0.4.5] — 2026-04-19 ### Added diff --git a/includes/admin/class-settings-fields-extended.php b/includes/admin/class-settings-fields-extended.php index 20e3d28..b18d818 100644 --- a/includes/admin/class-settings-fields-extended.php +++ b/includes/admin/class-settings-fields-extended.php @@ -172,7 +172,15 @@ class PRAutoBlogger_Settings_Fields_Extended { 'type' => 'toggle', 'section' => 'prautoblogger_images', 'default' => '0', - 'description' => __( 'When enabled, generate two images (A/B) for each published article.', 'prautoblogger' ), + 'description' => __( 'Generate images for each published article.', 'prautoblogger' ), + ], + [ + 'id' => 'prautoblogger_image_b_enabled', + 'label' => __( 'Generate Second Image (B)', 'prautoblogger' ), + 'type' => 'toggle', + 'section' => 'prautoblogger_images', + 'default' => '1', + 'description' => __( 'Generate a second image from source data for A/B testing. Disabling saves one image generation + one LLM prompt rewrite per article.', 'prautoblogger' ), ], [ 'id' => 'prautoblogger_image_provider', diff --git a/includes/core/class-image-pipeline.php b/includes/core/class-image-pipeline.php index 25f7f68..c805621 100644 --- a/includes/core/class-image-pipeline.php +++ b/includes/core/class-image-pipeline.php @@ -94,8 +94,13 @@ class PRAutoBlogger_Image_Pipeline { return $result; } + // Check whether Image B is enabled in settings. + $image_b_enabled = get_option( 'prautoblogger_image_b_enabled', '1' ); + $has_source_data = null !== $source_data && ! empty( $source_data ); + $generate_b = $has_source_data && '1' === $image_b_enabled; + // Budget pre-check: estimate cost for all images before any HTTP calls. - $image_count = ( null !== $source_data && ! empty( $source_data ) ) ? 2 : 1; + $image_count = $generate_b ? 2 : 1; $estimated_cost = $this->provider->estimate_cost( self::DEFAULT_WIDTH, self::DEFAULT_HEIGHT ) * $image_count; if ( $this->cost_tracker->would_exceed_budget( $estimated_cost ) ) { $result['errors'][] = 'Image generation would exceed monthly budget.'; @@ -114,7 +119,7 @@ class PRAutoBlogger_Image_Pipeline { $captions = [ 'image_a' => $article_prompt['caption'] ]; $source_prompt = null; - if ( null !== $source_data && ! empty( $source_data ) ) { + if ( $generate_b ) { $source_prompt = $this->prompt_builder->build_source_prompt( $source_data ); $batch_requests['image_b'] = [ 'prompt' => $source_prompt['prompt'], diff --git a/prautoblogger.php b/prautoblogger.php index 748b151..b730aee 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.4.5 + * Version: 0.4.6 * 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.4.5' ); +define( 'PRAUTOBLOGGER_VERSION', '0.4.6' ); define( 'PRAUTOBLOGGER_DB_VERSION', '1.1.0' ); define( 'PRAUTOBLOGGER_PLUGIN_FILE', __FILE__ ); define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );