number_format() in PHP 8.3 strictly requires int|float; $wpdb->get_var()
returns string|null. Cast $total to (int) at point of assignment in
admin/partials/articles-list.php to fix HTTP 500 on Articles admin page.
Also add PHPUnit test covering the string->int cast contract.
Fixes#31. Version bump 2.5.0 -> 2.5.1.
Agent-Session: fix-articles-500-20260617
Extract article listing endpoint and source-suffix stripping into
Peptide_News_Rest_Articles (195 lines). Main REST API retains route
registration, analytics endpoint wrappers, AJAX delete handler, and
permission/validation helpers (210 lines).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract source-resolution and RSS-specific logic from the monolithic
Peptide_News_Fetcher:
- class-peptide-news-source-resolver.php (229 lines) — aggregator
source detection, redirect resolution, title parsing, backfill
- class-peptide-news-rss-source.php (118 lines) — RSS/Atom feed
fetching and SimplePie item processing
- class-peptide-news-fetcher.php (271 lines) — orchestrator with
NewsAPI, storage, pruning, caching, and AI post-processing
Also consolidated duplicate clear_article_cache/invalidate_rest_api_cache
methods (they were identical) into a single clear_article_cache().
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New Cost_Tracker class: logs every API call (model, tokens, cost), enforces
monthly budgets with hard-stop mode, provides aggregated reporting
- New llm_costs database table with indexes on created_at, model, operation
- Modified LLM class: call_openrouter_with_usage() extracts token usage from
OpenRouter responses; budget gate checks before each API call
- Admin settings: monthly budget (USD), enforcement mode (disabled/warn/hard-stop),
cost log retention period
- Admin cost dashboard: budget progress bar, daily cost chart (Chart.js),
per-model and per-operation breakdowns, recent API call log
- PHPUnit tests: 16 tests covering cost calculation, pricing lookups,
budget enforcement logic, and model validation
- Updated ARCHITECTURE.md with new table schema, data flow, and key decisions
- Updated CONVENTIONS.md with "how to add cost tracking for a new operation"
- Version bump to 2.4.0
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two-tier filtering during article fetch: keyword/pattern rules as a fast
first pass, then optional LLM classification for borderline cases via
OpenRouter. Configurable sensitivity (strict/moderate/lenient), editable
keyword lists, blocked domain list, and admin stats display. Includes
30 unit tests covering domain blocking, title/body keywords, URL paths,
edge cases, and prompt structure.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduces GitHub Actions workflows for continuous integration and
deployment. CI runs PHP linting (7.4, 8.1, 8.3), PHPCS with WordPress
coding standards, PHPUnit tests across PHP versions, and JS syntax
checks. Deployment to Hostinger via FTPS triggers on push to main
after all CI checks pass, with optional LiteSpeed cache purge.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>