=== SemanticHub ===
Contributors: semantichub
Tags: content, automation, publishing, editorial, api
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.15.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Pull publication-ready content from SemanticHub into a moderated WordPress draft queue.

== Description ==

SemanticHub groups related source articles and generates new editorial content from them. This plugin periodically pulls completed content from your SemanticHub account into a moderation queue. An editor can turn each queue item into a WordPress draft with one click.

Editing, workflow configuration and source-cluster management stay in the SemanticHub application. The plugin only retrieves approved content, acknowledges delivery and converts it into a native WordPress post, including supported blocks, media and SEO metadata. It requires a SemanticHub account and API token. The API endpoint is provided by the plugin and can be overridden by the site administrator in `wp-config.php` or with the `semantichub_api_base` filter.

After activation the plugin opens a **Start** screen that explains what the service does and walks the administrator through connecting the site: create an account, paste an API token, report this installation's capabilities. The screen disappears from the menu once the connection works.

= External service =

This plugin is a client for SemanticHub, a hosted service that groups source articles into topics and generates editorial content from them. The plugin is useless without an account there, because all content it imports is produced by that service.

The plugin contacts the SemanticHub API (by default `https://semantichub.app`, overridable with the `SEMANTICHUB_API_BASE` constant or the `semantichub_api_base` filter) in these situations:

* every 15 minutes, and when an administrator selects "Fetch now", to download content approved in your SemanticHub account (`GET /api/plugin/feed`);
* after an item is imported or dismissed, to confirm the delivery so it is not sent twice (`POST /api/plugin/feed/ack`, `POST /api/plugin/feed/published`);
* once a day, and on demand from the settings screen, to report which Gutenberg blocks and content sections this installation can render (`GET /api/plugin/goals`, `PUT /api/goals/{id}/target-manifest`);
* when an administrator selects "Test connection".

Data sent: the API token of this installation, the list of block and section names the plugin supports, the plugin version, and the identifiers plus resulting post IDs of items you import. No post content, visitor data, or personal data of your site's users is sent. Requests are authenticated with `Authorization: Bearer sh_…` over HTTPS.

Service terms: <https://semantichub.app/legal/terms>. Privacy policy: <https://semantichub.app/legal/privacy>.

= Third-party resources =

The bundled Geist and Geist Mono web fonts (`assets/fonts/`) are Copyright (c) 2023 Vercel, licensed under the SIL Open Font License 1.1. The full license text ships in `assets/fonts/LICENSE.txt`.

== Installation ==

1. Install and activate the plugin.
2. The **SemanticHub → Start** screen opens automatically. It explains the service and lists the three connection steps.
3. Create an API token in your SemanticHub account (Settings → API tokens) and paste it on the Start screen.
4. Select "Report capabilities and check goals". A working connection reports at least one goal.
5. Content appears under the "SemanticHub → Content" menu; the feed is checked every 15 minutes.

Publication defaults (post author, category, and whether deliveries become drafts or published posts) live under SemanticHub → Settings.

== Frequently Asked Questions ==

= Do I need a SemanticHub account? =

Yes. The plugin imports content produced by the SemanticHub service and does nothing on its own.

= Does the plugin publish without me? =

Only if you ask it to. By default each delivery becomes a draft, and "Automatic publication" follows the setting of the goal in SemanticHub. You can force "always draft" or "always publish" in the plugin settings. Publishing also requires the selected post author to have the `publish_posts` capability; without it the post is left as pending review.

= Where does the content come from? =

From goals you configure in SemanticHub: sources you pick, clustered into topics, filtered by your own description of the site profile, and written into the structure you define there.

= Can I point the plugin at a different API host? =

Yes. Define `SEMANTICHUB_API_BASE` in `wp-config.php` or use the `semantichub_api_base` filter. The address is not editable in the admin UI on purpose.

= What happens when I deactivate or delete the plugin? =

Deactivation stops the scheduled feed checks. Deleting the plugin removes its options and its delivery queue table.

== Screenshots ==

1. Start screen: what the service does and the three connection steps.
2. Content: deliveries waiting to be imported into WordPress.
3. Settings: connection, publication defaults and capability reporting.

== Upgrade Notice ==

= 0.13.0 =
Updates now come from the WordPress.org plugin directory. The plugin no longer contacts semantichub.app to check for new versions.

