=== AI Research Publisher ===
Contributors: pixeldust-interactive
Tags: artificial intelligence, content, publishing, research, openai
Requires at least: 6.4
Requires PHP: 7.4
Stable tag: 0.4.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Researches topics, writes sourced posts, validates internal and external links, and publishes through a configurable queue.

== Description ==

AI Research Publisher turns reusable campaign criteria into researched WordPress posts. It is designed for general editorial use rather than a specific industry or B2B workflow.

MVP features include:

* Generic research briefs, target audiences, formats, tone, freshness, and guided campaign variables.
* OpenAI Responses API web research and Structured Outputs.
* Verified external sources and validated internal links.
* Priority internal URLs and configurable link ranges.
* Draft, pending-review, or immediate publishing.
* Run once, hourly, twice-daily, daily, and weekly campaigns.
* One to five queued posts per run.
* Duplicate protection, delayed retries, stale-job recovery, overlap protection, and activity logs.
* Optional Yoast SEO metadata.
* No telemetry.

* Save or Update stores campaign changes without creating a post. Run Now saves and immediately creates the next batch.

Automatic publishing is opt-in. New campaigns default to drafts.

= External service =

This plugin connects to the OpenAI API. Campaign instructions, site details, recent post titles, selected internal-link titles and URLs, and generation requests are sent to OpenAI. When web research is enabled, OpenAI may retrieve public web content. API usage is billed to the account associated with the supplied API key.

OpenAI policies:

* Terms of Use: https://openai.com/policies/terms-of-use/
* Privacy Policy: https://openai.com/policies/privacy-policy/
* Services Agreement: https://openai.com/policies/services-agreement/

== Installation ==

1. Upload and activate the plugin.
2. Open AI Research > Settings.
3. Enter an OpenAI API key and save.
4. Run the connection test.
5. Create a campaign under AI Research > Campaigns.
6. Keep the output status set to Draft for initial testing.
7. Save the campaign for later, or use Run Now and review Activity.

The API key can instead be defined in wp-config.php:

`define( 'ARP_OPENAI_API_KEY', 'sk-your-key-here' );`

== Frequently Asked Questions ==

= Is this limited to business posts? =

No. Campaign criteria are generic and can be used for virtually any editorial subject.

= Does it add internal links? =

Yes. It searches existing published WordPress content, prioritizes administrator-supplied URLs, validates generated internal links, and adds fallback related-reading links when needed.

= Does it add external links? =

Yes. External links are restricted to URLs returned in OpenAI web-search source metadata. Invented and excessive links are removed.

= Can it publish automatically? =

Yes, but draft is the default. A campaign can create drafts, pending-review posts, or immediately published posts.

= Why can a scheduled run be late? =

WP-Cron starts when WordPress receives traffic. Configure a real server cron calling wp-cron.php or WP-CLI every five minutes for reliable timing.

= Does a ChatGPT subscription cover the API cost? =

No. OpenAI API billing is separate and belongs to the API-key account.

= Does uninstall delete generated posts? =

No. Generated posts remain. Plugin tables, settings, locks, notices, and _arp_* metadata are deleted only when the uninstall-deletion setting was enabled before uninstalling.

== Changelog ==

= 0.4.2 =

* Added View campaigns to the dashboard.
* Limited campaign post types to Post and Page.
* Added separate Save/Update and Run Now actions while preserving the state of existing campaigns.
* Made GPT-5.6 Terra the balanced default for new installations and added simple cost/quality model choices.
* Reduced OpenAI request and response size by sending fewer internal-link candidates and omitting unused SEO, tag, and source fields.
* Added clear cost guidance for research depth, source minimums, and posts per run.

= 0.4.1 =

* Renamed Activity & History to Activity and removed the redundant dashboard activity table.
* Rebalanced Campaign and Activity columns so descriptive results receive the available space.
* Moved Cancel and Retry beside the applicable status and removed the empty Activity actions column.
* Removed repetitive attempt text, raw technical details, and OpenAI token statistics from Activity.
* Standardized buttons, simplified help markers, and replaced blue field focus with a neutral treatment.

= 0.4.0 =

* Completed a final consistency, security-boundary, and packaging audit.
* Removed obsolete action and workflow code after the simplified UX replaced it.
* Standardized remaining background-processing language.

= 0.3.9 =

* Preserved campaign work when OpenAI setup is incomplete.
* Added safe, contextual retry for failed posts.

= 0.3.8 =

* Added state-aware first-run setup guidance.
* Added useful empty states and reduced repeated workflow instructions.

= 0.3.7 =

* Improved keyboard, touch, focus, live-status, and responsive-table accessibility.
* Converted contextual help markers to semantic toggle buttons.

= 0.3.6 =

* Replaced user-facing queue terminology with waiting and background-processing language.
* Moved manual processing into a Troubleshooting disclosure.

= 0.3.5 =

* Reduced and relevance-ranked OpenAI title and internal-link context.
* Preserved broader local duplicate checks while lowering request size.

= 0.3.4 =

* Sized OpenAI output limits from campaign target length.
* Added input, output, and cached token usage to Activity & History.

= 0.3.3 =

* Unified campaign state and next-run feedback.
* Linked each campaign to its filtered activity history.
* Improved one-time campaign completion handling.

= 0.3.2 =

* Simplified campaign setup with progressive disclosure for advanced targeting, research, sources, and linking.
* Replaced the repeated workflow banner on the campaign form with concise task guidance.

= 0.3.1 =

* Added 25-item pagination to Activity & History.
* Preserved campaign and status filters while paging.
* Renamed the Created column to Added.

= 0.3.0 =

* Renamed Manual only to Run once.
* Run Now saves new or edited campaigns and immediately executes the first batch.
* Simplified campaign actions to Edit, Duplicate, Start/Stop, and Delete.
* Added Running, Stopped, and Completed campaign status wording.
* Reframed Queue & Activity as Activity & History with campaign and status filters.

= 0.2.0 =

* Added Duplicate Campaign; copies are paused by default.
* Replaced free-form variable names with a guided dropdown of common campaign criteria.
* Added examples and value guidance for campaign variables.
* Added plain-English workflow explanations, contextual tooltips, and bottom-of-page instructions throughout the admin UI.
* Queue activity now shows whether each campaign repeats and when its next automatic run is scheduled.
* Improved recurring campaign next-run labels so paused schedules are not shown as manual-only.

= 0.1.0 =

* Initial MVP.
* Added generic research campaigns and custom variables.
* Added OpenAI web research and structured article generation.
* Added internal and external link validation.
* Added scheduling, durable queue, delayed retries, overlap protection, and logs.
* Added duplicate detection and Yoast metadata.
