# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.0] - 2026-04-19

### Added
- **Expanded Language dropdown**: Preset, Generate, and Rewrite forms now offer 20 languages — Bahasa Indonesia, English, Bahasa Melayu, Mandarin Chinese (Simplified), Japanese, Korean, Thai, Vietnamese, Filipino (Tagalog), Hindi, Arabic, Spanish, Portuguese, French, German, Italian, Dutch, Russian, Turkish, and Bengali
- New `apicoid_gw_get_supported_languages()` helper centralizing the supported-language list so future additions only need a single edit

### Changed
- Three language dropdowns (`includes/settings-page.php`, generate modal and rewrite modal in `includes/article-optimizer-page.php`) now render options by iterating the helper instead of hardcoded `<option>` markup

### Compatibility
- Existing presets stored as `"Indonesia"` or `"English"` are fully preserved; values remain unchanged and preselect correctly

## [1.4.8] - 2026-04-01

### Fixed
- **Background tasks not completing**: Replaced loopback HTTP requests with inline processing using `fastcgi_finish_request()` / `litespeed_finish_request()` — the loopback approach was subject to the same web server timeout, causing tasks to be killed before post creation
- **False "Task timed out" errors**: Removed server-side auto-fail that was overwriting still-running tasks as failed; timeout handling is now client-side only with a friendlier message
- **Improved polling resilience**: Client-side poller now reports elapsed time and gives a non-fatal message if the task takes longer than expected, instead of showing a hard error

## [1.4.7] - 2026-03-31

### Fixed
- **Prevent timeout errors**: Long-running operations (article generation, rewriting, image generation, suggestions) now run in the background to prevent web server timeout errors (500/502/504) on shared hosting
- **Background processing**: All API-intensive tasks are processed via non-blocking background requests, eliminating gateway timeout errors caused by web server connection limits
- **Polling-based status updates**: Frontend now polls for task completion instead of waiting for a single long HTTP response, keeping the connection alive
- **Improved PHP limits**: Added automatic PHP execution time and memory limit adjustments for background task processing

## [1.4.6] - 2026-02-08

### Changed
- **Additional Prompt placeholder**: Generate, Rewrite, and Preset forms now show a long-form example placeholder for Additional Prompt instead of forcing a default value when empty

## [1.4.5] - 2026-02-08

### Fixed
- **Hero card width**: API Status Hero card now uses the same max-width (1200px) as the main content so it aligns with the "Your Posts" section on the Article Generator page

## [1.4.4] - 2026-02-08

### Added
- **API Status Hero Card**: Eye-catching hero card on the main plugin page and Article Generator page showing "API Active" badge, account mode (Pay as you go / Bring your own key), and points (formatted count or "Unlimited")
- **Status Endpoint Validation**: API key validation now uses GET `{host}/article-generator/status` with `x-api-co-id` header; 401 = invalid, 200 = valid with mode and points in response

### Changed
- **Related Article Preview**: Settings page "Preview (real links from your posts)" now shows a single related article link (one post, no comma-separated list)
- **Related Article in Content**: Each related-article block in generated content now displays only one title/link instead of multiple comma-separated links

## [1.4.3] - 2026-02-22

### Changed
- **Bold FAQ Accordion Questions**: FAQ accordion questions are now wrapped in `<strong>` tags for better visual hierarchy

## [1.4.2] - 2026-02-22

### Changed
- **FAQ Dropdown**: FAQ setting changed from a simple checkbox to a dropdown with three options: "Disable", "Enable (Plain)", and "Enable with Accordion"
- **FAQ Accordion Mode**: When "Enable with Accordion" is selected, FAQ items are rendered as collapsible `<details><summary>` HTML elements for better UX
- **Backward Compatible**: Old presets with boolean FAQ values (`true`/`false`) are automatically normalized to the new string format (`plain`/`disable`)

## [1.4.1] - 2026-02-17

### Added
- **FAQ Option**: New "Generate FAQ" checkbox in article generation and rewriting forms to include an FAQ section in generated content
- **FAQ in Presets**: FAQ setting is now stored in and loaded from article presets (Settings page, all modal forms)
- **FAQ Across All Flows**: FAQ parameter is sent to the API in Generate Article, Rewrite Article, Generate by Category, and Create Support Article workflows

## [1.4.0] - 2026-02-15