= 0.12.1 =
Imported posts now use the current block editor markup (headings, lists, quotes, image captions, separators), so the editor no longer rewrites them silently on the first save.

= 0.12.0 =
The goal's publishing mode in SemanticHub (moderation, draft, publish) now sets the post status. "Always a draft" and "Always publish" in the plugin settings still override it.

= 0.11.0 =
Re-sent deliveries update the existing post instead of creating a duplicate. Failed publications are reported back to SemanticHub and listed under "Failed".

= 0.10.0 =
Revised articles from SemanticHub now update the existing post instead of creating a duplicate, and bilingual deliveries create linked translations when Polylang is active.

= 0.9.0 =
The plugin now reports available updates in WordPress and updates itself with the standard "Update now" button — no more manual ZIP uploads.

= 0.7.0 =
Editing and cluster management moved to the SemanticHub application; the plugin is now a delivery inbox with a guided setup screen.

== Changelog ==

= 0.15.1 =
* Payload v5 contract synced with SemanticHub: entries can carry source_type, and a newsletter issue may arrive without a source address.

= 0.15.0 =
* One site publishes exactly one goal: after saving the token, choose the goal on the Start screen or in Settings. The plugin then fetches only that goal's articles and reports its capabilities only to it.
* New "Disconnect" action clears the token, the chosen goal and the connection state, so the site can be connected again from the Start screen. Publishing defaults and published posts stay.
* The Start screen explains how SemanticHub works and links to the API tokens page.
* Content screen: tabs with counts, a status badge and a row action menu.

= 0.14.0 =
* Other post taxonomies (besides the category) can now be exposed to SemanticHub as receiver fields, in Settings under "Other taxonomies": hierarchical ones become a term picker, flat ones a comma-separated text field. Tags get proposed values from the story topics when the field has no default.

= 0.13.0 =
* Removed the built-in update checker and the "Plugin version" panel in the settings. Updates are delivered by the WordPress.org plugin directory.
* Uninstalling also removes the cached update manifest left by earlier versions.
* Translations load on `init`, and queue queries use `%i` placeholders for the table name.

= 0.12.1 =
* Block markup of imported posts matches what the block editor saves in WordPress 6.4 and newer: headings carry `wp-block-heading`, lists and quotes use inner blocks (`core/list-item`, `core/paragraph`), image captions carry `wp-element-caption` and separators `has-css-opacity`. Posts no longer depend on deprecated block migrations.
* Embeds use the same markup as the editor, so they no longer show "This block contains unexpected or invalid content".

= 0.12.0 =
* A delivery's `publish_mode` (moderation/draft/publish) now decides the WordPress post status when "Automatic publication" is set to "Follow the goal setting in SemanticHub"; a delivery without it falls back to the previous `auto_dispatch` behaviour. "Always a draft" and "Always publish" still override both.
* A database error while creating or updating the post is reported to SemanticHub as `db_error` (retried automatically) instead of `insert_error` (which waits for a human).
* Every request the plugin sends to SemanticHub now carries a `User-Agent: SemanticHub-wordpress/<version>` header.

= 0.11.0 =
* Deliveries are matched to posts by the SemanticHub result id carried in every payload (v5), so a re-sent first version updates the existing post instead of creating a second one.
* The source language comes from the payload (`source_lang`); a single-language delivery gets its language set in Polylang without creating a second post.
* Deliveries with a single language are matched to the existing post on re-send; the cluster fallback applies only to revisions.
* The plugin declares the required category in its manifest and takes the category from the delivery; a failed publication is reported back to SemanticHub instead of staying silent.

= 0.10.0 =
* Revisions and re-sent deliveries now update the existing post (matched by result or topic) instead of creating a duplicate. A published post is only updated in place when the publish policy allows it; otherwise the revision arrives as a new draft linked to the live post.
* Bilingual deliveries: when the payload carries both language versions and Polylang is active, the plugin creates two linked posts (one per language) and keeps both up to date on revisions.

= 0.9.0 =
* Added update notifications: the plugin checks the SemanticHub update manifest and reports a new version on the Plugins screen, with details and changelog in the standard modal.
* Updating now uses the built-in WordPress installer, so "Update now", automatic updates and WP-CLI all work.
* Added a "Plugin version" panel in the settings with the installed version and a manual update check.

