v0.11.0 — OpenRouter model picker (AJAX refresh + cost preview + Phase-2 asset extract) Replaces the free-text slug inputs for analysis_model, writing_model, and editor_model with a smart picker fed by a daily-refreshed OpenRouter model registry. Picker shows context size + input/output price + provider, filters by per-field capability, previews per-generation cost using existing cost-tracker history, and keeps a custom-slug fallback. Daily registry refresh fires from inside on_daily_generation() before lock acquire — no new top-level cron event. Commit sequence (preserved for review): -353aa4efeat(models): OpenRouter model picker + AJAX refresh + cost preview -283fa55fix(phpcs): resolve 4 PHPCS violations in model-registry-refresh handler -1b1336astyle(phpcs): fix array syntax in model field + cost tracker -283f9f9style(phpcs): fix tabs vs spaces in settings-page.php -aa78591refactor(assets): extract model-picker refresh handler to generic-handle file Verification - PHPCS strict (CI scope): 0 errors / 0 warnings - PHPUnit: 206/206 (555 assertions, 2 pre-existing skips) - All new files under 300-line cap (field renderer 163, AJAX handler 82) - Security: AJAX nonce + manage_options cap; output escaped; input sanitized - Phase 2 ready: zero PRAUTOBLOGGER_* coupling in registry/picker/AJAX classes; generic asset handle peptiderepo-model-picker QA verdict: PASS (qa-reviews/prautoblogger/2026-04-23-aa78591.md) Out of scope (untouched): cto-review.yml, prautoblogger_image_model field (Workers AI FLUX, Phase 3), Peptide Search AI / Peptide News fields (Phase 2). Co-authored-by: Engineer PRAutoBlogger (in-session subagent) <engineer-prautoblogger@peptiderepo.users.noreply.github.com>
113 lines
5.0 KiB
PHP
113 lines
5.0 KiB
PHP
<?php
|
||
|
||
/**
|
||
* phpcs:ignore Generic.PHP.RequireStrictTypes.MissingDeclaration -- strict_types must precede docblock
|
||
*
|
||
* PRAutoBlogger — Automated Content Research & Publishing
|
||
*
|
||
* @wordpress-plugin
|
||
* 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.11.0
|
||
* Requires at least: 6.0
|
||
* Requires PHP: 7.4
|
||
* Author: PeptideRepo
|
||
* Author URI: https://peptiderepo.com
|
||
* License: GPL v2 or later
|
||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||
* Text Domain: prautoblogger
|
||
* Domain Path: /languages
|
||
*
|
||
* @see ARCHITECTURE.md — Full data flow and file tree
|
||
* @see CONVENTIONS.md — Naming patterns and extension guides
|
||
*/
|
||
declare(strict_types=1);
|
||
|
||
// Abort if called directly.
|
||
if ( ! defined( 'ABSPATH' ) ) {
|
||
exit;
|
||
}
|
||
/*
|
||
|--------------------------------------------------------------------------
|
||
| Plugin Constants
|
||
|--------------------------------------------------------------------------
|
||
| Defined here so every file in the plugin can reference paths, versions,
|
||
| and limits without magic strings.
|
||
*/
|
||
define( 'PRAUTOBLOGGER_VERSION', '0.11.0' );
|
||
define( 'PRAUTOBLOGGER_DB_VERSION', '1.1.0' );
|
||
define( 'PRAUTOBLOGGER_PLUGIN_FILE', __FILE__ );
|
||
define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||
define( 'PRAUTOBLOGGER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||
define( 'PRAUTOBLOGGER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||
// API and retry limits — named constants instead of magic numbers.
|
||
define( 'PRAUTOBLOGGER_MAX_RETRIES', 3 );
|
||
define( 'PRAUTOBLOGGER_RETRY_BASE_DELAY_SECONDS', 2 );
|
||
define( 'PRAUTOBLOGGER_API_TIMEOUT_SECONDS', 180 );
|
||
define( 'PRAUTOBLOGGER_CACHE_TTL_SECONDS', 3600 );
|
||
// Default models for OpenRouter (user can override in settings).
|
||
define( 'PRAUTOBLOGGER_DEFAULT_ANALYSIS_MODEL', 'google/gemini-2.5-flash-lite' );
|
||
define( 'PRAUTOBLOGGER_DEFAULT_WRITING_MODEL', 'google/gemini-2.5-flash-lite' );
|
||
define( 'PRAUTOBLOGGER_DEFAULT_EDITOR_MODEL', 'google/gemini-2.5-flash-lite' );
|
||
// Image generation defaults.
|
||
// Default provider is Runware; OpenRouter (Gemini) remains as the alternate.
|
||
// Default model is FLUX.1 schnell via Runware (~$0.0006/image, ~2s). CEO
|
||
// decision 2026-04-21 after comic A/B: schnell's looser fidelity reads as
|
||
// editorial-cartoon style and is 65× cheaper than Nano Banana. Users can
|
||
// override via Settings → Images → Image Model.
|
||
define( 'PRAUTOBLOGGER_DEFAULT_IMAGE_PROVIDER', 'runware' );
|
||
define( 'PRAUTOBLOGGER_DEFAULT_IMAGE_MODEL', 'runware:100@1' );
|
||
// Default style suffix appended to every image-gen prompt. Updated
|
||
// 2026-04-18 v4: single-panel newspaper comic style. Caption is now
|
||
// inserted as HTML text below the image, NOT rendered inside it.
|
||
// Users may override via Settings → Images → Style Suffix.
|
||
define(
|
||
'PRAUTOBLOGGER_DEFAULT_IMAGE_STYLE_SUFFIX',
|
||
'Style: a single-panel newspaper comic in classic black ink on white paper, simple clean linework like The Far Side or B.C., slightly yellowed newsprint texture, hand-drawn crosshatching for shading, bold panel border, warm and humorous tone, visible in a newspaper comics section. IMPORTANT: Do not render any text, captions, speech bubbles, or words inside the image.'
|
||
);
|
||
/*
|
||
|--------------------------------------------------------------------------
|
||
| Autoloader
|
||
|--------------------------------------------------------------------------
|
||
*/
|
||
require_once PRAUTOBLOGGER_PLUGIN_DIR . 'includes/class-autoloader.php';
|
||
PRAutoBlogger_Autoloader::register();
|
||
// The main orchestrator class is loaded explicitly because its CamelCase name
|
||
// (PRAutoBlogger) doesn't map cleanly to a filename via the autoloader's
|
||
// kebab-case convention (it would look for class-pr-auto-blogger.php).
|
||
require_once PRAUTOBLOGGER_PLUGIN_DIR . 'includes/class-prautoblogger.php';
|
||
/*
|
||
|--------------------------------------------------------------------------
|
||
| Activation & Deactivation
|
||
|--------------------------------------------------------------------------
|
||
*/
|
||
register_activation_hook( __FILE__, array( 'PRAutoBlogger_Activator', 'activate' ) );
|
||
register_deactivation_hook( __FILE__, array( 'PRAutoBlogger_Deactivator', 'deactivate' ) );
|
||
/*
|
||
|--------------------------------------------------------------------------
|
||
| Boot the Plugin
|
||
|--------------------------------------------------------------------------
|
||
| The main orchestrator registers all hooks. Nothing else happens here —
|
||
| keep the bootstrap file minimal.
|
||
*/
|
||
/**
|
||
* Returns the singleton instance of the main plugin class.
|
||
*
|
||
* @return PRAutoBlogger
|
||
*/
|
||
function prautoblogger(): PRAutoBlogger {
|
||
static $instance = null;
|
||
if ( null === $instance ) {
|
||
$instance = new PRAutoBlogger();
|
||
}
|
||
return $instance;
|
||
}
|
||
// Initialize on plugins_loaded so all dependencies are available.
|
||
add_action(
|
||
'plugins_loaded',
|
||
static function (): void {
|
||
prautoblogger()->run();
|
||
}
|
||
);
|