=== PusatWeb AI Article Generator ===
Contributors: komponenweb
Tags: ai, content generation, claude, openai, seo
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 1.9.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Generate SEO-friendly WordPress articles automatically with Claude AI or OpenAI, complete with thumbnails and scheduling.

== Description ==

**PusatWeb AI Article Generator** connects your WordPress site to the [Claude API](https://console.anthropic.com) (Anthropic) or the [OpenAI API](https://platform.openai.com) — just pick one on the Settings page — to create quality, SEO-friendly articles automatically, either manually on demand or scheduled via WP-Cron.

This plugin uses a **BYOK (Bring Your Own Key)** model: you supply the API key for your AI provider of choice (plus optionally Unsplash/Gemini), and the plugin calls that API directly from your own server. No data is ever sent to the plugin developer's server — only to the AI/Unsplash provider you configure yourself.

= Key Features =

* **Generate articles via the Claude API or OpenAI API** — choose which provider is active on the Settings page; title, structured body content, meta description, tags, and an SEO-friendly slug in a single request.
* **Source URL support** — rewrite an article with an original perspective based on a reference, with attribution, not copying.
* **Automatic thumbnails** — 3 modes: Unsplash stock photos, a programmatic gradient canvas (GD, no external API), or the AI Image API (generate an original image via OpenAI gpt-image-1 or Google Gemini).
* **Image per sub-heading (optional)** — insert a relevant Unsplash photo under each H2 heading, with a source caption (photographer + Unsplash link).
* **Image watermark (optional)** — a small automatic text watermark in the bottom-left/bottom-right corner of every generated image.
* **Draft/review mode** — articles are created as a draft (or another status of your choice) for review before publishing.
* **Automatic scheduling (WP-Cron)** — set the frequency (daily/twice-daily/weekly), execution time, and number of articles per category on every run.
* **Yoast SEO & RankMath compatible** — the meta description automatically fills the installed SEO plugin's field.
* **Logs page** — activity & error history with a level filter, plus a list of every article generated by this plugin.
* **Security** — every API key is stored encrypted (AES-256-CBC) in the database, never sent to the browser/JavaScript.

= Requires an API Key =

* **Anthropic API key** or **OpenAI API key** (pick one, required) — sign up at [console.anthropic.com](https://console.anthropic.com) or [platform.openai.com](https://platform.openai.com). Both are pay-as-you-go and **separate** from a chat subscription (Claude.ai Pro/Free or ChatGPT Plus) — you need to add credit in the respective console before the API can be used.
* **Unsplash Access Key** (optional, for the stock photo thumbnail mode & image per sub-heading) — free signup at [unsplash.com/developers](https://unsplash.com/developers).
* **Google Gemini API Key** (optional, only if you choose Gemini as the AI Image Provider) — a free tier with a limited quota is available in Google AI Studio.

= Data Usage Disclosure =

This plugin sends content (category, topic/keyword, source URL if provided) to the **Anthropic API** or **OpenAI API** (depending on which provider you chose) to generate articles, and (if the Unsplash thumbnail/image-per-sub-heading mode is active) sends search keywords to the **Unsplash API** to find photos. No data is sent to this plugin's developer's server or any other party outside the provider you configure yourself. See the "External services" section below for full details on each service.

== External services ==

This plugin is BYOK (Bring Your Own Key): for each AI/image service below, you supply your own API key and the plugin calls that service directly from your own server — nothing passes through, or is stored on, any server operated by this plugin's developer.

**Anthropic API (Claude)** — used to generate article content (title, body, tags, meta description, slug) when Claude is the selected AI provider on the API & Model tab. Every time you generate an article, this plugin sends the category, an optional topic/keyword, and an optional source URL (as reference material) to this service. Requires your own Anthropic API key, entered in Settings.
Terms of Service: https://www.anthropic.com/legal/consumer-terms — Privacy Policy: https://www.anthropic.com/legal/privacy

**OpenAI API** — used to generate article content when OpenAI is the selected AI provider, and (if enabled) to generate an AI thumbnail image via the Images API. Sends the same category/topic/source-url data as above for text generation, and an image prompt for image generation. Requires your own OpenAI API key, entered in Settings.
Terms of Use: https://openai.com/policies/row-terms-of-use/ — Privacy Policy: https://openai.com/policies/row-privacy-policy/

**Google Gemini API** — optional, only used if you select Gemini as the AI Image Provider on the Thumbnail tab, to generate a thumbnail image. Sends an image-generation prompt derived from the article. Requires your own Google Gemini API key, entered in Settings.
Terms of Service: https://ai.google.dev/gemini-api/terms — Privacy Policy: https://policies.google.com/privacy

**Unsplash API** — optional, only used if you select Unsplash as the thumbnail mode, or enable "Image per Sub-Heading," to search for and download stock photos. Sends search keywords (derived from the article's category/content) each time a photo is looked up. Requires your own Unsplash Access Key, entered in Settings.
Terms of Service: https://unsplash.com/terms — Privacy Policy: https://unsplash.com/privacy

**Freemius** — used for optional PRO license management: checkout, license activation/validation, and update delivery for the paid tier. On first activation you're shown Freemius's own connect screen, where you can choose to connect (share basic, non-sensitive site data such as site URL and WordPress/PHP/plugin version, to enable license validation and security notices) or skip it entirely — skipping has no effect on any free-tier feature of this plugin.
Terms of Service: https://freemius.com/terms/ — Privacy Policy: https://freemius.com/privacy/

== Installation ==

1. Upload the `ai-article-generator` folder to the `/wp-content/plugins/` directory, or upload the zip file via **Plugins → Add New → Upload Plugin**.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Open the **AI Articles → Settings** menu, go to the **API & Model** tab, choose the **Active AI Provider** (Claude or OpenAI), enter the API Key for the provider you chose, then click **Test Connection** to verify it.
4. (Optional) Enter your Unsplash Access Key / Google Gemini API Key on the **Thumbnail** tab if you want to use stock photos or AI Image as the thumbnail.
5. Set your article preferences (language, tone, length, default status) on the **Article** tab.
6. Start generating articles manually from the **AI Articles → Generate** menu, or enable automatic scheduling on the **Article** tab.

== Frequently Asked Questions ==

= Is this plugin free? =

There's a free plan and a PRO plan. The free plan can generate unlimited articles manually (OpenAI only) from the Generate page, with automatic meta description and SEO plugin (Yoast/RankMath) compatibility included — no scheduling, no image watermark. PRO unlocks Claude as a provider, scheduled auto-generate, and image watermarking. Either way, you still supply and pay for your own Anthropic/OpenAI API key directly — this plugin never acts as a middleman for or holds AI costs on your behalf, on any plan.

= Which provider should I choose, Claude or OpenAI? =

On the free plan, article generation is limited to OpenAI. On PRO, either works — both are implemented through the same driver architecture and produce equally SEO-friendly results. Enter an API key for one (or both, then choose via "Active AI Provider" on the API & Model tab), click Test Connection to verify it, then generate as usual.

= Can I use my Claude Pro/ChatGPT Plus subscription directly? =

No. A chat subscription (Claude.ai Free/Pro/Max, ChatGPT Free/Plus) and its corresponding API (Anthropic API, OpenAI API) are separate billing systems, even under the same account. You need to create a separate API key at console.anthropic.com or platform.openai.com and add credit there.

= Why does the "Test Connection" button fail with a credit balance/quota too low message? =

That means your API key is valid, but your Anthropic/OpenAI account doesn't have any credit yet. Add credit at **console.anthropic.com → Plans & Billing** (Anthropic) or **platform.openai.com → Billing** (OpenAI).

= Are articles published immediately? =

Not by default — the default status is **draft** so you can review before publishing. You can change the default status on the Article tab.

= How does automatic scheduling work? =

The plugin uses WordPress's built-in WP-Cron. Once enabled on the Article tab (frequency, time, categories, article count per run), the event runs automatically. You can trigger it manually for testing with WP-CLI: `wp cron event run pwaag_scheduled_generate`.

= Does it support WordPress Multisite? =

The log table and cron schedule are created per-site on activation/network-activation. Each site manages its own API keys & preferences independently.

= Where are error logs stored? =

The **AI Articles → Logs** menu shows the full activity history (info/warning/error) with a level filter, plus a list of every article ever generated by this plugin.

== Screenshots ==

1. Generate Article page — choose a category, optional topic, optional source URL.
2. Settings page — License, API & Model, Article, Thumbnail tabs.
3. Logs page — activity history with a color-coded badge per level.

== Changelog ==

= 1.9.3 =
* **WordPress.org manual review response** (3 findings addressed):
* Fix: automatic meta description and SEO plugin (Yoast/RankMath) compatibility were being generated and parsed from the AI on every plan, then silently discarded on the free plan — an artificial restriction of an already-available feature. Both are now free/core on every plan; only Claude, scheduling, and image watermarking remain PRO-only, since those are the only ones where the underlying work is genuinely skipped (not generated then thrown away) on the free plan.
* Fix: text domain (and every translation string) changed from `ai-article-generator` to `pusatweb-ai-article-generator` to match the assigned WordPress.org slug — this also required renaming the plugin's folder, since Plugin Check derives its expected domain from the installed folder name, which matches the real slug on an actual wp.org install.
* Fix: Plugin URI updated from a subdomain that wasn't live yet to the main pusatweb.com site.

= 1.9.2 =
* **WordPress.org review response**: renamed the internal code prefix from `aag_`/`AAG_` to `pwaag_`/`PWAAG_` (the old one was 3 characters, below wp.org's 4-character minimum for avoiding naming collisions) — covers every function, class, constant, option, post meta key, the custom database table, and AJAX/cron hook names. Added a required "External services" section to this readme documenting each third-party API (Anthropic, OpenAI, Gemini, Unsplash, Freemius) with what data is sent and links to each one's terms/privacy policy. Enabled Freemius's WordPress.org compliance mode for this build. Added the correct Contributors entry. No functional changes — existing installs are unaffected since this plugin isn't public yet.

= 1.9.1 =
* **Fix: uninstall cleanup wasn't reachable by Freemius**: removed the plugin's root `uninstall.php` — WordPress only ever runs one uninstall mechanism, and its presence silently disabled `register_uninstall_hook()`, which is what the Freemius SDK relies on internally to track uninstalls. Cleanup logic (options, post meta, custom log table) now runs via Freemius's own `after_uninstall` action instead, so both the plugin's own data removal and Freemius's uninstall tracking work correctly.

= 1.9.0 =
* **Rename**: plugin name changed to **PusatWeb AI Article Generator** (from "AI Article Generator") to avoid listing confusion with similarly-named plugins already on WordPress.org. Slug/folder/text domain (`ai-article-generator`) are unchanged, so existing installs are unaffected.
* **Fix: fatal error on activation on PRO/full-codebase installs**: activating the plugin fresh (not yet active) ran the scheduler's `reschedule_event()` — which checks the license via `aag_is_premium()` — before `class-aag-license.php` had been loaded, since activation hooks can fire before `aag_bootstrap()` does. Every real install running the full (non wp.org-stripped) codebase hit this. Fixed by loading the license class during activation itself.
* **Plugin Check compliance pass**: fixed an unescaped output warning, raised the minimum WordPress version to 6.4 (required by the autoload-optimization functions already in use, and removed the now-unreachable pre-6.4 fallback code), removed the redundant manual `load_plugin_textdomain()` call (core handles this automatically for wp.org-hosted plugins since WP 4.6), removed a stray `languages/.gitkeep` placeholder, updated readme.txt's "Tested up to" to 7.0, and trimmed the tags list/short description to wp.org's limits.

= 1.8.0 =
* **Free/PRO plans, WordPress.org compliant now**: removed the free plan's daily generate cap entirely — manual generate is unlimited on every plan, since capping it was a "usage cutoff" that WordPress.org's guidelines explicitly forbid. Claude support, automatic meta description, SEO plugin compatibility, scheduled auto-generate, and image watermarking are now PRO-only by being physically excluded from this free build (not just disabled in code) — the same approach used by other freemium plugins in the directory. No change to what's free vs. PRO otherwise.

= 1.7.0 =
* Added a "How it works" usage guide and per-field explanations to the Generate page (Category, Topic/Keyword, Source URL) so new users understand the flow before generating.

= 1.6.2 =
* Hardened a local-development-only license override so it can no longer be triggered by a single wp-config.php constant on its own — internal change, no effect on normal use.

= 1.6.1 =
* Added a description under the Temperature field (API & Model tab) explaining what it controls and when to lower it.

= 1.6.0 =
* Freemius licensing SDK integrated: the License tab now shows a real "Upgrade to PRO" button and, once licensed, a "Manage License" link, instead of a placeholder. `aag_is_premium()` checks the real license status. No change to what's free vs. PRO (see 1.4.0) — this only wires up how a PRO license actually gets checked/purchased.

= 1.5.0 =
* New: a warning notice on this plugin's own admin pages when no AI API key has been configured yet for the active provider, with a direct link to Settings → API & Model.
* New: a dismissible banner on this plugin's own admin pages for free-plan sites, recommending an upgrade to PRO with a link to the License tab.

= 1.4.0 =
* **Free/PRO plans**: introduced a free plan and a PRO plan. Free is limited to OpenAI only, manual generate only (no scheduling) capped at 1 article/day, and no automatic meta description, SEO plugin compatibility, or image watermark. PRO removes all of those limits. Locked fields in Settings show a "PRO" badge and an upgrade note; every limit is also enforced server-side (not just hidden in the UI), so it can't be bypassed by editing form fields directly. PRO licensing itself (Freemius) isn't wired up yet — see `ARCHITECTURE.md`.

= 1.3.0 =
* **Language**: the plugin's default UI language is now **English** (WordPress.org/public-plugin convention) instead of Indonesian. Every admin-facing string now goes through the English source text by default; Indonesian is now a full translation (`languages/ai-article-generator-id_ID.po`/`.mo`) rather than the hardcoded default, so existing Indonesian-speaking users see no change on a site running an `id_ID` locale. No functional changes.

= 1.2.1 =
* **Rename**: the plugin name reverted to **AI Article Generator** (dropping the "PRO" suffix) for WordPress.org listing purposes — a free wp.org listing shouldn't use "PRO" in its name, since that implies a paid product. "PRO" will still be used later as the name of an upgrade tier (Freemius), not the plugin/listing name.

= 1.2.0 =
* **Architecture change**: reverted to a **BYOK (Bring Your Own Key)** model — every user supplies their own Claude/OpenAI API key (and optionally Unsplash/Gemini), instead of going through a developer-owned relay server. The "License" tab is temporarily an informational placeholder (PRO license management will follow, separate from AI access).
* Rebranded to **AI Article Generator PRO**.
* Second AI provider support: **OpenAI (ChatGPT)** as an alternative to Claude — choose via "Active AI Provider" on the API & Model tab.
* Thumbnail: **AI Image API** mode (OpenAI gpt-image-1 or Google Gemini) and **Unsplash** mode are now separate and configured directly with your own API key.

= 1.1.0 =
* New feature: a small automatic **text watermark** in the bottom-left/bottom-right corner of every generated image (thumbnail & image per sub-heading) — text, position (left/right), and on/off are set on the **Thumbnail** tab. Leave the text empty to automatically use the site name.

= 1.0.0 =
* First public edition release.

== Upgrade Notice ==

= 1.9.3 =
Automatic meta description & SEO plugin compatibility are now free on every plan. No action needed.

= 1.9.2 =
Internal option names changed (aag_* -> pwaag_*). If updating from 1.9.1 or earlier, re-enter your Settings (API keys, preferences) once — nothing is deleted, the old values just aren't read under the new names.

= 1.9.1 =
Fixes uninstall cleanup so it actually runs (moved off the old uninstall.php mechanism, which was silently blocking it). No feature changes.

= 1.9.0 =
Important: fixes a fatal error on plugin activation on full/PRO installs. Plugin renamed to "PusatWeb AI Article Generator" (slug unchanged). Minimum WordPress version is now 6.4 (was 6.0). No feature changes.

= 1.8.0 =
Free plan's daily generate cap removed — manual generate is now unlimited on every plan. Claude/meta description/SEO compatibility/scheduling/watermark remain PRO-only.

= 1.6.0 =
Freemius licensing is now wired up — PRO can be purchased from the License tab. No change to free/PRO feature limits.

= 1.5.0 =
Adds a "no API key configured" warning and a free-plan upgrade banner on the plugin's admin pages. No functional changes otherwise.

= 1.4.0 =
Introduces free/PRO plans: free is now limited to OpenAI, manual generate only (1/day), no meta description/SEO/watermark. Existing sites keep working — PRO is unlocked later via a license (not yet available).

= 1.3.0 =
Default UI language is now English (Indonesian available as a full translation). No functional changes.

= 1.2.1 =
Rename: the plugin name reverted to "AI Article Generator" (dropping "PRO") for the WordPress.org listing. No functional changes.

= 1.2.0 =
Architecture change: BYOK is active again — enter your own Claude/OpenAI API key on the "API & Model" tab after updating.