= 0.8.0 =
* Added a Start screen with an introduction to the service and a three-step connection walkthrough, shown until the site is connected.
* Documented the external service, its endpoints and the data sent, as required for distribution.
* Bundled the Open Font License text for the included Geist web fonts.

= 0.7.0 =
* Focused the plugin on WordPress delivery: connection, capability reporting, delivery inbox and native post import.
* Moved editing, response-contract configuration, cluster management and the AI agent exclusively to the SemanticHub application.
* Replaced the copied SemanticHub dashboard with a compact delivery inbox and direct links to the source result.

= 0.6.19 =
* Added agent conversation history and Enter-to-send support.
* Added reduced-motion-aware directional animation to the content flow.

= 0.6.18 =
* Normalized header actions and the goal selector to the same height.

= 0.6.17 =
* Replaced the native research prompt with an accessible SemanticHub modal.
* Standardized back-navigation controls as outline buttons.

= 0.6.16 =
* Added concrete content and source previews to agent proposal cards.

= 0.6.15 =
* Prevented long agent messages from being obscured by the docked composer.

= 0.6.14 =
* Merged queue KPIs and synchronization times into the content-flow component.
* Expanded the system pulse to 30 days by default.

= 0.6.13 =
* Restored the latest persisted agent conversation after page refresh.

= 0.6.12 =
* Replaced the attention list with a linked content-flow component.
* Simplified queue cards to a title followed directly by their description.

= 0.6.11 =
* Moved the goal selector to the right side of the desktop header.

= 0.6.10 =
* Connected the cluster-header action directly to the collapsible agent dock.

= 0.6.9 =
* Simplified the collapsed agent footer to one focused terminal-style toolbar.

= 0.6.8 =
* Added source-content excerpts to cluster details.

= 0.6.7 =
* Made the sticky cluster-agent footer collapsible and collapsed by default.

= 0.6.6 =
* Flattened the docked agent into a single workspace panel and toolbar.

= 0.6.5 =
* Replaced separate preview and agent actions with one cluster-details action.

= 0.6.4 =
* Docked the cluster agent as a responsive sticky footer workspace.

= 0.6.3 =
* Styled queue pagination consistently with the SemanticHub admin interface.

= 0.6.2 =
* Split publication-ready items from the below-threshold cluster feed.
* Added queue search, pagination, and newest-first ordering.
* Embedded the agent below cluster details with loading feedback and complete user-message history.

= 0.6.1 =
* Match the SaaS goal navigation, load the account's goals into a switcher and build verified goal-scoped URLs.

= 0.6.0 =
* Add a responsive WordPress header navigation with local queue/settings links and direct links to SemanticHub SaaS.

= 0.5.5 =
* Show meaningful fallback names in the merge picker and rank targets by semantic similarity.

= 0.5.4 =
* Display conversational agent replies as messages instead of an empty “Done” status.

= 0.5.3 =
* Prepared the distribution for WordPress.org checks: English readme, current compatibility metadata and stricter output escaping.
* Excluded PHPUnit cache data from release archives.

= 0.5.2 =
* Cluster management in the detail view: adding and excluding articles, merging clusters, regenerating the descriptor.
* Restricted the merge target picker to clusters of the same goal.
* Fixes: centered the cluster dialog, consistent 404 for other accounts' resources.

= 0.5.0 =
* Detail view for a single cluster and article.
* Rebuilt the agent page into a full conversation window.

= 0.4.0 =
* Rebuilt the queue as SemanticHub-style cards: header with metrics, change indicators, "needs attention" section.
* Full-width plugin background in the admin panel.
* Enlarged queue thumbnails to 128 px.

= 0.3.0 =
* Shared design system with the SemanticHub application (tokens plus a synchronization script) and the self-hosted Geist typeface.
* Richer agent conversation rendering: bubbles, tool results, image grids.

= 0.2.0 =
* Agent-assisted cluster editing in wp-admin: conversation with the model, accepting Gutenberg blocks, publishing a draft.
* Opened the agent from the cluster row in the queue instead of a separate menu entry.
* Queue interface fixes: aligned the "Fetch now" icon and the status tab margins.

= 0.1.0 =
* First release: feed polling, moderation queue, publishing as a draft.