### Added
- **Auto Schedule**: One-click post scheduling from the post editor (Classic & Block Editor) with a yellow "Auto Schedule" button
- **Auto Schedule Settings**: Configurable daily article limits (`Articles Per Day`), publishing time window (`Start Hour` / `End Hour`) on the Settings page
- **Rearrange Queue**: Redistribute all scheduled posts according to current settings while preserving their original order
- **Smart Related Article Reinjection**: When auto-scheduling, optionally strip and re-generate related article links to include scheduled posts — only links to posts that will be live before the current post (prevents 404s)
- **Confirm Dialog with Preview**: Auto Schedule shows a modal with the proposed date and updated related article links before confirming
- **Include Scheduled Content Checkbox**: New option in Generate by Category to include `future` posts in category analysis
- **Scheduled Posts in Article Generator**: Future posts now appear in the article list with a blue "Scheduled" badge and their scheduled publish date/time
- **Create Support Article for Scheduled Posts**: The "Create Support Article" button now appears for both published and scheduled posts

### Changed
- **Related Article Label from Preset**: `build_related_articles_html()` and auto-schedule reinjection now read the label from the Default preset instead of the legacy standalone `apicoid_gw_article_related_article_label` option
- **Article Generator Query**: Post status query updated to include `future` alongside `publish` and `draft`

## [1.3.3] - 2026-02-15

### Fixed
- **Increased API Timeouts to 10 Minutes**: All API calls to api.co.id (article generation, rewriting, suggestions, image generation) now use 600-second timeout to prevent premature request failures
- **Improved AJAX Timeout Handling**: Added 10-minute client-side timeout to Generate Article and Rewrite Article forms that were previously missing explicit timeouts
- **Better Error Messages for Timeouts**: Generate and Rewrite forms now show informative messages when server timeout (502/504) occurs, letting users know the article may still be generating in the background
- **Fixed False "Request Failed" Errors**: Resolved issue where articles were successfully generated but users saw error alerts due to web server gateway timeouts

## [1.3.2] - 2026-02-14

### Added
- **Multiple Article Presets**: New preset management system for article generation settings (language, writing style, tone, search intent, point of view, creativity level, audience, additional prompt, and more)
- **Preset CRUD on Settings Page**: Create, edit, and delete presets from the GhostWriter Settings page with AJAX-powered save/delete
- **Preset Selector in All Modals**: Preset dropdown added to Generate, Rewrite, Generate by Category, and Support Article modals with auto-fill on selection
- **Related Article Label per Preset**: Configurable "Related Article Label" text (e.g. "Related Article", "Artikel Terkait") stored per preset and used when inserting related article links
- **Live Preview for Related Article Label**: Settings page shows a real-time preview of the related article label using actual published posts
- **Auto-migration to Presets**: Existing default settings are automatically migrated into a "Default" preset on first load

### Changed
- **Settings Page Redesigned**: Removed old individual default settings form; presets are now the sole source of truth for article generation defaults
- **Default Preset Auto-selected**: The "Default" preset is automatically selected and applied when opening any article generation modal
- **PHP Defaults from Preset**: Generate/Rewrite modal initial values now read from the "Default" preset instead of individual `get_option()` calls

### Fixed
- **Preset Not Applied in Generate by Category**: Fixed preset dropdown change not updating form fields in cloned forms (Generate by Category, Support Article) by adding proper CSS class for event delegation
- **Checkboxes Not Following Preset**: Fixed "Enable Related Articles", "Generate Image", and "Allow Related Keywords" checkboxes not updating when switching presets
- **Related Article Label Not Sent to Server**: Fixed `related_article_label` not being included in AJAX POST data for all generation types (generate, rewrite, category, suggestion)
- **Related Article Label Not Passed to Builder**: Fixed `build_related_articles_html()` to accept label from form submission instead of only reading from old `get_option()`

## [1.3.1] - 2026-02-08

### Added
- **Auto Google Index**: New feature to automatically submit post and page URLs to Google Indexing API when published or updated
- **Google Indexing API Integration**: Full integration with Google's Indexing API using service account authentication (JWT/OAuth2)
- **Submission Log**: Comprehensive logging system with database table to track all submission attempts (success/failure) with pagination
- **Encrypted Service Account Storage**: Service account JSON keys are encrypted using AES-256-CBC before storing in database
- **Test Connection Feature**: Built-in test connection button to verify Google Indexing API credentials before enabling auto-submission
- **Setup Guide with Tutorial Link**: Added step-by-step setup guide with link to full tutorial at https://api.co.id/blog/auto-index-ghostwriter/
- **Auto-submit on Publish/Update**: Automatically submits URLs to Google when posts or pages are published or updated (for post and page post types only)
- **Log Management**: View submission history with status indicators, source tracking (auto/test), and clear logs functionality

### Technical Details
- New database table: `wp_apicoid_gw_google_index_log` for storing submission logs
- New admin page: "Auto Google Index" submenu under GhostWriter menu
- JWT/OAuth2 authentication implementation without external dependencies
- AES-256-CBC encryption for service account keys using WordPress AUTH_KEY

