Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
67 lines
2.5 KiB
PHP
67 lines
2.5 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace LIT\MCP\Integrations\WordPress\Content;
|
||
|
||
use Throwable;
|
||
use WP_Error;
|
||
|
||
defined('ABSPATH') || exit;
|
||
|
||
/**
|
||
* Builds the content of a new entry for lit/content-create from a structured description
|
||
* (spec §6.2: "optional Divi-Inhalt in Kurzform"). Implemented by the Divi integration, so the
|
||
* WordPress integration does not depend on Divi.
|
||
*
|
||
* Two steps, because the entry does not exist before the insert: check() validates the whole
|
||
* description before anything is created (all or nothing); write() stores the content into the
|
||
* brand-new draft, which lit/content-create inserted with its normal WordPress fields only.
|
||
*/
|
||
interface ContentComposer
|
||
{
|
||
/** Whether composing is possible on this site right now (e.g. Divi 5 active). */
|
||
public function available(): bool;
|
||
|
||
/**
|
||
* Whether the site owner lets LIT MCP write such content (Tools tab: for Divi, lit/divi-insert
|
||
* is not disabled and the Divi group is neither disabled nor "nur lesen" – security M2).
|
||
*/
|
||
public function writable(): bool;
|
||
|
||
/**
|
||
* Why writing such content is refused right now although it is enabled (e.g. the installed Divi version is not
|
||
* released for LIT MCP, spec §5.5); null = allowed.
|
||
*/
|
||
public function refusal(): ?WP_Error;
|
||
|
||
/**
|
||
* IDs of the capabilities of the composing integration that composing a new entry needs (the Divi integration:
|
||
* the DiviFeature values). lit/content-create hands them on as DeclaresRequirements; the core never interprets
|
||
* them.
|
||
*
|
||
* @return list<string>
|
||
*/
|
||
public function requirements(): array;
|
||
|
||
/**
|
||
* Validates the description for a new entry of $postType. Nothing is written.
|
||
*
|
||
* @param list<mixed> $sections
|
||
* @return WP_Error|null Every problem of the description; null = valid.
|
||
*/
|
||
public function check(string $postType, array $sections): ?WP_Error;
|
||
|
||
/**
|
||
* Composes the description for the new draft $postId and stores it. A WP_Error means the
|
||
* description is invalid for this entry (nothing was written) – like a throw, it makes
|
||
* lit/content-create delete the draft again.
|
||
*
|
||
* @param list<mixed> $sections
|
||
* @return array{warnings: list<string>, outline: ?string, edit_url?: string}|WP_Error edit_url: where
|
||
* the new content is edited (e.g. the Divi builder) instead of the WordPress editor.
|
||
* @throws Throwable When storing failed.
|
||
*/
|
||
public function write(int $postId, string $postType, array $sections): array|WP_Error;
|
||
}
|