## [1.3.0] - Previous Release

### Added
- Generate Article by Category: New feature to generate article suggestions based on selected category
- Auto link related articles: When generating articles from category suggestions, the plugin automatically includes contextual links to related articles from the same category
- Enhanced category-based workflow: Streamlined workflow for generating multiple articles from a single category with intelligent suggestion system
- Improved modal layout: Two-column layout for category suggestions and article generation form for better user experience
- Category suggestion API integration: Integrated with Api.co.id's category-based article suggestion endpoint for intelligent content recommendations

## [1.2.4] - Previous Release

### Added
- Added pagination to Article Generator page: Implemented pagination for the article list with configurable page size
- Configurable articles per page: Added setting in Settings page to configure number of articles displayed per page (default: 30)
- Improved article list navigation: Added pagination controls with page numbers, previous/next buttons, and "Showing X-Y of Z posts" information

## [1.2.3] - Previous Release

### Added
- Generate image from media library: Added "Generate Image" button in WordPress media library sidebar

### Fixed
- Fixed duplicate image insertion: Fixed issue where clicking "Insert into post" after generating an image would insert the image twice

### Changed
- Code cleanup: Removed all console.log statements for production-ready code

## [1.2.2] - Previous Release

### Added
- Add more configurable functions: Added optional "Treat as Support Article" checkbox when generating articles from suggestions

### Fixed
- Fix generate image button not showing on empty featured image: Fixed issue where the "Generate Featured Image" button was not appearing in the Classic Editor when no featured image was set

### Changed
- Improved featured image generation: Featured image now updates dynamically without page reload in Block Editor

## [1.2.1] - Previous Release

### Added
- Generate featured image from post edit page: Added "Generate Featured Image" button in the Featured Image meta box on post edit pages

## [1.2.0] - Previous Release

### Added
- Auto generate support article: New feature to automatically generate support articles for published articles with intelligent linking to pillar articles

### Fixed
- Fix API key validation not working: Fixed issue where API key validation button was not functioning properly

## [1.1.0] - Previous Release

### Added
- Smarter AI: Enhanced AI capabilities for better content generation
- Compressed image + WebP format: Images are now automatically compressed and converted to WebP format for better performance
- Added more settings: Configurable related articles feature, additional customization options in generate and rewrite forms
- Added plugin action links: Quick access to GhostWriter settings from plugins page

### Fixed
- Bugfix: Fixed issue where articles and images were not being generated properly

## [1.0.0] - Initial Release

### Added
- AI-powered article generation
- Content rewriting from URL
- Automatic related article linking
- SEO plugin integration
- Image generation support
- Category management
- Settings management
- Secure API key validation

[1.5.0]: https://github.com/apicoid/ghostwriter/compare/v1.4.8...v1.5.0
[1.4.8]: https://github.com/apicoid/ghostwriter/compare/v1.4.7...v1.4.8
[1.4.7]: https://github.com/apicoid/ghostwriter/compare/v1.4.6...v1.4.7
[1.4.6]: https://github.com/apicoid/ghostwriter/compare/v1.4.5...v1.4.6
[1.4.5]: https://github.com/apicoid/ghostwriter/compare/v1.4.4...v1.4.5
[1.4.5]: https://github.com/apicoid/ghostwriter/compare/v1.4.4...v1.4.5
[1.4.4]: https://github.com/apicoid/ghostwriter/compare/v1.4.3...v1.4.4
[1.4.3]: https://github.com/apicoid/ghostwriter/compare/v1.4.2...v1.4.3
[1.4.2]: https://github.com/apicoid/ghostwriter/compare/v1.4.1...v1.4.2
[1.4.1]: https://github.com/apicoid/ghostwriter/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/apicoid/ghostwriter/compare/v1.3.3...v1.4.0
[1.3.3]: https://github.com/apicoid/ghostwriter/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/apicoid/ghostwriter/compare/v1.3.1...v1.3.2
[1.3.1]: https://github.com/apicoid/ghostwriter/compare/v1.3.0...v1.3.1
[1.3.0]: https://github.com/apicoid/ghostwriter/compare/v1.2.4...v1.3.0
[1.2.4]: https://github.com/apicoid/ghostwriter/compare/v1.2.3...v1.2.4
[1.2.3]: https://github.com/apicoid/ghostwriter/compare/v1.2.2...v1.2.3
[1.2.2]: https://github.com/apicoid/ghostwriter/compare/v1.2.1...v1.2.2
[1.2.1]: https://github.com/apicoid/ghostwriter/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/apicoid/ghostwriter/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/apicoid/ghostwriter/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/apicoid/ghostwriter/releases/tag/v1.0.0
